blob: 69c652cfe858b0dc67e17ca8a55168e7c2c4b5bd [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[] = {
148 TLV_DB_RANGE_HEAD(3),
149 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
150 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
151 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0),
152};
153/* 0db min scale, 6 db steps, no mute */
154static const DECLARE_TLV_DB_SCALE(dig_tlv, 0, 600, 0);
155/* 0db min scalem 0.75db steps, no mute */
Andrey Danin39be1af2012-02-11 23:26:28 +0200156static const DECLARE_TLV_DB_SCALE(vdac_tlv, -3525, 75, 0);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200157
158static const struct snd_kcontrol_new alc5632_vol_snd_controls[] = {
159 /* left starts at bit 8, right at bit 0 */
160 /* 31 steps (5 bit), -46.5db scale */
Andrey Danin1a083252011-11-13 21:53:13 +0200161 SOC_DOUBLE_TLV("Speaker Playback Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200162 ALC5632_SPK_OUT_VOL, 8, 0, 31, 1, hp_tlv),
163 /* bit 15 mutes left, bit 7 right */
Andrey Danin1a083252011-11-13 21:53:13 +0200164 SOC_DOUBLE("Speaker Playback Switch",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200165 ALC5632_SPK_OUT_VOL, 15, 7, 1, 1),
166 SOC_DOUBLE_TLV("Headphone Playback Volume",
167 ALC5632_HP_OUT_VOL, 8, 0, 31, 1, hp_tlv),
168 SOC_DOUBLE("Headphone Playback Switch",
169 ALC5632_HP_OUT_VOL, 15, 7, 1, 1),
170};
171
172static const struct snd_kcontrol_new alc5632_snd_controls[] = {
173 SOC_DOUBLE_TLV("Auxout Playback Volume",
174 ALC5632_AUX_OUT_VOL, 8, 0, 31, 1, hp_tlv),
175 SOC_DOUBLE("Auxout Playback Switch",
176 ALC5632_AUX_OUT_VOL, 15, 7, 1, 1),
177 SOC_SINGLE_TLV("Voice DAC Playback Volume",
178 ALC5632_VOICE_DAC_VOL, 0, 63, 0, vdac_tlv),
Andrey Danin0a2c0562012-02-11 23:26:29 +0200179 SOC_SINGLE("Voice DAC Playback Switch",
180 ALC5632_VOICE_DAC_VOL, 12, 1, 1),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200181 SOC_SINGLE_TLV("Phone Capture Volume",
182 ALC5632_PHONE_IN_VOL, 8, 31, 1, vol_tlv),
183 SOC_DOUBLE_TLV("LineIn Capture Volume",
184 ALC5632_LINE_IN_VOL, 8, 0, 31, 1, vol_tlv),
Andrey Danin1a083252011-11-13 21:53:13 +0200185 SOC_DOUBLE_TLV("Master Playback Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200186 ALC5632_STEREO_DAC_IN_VOL, 8, 0, 63, 1, vdac_tlv),
Andrey Danin1a083252011-11-13 21:53:13 +0200187 SOC_DOUBLE("Master Playback Switch",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200188 ALC5632_STEREO_DAC_IN_VOL, 15, 7, 1, 1),
189 SOC_SINGLE_TLV("Mic1 Capture Volume",
190 ALC5632_MIC_VOL, 8, 31, 1, vol_tlv),
191 SOC_SINGLE_TLV("Mic2 Capture Volume",
192 ALC5632_MIC_VOL, 0, 31, 1, vol_tlv),
193 SOC_DOUBLE_TLV("Rec Capture Volume",
194 ALC5632_ADC_REC_GAIN, 8, 0, 31, 0, adc_rec_tlv),
195 SOC_SINGLE_TLV("Mic 1 Boost Volume",
196 ALC5632_MIC_CTRL, 10, 2, 0, boost_tlv),
197 SOC_SINGLE_TLV("Mic 2 Boost Volume",
198 ALC5632_MIC_CTRL, 8, 2, 0, boost_tlv),
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200199 SOC_SINGLE_TLV("DMIC Boost Volume",
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200200 ALC5632_DIGI_BOOST_CTRL, 0, 7, 0, dig_tlv),
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200201 SOC_SINGLE("DMIC En Capture Switch",
202 ALC5632_DIGI_BOOST_CTRL, 15, 1, 0),
203 SOC_SINGLE("DMIC PreFilter Capture Switch",
204 ALC5632_DIGI_BOOST_CTRL, 12, 1, 0),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200205};
206
207/*
208 * DAPM Controls
209 */
210static const struct snd_kcontrol_new alc5632_hp_mixer_controls[] = {
211SOC_DAPM_SINGLE("LI2HP Playback Switch", ALC5632_LINE_IN_VOL, 15, 1, 1),
212SOC_DAPM_SINGLE("PHONE2HP Playback Switch", ALC5632_PHONE_IN_VOL, 15, 1, 1),
213SOC_DAPM_SINGLE("MIC12HP Playback Switch", ALC5632_MIC_ROUTING_CTRL, 15, 1, 1),
214SOC_DAPM_SINGLE("MIC22HP Playback Switch", ALC5632_MIC_ROUTING_CTRL, 11, 1, 1),
215SOC_DAPM_SINGLE("VOICE2HP Playback Switch", ALC5632_VOICE_DAC_VOL, 15, 1, 1),
216};
217
218static const struct snd_kcontrol_new alc5632_hpl_mixer_controls[] = {
219SOC_DAPM_SINGLE("ADC2HP_L Playback Switch", ALC5632_ADC_REC_GAIN, 15, 1, 1),
220SOC_DAPM_SINGLE("DACL2HP Playback Switch", ALC5632_MIC_ROUTING_CTRL, 3, 1, 1),
221};
222
223static const struct snd_kcontrol_new alc5632_hpr_mixer_controls[] = {
224SOC_DAPM_SINGLE("ADC2HP_R Playback Switch", ALC5632_ADC_REC_GAIN, 7, 1, 1),
225SOC_DAPM_SINGLE("DACR2HP Playback Switch", ALC5632_MIC_ROUTING_CTRL, 2, 1, 1),
226};
227
228static const struct snd_kcontrol_new alc5632_mono_mixer_controls[] = {
229SOC_DAPM_SINGLE("ADC2MONO_L Playback Switch", ALC5632_ADC_REC_GAIN, 14, 1, 1),
230SOC_DAPM_SINGLE("ADC2MONO_R Playback Switch", ALC5632_ADC_REC_GAIN, 6, 1, 1),
231SOC_DAPM_SINGLE("LI2MONO Playback Switch", ALC5632_LINE_IN_VOL, 13, 1, 1),
232SOC_DAPM_SINGLE("MIC12MONO Playback Switch",
233 ALC5632_MIC_ROUTING_CTRL, 13, 1, 1),
234SOC_DAPM_SINGLE("MIC22MONO Playback Switch",
235 ALC5632_MIC_ROUTING_CTRL, 9, 1, 1),
236SOC_DAPM_SINGLE("DAC2MONO Playback Switch", ALC5632_MIC_ROUTING_CTRL, 0, 1, 1),
237SOC_DAPM_SINGLE("VOICE2MONO Playback Switch", ALC5632_VOICE_DAC_VOL, 13, 1, 1),
238};
239
240static const struct snd_kcontrol_new alc5632_speaker_mixer_controls[] = {
241SOC_DAPM_SINGLE("LI2SPK Playback Switch", ALC5632_LINE_IN_VOL, 14, 1, 1),
242SOC_DAPM_SINGLE("PHONE2SPK Playback Switch", ALC5632_PHONE_IN_VOL, 14, 1, 1),
243SOC_DAPM_SINGLE("MIC12SPK Playback Switch",
244 ALC5632_MIC_ROUTING_CTRL, 14, 1, 1),
245SOC_DAPM_SINGLE("MIC22SPK Playback Switch",
246 ALC5632_MIC_ROUTING_CTRL, 10, 1, 1),
247SOC_DAPM_SINGLE("DAC2SPK Playback Switch", ALC5632_MIC_ROUTING_CTRL, 1, 1, 1),
248SOC_DAPM_SINGLE("VOICE2SPK Playback Switch", ALC5632_VOICE_DAC_VOL, 14, 1, 1),
249};
250
251/* Left Record Mixer */
252static const struct snd_kcontrol_new alc5632_captureL_mixer_controls[] = {
Andrey Danina15a9af2012-02-11 23:26:30 +0200253SOC_DAPM_SINGLE("MIC12REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 14, 1, 1),
254SOC_DAPM_SINGLE("MIC22REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 13, 1, 1),
255SOC_DAPM_SINGLE("LIL2REC Capture Switch", ALC5632_ADC_REC_MIXER, 12, 1, 1),
256SOC_DAPM_SINGLE("PH2REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 11, 1, 1),
257SOC_DAPM_SINGLE("HPL2REC Capture Switch", ALC5632_ADC_REC_MIXER, 10, 1, 1),
258SOC_DAPM_SINGLE("SPK2REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 9, 1, 1),
259SOC_DAPM_SINGLE("MONO2REC_L Capture Switch", ALC5632_ADC_REC_MIXER, 8, 1, 1),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200260};
261
262/* Right Record Mixer */
263static const struct snd_kcontrol_new alc5632_captureR_mixer_controls[] = {
Andrey Danina15a9af2012-02-11 23:26:30 +0200264SOC_DAPM_SINGLE("MIC12REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 6, 1, 1),
265SOC_DAPM_SINGLE("MIC22REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 5, 1, 1),
266SOC_DAPM_SINGLE("LIR2REC Capture Switch", ALC5632_ADC_REC_MIXER, 4, 1, 1),
267SOC_DAPM_SINGLE("PH2REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 3, 1, 1),
268SOC_DAPM_SINGLE("HPR2REC Capture Switch", ALC5632_ADC_REC_MIXER, 2, 1, 1),
269SOC_DAPM_SINGLE("SPK2REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 1, 1, 1),
270SOC_DAPM_SINGLE("MONO2REC_R Capture Switch", ALC5632_ADC_REC_MIXER, 0, 1, 1),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200271};
272
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200273/* Dmic Mixer */
274static const struct snd_kcontrol_new alc5632_dmicl_mixer_controls[] = {
275SOC_DAPM_SINGLE("DMICL2ADC Capture Switch", ALC5632_DIGI_BOOST_CTRL, 7, 1, 1),
276};
277static const struct snd_kcontrol_new alc5632_dmicr_mixer_controls[] = {
278SOC_DAPM_SINGLE("DMICR2ADC Capture Switch", ALC5632_DIGI_BOOST_CTRL, 6, 1, 1),
279};
280
Andrey Danin75b35662012-02-11 23:26:32 +0200281static const char * const alc5632_spk_n_sour_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200282 "RN/-R", "RP/+R", "LN/-R", "Mute"};
Andrey Danin75b35662012-02-11 23:26:32 +0200283static const char * const alc5632_hpl_out_input_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200284 "Vmid", "HP Left Mix"};
Andrey Danin75b35662012-02-11 23:26:32 +0200285static const char * const alc5632_hpr_out_input_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200286 "Vmid", "HP Right Mix"};
Andrey Danin75b35662012-02-11 23:26:32 +0200287static const char * const alc5632_spkout_input_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200288 "Vmid", "HPOut Mix", "Speaker Mix", "Mono Mix"};
Andrey Danin75b35662012-02-11 23:26:32 +0200289static const char * const alc5632_aux_out_input_sel[] = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200290 "Vmid", "HPOut Mix", "Speaker Mix", "Mono Mix"};
Andrey Danin75b35662012-02-11 23:26:32 +0200291static const char * const alc5632_adcr_func_sel[] = {
292 "Stereo ADC", "Voice ADC"};
293static const char * const alc5632_i2s_out_sel[] = {
294 "ADC LR", "Voice Stereo Digital"};
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200295
296/* auxout output mux */
297static const struct soc_enum alc5632_aux_out_input_enum =
298SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 6, 4, alc5632_aux_out_input_sel);
299static const struct snd_kcontrol_new alc5632_auxout_mux_controls =
300SOC_DAPM_ENUM("AuxOut Mux", alc5632_aux_out_input_enum);
301
302/* speaker output mux */
303static const struct soc_enum alc5632_spkout_input_enum =
304SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 10, 4, alc5632_spkout_input_sel);
305static const struct snd_kcontrol_new alc5632_spkout_mux_controls =
306SOC_DAPM_ENUM("SpeakerOut Mux", alc5632_spkout_input_enum);
307
308/* headphone left output mux */
309static const struct soc_enum alc5632_hpl_out_input_enum =
310SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 9, 2, alc5632_hpl_out_input_sel);
311static const struct snd_kcontrol_new alc5632_hpl_out_mux_controls =
312SOC_DAPM_ENUM("Left Headphone Mux", alc5632_hpl_out_input_enum);
313
314/* headphone right output mux */
315static const struct soc_enum alc5632_hpr_out_input_enum =
316SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 8, 2, alc5632_hpr_out_input_sel);
317static const struct snd_kcontrol_new alc5632_hpr_out_mux_controls =
318SOC_DAPM_ENUM("Right Headphone Mux", alc5632_hpr_out_input_enum);
319
320/* speaker output N select */
321static const struct soc_enum alc5632_spk_n_sour_enum =
322SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 14, 4, alc5632_spk_n_sour_sel);
323static const struct snd_kcontrol_new alc5632_spkoutn_mux_controls =
324SOC_DAPM_ENUM("SpeakerOut N Mux", alc5632_spk_n_sour_enum);
325
326/* speaker amplifier */
327static const char *alc5632_amp_names[] = {"AB Amp", "D Amp"};
328static const struct soc_enum alc5632_amp_enum =
329 SOC_ENUM_SINGLE(ALC5632_OUTPUT_MIXER_CTRL, 13, 2, alc5632_amp_names);
330static const struct snd_kcontrol_new alc5632_amp_mux_controls =
331 SOC_DAPM_ENUM("AB-D Amp Mux", alc5632_amp_enum);
332
Andrey Danin75b35662012-02-11 23:26:32 +0200333/* ADC output select */
334static const struct soc_enum alc5632_adcr_func_enum =
335 SOC_ENUM_SINGLE(ALC5632_DAC_FUNC_SELECT, 5, 2, alc5632_adcr_func_sel);
336static const struct snd_kcontrol_new alc5632_adcr_func_controls =
337 SOC_DAPM_ENUM("ADCR Mux", alc5632_adcr_func_enum);
338
339/* I2S out select */
340static const struct soc_enum alc5632_i2s_out_enum =
341 SOC_ENUM_SINGLE(ALC5632_I2S_OUT_CTL, 5, 2, alc5632_i2s_out_sel);
342static const struct snd_kcontrol_new alc5632_i2s_out_controls =
343 SOC_DAPM_ENUM("I2SOut Mux", alc5632_i2s_out_enum);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200344
345static const struct snd_soc_dapm_widget alc5632_dapm_widgets[] = {
346/* Muxes */
347SND_SOC_DAPM_MUX("AuxOut Mux", SND_SOC_NOPM, 0, 0,
348 &alc5632_auxout_mux_controls),
349SND_SOC_DAPM_MUX("SpeakerOut Mux", SND_SOC_NOPM, 0, 0,
350 &alc5632_spkout_mux_controls),
351SND_SOC_DAPM_MUX("Left Headphone Mux", SND_SOC_NOPM, 0, 0,
352 &alc5632_hpl_out_mux_controls),
353SND_SOC_DAPM_MUX("Right Headphone Mux", SND_SOC_NOPM, 0, 0,
354 &alc5632_hpr_out_mux_controls),
355SND_SOC_DAPM_MUX("SpeakerOut N Mux", SND_SOC_NOPM, 0, 0,
356 &alc5632_spkoutn_mux_controls),
Andrey Danin75b35662012-02-11 23:26:32 +0200357SND_SOC_DAPM_MUX("ADCR Mux", SND_SOC_NOPM, 0, 0,
358 &alc5632_adcr_func_controls),
Andrey Danin9e751772012-02-11 23:26:34 +0200359SND_SOC_DAPM_MUX("I2SOut Mux", ALC5632_PWR_MANAG_ADD1, 11, 0,
Andrey Danin75b35662012-02-11 23:26:32 +0200360 &alc5632_i2s_out_controls),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200361
362/* output mixers */
363SND_SOC_DAPM_MIXER("HP Mix", SND_SOC_NOPM, 0, 0,
364 &alc5632_hp_mixer_controls[0],
365 ARRAY_SIZE(alc5632_hp_mixer_controls)),
366SND_SOC_DAPM_MIXER("HPR Mix", ALC5632_PWR_MANAG_ADD2, 4, 0,
367 &alc5632_hpr_mixer_controls[0],
368 ARRAY_SIZE(alc5632_hpr_mixer_controls)),
369SND_SOC_DAPM_MIXER("HPL Mix", ALC5632_PWR_MANAG_ADD2, 5, 0,
370 &alc5632_hpl_mixer_controls[0],
371 ARRAY_SIZE(alc5632_hpl_mixer_controls)),
372SND_SOC_DAPM_MIXER("HPOut Mix", SND_SOC_NOPM, 0, 0, NULL, 0),
373SND_SOC_DAPM_MIXER("Mono Mix", ALC5632_PWR_MANAG_ADD2, 2, 0,
374 &alc5632_mono_mixer_controls[0],
375 ARRAY_SIZE(alc5632_mono_mixer_controls)),
376SND_SOC_DAPM_MIXER("Speaker Mix", ALC5632_PWR_MANAG_ADD2, 3, 0,
377 &alc5632_speaker_mixer_controls[0],
378 ARRAY_SIZE(alc5632_speaker_mixer_controls)),
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200379SND_SOC_DAPM_MIXER("DMICL Mix", SND_SOC_NOPM, 0, 0,
380 &alc5632_dmicl_mixer_controls[0],
381 ARRAY_SIZE(alc5632_dmicl_mixer_controls)),
382SND_SOC_DAPM_MIXER("DMICR Mix", SND_SOC_NOPM, 0, 0,
383 &alc5632_dmicr_mixer_controls[0],
384 ARRAY_SIZE(alc5632_dmicr_mixer_controls)),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200385
386/* input mixers */
387SND_SOC_DAPM_MIXER("Left Capture Mix", ALC5632_PWR_MANAG_ADD2, 1, 0,
388 &alc5632_captureL_mixer_controls[0],
389 ARRAY_SIZE(alc5632_captureL_mixer_controls)),
390SND_SOC_DAPM_MIXER("Right Capture Mix", ALC5632_PWR_MANAG_ADD2, 0, 0,
391 &alc5632_captureR_mixer_controls[0],
392 ARRAY_SIZE(alc5632_captureR_mixer_controls)),
393
Andrey Danin75b35662012-02-11 23:26:32 +0200394SND_SOC_DAPM_AIF_IN("AIFRXL", "Left HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
395SND_SOC_DAPM_AIF_IN("AIFRXR", "Right HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
396SND_SOC_DAPM_AIF_OUT("AIFTXL", "Left HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
397SND_SOC_DAPM_AIF_OUT("AIFTXR", "Right HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
398SND_SOC_DAPM_AIF_IN("VAIFRX", "Voice Playback", 0, SND_SOC_NOPM, 0, 0),
399SND_SOC_DAPM_AIF_OUT("VAIFTX", "Voice Capture", 0, SND_SOC_NOPM, 0, 0),
400
401SND_SOC_DAPM_DAC("Voice DAC", NULL, ALC5632_PWR_MANAG_ADD2, 10, 0),
402SND_SOC_DAPM_DAC("Left DAC", NULL, ALC5632_PWR_MANAG_ADD2, 9, 0),
403SND_SOC_DAPM_DAC("Right DAC", NULL, ALC5632_PWR_MANAG_ADD2, 8, 0),
404SND_SOC_DAPM_ADC("Left ADC", NULL, ALC5632_PWR_MANAG_ADD2, 7, 0),
405SND_SOC_DAPM_ADC("Right ADC", NULL, ALC5632_PWR_MANAG_ADD2, 6, 0),
406
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200407SND_SOC_DAPM_MIXER("DAC Left Channel", ALC5632_PWR_MANAG_ADD1, 15, 0, NULL, 0),
408SND_SOC_DAPM_MIXER("DAC Right Channel",
409 ALC5632_PWR_MANAG_ADD1, 14, 0, NULL, 0),
410SND_SOC_DAPM_MIXER("I2S Mix", ALC5632_PWR_MANAG_ADD1, 11, 0, NULL, 0),
411SND_SOC_DAPM_MIXER("Phone Mix", SND_SOC_NOPM, 0, 0, NULL, 0),
412SND_SOC_DAPM_MIXER("Line Mix", SND_SOC_NOPM, 0, 0, NULL, 0),
Andrey Danin75b35662012-02-11 23:26:32 +0200413SND_SOC_DAPM_MIXER("Voice Mix", SND_SOC_NOPM, 0, 0, NULL, 0),
414SND_SOC_DAPM_MIXER("ADCLR", SND_SOC_NOPM, 0, 0, NULL, 0),
415
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200416SND_SOC_DAPM_PGA("Left Headphone", ALC5632_PWR_MANAG_ADD3, 11, 0, NULL, 0),
417SND_SOC_DAPM_PGA("Right Headphone", ALC5632_PWR_MANAG_ADD3, 10, 0, NULL, 0),
418SND_SOC_DAPM_PGA("Left Speaker", ALC5632_PWR_MANAG_ADD3, 13, 0, NULL, 0),
419SND_SOC_DAPM_PGA("Right Speaker", ALC5632_PWR_MANAG_ADD3, 12, 0, NULL, 0),
420SND_SOC_DAPM_PGA("Aux Out", ALC5632_PWR_MANAG_ADD3, 14, 0, NULL, 0),
421SND_SOC_DAPM_PGA("Left LineIn", ALC5632_PWR_MANAG_ADD3, 7, 0, NULL, 0),
422SND_SOC_DAPM_PGA("Right LineIn", ALC5632_PWR_MANAG_ADD3, 6, 0, NULL, 0),
423SND_SOC_DAPM_PGA("Phone", ALC5632_PWR_MANAG_ADD3, 5, 0, NULL, 0),
424SND_SOC_DAPM_PGA("Phone ADMix", ALC5632_PWR_MANAG_ADD3, 4, 0, NULL, 0),
425SND_SOC_DAPM_PGA("MIC1 PGA", ALC5632_PWR_MANAG_ADD3, 3, 0, NULL, 0),
426SND_SOC_DAPM_PGA("MIC2 PGA", ALC5632_PWR_MANAG_ADD3, 2, 0, NULL, 0),
427SND_SOC_DAPM_PGA("MIC1 Pre Amp", ALC5632_PWR_MANAG_ADD3, 1, 0, NULL, 0),
428SND_SOC_DAPM_PGA("MIC2 Pre Amp", ALC5632_PWR_MANAG_ADD3, 0, 0, NULL, 0),
Leon Romanovsky9215aa42011-12-12 21:43:45 +0200429SND_SOC_DAPM_SUPPLY("MICBIAS1", ALC5632_PWR_MANAG_ADD1, 3, 0, NULL, 0),
430SND_SOC_DAPM_SUPPLY("MICBIAS2", ALC5632_PWR_MANAG_ADD1, 2, 0, NULL, 0),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200431
432SND_SOC_DAPM_PGA_E("D Amp", ALC5632_PWR_MANAG_ADD2, 14, 0, NULL, 0,
433 amp_mixer_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
434SND_SOC_DAPM_PGA("AB Amp", ALC5632_PWR_MANAG_ADD2, 15, 0, NULL, 0),
435SND_SOC_DAPM_MUX("AB-D Amp Mux", ALC5632_PWR_MANAG_ADD1, 10, 0,
436 &alc5632_amp_mux_controls),
437
438SND_SOC_DAPM_OUTPUT("AUXOUT"),
439SND_SOC_DAPM_OUTPUT("HPL"),
440SND_SOC_DAPM_OUTPUT("HPR"),
441SND_SOC_DAPM_OUTPUT("SPKOUT"),
442SND_SOC_DAPM_OUTPUT("SPKOUTN"),
Andrey Danin75b35662012-02-11 23:26:32 +0200443
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200444SND_SOC_DAPM_INPUT("LINEINL"),
445SND_SOC_DAPM_INPUT("LINEINR"),
446SND_SOC_DAPM_INPUT("PHONEP"),
447SND_SOC_DAPM_INPUT("PHONEN"),
Andrey Danin75b35662012-02-11 23:26:32 +0200448SND_SOC_DAPM_INPUT("DMICDAT"),
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200449SND_SOC_DAPM_INPUT("MIC1"),
450SND_SOC_DAPM_INPUT("MIC2"),
451SND_SOC_DAPM_VMID("Vmid"),
452};
453
454
455static const struct snd_soc_dapm_route alc5632_dapm_routes[] = {
Andrey Danin75b35662012-02-11 23:26:32 +0200456 /* Playback streams */
457 {"Left DAC", NULL, "AIFRXL"},
458 {"Right DAC", NULL, "AIFRXR"},
459
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200460 /* virtual mixer - mixes left & right channels */
461 {"I2S Mix", NULL, "Left DAC"},
462 {"I2S Mix", NULL, "Right DAC"},
463 {"Line Mix", NULL, "Right LineIn"},
464 {"Line Mix", NULL, "Left LineIn"},
465 {"Phone Mix", NULL, "Phone"},
466 {"Phone Mix", NULL, "Phone ADMix"},
467 {"AUXOUT", NULL, "Aux Out"},
468
469 /* DAC */
470 {"DAC Right Channel", NULL, "I2S Mix"},
471 {"DAC Left Channel", NULL, "I2S Mix"},
472
473 /* HP mixer */
474 {"HPL Mix", "ADC2HP_L Playback Switch", "Left Capture Mix"},
475 {"HPL Mix", NULL, "HP Mix"},
476 {"HPR Mix", "ADC2HP_R Playback Switch", "Right Capture Mix"},
477 {"HPR Mix", NULL, "HP Mix"},
478 {"HP Mix", "LI2HP Playback Switch", "Line Mix"},
479 {"HP Mix", "PHONE2HP Playback Switch", "Phone Mix"},
480 {"HP Mix", "MIC12HP Playback Switch", "MIC1 PGA"},
481 {"HP Mix", "MIC22HP Playback Switch", "MIC2 PGA"},
Andrey Danin75b35662012-02-11 23:26:32 +0200482 {"HP Mix", "VOICE2HP Playback Switch", "Voice Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200483 {"HPR Mix", "DACR2HP Playback Switch", "DAC Right Channel"},
484 {"HPL Mix", "DACL2HP Playback Switch", "DAC Left Channel"},
Marc Dietrich2435d462012-02-11 23:26:35 +0200485 {"HPOut Mix", NULL, "HP Mix"},
486 {"HPOut Mix", NULL, "HPR Mix"},
487 {"HPOut Mix", NULL, "HPL Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200488
489 /* speaker mixer */
490 {"Speaker Mix", "LI2SPK Playback Switch", "Line Mix"},
491 {"Speaker Mix", "PHONE2SPK Playback Switch", "Phone Mix"},
492 {"Speaker Mix", "MIC12SPK Playback Switch", "MIC1 PGA"},
493 {"Speaker Mix", "MIC22SPK Playback Switch", "MIC2 PGA"},
494 {"Speaker Mix", "DAC2SPK Playback Switch", "DAC Left Channel"},
Andrey Danin75b35662012-02-11 23:26:32 +0200495 {"Speaker Mix", "VOICE2SPK Playback Switch", "Voice Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200496
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200497 /* mono mixer */
498 {"Mono Mix", "ADC2MONO_L Playback Switch", "Left Capture Mix"},
499 {"Mono Mix", "ADC2MONO_R Playback Switch", "Right Capture Mix"},
500 {"Mono Mix", "LI2MONO Playback Switch", "Line Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200501 {"Mono Mix", "MIC12MONO Playback Switch", "MIC1 PGA"},
502 {"Mono Mix", "MIC22MONO Playback Switch", "MIC2 PGA"},
503 {"Mono Mix", "DAC2MONO Playback Switch", "DAC Left Channel"},
Andrey Danin75b35662012-02-11 23:26:32 +0200504 {"Mono Mix", "VOICE2MONO Playback Switch", "Voice Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200505
506 /* Left record mixer */
Andrey Danina15a9af2012-02-11 23:26:30 +0200507 {"Left Capture Mix", "LIL2REC Capture Switch", "LINEINL"},
508 {"Left Capture Mix", "PH2REC_L Capture Switch", "PHONEN"},
509 {"Left Capture Mix", "MIC12REC_L Capture Switch", "MIC1 Pre Amp"},
510 {"Left Capture Mix", "MIC22REC_L Capture Switch", "MIC2 Pre Amp"},
511 {"Left Capture Mix", "HPL2REC Capture Switch", "HPL Mix"},
512 {"Left Capture Mix", "SPK2REC_L Capture Switch", "Speaker Mix"},
513 {"Left Capture Mix", "MONO2REC_L Capture Switch", "Mono Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200514
515 /*Right record mixer */
Andrey Danina15a9af2012-02-11 23:26:30 +0200516 {"Right Capture Mix", "LIR2REC Capture Switch", "LINEINR"},
517 {"Right Capture Mix", "PH2REC_R Capture Switch", "PHONEP"},
518 {"Right Capture Mix", "MIC12REC_R Capture Switch", "MIC1 Pre Amp"},
519 {"Right Capture Mix", "MIC22REC_R Capture Switch", "MIC2 Pre Amp"},
520 {"Right Capture Mix", "HPR2REC Capture Switch", "HPR Mix"},
521 {"Right Capture Mix", "SPK2REC_R Capture Switch", "Speaker Mix"},
522 {"Right Capture Mix", "MONO2REC_R Capture Switch", "Mono Mix"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200523
524 /* headphone left mux */
525 {"Left Headphone Mux", "HP Left Mix", "HPL Mix"},
526 {"Left Headphone Mux", "Vmid", "Vmid"},
527
528 /* headphone right mux */
529 {"Right Headphone Mux", "HP Right Mix", "HPR Mix"},
530 {"Right Headphone Mux", "Vmid", "Vmid"},
531
532 /* speaker out mux */
533 {"SpeakerOut Mux", "Vmid", "Vmid"},
534 {"SpeakerOut Mux", "HPOut Mix", "HPOut Mix"},
535 {"SpeakerOut Mux", "Speaker Mix", "Speaker Mix"},
536 {"SpeakerOut Mux", "Mono Mix", "Mono Mix"},
537
538 /* Mono/Aux Out mux */
539 {"AuxOut Mux", "Vmid", "Vmid"},
540 {"AuxOut Mux", "HPOut Mix", "HPOut Mix"},
541 {"AuxOut Mux", "Speaker Mix", "Speaker Mix"},
542 {"AuxOut Mux", "Mono Mix", "Mono Mix"},
543
544 /* output pga */
545 {"HPL", NULL, "Left Headphone"},
546 {"Left Headphone", NULL, "Left Headphone Mux"},
547 {"HPR", NULL, "Right Headphone"},
548 {"Right Headphone", NULL, "Right Headphone Mux"},
549 {"Aux Out", NULL, "AuxOut Mux"},
550
551 /* input pga */
552 {"Left LineIn", NULL, "LINEINL"},
553 {"Right LineIn", NULL, "LINEINR"},
554 {"Phone", NULL, "PHONEP"},
555 {"MIC1 Pre Amp", NULL, "MIC1"},
556 {"MIC2 Pre Amp", NULL, "MIC2"},
557 {"MIC1 PGA", NULL, "MIC1 Pre Amp"},
558 {"MIC2 PGA", NULL, "MIC2 Pre Amp"},
559
560 /* left ADC */
561 {"Left ADC", NULL, "Left Capture Mix"},
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200562 {"DMICL Mix", "DMICL2ADC Capture Switch", "DMICDAT"},
563 {"Left ADC", NULL, "DMICL Mix"},
Andrey Danin75b35662012-02-11 23:26:32 +0200564 {"ADCLR", NULL, "Left ADC"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200565
566 /* right ADC */
Andrey Danin75b35662012-02-11 23:26:32 +0200567 {"Right ADC", NULL, "Right Capture Mix"},
Andrey Danin5e4e94a2012-02-11 23:26:33 +0200568 {"DMICR Mix", "DMICR2ADC Capture Switch", "DMICDAT"},
569 {"Right ADC", NULL, "DMICR Mix"},
Andrey Danin75b35662012-02-11 23:26:32 +0200570 {"ADCR Mux", "Stereo ADC", "Right ADC"},
571 {"ADCR Mux", "Voice ADC", "Right ADC"},
572 {"ADCLR", NULL, "ADCR Mux"},
573 {"VAIFTX", NULL, "ADCR Mux"},
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200574
Andrey Danin75b35662012-02-11 23:26:32 +0200575 /* Digital I2S out */
576 {"I2SOut Mux", "ADC LR", "ADCLR"},
577 {"I2SOut Mux", "Voice Stereo Digital", "VAIFRX"},
578 {"AIFTXL", NULL, "I2SOut Mux"},
579 {"AIFTXR", NULL, "I2SOut Mux"},
580
581 /* Voice Mix */
582 {"Voice DAC", NULL, "VAIFRX"},
583 {"Voice Mix", NULL, "Voice DAC"},
584
585 /* Speaker Output */
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200586 {"SpeakerOut N Mux", "RN/-R", "Left Speaker"},
587 {"SpeakerOut N Mux", "RP/+R", "Left Speaker"},
588 {"SpeakerOut N Mux", "LN/-R", "Left Speaker"},
589 {"SpeakerOut N Mux", "Mute", "Vmid"},
590
591 {"SpeakerOut N Mux", "RN/-R", "Right Speaker"},
592 {"SpeakerOut N Mux", "RP/+R", "Right Speaker"},
593 {"SpeakerOut N Mux", "LN/-R", "Right Speaker"},
594 {"SpeakerOut N Mux", "Mute", "Vmid"},
595
596 {"AB Amp", NULL, "SpeakerOut Mux"},
597 {"D Amp", NULL, "SpeakerOut Mux"},
598 {"AB-D Amp Mux", "AB Amp", "AB Amp"},
599 {"AB-D Amp Mux", "D Amp", "D Amp"},
600 {"Left Speaker", NULL, "AB-D Amp Mux"},
601 {"Right Speaker", NULL, "AB-D Amp Mux"},
602
603 {"SPKOUT", NULL, "Left Speaker"},
604 {"SPKOUT", NULL, "Right Speaker"},
605
606 {"SPKOUTN", NULL, "SpeakerOut N Mux"},
607
608};
609
610/* PLL divisors */
611struct _pll_div {
612 u32 pll_in;
613 u32 pll_out;
614 u16 regvalue;
615};
616
617/* Note : pll code from original alc5632 driver. Not sure of how good it is */
618/* usefull only for master mode */
619static const struct _pll_div codec_master_pll_div[] = {
620
621 { 2048000, 8192000, 0x0ea0},
622 { 3686400, 8192000, 0x4e27},
623 { 12000000, 8192000, 0x456b},
624 { 13000000, 8192000, 0x495f},
625 { 13100000, 8192000, 0x0320},
626 { 2048000, 11289600, 0xf637},
627 { 3686400, 11289600, 0x2f22},
628 { 12000000, 11289600, 0x3e2f},
629 { 13000000, 11289600, 0x4d5b},
630 { 13100000, 11289600, 0x363b},
631 { 2048000, 16384000, 0x1ea0},
632 { 3686400, 16384000, 0x9e27},
633 { 12000000, 16384000, 0x452b},
634 { 13000000, 16384000, 0x542f},
635 { 13100000, 16384000, 0x03a0},
636 { 2048000, 16934400, 0xe625},
637 { 3686400, 16934400, 0x9126},
638 { 12000000, 16934400, 0x4d2c},
639 { 13000000, 16934400, 0x742f},
640 { 13100000, 16934400, 0x3c27},
641 { 2048000, 22579200, 0x2aa0},
642 { 3686400, 22579200, 0x2f20},
643 { 12000000, 22579200, 0x7e2f},
644 { 13000000, 22579200, 0x742f},
645 { 13100000, 22579200, 0x3c27},
646 { 2048000, 24576000, 0x2ea0},
647 { 3686400, 24576000, 0xee27},
648 { 12000000, 24576000, 0x2915},
649 { 13000000, 24576000, 0x772e},
650 { 13100000, 24576000, 0x0d20},
651};
652
653/* FOUT = MCLK*(N+2)/((M+2)*(K+2))
654 N: bit 15:8 (div 2 .. div 257)
655 K: bit 6:4 typical 2
656 M: bit 3:0 (div 2 .. div 17)
657
658 same as for 5623 - thanks!
659*/
660
661static const struct _pll_div codec_slave_pll_div[] = {
662
663 { 1024000, 16384000, 0x3ea0},
664 { 1411200, 22579200, 0x3ea0},
665 { 1536000, 24576000, 0x3ea0},
666 { 2048000, 16384000, 0x1ea0},
667 { 2822400, 22579200, 0x1ea0},
668 { 3072000, 24576000, 0x1ea0},
669
670};
671
672static int alc5632_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
673 int source, unsigned int freq_in, unsigned int freq_out)
674{
675 int i;
676 struct snd_soc_codec *codec = codec_dai->codec;
677 int gbl_clk = 0, pll_div = 0;
678 u16 reg;
679
680 if (pll_id < ALC5632_PLL_FR_MCLK || pll_id > ALC5632_PLL_FR_VBCLK)
681 return -EINVAL;
682
683 /* Disable PLL power */
684 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
685 ALC5632_PWR_ADD2_PLL1,
686 0);
687 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
688 ALC5632_PWR_ADD2_PLL2,
689 0);
690
691 /* pll is not used in slave mode */
692 reg = snd_soc_read(codec, ALC5632_DAI_CONTROL);
693 if (reg & ALC5632_DAI_SDP_SLAVE_MODE)
694 return 0;
695
696 if (!freq_in || !freq_out)
697 return 0;
698
699 switch (pll_id) {
700 case ALC5632_PLL_FR_MCLK:
701 for (i = 0; i < ARRAY_SIZE(codec_master_pll_div); i++) {
702 if (codec_master_pll_div[i].pll_in == freq_in
703 && codec_master_pll_div[i].pll_out == freq_out) {
704 /* PLL source from MCLK */
705 pll_div = codec_master_pll_div[i].regvalue;
706 break;
707 }
708 }
709 break;
710 case ALC5632_PLL_FR_BCLK:
711 for (i = 0; i < ARRAY_SIZE(codec_slave_pll_div); i++) {
712 if (codec_slave_pll_div[i].pll_in == freq_in
713 && codec_slave_pll_div[i].pll_out == freq_out) {
714 /* PLL source from Bitclk */
715 gbl_clk = ALC5632_PLL_FR_BCLK;
716 pll_div = codec_slave_pll_div[i].regvalue;
717 break;
718 }
719 }
720 break;
721 case ALC5632_PLL_FR_VBCLK:
722 for (i = 0; i < ARRAY_SIZE(codec_slave_pll_div); i++) {
723 if (codec_slave_pll_div[i].pll_in == freq_in
724 && codec_slave_pll_div[i].pll_out == freq_out) {
725 /* PLL source from voice clock */
726 gbl_clk = ALC5632_PLL_FR_VBCLK;
727 pll_div = codec_slave_pll_div[i].regvalue;
728 break;
729 }
730 }
731 break;
732 default:
733 return -EINVAL;
734 }
735
736 if (!pll_div)
737 return -EINVAL;
738
739 /* choose MCLK/BCLK/VBCLK */
740 snd_soc_write(codec, ALC5632_GPCR2, gbl_clk);
741 /* choose PLL1 clock rate */
742 snd_soc_write(codec, ALC5632_PLL1_CTRL, pll_div);
743 /* enable PLL1 */
744 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
745 ALC5632_PWR_ADD2_PLL1,
746 ALC5632_PWR_ADD2_PLL1);
747 /* enable PLL2 */
748 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
749 ALC5632_PWR_ADD2_PLL2,
750 ALC5632_PWR_ADD2_PLL2);
751 /* use PLL1 as main SYSCLK */
752 snd_soc_update_bits(codec, ALC5632_GPCR1,
753 ALC5632_GPCR1_CLK_SYS_SRC_SEL_PLL1,
754 ALC5632_GPCR1_CLK_SYS_SRC_SEL_PLL1);
755
756 return 0;
757}
758
759struct _coeff_div {
760 u16 fs;
761 u16 regvalue;
762};
763
764/* codec hifi mclk (after PLL) clock divider coefficients */
765/* values inspired from column BCLK=32Fs of Appendix A table */
766static const struct _coeff_div coeff_div[] = {
767 {512*1, 0x3075},
768};
769
770static int get_coeff(struct snd_soc_codec *codec, int rate)
771{
772 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec);
773 int i;
774
775 for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
776 if (coeff_div[i].fs * rate == alc5632->sysclk)
777 return i;
778 }
779 return -EINVAL;
780}
781
782/*
783 * Clock after PLL and dividers
784 */
785static int alc5632_set_dai_sysclk(struct snd_soc_dai *codec_dai,
786 int clk_id, unsigned int freq, int dir)
787{
788 struct snd_soc_codec *codec = codec_dai->codec;
789 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec);
790
791 switch (freq) {
792 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{
864 struct snd_soc_pcm_runtime *rtd = substream->private_data;
865 struct snd_soc_codec *codec = rtd->codec;
866 int coeff, rate;
867 u16 iface;
868
869 iface = snd_soc_read(codec, ALC5632_DAI_CONTROL);
870 iface &= ~ALC5632_DAI_I2S_DL_MASK;
871
872 /* bit size */
873 switch (params_format(params)) {
874 case SNDRV_PCM_FORMAT_S16_LE:
875 iface |= ALC5632_DAI_I2S_DL_16;
876 break;
877 case SNDRV_PCM_FORMAT_S20_3LE:
878 iface |= ALC5632_DAI_I2S_DL_20;
879 break;
880 case SNDRV_PCM_FORMAT_S24_LE:
881 iface |= ALC5632_DAI_I2S_DL_24;
882 break;
883 default:
884 return -EINVAL;
885 }
886
887 /* set iface & srate */
888 snd_soc_write(codec, ALC5632_DAI_CONTROL, iface);
889 rate = params_rate(params);
890 coeff = get_coeff(codec, rate);
891 if (coeff < 0)
892 return -EINVAL;
893
894 coeff = coeff_div[coeff].regvalue;
895 snd_soc_write(codec, ALC5632_DAC_CLK_CTRL1, coeff);
896
897 return 0;
898}
899
900static int alc5632_mute(struct snd_soc_dai *dai, int mute)
901{
902 struct snd_soc_codec *codec = dai->codec;
Leon Romanovsky88c494b2011-11-10 21:22:16 +0200903 u16 hp_mute = ALC5632_MISC_HP_DEPOP_MUTE_L
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +0200904 |ALC5632_MISC_HP_DEPOP_MUTE_R;
905 u16 mute_reg = snd_soc_read(codec, ALC5632_MISC_CTRL) & ~hp_mute;
906
907 if (mute)
908 mute_reg |= hp_mute;
909
910 return snd_soc_write(codec, ALC5632_MISC_CTRL, mute_reg);
911}
912
913#define ALC5632_ADD2_POWER_EN (ALC5632_PWR_ADD2_VREF)
914
915#define ALC5632_ADD3_POWER_EN (ALC5632_PWR_ADD3_MIC1_BOOST_AD)
916
917#define ALC5632_ADD1_POWER_EN \
918 (ALC5632_PWR_ADD1_DAC_REF \
919 | ALC5632_PWR_ADD1_SOFTGEN_EN \
920 | ALC5632_PWR_ADD1_HP_OUT_AMP \
921 | ALC5632_PWR_ADD1_HP_OUT_ENH_AMP \
922 | ALC5632_PWR_ADD1_MAIN_BIAS)
923
924static void enable_power_depop(struct snd_soc_codec *codec)
925{
926 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1,
927 ALC5632_PWR_ADD1_SOFTGEN_EN,
928 ALC5632_PWR_ADD1_SOFTGEN_EN);
929
930 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD3,
931 ALC5632_ADD3_POWER_EN,
932 ALC5632_ADD3_POWER_EN);
933
934 snd_soc_update_bits(codec, ALC5632_MISC_CTRL,
935 ALC5632_MISC_HP_DEPOP_MODE2_EN,
936 ALC5632_MISC_HP_DEPOP_MODE2_EN);
937
938 /* "normal" mode: 0 @ 26 */
939 /* set all PR0-7 mixers to 0 */
940 snd_soc_update_bits(codec, ALC5632_PWR_DOWN_CTRL_STATUS,
941 ALC5632_PWR_DOWN_CTRL_STATUS_MASK,
942 0);
943
944 msleep(500);
945
946 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
947 ALC5632_ADD2_POWER_EN,
948 ALC5632_ADD2_POWER_EN);
949
950 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1,
951 ALC5632_ADD1_POWER_EN,
952 ALC5632_ADD1_POWER_EN);
953
954 /* disable HP Depop2 */
955 snd_soc_update_bits(codec, ALC5632_MISC_CTRL,
956 ALC5632_MISC_HP_DEPOP_MODE2_EN,
957 0);
958
959}
960
961static int alc5632_set_bias_level(struct snd_soc_codec *codec,
962 enum snd_soc_bias_level level)
963{
964 switch (level) {
965 case SND_SOC_BIAS_ON:
966 enable_power_depop(codec);
967 break;
968 case SND_SOC_BIAS_PREPARE:
969 break;
970 case SND_SOC_BIAS_STANDBY:
971 /* everything off except vref/vmid, */
972 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1,
973 ALC5632_PWR_MANAG_ADD1_MASK,
974 ALC5632_PWR_ADD1_MAIN_BIAS);
975 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
976 ALC5632_PWR_MANAG_ADD2_MASK,
977 ALC5632_PWR_ADD2_VREF);
978 /* "normal" mode: 0 @ 26 */
979 snd_soc_update_bits(codec, ALC5632_PWR_DOWN_CTRL_STATUS,
980 ALC5632_PWR_DOWN_CTRL_STATUS_MASK,
981 0xffff ^ (ALC5632_PWR_VREF_PR3
982 | ALC5632_PWR_VREF_PR2));
983 break;
984 case SND_SOC_BIAS_OFF:
985 /* everything off, dac mute, inactive */
986 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2,
987 ALC5632_PWR_MANAG_ADD2_MASK, 0);
988 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD3,
989 ALC5632_PWR_MANAG_ADD3_MASK, 0);
990 snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1,
991 ALC5632_PWR_MANAG_ADD1_MASK, 0);
992 break;
993 }
994 codec->dapm.bias_level = level;
995 return 0;
996}
997
998#define ALC5632_FORMATS (SNDRV_PCM_FMTBIT_S16_LE \
999 | SNDRV_PCM_FMTBIT_S24_LE \
1000 | SNDRV_PCM_FMTBIT_S32_LE)
1001
Lars-Peter Clausen85e76522011-11-23 11:40:40 +01001002static const struct snd_soc_dai_ops alc5632_dai_ops = {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001003 .hw_params = alc5632_pcm_hw_params,
1004 .digital_mute = alc5632_mute,
1005 .set_fmt = alc5632_set_dai_fmt,
1006 .set_sysclk = alc5632_set_dai_sysclk,
1007 .set_pll = alc5632_set_dai_pll,
1008};
1009
1010static struct snd_soc_dai_driver alc5632_dai = {
1011 .name = "alc5632-hifi",
1012 .playback = {
1013 .stream_name = "HiFi Playback",
1014 .channels_min = 1,
1015 .channels_max = 2,
1016 .rate_min = 8000,
1017 .rate_max = 48000,
1018 .rates = SNDRV_PCM_RATE_8000_48000,
1019 .formats = ALC5632_FORMATS,},
1020 .capture = {
1021 .stream_name = "HiFi Capture",
1022 .channels_min = 1,
1023 .channels_max = 2,
1024 .rate_min = 8000,
1025 .rate_max = 48000,
1026 .rates = SNDRV_PCM_RATE_8000_48000,
1027 .formats = ALC5632_FORMATS,},
1028
1029 .ops = &alc5632_dai_ops,
1030 .symmetric_rates = 1,
1031};
1032
Leon Romanovskyc9be8422011-11-16 12:07:00 +02001033#ifdef CONFIG_PM
Lars-Peter Clausen84b315e2011-12-02 10:18:28 +01001034static int alc5632_suspend(struct snd_soc_codec *codec)
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001035{
1036 alc5632_set_bias_level(codec, SND_SOC_BIAS_OFF);
1037 return 0;
1038}
1039
1040static int alc5632_resume(struct snd_soc_codec *codec)
1041{
Leon Romanovskybb397532011-11-16 12:06:58 +02001042 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001043
Leon Romanovskybb397532011-11-16 12:06:58 +02001044 regcache_sync(alc5632->regmap);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001045
1046 alc5632_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1047 return 0;
1048}
Leon Romanovskyc9be8422011-11-16 12:07:00 +02001049#else
1050#define alc5632_suspend NULL
1051#define alc5632_resume NULL
1052#endif
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001053
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001054static int alc5632_probe(struct snd_soc_codec *codec)
1055{
1056 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec);
1057 int ret;
1058
Leon Romanovskybb397532011-11-16 12:06:58 +02001059 codec->control_data = alc5632->regmap;
1060
1061 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
1062 if (ret != 0) {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001063 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
1064 return ret;
1065 }
1066
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001067 /* power on device */
1068 alc5632_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1069
1070 switch (alc5632->id) {
1071 case 0x5c:
Liam Girdwood022658b2012-02-03 17:43:09 +00001072 snd_soc_add_codec_controls(codec, alc5632_vol_snd_controls,
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001073 ARRAY_SIZE(alc5632_vol_snd_controls));
1074 break;
1075 default:
1076 return -EINVAL;
1077 }
1078
1079 return ret;
1080}
1081
1082/* power down chip */
1083static int alc5632_remove(struct snd_soc_codec *codec)
1084{
1085 alc5632_set_bias_level(codec, SND_SOC_BIAS_OFF);
1086 return 0;
1087}
1088
1089static struct snd_soc_codec_driver soc_codec_device_alc5632 = {
1090 .probe = alc5632_probe,
1091 .remove = alc5632_remove,
1092 .suspend = alc5632_suspend,
1093 .resume = alc5632_resume,
1094 .set_bias_level = alc5632_set_bias_level,
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001095 .controls = alc5632_snd_controls,
1096 .num_controls = ARRAY_SIZE(alc5632_snd_controls),
1097 .dapm_widgets = alc5632_dapm_widgets,
1098 .num_dapm_widgets = ARRAY_SIZE(alc5632_dapm_widgets),
1099 .dapm_routes = alc5632_dapm_routes,
1100 .num_dapm_routes = ARRAY_SIZE(alc5632_dapm_routes),
1101};
1102
Leon Romanovskybb397532011-11-16 12:06:58 +02001103static struct regmap_config alc5632_regmap = {
1104 .reg_bits = 8,
1105 .val_bits = 16,
1106
1107 .max_register = ALC5632_MAX_REGISTER,
1108 .reg_defaults = alc5632_reg_defaults,
1109 .num_reg_defaults = ARRAY_SIZE(alc5632_reg_defaults),
1110 .volatile_reg = alc5632_volatile_register,
1111 .cache_type = REGCACHE_RBTREE,
1112};
1113
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001114/*
1115 * alc5632 2 wire address is determined by A1 pin
1116 * state during powerup.
1117 * low = 0x1a
1118 * high = 0x1b
1119 */
Leon Romanovskybb397532011-11-16 12:06:58 +02001120static __devinit int alc5632_i2c_probe(struct i2c_client *client,
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001121 const struct i2c_device_id *id)
1122{
1123 struct alc5632_priv *alc5632;
Leon Romanovsky277c01b2011-11-17 12:01:30 +02001124 int ret, ret1, ret2;
1125 unsigned int vid1, vid2;
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001126
1127 alc5632 = devm_kzalloc(&client->dev,
1128 sizeof(struct alc5632_priv), GFP_KERNEL);
1129 if (alc5632 == NULL)
1130 return -ENOMEM;
1131
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001132 i2c_set_clientdata(client, alc5632);
Leon Romanovskybb397532011-11-16 12:06:58 +02001133
1134 alc5632->regmap = regmap_init_i2c(client, &alc5632_regmap);
1135 if (IS_ERR(alc5632->regmap)) {
1136 ret = PTR_ERR(alc5632->regmap);
1137 dev_err(&client->dev, "regmap_init() failed: %d\n", ret);
1138 return ret;
1139 }
1140
Leon Romanovsky277c01b2011-11-17 12:01:30 +02001141 ret1 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID1, &vid1);
1142 ret2 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID2, &vid2);
1143 if (ret1 != 0 || ret2 != 0) {
1144 dev_err(&client->dev,
1145 "Failed to read chip ID: ret1=%d, ret2=%d\n", ret1, ret2);
1146 regmap_exit(alc5632->regmap);
1147 return -EIO;
1148 }
1149
1150 vid2 >>= 8;
1151
1152 if ((vid1 != 0x10EC) || (vid2 != id->driver_data)) {
1153 dev_err(&client->dev,
1154 "Device is not a ALC5632: VID1=0x%x, VID2=0x%x\n", vid1, vid2);
1155 regmap_exit(alc5632->regmap);
1156 return -EINVAL;
1157 }
1158
Leon Romanovskybb397532011-11-16 12:06:58 +02001159 ret = alc5632_reset(alc5632->regmap);
1160 if (ret < 0) {
1161 dev_err(&client->dev, "Failed to issue reset\n");
1162 regmap_exit(alc5632->regmap);
1163 return ret;
1164 }
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001165
Leon Romanovsky277c01b2011-11-17 12:01:30 +02001166 alc5632->id = vid2;
1167 switch (alc5632->id) {
1168 case 0x5c:
1169 alc5632_dai.name = "alc5632-hifi";
1170 break;
1171 default:
1172 return -EINVAL;
1173 }
1174
1175 ret = snd_soc_register_codec(&client->dev,
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001176 &soc_codec_device_alc5632, &alc5632_dai, 1);
Leon Romanovskybb397532011-11-16 12:06:58 +02001177
1178 if (ret < 0) {
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001179 dev_err(&client->dev, "Failed to register codec: %d\n", ret);
Leon Romanovskybb397532011-11-16 12:06:58 +02001180 regmap_exit(alc5632->regmap);
1181 return ret;
1182 }
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001183
1184 return ret;
1185}
1186
Axel Lin5091f5b2012-01-23 11:18:17 +08001187static __devexit int alc5632_i2c_remove(struct i2c_client *client)
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001188{
Leon Romanovskybb397532011-11-16 12:06:58 +02001189 struct alc5632_priv *alc5632 = i2c_get_clientdata(client);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001190 snd_soc_unregister_codec(&client->dev);
Leon Romanovskybb397532011-11-16 12:06:58 +02001191 regmap_exit(alc5632->regmap);
Leon Romanovsky94d5f7c2011-11-05 12:38:02 +02001192 return 0;
1193}
1194
1195static const struct i2c_device_id alc5632_i2c_table[] = {
1196 {"alc5632", 0x5c},
1197 {}
1198};
1199MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table);
1200
1201/* i2c codec control layer */
1202static struct i2c_driver alc5632_i2c_driver = {
1203 .driver = {
1204 .name = "alc5632",
1205 .owner = THIS_MODULE,
1206 },
1207 .probe = alc5632_i2c_probe,
1208 .remove = __devexit_p(alc5632_i2c_remove),
1209 .id_table = alc5632_i2c_table,
1210};
1211
1212static int __init alc5632_modinit(void)
1213{
1214 int ret;
1215
1216 ret = i2c_add_driver(&alc5632_i2c_driver);
1217 if (ret != 0) {
1218 printk(KERN_ERR "%s: can't add i2c driver", __func__);
1219 return ret;
1220 }
1221
1222 return ret;
1223}
1224module_init(alc5632_modinit);
1225
1226static void __exit alc5632_modexit(void)
1227{
1228 i2c_del_driver(&alc5632_i2c_driver);
1229}
1230module_exit(alc5632_modexit);
1231
1232MODULE_DESCRIPTION("ASoC ALC5632 driver");
1233MODULE_AUTHOR("Leon Romanovsky <leon@leon.nu>");
1234MODULE_LICENSE("GPL");