blob: f2e62e45f91288916a252486a4ac130c5d7dd022 [file] [log] [blame]
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001/*
2* alc5632.c -- ALC5632 ALSA SoC Audio Codec
3*
4* Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.lauchpad.net>
5*
6* Authors: Leon Romanovsky <leon@leon.nu>
7* Andrey Danin <danindrey@mail.ru>
8* Ilya Petrov <ilya.muromec@gmail.com>
9* Marc Dietrich <marvin24@gmx.de>
10*
11* Based on alc5623.c by Arnaud Patard
12*
13* This program is free software; you can redistribute it and/or modify
14* it under the terms of the GNU General Public License version 2 as
15* published by the Free Software Foundation.
16*/
17
18#include <linux/module.h>
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/delay.h>
22#include <linux/pm.h>
23#include <linux/i2c.h>
24#include <linux/slab.h>
Leon Romanovskybb397532011-11-16 12:06:58 +020025#include <linux/regmap.h>
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +020026#include <sound/core.h>
27#include <sound/pcm.h>
28#include <sound/pcm_params.h>
29#include <sound/tlv.h>
30#include <sound/soc.h>
31#include <sound/initval.h>
32
33#include "alc5632.h"
34
35/*
36 * ALC5632 register cache
37 */
Leon Romanovskybb397532011-11-16 12:06:58 +020038static struct reg_default alc5632_reg_defaults[] = {
Leon Romanovsky43fa8e52011-11-17 12:01:28 +020039 { 2, 0x8080 }, /* R2 - Speaker Output Volume */
40 { 4, 0x8080 }, /* R4 - Headphone Output Volume */
41 { 6, 0x8080 }, /* R6 - AUXOUT Volume */
42 { 8, 0xC800 }, /* R8 - Phone Input */
43 { 10, 0xE808 }, /* R10 - LINE_IN Volume */
44 { 12, 0x1010 }, /* R12 - STEREO DAC Input Volume */
45 { 14, 0x0808 }, /* R14 - MIC Input Volume */
46 { 16, 0xEE0F }, /* R16 - Stereo DAC and MIC Routing Control */
47 { 18, 0xCBCB }, /* R18 - ADC Record Gain */
48 { 20, 0x7F7F }, /* R20 - ADC Record Mixer Control */
49 { 24, 0xE010 }, /* R24 - Voice DAC Volume */
50 { 28, 0x8008 }, /* R28 - Output Mixer Control */
51 { 34, 0x0000 }, /* R34 - Microphone Control */
52 { 36, 0x00C0 }, /* R36 - Codec Digital MIC/Digital Boost
53 Control */
Leon Romanovsky43fa8e52011-11-17 12:01:28 +020054 { 46, 0x0000 }, /* R46 - Stereo DAC/Voice DAC/Stereo ADC
55 Function Select */
56 { 52, 0x8000 }, /* R52 - Main Serial Data Port Control
57 (Stereo I2S) */
58 { 54, 0x0000 }, /* R54 - Extend Serial Data Port Control
59 (VoDAC_I2S/PCM) */
60 { 58, 0x0000 }, /* R58 - Power Management Addition 1 */
61 { 60, 0x0000 }, /* R60 - Power Management Addition 2 */
62 { 62, 0x8000 }, /* R62 - Power Management Addition 3 */
63 { 64, 0x0C0A }, /* R64 - General Purpose Control Register 1 */
64 { 66, 0x0000 }, /* R66 - General Purpose Control Register 2 */
65 { 68, 0x0000 }, /* R68 - PLL1 Control */
66 { 70, 0x0000 }, /* R70 - PLL2 Control */
67 { 76, 0xBE3E }, /* R76 - GPIO Pin Configuration */
68 { 78, 0xBE3E }, /* R78 - GPIO Pin Polarity */
69 { 80, 0x0000 }, /* R80 - GPIO Pin Sticky */
70 { 82, 0x0000 }, /* R82 - GPIO Pin Wake Up */
Leon Romanovsky43fa8e52011-11-17 12:01:28 +020071 { 86, 0x0000 }, /* R86 - Pin Sharing */
Leon Romanovsky43fa8e52011-11-17 12:01:28 +020072 { 90, 0x0009 }, /* R90 - Soft Volume Control Setting */
73 { 92, 0x0000 }, /* R92 - GPIO_Output Pin Control */
74 { 94, 0x3000 }, /* R94 - MISC Control */
75 { 96, 0x3075 }, /* R96 - Stereo DAC Clock Control_1 */
76 { 98, 0x1010 }, /* R98 - Stereo DAC Clock Control_2 */
77 { 100, 0x3110 }, /* R100 - VoDAC_PCM Clock Control_1 */
78 { 104, 0x0553 }, /* R104 - Pseudo Stereo and Spatial Effect
79 Block Control */
80 { 106, 0x0000 }, /* R106 - Private Register Address */
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +020081};
82
83/* codec private data */
84struct alc5632_priv {
Leon Romanovskybb397532011-11-16 12:06:58 +020085 struct regmap *regmap;
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +020086 u8 id;
87 unsigned int sysclk;
88};
89
Leon Romanovskybb397532011-11-16 12:06:58 +020090static bool alc5632_volatile_register(struct device *dev,
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +020091 unsigned int reg)
92{
93 switch (reg) {
94 case ALC5632_RESET:
95 case ALC5632_PWR_DOWN_CTRL_STATUS:
96 case ALC5632_GPIO_PIN_STATUS:
97 case ALC5632_OVER_CURR_STATUS:
98 case ALC5632_HID_CTRL_DATA:
99 case ALC5632_EQ_CTRL:
Leon Romanovsky9b4156c2011-11-17 12:01:29 +0200100 case ALC5632_VENDOR_ID1:
101 case ALC5632_VENDOR_ID2:
Leon Romanovskybb397532011-11-16 12:06:58 +0200102 return true;
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200103
104 default:
105 break;
106 }
107
Leon Romanovskybb397532011-11-16 12:06:58 +0200108 return false;
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200109}
110
Leon Romanovskybb397532011-11-16 12:06:58 +0200111static inline int alc5632_reset(struct regmap *map)
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200112{
Leon Romanovskybb397532011-11-16 12:06:58 +0200113 return regmap_write(map, ALC5632_RESET, 0x59B4);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200114}
115
116static int amp_mixer_event(struct snd_soc_dapm_widget *w,
117 struct snd_kcontrol *kcontrol, int event)
118{
119 /* to power-on/off class-d amp generators/speaker */
120 /* need to write to 'index-46h' register : */
121 /* so write index num (here 0x46) to reg 0x6a */
122 /* and then 0xffff/0 to reg 0x6c */
123 snd_soc_write(w->codec, ALC5632_HID_CTRL_INDEX, 0x46);
124
125 switch (event) {
126 case SND_SOC_DAPM_PRE_PMU:
127 snd_soc_write(w->codec, ALC5632_HID_CTRL_DATA, 0xFFFF);
128 break;
129 case SND_SOC_DAPM_POST_PMD:
130 snd_soc_write(w->codec, ALC5632_HID_CTRL_DATA, 0);
131 break;
132 }
133
134 return 0;
135}
136
137/*
138 * ALC5632 Controls
139 */
140
141/* -34.5db min scale, 1.5db steps, no mute */
142static const DECLARE_TLV_DB_SCALE(vol_tlv, -3450, 150, 0);
143/* -46.5db min scale, 1.5db steps, no mute */
144static const DECLARE_TLV_DB_SCALE(hp_tlv, -4650, 150, 0);
145/* -16.5db min scale, 1.5db steps, no mute */
146static const DECLARE_TLV_DB_SCALE(adc_rec_tlv, -1650, 150, 0);
147static const unsigned int boost_tlv[] = {
Paul Fertserabb015b2012-02-11 23:26:36 +0200148 TLV_DB_RANGE_HEAD(2),
149 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0),
150 1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200151};
152/* 0db min scale, 6 db steps, no mute */
153static const DECLARE_TLV_DB_SCALE(dig_tlv, 0, 600, 0);
154/* 0db min scalem 0.75db steps, no mute */
Andrey Danin39be1af2012-02-11 23:26:28 +0200155static const DECLARE_TLV_DB_SCALE(vdac_tlv, -3525, 75, 0);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200156
157static const struct snd_kcontrol_new alc5632_vol_snd_controls[] = {
158 /* left starts at bit 8, right at bit 0 */
159 /* 31 steps (5 bit), -46.5db scale */
Andrey Danin1a083252011-11-13 21:53:13 +0200160 SOC_DOUBLE_TLV("Speaker Playback Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200161 ALC5632_SPK_OUT_VOL, 8, 0, 31, 1, hp_tlv),
162 /* bit 15 mutes left, bit 7 right */
Andrey Danin1a083252011-11-13 21:53:13 +0200163 SOC_DOUBLE("Speaker Playback Switch",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200164 ALC5632_SPK_OUT_VOL, 15, 7, 1, 1),
165 SOC_DOUBLE_TLV("Headphone Playback Volume",
166 ALC5632_HP_OUT_VOL, 8, 0, 31, 1, hp_tlv),
167 SOC_DOUBLE("Headphone Playback Switch",
168 ALC5632_HP_OUT_VOL, 15, 7, 1, 1),
169};
170
171static const struct snd_kcontrol_new alc5632_snd_controls[] = {
172 SOC_DOUBLE_TLV("Auxout Playback Volume",
173 ALC5632_AUX_OUT_VOL, 8, 0, 31, 1, hp_tlv),
174 SOC_DOUBLE("Auxout Playback Switch",
175 ALC5632_AUX_OUT_VOL, 15, 7, 1, 1),
176 SOC_SINGLE_TLV("Voice DAC Playback Volume",
177 ALC5632_VOICE_DAC_VOL, 0, 63, 0, vdac_tlv),
Andrey Danin0a2c0562012-02-11 23:26:29 +0200178 SOC_SINGLE("Voice DAC Playback Switch",
179 ALC5632_VOICE_DAC_VOL, 12, 1, 1),
Paul Fertser5148aed2012-02-11 23:26:37 +0200180 SOC_SINGLE_TLV("Phone Playback Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200181 ALC5632_PHONE_IN_VOL, 8, 31, 1, vol_tlv),
Paul Fertser5148aed2012-02-11 23:26:37 +0200182 SOC_DOUBLE_TLV("LineIn Playback Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200183 ALC5632_LINE_IN_VOL, 8, 0, 31, 1, vol_tlv),
Andrey Danin1a083252011-11-13 21:53:13 +0200184 SOC_DOUBLE_TLV("Master Playback Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200185 ALC5632_STEREO_DAC_IN_VOL, 8, 0, 63, 1, vdac_tlv),
Andrey Danin1a083252011-11-13 21:53:13 +0200186 SOC_DOUBLE("Master Playback Switch",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200187 ALC5632_STEREO_DAC_IN_VOL, 15, 7, 1, 1),
Paul Fertser5148aed2012-02-11 23:26:37 +0200188 SOC_SINGLE_TLV("Mic1 Playback Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200189 ALC5632_MIC_VOL, 8, 31, 1, vol_tlv),
Paul Fertser5148aed2012-02-11 23:26:37 +0200190 SOC_SINGLE_TLV("Mic2 Playback Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200191 ALC5632_MIC_VOL, 0, 31, 1, vol_tlv),
192 SOC_DOUBLE_TLV("Rec Capture Volume",
193 ALC5632_ADC_REC_GAIN, 8, 0, 31, 0, adc_rec_tlv),
194 SOC_SINGLE_TLV("Mic 1 Boost Volume",
Paul Fertserabb015b2012-02-11 23:26:36 +0200195 ALC5632_MIC_CTRL, 10, 3, 0, boost_tlv),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200196 SOC_SINGLE_TLV("Mic 2 Boost Volume",
Paul Fertserabb015b2012-02-11 23:26:36 +0200197 ALC5632_MIC_CTRL, 8, 3, 0, boost_tlv),
Paul Fertser5148aed2012-02-11 23:26:37 +0200198 SOC_SINGLE_TLV("DMIC Boost Capture Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200199 ALC5632_DIGI_BOOST_CTRL, 0, 7, 0, dig_tlv),
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200200 SOC_SINGLE("DMIC En Capture Switch",
201 ALC5632_DIGI_BOOST_CTRL, 15, 1, 0),
202 SOC_SINGLE("DMIC PreFilter Capture Switch",
203 ALC5632_DIGI_BOOST_CTRL, 12, 1, 0),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200204};
205
206/*
207 * DAPM Controls
208 */
209static const struct snd_kcontrol_new alc5632_hp_mixer_controls[] = {
210SOC_DAPM_SINGLE("LI2HP Playback Switch", ALC5632_LINE_IN_VOL, 15, 1, 1),
211SOC_DAPM_SINGLE("PHONE2HP Playback Switch", ALC5632_PHONE_IN_VOL, 15, 1, 1),
212SOC_DAPM_SINGLE("MIC12HP Playback Switch", ALC5632_MIC_ROUTING_CTRL, 15, 1, 1),
213SOC_DAPM_SINGLE("MIC22HP Playback Switch", ALC5632_MIC_ROUTING_CTRL, 11, 1, 1),
214SOC_DAPM_SINGLE("VOICE2HP Playback Switch", ALC5632_VOICE_DAC_VOL, 15, 1, 1),
215};
216
217static const struct snd_kcontrol_new alc5632_hpl_mixer_controls[] = {
218SOC_DAPM_SINGLE("ADC2HP_L Playback Switch", ALC5632_ADC_REC_GAIN, 15, 1, 1),
219SOC_DAPM_SINGLE("DACL2HP Playback Switch", ALC5632_MIC_ROUTING_CTRL, 3, 1, 1),
220};
221
222static const struct snd_kcontrol_new alc5632_hpr_mixer_controls[] = {
223SOC_DAPM_SINGLE("ADC2HP_R Playback Switch", ALC5632_ADC_REC_GAIN, 7, 1, 1),
224SOC_DAPM_SINGLE("DACR2HP Playback Switch", ALC5632_MIC_ROUTING_CTRL, 2, 1, 1),
225};
226
227static const struct snd_kcontrol_new alc5632_mono_mixer_controls[] = {
228SOC_DAPM_SINGLE("ADC2MONO_L Playback Switch", ALC5632_ADC_REC_GAIN, 14, 1, 1),
229SOC_DAPM_SINGLE("ADC2MONO_R Playback Switch", ALC5632_ADC_REC_GAIN, 6, 1, 1),
230SOC_DAPM_SINGLE("LI2MONO Playback Switch", ALC5632_LINE_IN_VOL, 13, 1, 1),
231SOC_DAPM_SINGLE("MIC12MONO Playback Switch",
232 ALC5632_MIC_ROUTING_CTRL, 13, 1, 1),
233SOC_DAPM_SINGLE("MIC22MONO Playback Switch",
234 ALC5632_MIC_ROUTING_CTRL, 9, 1, 1),
235SOC_DAPM_SINGLE("DAC2MONO Playback Switch", ALC5632_MIC_ROUTING_CTRL, 0, 1, 1),
236SOC_DAPM_SINGLE("VOICE2MONO Playback Switch", ALC5632_VOICE_DAC_VOL, 13, 1, 1),
237};
238
239static const struct snd_kcontrol_new alc5632_speaker_mixer_controls[] = {
240SOC_DAPM_SINGLE("LI2SPK Playback Switch", ALC5632_LINE_IN_VOL, 14, 1, 1),
241SOC_DAPM_SINGLE("PHONE2SPK Playback Switch", ALC5632_PHONE_IN_VOL, 14, 1, 1),
242SOC_DAPM_SINGLE("MIC12SPK Playback Switch",
243 ALC5632_MIC_ROUTING_CTRL, 14, 1, 1),
244SOC_DAPM_SINGLE("MIC22SPK Playback Switch",
245 ALC5632_MIC_ROUTING_CTRL, 10, 1, 1),
246SOC_DAPM_SINGLE("DAC2SPK Playback Switch", ALC5632_MIC_ROUTING_CTRL, 1, 1, 1),
247SOC_DAPM_SINGLE("VOICE2SPK Playback Switch", ALC5632_VOICE_DAC_VOL, 14, 1, 1),
248};
249
250/* Left Record Mixer */
251static const struct snd_kcontrol_new alc5632_captureL_mixer_controls[] = {
Andrey Danina15a9af2012-02-11 23:26:30 +0200252SOC_DAPM_SINGLE("MIC12REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 14, 1, 1),
253SOC_DAPM_SINGLE("MIC22REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 13, 1, 1),
254SOC_DAPM_SINGLE("LIL2REC Capture Switch", ALC5632_ADC_REC_MIXER, 12, 1, 1),
255SOC_DAPM_SINGLE("PH2REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 11, 1, 1),
256SOC_DAPM_SINGLE("HPL2REC Capture Switch", ALC5632_ADC_REC_MIXER, 10, 1, 1),
257SOC_DAPM_SINGLE("SPK2REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 9, 1, 1),
258SOC_DAPM_SINGLE("MONO2REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 8, 1, 1),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200259};
260
261/* Right Record Mixer */
262static const struct snd_kcontrol_new alc5632_captureR_mixer_controls[] = {
Andrey Danina15a9af2012-02-11 23:26:30 +0200263SOC_DAPM_SINGLE("MIC12REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 6, 1, 1),
264SOC_DAPM_SINGLE("MIC22REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 5, 1, 1),
265SOC_DAPM_SINGLE("LIR2REC Capture Switch", ALC5632_ADC_REC_MIXER, 4, 1, 1),
266SOC_DAPM_SINGLE("PH2REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 3, 1, 1),
267SOC_DAPM_SINGLE("HPR2REC Capture Switch", ALC5632_ADC_REC_MIXER, 2, 1, 1),
268SOC_DAPM_SINGLE("SPK2REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 1, 1, 1),
269SOC_DAPM_SINGLE("MONO2REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 0, 1, 1),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200270};
271
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200272/* Dmic Mixer */
273static const struct snd_kcontrol_new alc5632_dmicl_mixer_controls[] = {
274SOC_DAPM_SINGLE("DMICL2ADC Capture Switch", ALC5632_DIGI_BOOST_CTRL, 7, 1, 1),
275};
276static const struct snd_kcontrol_new alc5632_dmicr_mixer_controls[] = {
277SOC_DAPM_SINGLE("DMICR2ADC Capture Switch", ALC5632_DIGI_BOOST_CTRL, 6, 1, 1),
278};
279
Andrey Danin75b35662012-02-11 23:26:32 +0200280static const char * const alc5632_spk_n_sour_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200281 "RN/-R", "RP/+R", "LN/-R", "Mute"};
Andrey Danin75b35662012-02-11 23:26:32 +0200282static const char * const alc5632_hpl_out_input_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200283 "Vmid", "HP Left Mix"};
Andrey Danin75b35662012-02-11 23:26:32 +0200284static const char * const alc5632_hpr_out_input_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200285 "Vmid", "HP Right Mix"};
Andrey Danin75b35662012-02-11 23:26:32 +0200286static const char * const alc5632_spkout_input_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200287 "Vmid", "HPOut Mix", "Speaker Mix", "Mono Mix"};
Andrey Danin75b35662012-02-11 23:26:32 +0200288static const char * const alc5632_aux_out_input_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200289 "Vmid", "HPOut Mix", "Speaker Mix", "Mono Mix"};
Andrey Danin75b35662012-02-11 23:26:32 +0200290static const char * const alc5632_adcr_func_sel[] = {
291 "Stereo ADC", "Voice ADC"};
292static const char * const alc5632_i2s_out_sel[] = {
293 "ADC LR", "Voice Stereo Digital"};
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200294
295/* auxout output mux */
296static const struct soc_enum alc5632_aux_out_input_enum =
297SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 6, 4, alc5632_aux_out_input_sel);
298static const struct snd_kcontrol_new alc5632_auxout_mux_controls =
299SOC_DAPM_ENUM("AuxOut Mux", alc5632_aux_out_input_enum);
300
301/* speaker output mux */
302static const struct soc_enum alc5632_spkout_input_enum =
303SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 10, 4, alc5632_spkout_input_sel);
304static const struct snd_kcontrol_new alc5632_spkout_mux_controls =
305SOC_DAPM_ENUM("SpeakerOut Mux", alc5632_spkout_input_enum);
306
307/* headphone left output mux */
308static const struct soc_enum alc5632_hpl_out_input_enum =
309SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 9, 2, alc5632_hpl_out_input_sel);
310static const struct snd_kcontrol_new alc5632_hpl_out_mux_controls =
311SOC_DAPM_ENUM("Left Headphone Mux", alc5632_hpl_out_input_enum);
312
313/* headphone right output mux */
314static const struct soc_enum alc5632_hpr_out_input_enum =
315SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 8, 2, alc5632_hpr_out_input_sel);
316static const struct snd_kcontrol_new alc5632_hpr_out_mux_controls =
317SOC_DAPM_ENUM("Right Headphone Mux", alc5632_hpr_out_input_enum);
318
319/* speaker output N select */
320static const struct soc_enum alc5632_spk_n_sour_enum =
321SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 14, 4, alc5632_spk_n_sour_sel);
322static const struct snd_kcontrol_new alc5632_spkoutn_mux_controls =
323SOC_DAPM_ENUM("SpeakerOut N Mux", alc5632_spk_n_sour_enum);
324
325/* speaker amplifier */
326static const char *alc5632_amp_names[] = {"AB Amp", "D Amp"};
327static const struct soc_enum alc5632_amp_enum =
328 SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 13, 2, alc5632_amp_names);
329static const struct snd_kcontrol_new alc5632_amp_mux_controls =
330 SOC_DAPM_ENUM("AB-D Amp Mux", alc5632_amp_enum);
331
Andrey Danin75b35662012-02-11 23:26:32 +0200332/* ADC output select */
333static const struct soc_enum alc5632_adcr_func_enum =
334 SOC_ENUM_SINGLE(ALC5632_DAC_FUNC_SELECT, 5, 2, alc5632_adcr_func_sel);
335static const struct snd_kcontrol_new alc5632_adcr_func_controls =
336 SOC_DAPM_ENUM("ADCR Mux", alc5632_adcr_func_enum);
337
338/* I2S out select */
339static const struct soc_enum alc5632_i2s_out_enum =
340 SOC_ENUM_SINGLE(ALC5632_I2S_OUT_CTL, 5, 2, alc5632_i2s_out_sel);
341static const struct snd_kcontrol_new alc5632_i2s_out_controls =
342 SOC_DAPM_ENUM("I2SOut Mux", alc5632_i2s_out_enum);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200343
344static const struct snd_soc_dapm_widget alc5632_dapm_widgets[] = {
345/* Muxes */
346SND_SOC_DAPM_MUX("AuxOut Mux", SND_SOC_NOPM, 0, 0,
347 &alc5632_auxout_mux_controls),
348SND_SOC_DAPM_MUX("SpeakerOut Mux", SND_SOC_NOPM, 0, 0,
349 &alc5632_spkout_mux_controls),
350SND_SOC_DAPM_MUX("Left Headphone Mux", SND_SOC_NOPM, 0, 0,
351 &alc5632_hpl_out_mux_controls),
352SND_SOC_DAPM_MUX("Right Headphone Mux", SND_SOC_NOPM, 0, 0,
353 &alc5632_hpr_out_mux_controls),
354SND_SOC_DAPM_MUX("SpeakerOut N Mux", SND_SOC_NOPM, 0, 0,
355 &alc5632_spkoutn_mux_controls),
Andrey Danin75b35662012-02-11 23:26:32 +0200356SND_SOC_DAPM_MUX("ADCR Mux", SND_SOC_NOPM, 0, 0,
357 &alc5632_adcr_func_controls),
Andrey Danin9e751772012-02-11 23:26:34 +0200358SND_SOC_DAPM_MUX("I2SOut Mux", ALC5632_PWR_MANAG_ADD1, 11, 0,
Andrey Danin75b35662012-02-11 23:26:32 +0200359 &alc5632_i2s_out_controls),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200360
361/* output mixers */
362SND_SOC_DAPM_MIXER("HP Mix", SND_SOC_NOPM, 0, 0,
363 &alc5632_hp_mixer_controls[0],
364 ARRAY_SIZE(alc5632_hp_mixer_controls)),
365SND_SOC_DAPM_MIXER("HPR Mix", ALC5632_PWR_MANAG_ADD2, 4, 0,
366 &alc5632_hpr_mixer_controls[0],
367 ARRAY_SIZE(alc5632_hpr_mixer_controls)),
368SND_SOC_DAPM_MIXER("HPL Mix", ALC5632_PWR_MANAG_ADD2, 5, 0,
369 &alc5632_hpl_mixer_controls[0],
370 ARRAY_SIZE(alc5632_hpl_mixer_controls)),
371SND_SOC_DAPM_MIXER("HPOut Mix", SND_SOC_NOPM, 0, 0, NULL, 0),
372SND_SOC_DAPM_MIXER("Mono Mix", ALC5632_PWR_MANAG_ADD2, 2, 0,
373 &alc5632_mono_mixer_controls[0],
374 ARRAY_SIZE(alc5632_mono_mixer_controls)),
375SND_SOC_DAPM_MIXER("Speaker Mix", ALC5632_PWR_MANAG_ADD2, 3, 0,
376 &alc5632_speaker_mixer_controls[0],
377 ARRAY_SIZE(alc5632_speaker_mixer_controls)),
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200378SND_SOC_DAPM_MIXER("DMICL Mix", SND_SOC_NOPM, 0, 0,
379 &alc5632_dmicl_mixer_controls[0],
380 ARRAY_SIZE(alc5632_dmicl_mixer_controls)),
381SND_SOC_DAPM_MIXER("DMICR Mix", SND_SOC_NOPM, 0, 0,
382 &alc5632_dmicr_mixer_controls[0],
383 ARRAY_SIZE(alc5632_dmicr_mixer_controls)),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200384
385/* input mixers */
386SND_SOC_DAPM_MIXER("Left Capture Mix", ALC5632_PWR_MANAG_ADD2, 1, 0,
387 &alc5632_captureL_mixer_controls[0],
388 ARRAY_SIZE(alc5632_captureL_mixer_controls)),
389SND_SOC_DAPM_MIXER("Right Capture Mix", ALC5632_PWR_MANAG_ADD2, 0, 0,
390 &alc5632_captureR_mixer_controls[0],
391 ARRAY_SIZE(alc5632_captureR_mixer_controls)),
392
Andrey Danin75b35662012-02-11 23:26:32 +0200393SND_SOC_DAPM_AIF_IN("AIFRXL", "Left HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
394SND_SOC_DAPM_AIF_IN("AIFRXR", "Right HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
395SND_SOC_DAPM_AIF_OUT("AIFTXL", "Left HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
396SND_SOC_DAPM_AIF_OUT("AIFTXR", "Right HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
397SND_SOC_DAPM_AIF_IN("VAIFRX", "Voice Playback", 0, SND_SOC_NOPM, 0, 0),
398SND_SOC_DAPM_AIF_OUT("VAIFTX", "Voice Capture", 0, SND_SOC_NOPM, 0, 0),
399
400SND_SOC_DAPM_DAC("Voice DAC", NULL, ALC5632_PWR_MANAG_ADD2, 10, 0),
401SND_SOC_DAPM_DAC("Left DAC", NULL, ALC5632_PWR_MANAG_ADD2, 9, 0),
402SND_SOC_DAPM_DAC("Right DAC", NULL, ALC5632_PWR_MANAG_ADD2, 8, 0),
403SND_SOC_DAPM_ADC("Left ADC", NULL, ALC5632_PWR_MANAG_ADD2, 7, 0),
404SND_SOC_DAPM_ADC("Right ADC", NULL, ALC5632_PWR_MANAG_ADD2, 6, 0),
405
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200406SND_SOC_DAPM_MIXER("DAC Left Channel", ALC5632_PWR_MANAG_ADD1, 15, 0, NULL, 0),
407SND_SOC_DAPM_MIXER("DAC Right Channel",
408 ALC5632_PWR_MANAG_ADD1, 14, 0, NULL, 0),
409SND_SOC_DAPM_MIXER("I2S Mix", ALC5632_PWR_MANAG_ADD1, 11, 0, NULL, 0),
410SND_SOC_DAPM_MIXER("Phone Mix", SND_SOC_NOPM, 0, 0, NULL, 0),
411SND_SOC_DAPM_MIXER("Line Mix", SND_SOC_NOPM, 0, 0, NULL, 0),
Andrey Danin75b35662012-02-11 23:26:32 +0200412SND_SOC_DAPM_MIXER("Voice Mix", SND_SOC_NOPM, 0, 0, NULL, 0),
413SND_SOC_DAPM_MIXER("ADCLR", SND_SOC_NOPM, 0, 0, NULL, 0),
414
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200415SND_SOC_DAPM_PGA("Left Headphone", ALC5632_PWR_MANAG_ADD3, 11, 0, NULL, 0),
416SND_SOC_DAPM_PGA("Right Headphone", ALC5632_PWR_MANAG_ADD3, 10, 0, NULL, 0),
417SND_SOC_DAPM_PGA("Left Speaker", ALC5632_PWR_MANAG_ADD3, 13, 0, NULL, 0),
418SND_SOC_DAPM_PGA("Right Speaker", ALC5632_PWR_MANAG_ADD3, 12, 0, NULL, 0),
419SND_SOC_DAPM_PGA("Aux Out", ALC5632_PWR_MANAG_ADD3, 14, 0, NULL, 0),
420SND_SOC_DAPM_PGA("Left LineIn", ALC5632_PWR_MANAG_ADD3, 7, 0, NULL, 0),
421SND_SOC_DAPM_PGA("Right LineIn", ALC5632_PWR_MANAG_ADD3, 6, 0, NULL, 0),
422SND_SOC_DAPM_PGA("Phone", ALC5632_PWR_MANAG_ADD3, 5, 0, NULL, 0),
423SND_SOC_DAPM_PGA("Phone ADMix", ALC5632_PWR_MANAG_ADD3, 4, 0, NULL, 0),
424SND_SOC_DAPM_PGA("MIC1 PGA", ALC5632_PWR_MANAG_ADD3, 3, 0, NULL, 0),
425SND_SOC_DAPM_PGA("MIC2 PGA", ALC5632_PWR_MANAG_ADD3, 2, 0, NULL, 0),
426SND_SOC_DAPM_PGA("MIC1 Pre Amp", ALC5632_PWR_MANAG_ADD3, 1, 0, NULL, 0),
427SND_SOC_DAPM_PGA("MIC2 Pre Amp", ALC5632_PWR_MANAG_ADD3, 0, 0, NULL, 0),
Leon Romanovsky9215aa42011-12-12 21:43:45 +0200428SND_SOC_DAPM_SUPPLY("MICBIAS1", ALC5632_PWR_MANAG_ADD1, 3, 0, NULL, 0),
429SND_SOC_DAPM_SUPPLY("MICBIAS2", ALC5632_PWR_MANAG_ADD1, 2, 0, NULL, 0),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200430
431SND_SOC_DAPM_PGA_E("D Amp", ALC5632_PWR_MANAG_ADD2, 14, 0, NULL, 0,
432 amp_mixer_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
433SND_SOC_DAPM_PGA("AB Amp", ALC5632_PWR_MANAG_ADD2, 15, 0, NULL, 0),
434SND_SOC_DAPM_MUX("AB-D Amp Mux", ALC5632_PWR_MANAG_ADD1, 10, 0,
435 &alc5632_amp_mux_controls),
436
437SND_SOC_DAPM_OUTPUT("AUXOUT"),
438SND_SOC_DAPM_OUTPUT("HPL"),
439SND_SOC_DAPM_OUTPUT("HPR"),
440SND_SOC_DAPM_OUTPUT("SPKOUT"),
441SND_SOC_DAPM_OUTPUT("SPKOUTN"),
Andrey Danin75b35662012-02-11 23:26:32 +0200442
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200443SND_SOC_DAPM_INPUT("LINEINL"),
444SND_SOC_DAPM_INPUT("LINEINR"),
445SND_SOC_DAPM_INPUT("PHONEP"),
446SND_SOC_DAPM_INPUT("PHONEN"),
Andrey Danin75b35662012-02-11 23:26:32 +0200447SND_SOC_DAPM_INPUT("DMICDAT"),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200448SND_SOC_DAPM_INPUT("MIC1"),
449SND_SOC_DAPM_INPUT("MIC2"),
450SND_SOC_DAPM_VMID("Vmid"),
451};
452
453
454static const struct snd_soc_dapm_route alc5632_dapm_routes[] = {
Andrey Danin75b35662012-02-11 23:26:32 +0200455 /* Playback streams */
456 {"Left DAC", NULL, "AIFRXL"},
457 {"Right DAC", NULL, "AIFRXR"},
458
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200459 /* virtual mixer - mixes left & right channels */
460 {"I2S Mix", NULL, "Left DAC"},
461 {"I2S Mix", NULL, "Right DAC"},
462 {"Line Mix", NULL, "Right LineIn"},
463 {"Line Mix", NULL, "Left LineIn"},
464 {"Phone Mix", NULL, "Phone"},
465 {"Phone Mix", NULL, "Phone ADMix"},
466 {"AUXOUT", NULL, "Aux Out"},
467
468 /* DAC */
469 {"DAC Right Channel", NULL, "I2S Mix"},
470 {"DAC Left Channel", NULL, "I2S Mix"},
471
472 /* HP mixer */
473 {"HPL Mix", "ADC2HP_L Playback Switch", "Left Capture Mix"},
474 {"HPL Mix", NULL, "HP Mix"},
475 {"HPR Mix", "ADC2HP_R Playback Switch", "Right Capture Mix"},
476 {"HPR Mix", NULL, "HP Mix"},
477 {"HP Mix", "LI2HP Playback Switch", "Line Mix"},
478 {"HP Mix", "PHONE2HP Playback Switch", "Phone Mix"},
479 {"HP Mix", "MIC12HP Playback Switch", "MIC1 PGA"},
480 {"HP Mix", "MIC22HP Playback Switch", "MIC2 PGA"},
Andrey Danin75b35662012-02-11 23:26:32 +0200481 {"HP Mix", "VOICE2HP Playback Switch", "Voice Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200482 {"HPR Mix", "DACR2HP Playback Switch", "DAC Right Channel"},
483 {"HPL Mix", "DACL2HP Playback Switch", "DAC Left Channel"},
Marc Dietrich2435d462012-02-11 23:26:35 +0200484 {"HPOut Mix", NULL, "HP Mix"},
485 {"HPOut Mix", NULL, "HPR Mix"},
486 {"HPOut Mix", NULL, "HPL Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200487
488 /* speaker mixer */
489 {"Speaker Mix", "LI2SPK Playback Switch", "Line Mix"},
490 {"Speaker Mix", "PHONE2SPK Playback Switch", "Phone Mix"},
491 {"Speaker Mix", "MIC12SPK Playback Switch", "MIC1 PGA"},
492 {"Speaker Mix", "MIC22SPK Playback Switch", "MIC2 PGA"},
493 {"Speaker Mix", "DAC2SPK Playback Switch", "DAC Left Channel"},
Andrey Danin75b35662012-02-11 23:26:32 +0200494 {"Speaker Mix", "VOICE2SPK Playback Switch", "Voice Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200495
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200496 /* mono mixer */
497 {"Mono Mix", "ADC2MONO_L Playback Switch", "Left Capture Mix"},
498 {"Mono Mix", "ADC2MONO_R Playback Switch", "Right Capture Mix"},
499 {"Mono Mix", "LI2MONO Playback Switch", "Line Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200500 {"Mono Mix", "MIC12MONO Playback Switch", "MIC1 PGA"},
501 {"Mono Mix", "MIC22MONO Playback Switch", "MIC2 PGA"},
502 {"Mono Mix", "DAC2MONO Playback Switch", "DAC Left Channel"},
Andrey Danin75b35662012-02-11 23:26:32 +0200503 {"Mono Mix", "VOICE2MONO Playback Switch", "Voice Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200504
505 /* Left record mixer */
Andrey Danina15a9af2012-02-11 23:26:30 +0200506 {"Left Capture Mix", "LIL2REC Capture Switch", "LINEINL"},
507 {"Left Capture Mix", "PH2REC_L Capture Switch", "PHONEN"},
508 {"Left Capture Mix", "MIC12REC_L Capture Switch", "MIC1 Pre Amp"},
509 {"Left Capture Mix", "MIC22REC_L Capture Switch", "MIC2 Pre Amp"},
510 {"Left Capture Mix", "HPL2REC Capture Switch", "HPL Mix"},
511 {"Left Capture Mix", "SPK2REC_L Capture Switch", "Speaker Mix"},
512 {"Left Capture Mix", "MONO2REC_L Capture Switch", "Mono Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200513
514 /*Right record mixer */
Andrey Danina15a9af2012-02-11 23:26:30 +0200515 {"Right Capture Mix", "LIR2REC Capture Switch", "LINEINR"},
516 {"Right Capture Mix", "PH2REC_R Capture Switch", "PHONEP"},
517 {"Right Capture Mix", "MIC12REC_R Capture Switch", "MIC1 Pre Amp"},
518 {"Right Capture Mix", "MIC22REC_R Capture Switch", "MIC2 Pre Amp"},
519 {"Right Capture Mix", "HPR2REC Capture Switch", "HPR Mix"},
520 {"Right Capture Mix", "SPK2REC_R Capture Switch", "Speaker Mix"},
521 {"Right Capture Mix", "MONO2REC_R Capture Switch", "Mono Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200522
523 /* headphone left mux */
524 {"Left Headphone Mux", "HP Left Mix", "HPL Mix"},
525 {"Left Headphone Mux", "Vmid", "Vmid"},
526
527 /* headphone right mux */
528 {"Right Headphone Mux", "HP Right Mix", "HPR Mix"},
529 {"Right Headphone Mux", "Vmid", "Vmid"},
530
531 /* speaker out mux */
532 {"SpeakerOut Mux", "Vmid", "Vmid"},
533 {"SpeakerOut Mux", "HPOut Mix", "HPOut Mix"},
534 {"SpeakerOut Mux", "Speaker Mix", "Speaker Mix"},
535 {"SpeakerOut Mux", "Mono Mix", "Mono Mix"},
536
537 /* Mono/Aux Out mux */
538 {"AuxOut Mux", "Vmid", "Vmid"},
539 {"AuxOut Mux", "HPOut Mix", "HPOut Mix"},
540 {"AuxOut Mux", "Speaker Mix", "Speaker Mix"},
541 {"AuxOut Mux", "Mono Mix", "Mono Mix"},
542
543 /* output pga */
544 {"HPL", NULL, "Left Headphone"},
545 {"Left Headphone", NULL, "Left Headphone Mux"},
546 {"HPR", NULL, "Right Headphone"},
547 {"Right Headphone", NULL, "Right Headphone Mux"},
548 {"Aux Out", NULL, "AuxOut Mux"},
549
550 /* input pga */
551 {"Left LineIn", NULL, "LINEINL"},
552 {"Right LineIn", NULL, "LINEINR"},
553 {"Phone", NULL, "PHONEP"},
554 {"MIC1 Pre Amp", NULL, "MIC1"},
555 {"MIC2 Pre Amp", NULL, "MIC2"},
556 {"MIC1 PGA", NULL, "MIC1 Pre Amp"},
557 {"MIC2 PGA", NULL, "MIC2 Pre Amp"},
558
559 /* left ADC */
560 {"Left ADC", NULL, "Left Capture Mix"},
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200561 {"DMICL Mix", "DMICL2ADC Capture Switch", "DMICDAT"},
562 {"Left ADC", NULL, "DMICL Mix"},
Andrey Danin75b35662012-02-11 23:26:32 +0200563 {"ADCLR", NULL, "Left ADC"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200564
565 /* right ADC */
Andrey Danin75b35662012-02-11 23:26:32 +0200566 {"Right ADC", NULL, "Right Capture Mix"},
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200567 {"DMICR Mix", "DMICR2ADC Capture Switch", "DMICDAT"},
568 {"Right ADC", NULL, "DMICR Mix"},
Andrey Danin75b35662012-02-11 23:26:32 +0200569 {"ADCR Mux", "Stereo ADC", "Right ADC"},
570 {"ADCR Mux", "Voice ADC", "Right ADC"},
571 {"ADCLR", NULL, "ADCR Mux"},
572 {"VAIFTX", NULL, "ADCR Mux"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200573
Andrey Danin75b35662012-02-11 23:26:32 +0200574 /* Digital I2S out */
575 {"I2SOut Mux", "ADC LR", "ADCLR"},
576 {"I2SOut Mux", "Voice Stereo Digital", "VAIFRX"},
577 {"AIFTXL", NULL, "I2SOut Mux"},
578 {"AIFTXR", NULL, "I2SOut Mux"},
579
580 /* Voice Mix */
581 {"Voice DAC", NULL, "VAIFRX"},
582 {"Voice Mix", NULL, "Voice DAC"},
583
584 /* Speaker Output */
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200585 {"SpeakerOut N Mux", "RN/-R", "Left Speaker"},
586 {"SpeakerOut N Mux", "RP/+R", "Left Speaker"},
587 {"SpeakerOut N Mux", "LN/-R", "Left Speaker"},
588 {"SpeakerOut N Mux", "Mute", "Vmid"},
589
590 {"SpeakerOut N Mux", "RN/-R", "Right Speaker"},
591 {"SpeakerOut N Mux", "RP/+R", "Right Speaker"},
592 {"SpeakerOut N Mux", "LN/-R", "Right Speaker"},
593 {"SpeakerOut N Mux", "Mute", "Vmid"},
594
595 {"AB Amp", NULL, "SpeakerOut Mux"},
596 {"D Amp", NULL, "SpeakerOut Mux"},
597 {"AB-D Amp Mux", "AB Amp", "AB Amp"},
598 {"AB-D Amp Mux", "D Amp", "D Amp"},
599 {"Left Speaker", NULL, "AB-D Amp Mux"},
600 {"Right Speaker", NULL, "AB-D Amp Mux"},
601
602 {"SPKOUT", NULL, "Left Speaker"},
603 {"SPKOUT", NULL, "Right Speaker"},
604
605 {"SPKOUTN", NULL, "SpeakerOut N Mux"},
606
607};
608
609/* PLL divisors */
610struct _pll_div {
611 u32 pll_in;
612 u32 pll_out;
613 u16 regvalue;
614};
615
616/* Note : pll code from original alc5632 driver. Not sure of how good it is */
617/* usefull only for master mode */
618static const struct _pll_div codec_master_pll_div[] = {
619
620 { 2048000, 8192000, 0x0ea0},
621 { 3686400, 8192000, 0x4e27},
622 { 12000000, 8192000, 0x456b},
623 { 13000000, 8192000, 0x495f},
624 { 13100000, 8192000, 0x0320},
625 { 2048000, 11289600, 0xf637},
626 { 3686400, 11289600, 0x2f22},
627 { 12000000, 11289600, 0x3e2f},
628 { 13000000, 11289600, 0x4d5b},
629 { 13100000, 11289600, 0x363b},
630 { 2048000, 16384000, 0x1ea0},
631 { 3686400, 16384000, 0x9e27},
632 { 12000000, 16384000, 0x452b},
633 { 13000000, 16384000, 0x542f},
634 { 13100000, 16384000, 0x03a0},
635 { 2048000, 16934400, 0xe625},
636 { 3686400, 16934400, 0x9126},
637 { 12000000, 16934400, 0x4d2c},
638 { 13000000, 16934400, 0x742f},
639 { 13100000, 16934400, 0x3c27},
640 { 2048000, 22579200, 0x2aa0},
641 { 3686400, 22579200, 0x2f20},
642 { 12000000, 22579200, 0x7e2f},
643 { 13000000, 22579200, 0x742f},
644 { 13100000, 22579200, 0x3c27},
645 { 2048000, 24576000, 0x2ea0},
646 { 3686400, 24576000, 0xee27},
647 { 12000000, 24576000, 0x2915},
648 { 13000000, 24576000, 0x772e},
649 { 13100000, 24576000, 0x0d20},
650};
651
652/* FOUT = MCLK*(N+2)/((M+2)*(K+2))
653 N: bit 15:8 (div 2 .. div 257)
654 K: bit 6:4 typical 2
655 M: bit 3:0 (div 2 .. div 17)
656
657 same as for 5623 - thanks!
658*/
659
660static const struct _pll_div codec_slave_pll_div[] = {
661
662 { 1024000, 16384000, 0x3ea0},
663 { 1411200, 22579200, 0x3ea0},
664 { 1536000, 24576000, 0x3ea0},
665 { 2048000, 16384000, 0x1ea0},
666 { 2822400, 22579200, 0x1ea0},
667 { 3072000, 24576000, 0x1ea0},
668
669};
670
671static int alc5632_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
672 int source, unsigned int freq_in, unsigned int freq_out)
673{
674 int i;
675 struct snd_soc_codec *codec = codec_dai->codec;
676 int gbl_clk = 0, pll_div = 0;
677 u16 reg;
678
679 if (pll_id < ALC5632_PLL_FR_MCLK || pll_id > ALC5632_PLL_FR_VBCLK)
680 return -EINVAL;
681
682 /* Disable PLL power */
683 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
684 ALC5632_PWR_ADD2_PLL1,
685 0);
686 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
687 ALC5632_PWR_ADD2_PLL2,
688 0);
689
690 /* pll is not used in slave mode */
691 reg = snd_soc_read(codec, ALC5632_DAI_CONTROL);
692 if (reg & ALC5632_DAI_SDP_SLAVE_MODE)
693 return 0;
694
695 if (!freq_in || !freq_out)
696 return 0;
697
698 switch (pll_id) {
699 case ALC5632_PLL_FR_MCLK:
700 for (i = 0; i < ARRAY_SIZE(codec_master_pll_div); i++) {
701 if (codec_master_pll_div[i].pll_in == freq_in
702 && codec_master_pll_div[i].pll_out == freq_out) {
703 /* PLL source from MCLK */
704 pll_div = codec_master_pll_div[i].regvalue;
705 break;
706 }
707 }
708 break;
709 case ALC5632_PLL_FR_BCLK:
710 for (i = 0; i < ARRAY_SIZE(codec_slave_pll_div); i++) {
711 if (codec_slave_pll_div[i].pll_in == freq_in
712 && codec_slave_pll_div[i].pll_out == freq_out) {
713 /* PLL source from Bitclk */
714 gbl_clk = ALC5632_PLL_FR_BCLK;
715 pll_div = codec_slave_pll_div[i].regvalue;
716 break;
717 }
718 }
719 break;
720 case ALC5632_PLL_FR_VBCLK:
721 for (i = 0; i < ARRAY_SIZE(codec_slave_pll_div); i++) {
722 if (codec_slave_pll_div[i].pll_in == freq_in
723 && codec_slave_pll_div[i].pll_out == freq_out) {
724 /* PLL source from voice clock */
725 gbl_clk = ALC5632_PLL_FR_VBCLK;
726 pll_div = codec_slave_pll_div[i].regvalue;
727 break;
728 }
729 }
730 break;
731 default:
732 return -EINVAL;
733 }
734
735 if (!pll_div)
736 return -EINVAL;
737
738 /* choose MCLK/BCLK/VBCLK */
739 snd_soc_write(codec, ALC5632_GPCR2, gbl_clk);
740 /* choose PLL1 clock rate */
741 snd_soc_write(codec, ALC5632_PLL1_CTRL, pll_div);
742 /* enable PLL1 */
743 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
744 ALC5632_PWR_ADD2_PLL1,
745 ALC5632_PWR_ADD2_PLL1);
746 /* enable PLL2 */
747 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
748 ALC5632_PWR_ADD2_PLL2,
749 ALC5632_PWR_ADD2_PLL2);
750 /* use PLL1 as main SYSCLK */
751 snd_soc_update_bits(codec, ALC5632_GPCR1,
752 ALC5632_GPCR1_CLK_SYS_SRC_SEL_PLL1,
753 ALC5632_GPCR1_CLK_SYS_SRC_SEL_PLL1);
754
755 return 0;
756}
757
758struct _coeff_div {
759 u16 fs;
760 u16 regvalue;
761};
762
763/* codec hifi mclk (after PLL) clock divider coefficients */
764/* values inspired from column BCLK=32Fs of Appendix A table */
765static const struct _coeff_div coeff_div[] = {
766 {512*1, 0x3075},
767};
768
769static int get_coeff(struct snd_soc_codec *codec, int rate)
770{
771 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec);
772 int i;
773
774 for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
775 if (coeff_div[i].fs * rate == alc5632->sysclk)
776 return i;
777 }
778 return -EINVAL;
779}
780
781/*
782 * Clock after PLL and dividers
783 */
784static int alc5632_set_dai_sysclk(struct snd_soc_dai *codec_dai,
785 int clk_id, unsigned int freq, int dir)
786{
787 struct snd_soc_codec *codec = codec_dai->codec;
788 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec);
789
790 switch (freq) {
Andrey Danin0f613c22012-02-11 23:26:38 +0200791 case 4096000:
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200792 case 8192000:
793 case 11289600:
794 case 12288000:
795 case 16384000:
796 case 16934400:
797 case 18432000:
798 case 22579200:
799 case 24576000:
800 alc5632->sysclk = freq;
801 return 0;
802 }
803 return -EINVAL;
804}
805
806static int alc5632_set_dai_fmt(struct snd_soc_dai *codec_dai,
807 unsigned int fmt)
808{
809 struct snd_soc_codec *codec = codec_dai->codec;
810 u16 iface = 0;
811
812 /* set master/slave audio interface */
813 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
814 case SND_SOC_DAIFMT_CBM_CFM:
815 iface = ALC5632_DAI_SDP_MASTER_MODE;
816 break;
817 case SND_SOC_DAIFMT_CBS_CFS:
818 iface = ALC5632_DAI_SDP_SLAVE_MODE;
819 break;
820 default:
821 return -EINVAL;
822 }
823
824 /* interface format */
825 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
826 case SND_SOC_DAIFMT_I2S:
827 iface |= ALC5632_DAI_I2S_DF_I2S;
828 break;
829 case SND_SOC_DAIFMT_LEFT_J:
830 iface |= ALC5632_DAI_I2S_DF_LEFT;
831 break;
832 case SND_SOC_DAIFMT_DSP_A:
833 iface |= ALC5632_DAI_I2S_DF_PCM_A;
834 break;
835 case SND_SOC_DAIFMT_DSP_B:
836 iface |= ALC5632_DAI_I2S_DF_PCM_B;
837 break;
838 default:
839 return -EINVAL;
840 }
841
842 /* clock inversion */
843 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
844 case SND_SOC_DAIFMT_NB_NF:
845 break;
846 case SND_SOC_DAIFMT_IB_IF:
847 iface |= ALC5632_DAI_MAIN_I2S_BCLK_POL_CTRL;
848 break;
849 case SND_SOC_DAIFMT_IB_NF:
850 iface |= ALC5632_DAI_MAIN_I2S_BCLK_POL_CTRL;
851 break;
852 case SND_SOC_DAIFMT_NB_IF:
853 break;
854 default:
855 return -EINVAL;
856 }
857
858 return snd_soc_write(codec, ALC5632_DAI_CONTROL, iface);
859}
860
861static int alc5632_pcm_hw_params(struct snd_pcm_substream *substream,
862 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
863{
Mark Browne6968a12012-04-04 15:58:16 +0100864 struct snd_soc_codec *codec = dai->codec;
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200865 int coeff, rate;
866 u16 iface;
867
868 iface = snd_soc_read(codec, ALC5632_DAI_CONTROL);
869 iface &= ~ALC5632_DAI_I2S_DL_MASK;
870
871 /* bit size */
872 switch (params_format(params)) {
873 case SNDRV_PCM_FORMAT_S16_LE:
874 iface |= ALC5632_DAI_I2S_DL_16;
875 break;
876 case SNDRV_PCM_FORMAT_S20_3LE:
877 iface |= ALC5632_DAI_I2S_DL_20;
878 break;
879 case SNDRV_PCM_FORMAT_S24_LE:
880 iface |= ALC5632_DAI_I2S_DL_24;
881 break;
882 default:
883 return -EINVAL;
884 }
885
886 /* set iface & srate */
887 snd_soc_write(codec, ALC5632_DAI_CONTROL, iface);
888 rate = params_rate(params);
889 coeff = get_coeff(codec, rate);
890 if (coeff < 0)
891 return -EINVAL;
892
893 coeff = coeff_div[coeff].regvalue;
894 snd_soc_write(codec, ALC5632_DAC_CLK_CTRL1, coeff);
895
896 return 0;
897}
898
899static int alc5632_mute(struct snd_soc_dai *dai, int mute)
900{
901 struct snd_soc_codec *codec = dai->codec;
Leon Romanovsky88c494b2011-11-10 21:22:16 +0200902 u16 hp_mute = ALC5632_MISC_HP_DEPOP_MUTE_L
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200903 |ALC5632_MISC_HP_DEPOP_MUTE_R;
904 u16 mute_reg = snd_soc_read(codec, ALC5632_MISC_CTRL) & ~hp_mute;
905
906 if (mute)
907 mute_reg |= hp_mute;
908
909 return snd_soc_write(codec, ALC5632_MISC_CTRL, mute_reg);
910}
911
912#define ALC5632_ADD2_POWER_EN (ALC5632_PWR_ADD2_VREF)
913
914#define ALC5632_ADD3_POWER_EN (ALC5632_PWR_ADD3_MIC1_BOOST_AD)
915
916#define ALC5632_ADD1_POWER_EN \
917 (ALC5632_PWR_ADD1_DAC_REF \
918 | ALC5632_PWR_ADD1_SOFTGEN_EN \
919 | ALC5632_PWR_ADD1_HP_OUT_AMP \
920 | ALC5632_PWR_ADD1_HP_OUT_ENH_AMP \
921 | ALC5632_PWR_ADD1_MAIN_BIAS)
922
923static void enable_power_depop(struct snd_soc_codec *codec)
924{
925 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1,
926 ALC5632_PWR_ADD1_SOFTGEN_EN,
927 ALC5632_PWR_ADD1_SOFTGEN_EN);
928
929 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD3,
930 ALC5632_ADD3_POWER_EN,
931 ALC5632_ADD3_POWER_EN);
932
933 snd_soc_update_bits(codec, ALC5632_MISC_CTRL,
934 ALC5632_MISC_HP_DEPOP_MODE2_EN,
935 ALC5632_MISC_HP_DEPOP_MODE2_EN);
936
937 /* "normal" mode: 0 @ 26 */
938 /* set all PR0-7 mixers to 0 */
939 snd_soc_update_bits(codec, ALC5632_PWR_DOWN_CTRL_STATUS,
940 ALC5632_PWR_DOWN_CTRL_STATUS_MASK,
941 0);
942
943 msleep(500);
944
945 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
946 ALC5632_ADD2_POWER_EN,
947 ALC5632_ADD2_POWER_EN);
948
949 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1,
950 ALC5632_ADD1_POWER_EN,
951 ALC5632_ADD1_POWER_EN);
952
953 /* disable HP Depop2 */
954 snd_soc_update_bits(codec, ALC5632_MISC_CTRL,
955 ALC5632_MISC_HP_DEPOP_MODE2_EN,
956 0);
957
958}
959
960static int alc5632_set_bias_level(struct snd_soc_codec *codec,
961 enum snd_soc_bias_level level)
962{
963 switch (level) {
964 case SND_SOC_BIAS_ON:
965 enable_power_depop(codec);
966 break;
967 case SND_SOC_BIAS_PREPARE:
968 break;
969 case SND_SOC_BIAS_STANDBY:
970 /* everything off except vref/vmid, */
971 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1,
972 ALC5632_PWR_MANAG_ADD1_MASK,
973 ALC5632_PWR_ADD1_MAIN_BIAS);
974 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
975 ALC5632_PWR_MANAG_ADD2_MASK,
976 ALC5632_PWR_ADD2_VREF);
977 /* "normal" mode: 0 @ 26 */
978 snd_soc_update_bits(codec, ALC5632_PWR_DOWN_CTRL_STATUS,
979 ALC5632_PWR_DOWN_CTRL_STATUS_MASK,
980 0xffff ^ (ALC5632_PWR_VREF_PR3
981 | ALC5632_PWR_VREF_PR2));
982 break;
983 case SND_SOC_BIAS_OFF:
984 /* everything off, dac mute, inactive */
985 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
986 ALC5632_PWR_MANAG_ADD2_MASK, 0);
987 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD3,
988 ALC5632_PWR_MANAG_ADD3_MASK, 0);
989 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1,
990 ALC5632_PWR_MANAG_ADD1_MASK, 0);
991 break;
992 }
993 codec->dapm.bias_level = level;
994 return 0;
995}
996
997#define ALC5632_FORMATS (SNDRV_PCM_FMTBIT_S16_LE \
998 | SNDRV_PCM_FMTBIT_S24_LE \
999 | SNDRV_PCM_FMTBIT_S32_LE)
1000
Lars-Peter Clausen85e76522011-11-23 11:40:40 +01001001static const struct snd_soc_dai_ops alc5632_dai_ops = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001002 .hw_params = alc5632_pcm_hw_params,
1003 .digital_mute = alc5632_mute,
1004 .set_fmt = alc5632_set_dai_fmt,
1005 .set_sysclk = alc5632_set_dai_sysclk,
1006 .set_pll = alc5632_set_dai_pll,
1007};
1008
1009static struct snd_soc_dai_driver alc5632_dai = {
1010 .name = "alc5632-hifi",
1011 .playback = {
1012 .stream_name = "HiFi Playback",
1013 .channels_min = 1,
1014 .channels_max = 2,
1015 .rate_min = 8000,
1016 .rate_max = 48000,
1017 .rates = SNDRV_PCM_RATE_8000_48000,
1018 .formats = ALC5632_FORMATS,},
1019 .capture = {
1020 .stream_name = "HiFi Capture",
1021 .channels_min = 1,
1022 .channels_max = 2,
1023 .rate_min = 8000,
1024 .rate_max = 48000,
1025 .rates = SNDRV_PCM_RATE_8000_48000,
1026 .formats = ALC5632_FORMATS,},
1027
1028 .ops = &alc5632_dai_ops,
1029 .symmetric_rates = 1,
1030};
1031
Leon Romanovskyc9be8422011-11-16 12:07:00 +02001032#ifdef CONFIG_PM
Lars-Peter Clausen84b315e2011-12-02 10:18:28 +01001033static int alc5632_suspend(struct snd_soc_codec *codec)
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001034{
1035 alc5632_set_bias_level(codec, SND_SOC_BIAS_OFF);
1036 return 0;
1037}
1038
1039static int alc5632_resume(struct snd_soc_codec *codec)
1040{
Leon Romanovskybb397532011-11-16 12:06:58 +02001041 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001042
Leon Romanovskybb397532011-11-16 12:06:58 +02001043 regcache_sync(alc5632->regmap);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001044
1045 alc5632_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1046 return 0;
1047}
Leon Romanovskyc9be8422011-11-16 12:07:00 +02001048#else
1049#define alc5632_suspend NULL
1050#define alc5632_resume NULL
1051#endif
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001052
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001053static int alc5632_probe(struct snd_soc_codec *codec)
1054{
1055 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec);
1056 int ret;
1057
Leon Romanovskybb397532011-11-16 12:06:58 +02001058 codec->control_data = alc5632->regmap;
1059
1060 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
1061 if (ret != 0) {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001062 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
1063 return ret;
1064 }
1065
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001066 /* power on device */
1067 alc5632_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1068
1069 switch (alc5632->id) {
1070 case 0x5c:
Liam Girdwood022658b2012-02-03 17:43:09 +00001071 snd_soc_add_codec_controls(codec, alc5632_vol_snd_controls,
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001072 ARRAY_SIZE(alc5632_vol_snd_controls));
1073 break;
1074 default:
1075 return -EINVAL;
1076 }
1077
1078 return ret;
1079}
1080
1081/* power down chip */
1082static int alc5632_remove(struct snd_soc_codec *codec)
1083{
1084 alc5632_set_bias_level(codec, SND_SOC_BIAS_OFF);
1085 return 0;
1086}
1087
1088static struct snd_soc_codec_driver soc_codec_device_alc5632 = {
1089 .probe = alc5632_probe,
1090 .remove = alc5632_remove,
1091 .suspend = alc5632_suspend,
1092 .resume = alc5632_resume,
1093 .set_bias_level = alc5632_set_bias_level,
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001094 .controls = alc5632_snd_controls,
1095 .num_controls = ARRAY_SIZE(alc5632_snd_controls),
1096 .dapm_widgets = alc5632_dapm_widgets,
1097 .num_dapm_widgets = ARRAY_SIZE(alc5632_dapm_widgets),
1098 .dapm_routes = alc5632_dapm_routes,
1099 .num_dapm_routes = ARRAY_SIZE(alc5632_dapm_routes),
1100};
1101
Leon Romanovskybb397532011-11-16 12:06:58 +02001102static struct regmap_config alc5632_regmap = {
1103 .reg_bits = 8,
1104 .val_bits = 16,
1105
1106 .max_register = ALC5632_MAX_REGISTER,
1107 .reg_defaults = alc5632_reg_defaults,
1108 .num_reg_defaults = ARRAY_SIZE(alc5632_reg_defaults),
1109 .volatile_reg = alc5632_volatile_register,
1110 .cache_type = REGCACHE_RBTREE,
1111};
1112
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001113/*
1114 * alc5632 2 wire address is determined by A1 pin
1115 * state during powerup.
1116 * low = 0x1a
1117 * high = 0x1b
1118 */
Bill Pemberton7a79e942012-12-07 09:26:37 -05001119static int alc5632_i2c_probe(struct i2c_client *client,
1120 const struct i2c_device_id *id)
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001121{
1122 struct alc5632_priv *alc5632;
Leon Romanovsky277c01b2011-11-17 12:01:30 +02001123 int ret, ret1, ret2;
1124 unsigned int vid1, vid2;
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001125
1126 alc5632 = devm_kzalloc(&client->dev,
1127 sizeof(struct alc5632_priv), GFP_KERNEL);
1128 if (alc5632 == NULL)
1129 return -ENOMEM;
1130
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001131 i2c_set_clientdata(client, alc5632);
Leon Romanovskybb397532011-11-16 12:06:58 +02001132
Axel Lin41a41ea2012-05-08 23:44:55 +08001133 alc5632->regmap = devm_regmap_init_i2c(client, &alc5632_regmap);
Leon Romanovskybb397532011-11-16 12:06:58 +02001134 if (IS_ERR(alc5632->regmap)) {
1135 ret = PTR_ERR(alc5632->regmap);
1136 dev_err(&client->dev, "regmap_init() failed: %d\n", ret);
1137 return ret;
1138 }
1139
Leon Romanovsky277c01b2011-11-17 12:01:30 +02001140 ret1 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID1, &vid1);
1141 ret2 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID2, &vid2);
1142 if (ret1 != 0 || ret2 != 0) {
1143 dev_err(&client->dev,
1144 "Failed to read chip ID: ret1=%d, ret2=%d\n", ret1, ret2);
Leon Romanovsky277c01b2011-11-17 12:01:30 +02001145 return -EIO;
1146 }
1147
1148 vid2 >>= 8;
1149
1150 if ((vid1 != 0x10EC) || (vid2 != id->driver_data)) {
1151 dev_err(&client->dev,
1152 "Device is not a ALC5632: VID1=0x%x, VID2=0x%x\n", vid1, vid2);
Leon Romanovsky277c01b2011-11-17 12:01:30 +02001153 return -EINVAL;
1154 }
1155
Leon Romanovskybb397532011-11-16 12:06:58 +02001156 ret = alc5632_reset(alc5632->regmap);
1157 if (ret < 0) {
1158 dev_err(&client->dev, "Failed to issue reset\n");
Leon Romanovskybb397532011-11-16 12:06:58 +02001159 return ret;
1160 }
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001161
Leon Romanovsky277c01b2011-11-17 12:01:30 +02001162 alc5632->id = vid2;
1163 switch (alc5632->id) {
1164 case 0x5c:
1165 alc5632_dai.name = "alc5632-hifi";
1166 break;
1167 default:
1168 return -EINVAL;
1169 }
1170
1171 ret = snd_soc_register_codec(&client->dev,
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001172 &soc_codec_device_alc5632, &alc5632_dai, 1);
Leon Romanovskybb397532011-11-16 12:06:58 +02001173
1174 if (ret < 0) {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001175 dev_err(&client->dev, "Failed to register codec: %d\n", ret);
Leon Romanovskybb397532011-11-16 12:06:58 +02001176 return ret;
1177 }
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001178
1179 return ret;
1180}
1181
Bill Pemberton7a79e942012-12-07 09:26:37 -05001182static int alc5632_i2c_remove(struct i2c_client *client)
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001183{
1184 snd_soc_unregister_codec(&client->dev);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001185 return 0;
1186}
1187
1188static const struct i2c_device_id alc5632_i2c_table[] = {
1189 {"alc5632", 0x5c},
1190 {}
1191};
1192MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table);
1193
1194/* i2c codec control layer */
1195static struct i2c_driver alc5632_i2c_driver = {
1196 .driver = {
1197 .name = "alc5632",
1198 .owner = THIS_MODULE,
1199 },
1200 .probe = alc5632_i2c_probe,
Bill Pemberton7a79e942012-12-07 09:26:37 -05001201 .remove = alc5632_i2c_remove,
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001202 .id_table = alc5632_i2c_table,
1203};
1204
Axel Lin8d8c0b32012-05-08 23:43:33 +08001205module_i2c_driver(alc5632_i2c_driver);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001206
1207MODULE_DESCRIPTION("ASoC ALC5632 driver");
1208MODULE_AUTHOR("Leon Romanovsky <leon@leon.nu>");
1209MODULE_LICENSE("GPL");