blob: 7843711729bcd79ce0f9d8938904199d7c056dd9 [file] [log] [blame]
Kuninori Morimoto98615452009-12-14 13:21:56 +09001/*
2 * DA7210 ALSA Soc codec driver
3 *
4 * Copyright (c) 2009 Dialog Semiconductor
5 * Written by David Chen <Dajun.chen@diasemi.com>
6 *
7 * Copyright (C) 2009 Renesas Solutions Corp.
8 * Cleanups by Kuninori Morimoto <morimoto.kuninori@renesas.com>
9 *
10 * Tested on SuperH Ecovec24 board with S16/S24 LE in 48KHz using I2S
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
Kuninori Morimoto98615452009-12-14 13:21:56 +090018#include <linux/delay.h>
Kuninori Morimoto98615452009-12-14 13:21:56 +090019#include <linux/i2c.h>
Ashish Chavan33593b52012-03-08 19:04:56 +053020#include <linux/regmap.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090021#include <linux/slab.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040022#include <linux/module.h>
Kuninori Morimoto98615452009-12-14 13:21:56 +090023#include <sound/pcm.h>
24#include <sound/pcm_params.h>
Liam Girdwoodce6120c2010-11-05 15:53:46 +020025#include <sound/soc.h>
Kuninori Morimoto98615452009-12-14 13:21:56 +090026#include <sound/initval.h>
Kuninori Morimotoa7e7cd52010-07-21 14:12:16 +090027#include <sound/tlv.h>
Kuninori Morimoto98615452009-12-14 13:21:56 +090028
Kuninori Morimoto98615452009-12-14 13:21:56 +090029/* DA7210 register space */
Ashish Chavande5eaf82011-10-19 14:24:37 +053030#define DA7210_CONTROL 0x01
Kuninori Morimoto98615452009-12-14 13:21:56 +090031#define DA7210_STATUS 0x02
32#define DA7210_STARTUP1 0x03
Ashish Chavan6950c602011-10-21 18:16:08 +053033#define DA7210_STARTUP2 0x04
34#define DA7210_STARTUP3 0x05
Kuninori Morimoto98615452009-12-14 13:21:56 +090035#define DA7210_MIC_L 0x07
36#define DA7210_MIC_R 0x08
Ashish Chavande5eaf82011-10-19 14:24:37 +053037#define DA7210_AUX1_L 0x09
38#define DA7210_AUX1_R 0x0A
Ashish Chavan5eda1942011-10-19 14:19:06 +053039#define DA7210_AUX2 0x0B
Ashish Chavande5eaf82011-10-19 14:24:37 +053040#define DA7210_IN_GAIN 0x0C
Kuninori Morimoto98615452009-12-14 13:21:56 +090041#define DA7210_INMIX_L 0x0D
42#define DA7210_INMIX_R 0x0E
43#define DA7210_ADC_HPF 0x0F
44#define DA7210_ADC 0x10
Ashish Chavan0ee6e9e2011-10-15 14:47:56 +053045#define DA7210_ADC_EQ1_2 0X11
46#define DA7210_ADC_EQ3_4 0x12
47#define DA7210_ADC_EQ5 0x13
Kuninori Morimoto98615452009-12-14 13:21:56 +090048#define DA7210_DAC_HPF 0x14
49#define DA7210_DAC_L 0x15
50#define DA7210_DAC_R 0x16
51#define DA7210_DAC_SEL 0x17
Ashish Chavan5eda1942011-10-19 14:19:06 +053052#define DA7210_SOFTMUTE 0x18
Ashish Chavan0ee6e9e2011-10-15 14:47:56 +053053#define DA7210_DAC_EQ1_2 0x19
54#define DA7210_DAC_EQ3_4 0x1A
55#define DA7210_DAC_EQ5 0x1B
Kuninori Morimoto98615452009-12-14 13:21:56 +090056#define DA7210_OUTMIX_L 0x1C
57#define DA7210_OUTMIX_R 0x1D
Ashish Chavan52082d82011-10-21 19:06:23 +053058#define DA7210_OUT1_L 0x1E
59#define DA7210_OUT1_R 0x1F
60#define DA7210_OUT2 0x20
Kuninori Morimoto98615452009-12-14 13:21:56 +090061#define DA7210_HP_L_VOL 0x21
62#define DA7210_HP_R_VOL 0x22
63#define DA7210_HP_CFG 0x23
Ashish Chavan5eda1942011-10-19 14:19:06 +053064#define DA7210_ZERO_CROSS 0x24
Kuninori Morimoto98615452009-12-14 13:21:56 +090065#define DA7210_DAI_SRC_SEL 0x25
66#define DA7210_DAI_CFG1 0x26
67#define DA7210_DAI_CFG3 0x28
Kuninori Morimoto960b3b42010-03-11 11:37:44 +090068#define DA7210_PLL_DIV1 0x29
69#define DA7210_PLL_DIV2 0x2A
Kuninori Morimoto98615452009-12-14 13:21:56 +090070#define DA7210_PLL_DIV3 0x2B
71#define DA7210_PLL 0x2C
Ashish Chavande5eaf82011-10-19 14:24:37 +053072#define DA7210_ALC_MAX 0x83
73#define DA7210_ALC_MIN 0x84
74#define DA7210_ALC_NOIS 0x85
75#define DA7210_ALC_ATT 0x86
76#define DA7210_ALC_REL 0x87
77#define DA7210_ALC_DEL 0x88
Kuninori Morimoto960b3b42010-03-11 11:37:44 +090078#define DA7210_A_HID_UNLOCK 0x8A
79#define DA7210_A_TEST_UNLOCK 0x8B
80#define DA7210_A_PLL1 0x90
81#define DA7210_A_CP_MODE 0xA7
Kuninori Morimoto98615452009-12-14 13:21:56 +090082
83/* STARTUP1 bit fields */
84#define DA7210_SC_MST_EN (1 << 0)
85
86/* MIC_L bit fields */
87#define DA7210_MICBIAS_EN (1 << 6)
88#define DA7210_MIC_L_EN (1 << 7)
89
90/* MIC_R bit fields */
91#define DA7210_MIC_R_EN (1 << 7)
92
93/* INMIX_L bit fields */
94#define DA7210_IN_L_EN (1 << 7)
95
96/* INMIX_R bit fields */
97#define DA7210_IN_R_EN (1 << 7)
98
Kuninori Morimoto98615452009-12-14 13:21:56 +090099/* ADC bit fields */
Ashish Chavande5eaf82011-10-19 14:24:37 +0530100#define DA7210_ADC_ALC_EN (1 << 0)
Kuninori Morimoto98615452009-12-14 13:21:56 +0900101#define DA7210_ADC_L_EN (1 << 3)
102#define DA7210_ADC_R_EN (1 << 7)
103
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900104/* DAC/ADC HPF fields */
105#define DA7210_VOICE_F0_MASK (0x7 << 4)
106#define DA7210_VOICE_F0_25 (1 << 4)
107#define DA7210_VOICE_EN (1 << 7)
Mark Brownc2151432009-12-16 20:36:37 +0000108
Kuninori Morimoto98615452009-12-14 13:21:56 +0900109/* DAC_SEL bit fields */
110#define DA7210_DAC_L_SRC_DAI_L (4 << 0)
111#define DA7210_DAC_L_EN (1 << 3)
112#define DA7210_DAC_R_SRC_DAI_R (5 << 4)
113#define DA7210_DAC_R_EN (1 << 7)
114
115/* OUTMIX_L bit fields */
116#define DA7210_OUT_L_EN (1 << 7)
117
118/* OUTMIX_R bit fields */
119#define DA7210_OUT_R_EN (1 << 7)
120
121/* HP_CFG bit fields */
122#define DA7210_HP_2CAP_MODE (1 << 1)
123#define DA7210_HP_SENSE_EN (1 << 2)
124#define DA7210_HP_L_EN (1 << 3)
125#define DA7210_HP_MODE (1 << 6)
126#define DA7210_HP_R_EN (1 << 7)
127
128/* DAI_SRC_SEL bit fields */
129#define DA7210_DAI_OUT_L_SRC (6 << 0)
130#define DA7210_DAI_OUT_R_SRC (7 << 4)
131
132/* DAI_CFG1 bit fields */
133#define DA7210_DAI_WORD_S16_LE (0 << 0)
Ashish Chavan0f8ea582011-10-12 20:33:21 +0530134#define DA7210_DAI_WORD_S20_3LE (1 << 0)
Kuninori Morimoto98615452009-12-14 13:21:56 +0900135#define DA7210_DAI_WORD_S24_LE (2 << 0)
Ashish Chavan0f8ea582011-10-12 20:33:21 +0530136#define DA7210_DAI_WORD_S32_LE (3 << 0)
Kuninori Morimoto98615452009-12-14 13:21:56 +0900137#define DA7210_DAI_FLEN_64BIT (1 << 2)
Ashish Chavan0f8ea582011-10-12 20:33:21 +0530138#define DA7210_DAI_MODE_SLAVE (0 << 7)
Kuninori Morimoto98615452009-12-14 13:21:56 +0900139#define DA7210_DAI_MODE_MASTER (1 << 7)
140
141/* DAI_CFG3 bit fields */
142#define DA7210_DAI_FORMAT_I2SMODE (0 << 0)
Ashish Chavan0f8ea582011-10-12 20:33:21 +0530143#define DA7210_DAI_FORMAT_LEFT_J (1 << 0)
144#define DA7210_DAI_FORMAT_RIGHT_J (2 << 0)
Kuninori Morimoto98615452009-12-14 13:21:56 +0900145#define DA7210_DAI_OE (1 << 3)
146#define DA7210_DAI_EN (1 << 7)
147
148/*PLL_DIV3 bit fields */
149#define DA7210_MCLK_RANGE_10_20_MHZ (1 << 4)
150#define DA7210_PLL_BYP (1 << 6)
151
152/* PLL bit fields */
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900153#define DA7210_PLL_FS_MASK (0xF << 0)
154#define DA7210_PLL_FS_8000 (0x1 << 0)
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900155#define DA7210_PLL_FS_11025 (0x2 << 0)
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900156#define DA7210_PLL_FS_12000 (0x3 << 0)
157#define DA7210_PLL_FS_16000 (0x5 << 0)
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900158#define DA7210_PLL_FS_22050 (0x6 << 0)
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900159#define DA7210_PLL_FS_24000 (0x7 << 0)
160#define DA7210_PLL_FS_32000 (0x9 << 0)
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900161#define DA7210_PLL_FS_44100 (0xA << 0)
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900162#define DA7210_PLL_FS_48000 (0xB << 0)
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900163#define DA7210_PLL_FS_88200 (0xE << 0)
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900164#define DA7210_PLL_FS_96000 (0xF << 0)
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900165#define DA7210_PLL_EN (0x1 << 7)
Kuninori Morimoto98615452009-12-14 13:21:56 +0900166
Ashish Chavan5eda1942011-10-19 14:19:06 +0530167/* SOFTMUTE bit fields */
168#define DA7210_RAMP_EN (1 << 6)
169
Ashish Chavande5eaf82011-10-19 14:24:37 +0530170/* CONTROL bit fields */
171#define DA7210_NOISE_SUP_EN (1 << 3)
172
173/* IN_GAIN bit fields */
174#define DA7210_INPGA_L_VOL (0x0F << 0)
175#define DA7210_INPGA_R_VOL (0xF0 << 0)
176
177/* ZERO_CROSS bit fields */
178#define DA7210_AUX1_L_ZC (1 << 0)
179#define DA7210_AUX1_R_ZC (1 << 1)
180#define DA7210_HP_L_ZC (1 << 6)
181#define DA7210_HP_R_ZC (1 << 7)
182
183/* AUX1_L bit fields */
184#define DA7210_AUX1_L_VOL (0x3F << 0)
Ashish Chavan24b6f262012-01-02 17:35:52 +0530185#define DA7210_AUX1_L_EN (1 << 7)
Ashish Chavande5eaf82011-10-19 14:24:37 +0530186
187/* AUX1_R bit fields */
188#define DA7210_AUX1_R_VOL (0x3F << 0)
Ashish Chavan24b6f262012-01-02 17:35:52 +0530189#define DA7210_AUX1_R_EN (1 << 7)
190
191/* AUX2 bit fields */
192#define DA7210_AUX2_EN (1 << 3)
Ashish Chavande5eaf82011-10-19 14:24:37 +0530193
194/* Minimum INPGA and AUX1 volume to enable noise suppression */
195#define DA7210_INPGA_MIN_VOL_NS 0x0A /* 10.5dB */
196#define DA7210_AUX1_MIN_VOL_NS 0x35 /* 6dB */
197
Ashish Chavan52082d82011-10-21 19:06:23 +0530198/* OUT1_L bit fields */
199#define DA7210_OUT1_L_EN (1 << 7)
200
201/* OUT1_R bit fields */
202#define DA7210_OUT1_R_EN (1 << 7)
203
204/* OUT2 bit fields */
205#define DA7210_OUT2_OUTMIX_R (1 << 5)
206#define DA7210_OUT2_OUTMIX_L (1 << 6)
207#define DA7210_OUT2_EN (1 << 7)
208
Kuninori Morimoto98615452009-12-14 13:21:56 +0900209#define DA7210_VERSION "0.0.1"
210
Kuninori Morimotoa7e7cd52010-07-21 14:12:16 +0900211/*
212 * Playback Volume
213 *
214 * max : 0x3F (+15.0 dB)
215 * (1.5 dB step)
216 * min : 0x11 (-54.0 dB)
217 * mute : 0x10
218 * reserved : 0x00 - 0x0F
219 *
Kuninori Morimotoa7e7cd52010-07-21 14:12:16 +0900220 * Reserved area are considered as "mute".
Kuninori Morimotoa7e7cd52010-07-21 14:12:16 +0900221 */
Ashish Chavan7a0e67b2011-10-14 16:25:25 +0530222static const unsigned int hp_out_tlv[] = {
223 TLV_DB_RANGE_HEAD(2),
224 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
225 /* -54 dB to +15 dB */
226 0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0),
227};
Kuninori Morimotoa7e7cd52010-07-21 14:12:16 +0900228
Ashish Chavan52082d82011-10-21 19:06:23 +0530229static const unsigned int lineout_vol_tlv[] = {
230 TLV_DB_RANGE_HEAD(2),
231 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
232 /* -54dB to 15dB */
233 0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0)
234};
235
236static const unsigned int mono_vol_tlv[] = {
237 TLV_DB_RANGE_HEAD(2),
238 0x0, 0x2, TLV_DB_SCALE_ITEM(-1800, 0, 1),
239 /* -18dB to 6dB */
240 0x3, 0x7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
241};
242
Ashish Chavan24b6f262012-01-02 17:35:52 +0530243static const unsigned int aux1_vol_tlv[] = {
244 TLV_DB_RANGE_HEAD(2),
245 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
246 /* -48dB to 21dB */
247 0x11, 0x3f, TLV_DB_SCALE_ITEM(-4800, 150, 0)
248};
249
Ashish Chavan0ee6e9e2011-10-15 14:47:56 +0530250static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0);
251static const DECLARE_TLV_DB_SCALE(adc_eq_master_gain_tlv, -1800, 600, 1);
Ashish Chavan52082d82011-10-21 19:06:23 +0530252static const DECLARE_TLV_DB_SCALE(dac_gain_tlv, -7725, 75, 0);
Ashish Chavan24b6f262012-01-02 17:35:52 +0530253static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0);
254static const DECLARE_TLV_DB_SCALE(aux2_vol_tlv, -600, 600, 0);
255static const DECLARE_TLV_DB_SCALE(inpga_gain_tlv, -450, 150, 0);
Ashish Chavan0ee6e9e2011-10-15 14:47:56 +0530256
Ashish Chavan4ced2b92011-10-15 14:50:06 +0530257/* ADC and DAC high pass filter f0 value */
Mark Brownf4034142011-11-09 23:15:26 +0000258static const char * const da7210_hpf_cutoff_txt[] = {
Ashish Chavan4ced2b92011-10-15 14:50:06 +0530259 "Fs/8192*pi", "Fs/4096*pi", "Fs/2048*pi", "Fs/1024*pi"
260};
261
262static const struct soc_enum da7210_dac_hpf_cutoff =
263 SOC_ENUM_SINGLE(DA7210_DAC_HPF, 0, 4, da7210_hpf_cutoff_txt);
264
265static const struct soc_enum da7210_adc_hpf_cutoff =
266 SOC_ENUM_SINGLE(DA7210_ADC_HPF, 0, 4, da7210_hpf_cutoff_txt);
267
268/* ADC and DAC voice (8kHz) high pass cutoff value */
Mark Brownf4034142011-11-09 23:15:26 +0000269static const char * const da7210_vf_cutoff_txt[] = {
Ashish Chavan4ced2b92011-10-15 14:50:06 +0530270 "2.5Hz", "25Hz", "50Hz", "100Hz", "150Hz", "200Hz", "300Hz", "400Hz"
271};
272
273static const struct soc_enum da7210_dac_vf_cutoff =
274 SOC_ENUM_SINGLE(DA7210_DAC_HPF, 4, 8, da7210_vf_cutoff_txt);
275
276static const struct soc_enum da7210_adc_vf_cutoff =
277 SOC_ENUM_SINGLE(DA7210_ADC_HPF, 4, 8, da7210_vf_cutoff_txt);
278
Ashish Chavan5eda1942011-10-19 14:19:06 +0530279static const char *da7210_hp_mode_txt[] = {
280 "Class H", "Class G"
281};
282
283static const struct soc_enum da7210_hp_mode_sel =
284 SOC_ENUM_SINGLE(DA7210_HP_CFG, 0, 2, da7210_hp_mode_txt);
285
Ashish Chavande5eaf82011-10-19 14:24:37 +0530286/* ALC can be enabled only if noise suppression is disabled */
287static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol,
288 struct snd_ctl_elem_value *ucontrol)
289{
290 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
291
292 if (ucontrol->value.integer.value[0]) {
293 /* Check if noise suppression is enabled */
294 if (snd_soc_read(codec, DA7210_CONTROL) & DA7210_NOISE_SUP_EN) {
295 dev_dbg(codec->dev,
296 "Disable noise suppression to enable ALC\n");
297 return -EINVAL;
298 }
299 }
300 /* If all conditions are met or we are actually disabling ALC */
301 return snd_soc_put_volsw(kcontrol, ucontrol);
302}
303
304/* Noise suppression can be enabled only if following conditions are met
305 * ALC disabled
306 * ZC enabled for HP and AUX1 PGA
307 * INPGA_L_VOL and INPGA_R_VOL >= 10.5 dB
308 * AUX1_L_VOL and AUX1_R_VOL >= 6 dB
309 */
310static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_value *ucontrol)
312{
313 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
314 u8 val;
315
316 if (ucontrol->value.integer.value[0]) {
317 /* Check if ALC is enabled */
318 if (snd_soc_read(codec, DA7210_ADC) & DA7210_ADC_ALC_EN)
319 goto err;
320
321 /* Check ZC for HP and AUX1 PGA */
322 if ((snd_soc_read(codec, DA7210_ZERO_CROSS) &
323 (DA7210_AUX1_L_ZC | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC |
324 DA7210_HP_R_ZC)) != (DA7210_AUX1_L_ZC |
325 DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | DA7210_HP_R_ZC))
326 goto err;
327
328 /* Check INPGA_L_VOL and INPGA_R_VOL */
329 val = snd_soc_read(codec, DA7210_IN_GAIN);
330 if (((val & DA7210_INPGA_L_VOL) < DA7210_INPGA_MIN_VOL_NS) ||
331 (((val & DA7210_INPGA_R_VOL) >> 4) <
332 DA7210_INPGA_MIN_VOL_NS))
333 goto err;
334
335 /* Check AUX1_L_VOL and AUX1_R_VOL */
336 if (((snd_soc_read(codec, DA7210_AUX1_L) & DA7210_AUX1_L_VOL) <
337 DA7210_AUX1_MIN_VOL_NS) ||
338 ((snd_soc_read(codec, DA7210_AUX1_R) & DA7210_AUX1_R_VOL) <
339 DA7210_AUX1_MIN_VOL_NS))
340 goto err;
341 }
342 /* If all conditions are met or we are actually disabling Noise sup */
343 return snd_soc_put_volsw(kcontrol, ucontrol);
344
345err:
346 return -EINVAL;
347}
348
Kuninori Morimotoa7e7cd52010-07-21 14:12:16 +0900349static const struct snd_kcontrol_new da7210_snd_controls[] = {
350
351 SOC_DOUBLE_R_TLV("HeadPhone Playback Volume",
352 DA7210_HP_L_VOL, DA7210_HP_R_VOL,
353 0, 0x3F, 0, hp_out_tlv),
Ashish Chavan52082d82011-10-21 19:06:23 +0530354 SOC_DOUBLE_R_TLV("Digital Playback Volume",
355 DA7210_DAC_L, DA7210_DAC_R,
356 0, 0x77, 1, dac_gain_tlv),
357 SOC_DOUBLE_R_TLV("Lineout Playback Volume",
358 DA7210_OUT1_L, DA7210_OUT1_R,
359 0, 0x3f, 0, lineout_vol_tlv),
360 SOC_SINGLE_TLV("Mono Playback Volume", DA7210_OUT2, 0, 0x7, 0,
361 mono_vol_tlv),
Ashish Chavan0ee6e9e2011-10-15 14:47:56 +0530362
Ashish Chavan24b6f262012-01-02 17:35:52 +0530363 SOC_DOUBLE_R_TLV("Mic Capture Volume",
364 DA7210_MIC_L, DA7210_MIC_R,
365 0, 0x5, 0, mic_vol_tlv),
366 SOC_DOUBLE_R_TLV("Aux1 Capture Volume",
367 DA7210_AUX1_L, DA7210_AUX1_R,
368 0, 0x3f, 0, aux1_vol_tlv),
369 SOC_SINGLE_TLV("Aux2 Capture Volume", DA7210_AUX2, 0, 0x3, 0,
370 aux2_vol_tlv),
371 SOC_DOUBLE_TLV("In PGA Capture Volume", DA7210_IN_GAIN, 0, 4, 0xF, 0,
372 inpga_gain_tlv),
373
Ashish Chavan0ee6e9e2011-10-15 14:47:56 +0530374 /* DAC Equalizer controls */
375 SOC_SINGLE("DAC EQ Switch", DA7210_DAC_EQ5, 7, 1, 0),
376 SOC_SINGLE_TLV("DAC EQ1 Volume", DA7210_DAC_EQ1_2, 0, 0xf, 1,
377 eq_gain_tlv),
378 SOC_SINGLE_TLV("DAC EQ2 Volume", DA7210_DAC_EQ1_2, 4, 0xf, 1,
379 eq_gain_tlv),
380 SOC_SINGLE_TLV("DAC EQ3 Volume", DA7210_DAC_EQ3_4, 0, 0xf, 1,
381 eq_gain_tlv),
382 SOC_SINGLE_TLV("DAC EQ4 Volume", DA7210_DAC_EQ3_4, 4, 0xf, 1,
383 eq_gain_tlv),
384 SOC_SINGLE_TLV("DAC EQ5 Volume", DA7210_DAC_EQ5, 0, 0xf, 1,
385 eq_gain_tlv),
386
387 /* ADC Equalizer controls */
388 SOC_SINGLE("ADC EQ Switch", DA7210_ADC_EQ5, 7, 1, 0),
389 SOC_SINGLE_TLV("ADC EQ Master Volume", DA7210_ADC_EQ5, 4, 0x3,
390 1, adc_eq_master_gain_tlv),
391 SOC_SINGLE_TLV("ADC EQ1 Volume", DA7210_ADC_EQ1_2, 0, 0xf, 1,
392 eq_gain_tlv),
393 SOC_SINGLE_TLV("ADC EQ2 Volume", DA7210_ADC_EQ1_2, 4, 0xf, 1,
394 eq_gain_tlv),
395 SOC_SINGLE_TLV("ADC EQ3 Volume", DA7210_ADC_EQ3_4, 0, 0xf, 1,
396 eq_gain_tlv),
397 SOC_SINGLE_TLV("ADC EQ4 Volume", DA7210_ADC_EQ3_4, 4, 0xf, 1,
398 eq_gain_tlv),
399 SOC_SINGLE_TLV("ADC EQ5 Volume", DA7210_ADC_EQ5, 0, 0xf, 1,
400 eq_gain_tlv),
Ashish Chavan4ced2b92011-10-15 14:50:06 +0530401
402 SOC_SINGLE("DAC HPF Switch", DA7210_DAC_HPF, 3, 1, 0),
403 SOC_ENUM("DAC HPF Cutoff", da7210_dac_hpf_cutoff),
404 SOC_SINGLE("DAC Voice Mode Switch", DA7210_DAC_HPF, 7, 1, 0),
405 SOC_ENUM("DAC Voice Cutoff", da7210_dac_vf_cutoff),
406
407 SOC_SINGLE("ADC HPF Switch", DA7210_ADC_HPF, 3, 1, 0),
408 SOC_ENUM("ADC HPF Cutoff", da7210_adc_hpf_cutoff),
409 SOC_SINGLE("ADC Voice Mode Switch", DA7210_ADC_HPF, 7, 1, 0),
410 SOC_ENUM("ADC Voice Cutoff", da7210_adc_vf_cutoff),
Ashish Chavan5eda1942011-10-19 14:19:06 +0530411
412 /* Mute controls */
413 SOC_DOUBLE_R("Mic Capture Switch", DA7210_MIC_L, DA7210_MIC_R, 3, 1, 0),
414 SOC_SINGLE("Aux2 Capture Switch", DA7210_AUX2, 2, 1, 0),
415 SOC_DOUBLE("ADC Capture Switch", DA7210_ADC, 2, 6, 1, 0),
416 SOC_SINGLE("Digital Soft Mute Switch", DA7210_SOFTMUTE, 7, 1, 0),
417 SOC_SINGLE("Digital Soft Mute Rate", DA7210_SOFTMUTE, 0, 0x7, 0),
418
419 /* Zero cross controls */
420 SOC_DOUBLE("Aux1 ZC Switch", DA7210_ZERO_CROSS, 0, 1, 1, 0),
421 SOC_DOUBLE("In PGA ZC Switch", DA7210_ZERO_CROSS, 2, 3, 1, 0),
422 SOC_DOUBLE("Lineout ZC Switch", DA7210_ZERO_CROSS, 4, 5, 1, 0),
423 SOC_DOUBLE("Headphone ZC Switch", DA7210_ZERO_CROSS, 6, 7, 1, 0),
424
425 SOC_ENUM("Headphone Class", da7210_hp_mode_sel),
Ashish Chavande5eaf82011-10-19 14:24:37 +0530426
427 /* ALC controls */
428 SOC_SINGLE_EXT("ALC Enable Switch", DA7210_ADC, 0, 1, 0,
429 snd_soc_get_volsw, da7210_put_alc_sw),
430 SOC_SINGLE("ALC Capture Max Volume", DA7210_ALC_MAX, 0, 0x3F, 0),
431 SOC_SINGLE("ALC Capture Min Volume", DA7210_ALC_MIN, 0, 0x3F, 0),
432 SOC_SINGLE("ALC Capture Noise Volume", DA7210_ALC_NOIS, 0, 0x3F, 0),
433 SOC_SINGLE("ALC Capture Attack Rate", DA7210_ALC_ATT, 0, 0xFF, 0),
434 SOC_SINGLE("ALC Capture Release Rate", DA7210_ALC_REL, 0, 0xFF, 0),
435 SOC_SINGLE("ALC Capture Release Delay", DA7210_ALC_DEL, 0, 0xFF, 0),
436
437 SOC_SINGLE_EXT("Noise Suppression Enable Switch", DA7210_CONTROL, 3, 1,
438 0, snd_soc_get_volsw, da7210_put_noise_sup_sw),
Kuninori Morimotoa7e7cd52010-07-21 14:12:16 +0900439};
440
Ashish Chavan6950c602011-10-21 18:16:08 +0530441/*
442 * DAPM Controls
443 *
444 * Current DAPM implementation covers almost all codec components e.g. IOs,
445 * mixers, PGAs,ADC and DAC.
446 */
447/* In Mixer Left */
448static const struct snd_kcontrol_new da7210_dapm_inmixl_controls[] = {
449 SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_L, 0, 1, 0),
450 SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_L, 1, 1, 0),
Ashish Chavan24b6f262012-01-02 17:35:52 +0530451 SOC_DAPM_SINGLE("Aux1 Left Switch", DA7210_INMIX_L, 2, 1, 0),
452 SOC_DAPM_SINGLE("Aux2 Switch", DA7210_INMIX_L, 3, 1, 0),
453 SOC_DAPM_SINGLE("Outmix Left Switch", DA7210_INMIX_L, 4, 1, 0),
Ashish Chavan6950c602011-10-21 18:16:08 +0530454};
455
456/* In Mixer Right */
457static const struct snd_kcontrol_new da7210_dapm_inmixr_controls[] = {
458 SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_R, 0, 1, 0),
459 SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_R, 1, 1, 0),
Ashish Chavan24b6f262012-01-02 17:35:52 +0530460 SOC_DAPM_SINGLE("Aux1 Right Switch", DA7210_INMIX_R, 2, 1, 0),
461 SOC_DAPM_SINGLE("Aux2 Switch", DA7210_INMIX_R, 3, 1, 0),
462 SOC_DAPM_SINGLE("Outmix Right Switch", DA7210_INMIX_R, 4, 1, 0),
Ashish Chavan6950c602011-10-21 18:16:08 +0530463};
464
465/* Out Mixer Left */
466static const struct snd_kcontrol_new da7210_dapm_outmixl_controls[] = {
Ashish Chavan24b6f262012-01-02 17:35:52 +0530467 SOC_DAPM_SINGLE("Aux1 Left Switch", DA7210_OUTMIX_L, 0, 1, 0),
468 SOC_DAPM_SINGLE("Aux2 Switch", DA7210_OUTMIX_L, 1, 1, 0),
469 SOC_DAPM_SINGLE("INPGA Left Switch", DA7210_OUTMIX_L, 2, 1, 0),
470 SOC_DAPM_SINGLE("INPGA Right Switch", DA7210_OUTMIX_L, 3, 1, 0),
Ashish Chavan6950c602011-10-21 18:16:08 +0530471 SOC_DAPM_SINGLE("DAC Left Switch", DA7210_OUTMIX_L, 4, 1, 0),
472};
473
474/* Out Mixer Right */
475static const struct snd_kcontrol_new da7210_dapm_outmixr_controls[] = {
Ashish Chavan24b6f262012-01-02 17:35:52 +0530476 SOC_DAPM_SINGLE("Aux1 Right Switch", DA7210_OUTMIX_R, 0, 1, 0),
477 SOC_DAPM_SINGLE("Aux2 Switch", DA7210_OUTMIX_R, 1, 1, 0),
478 SOC_DAPM_SINGLE("INPGA Left Switch", DA7210_OUTMIX_R, 2, 1, 0),
479 SOC_DAPM_SINGLE("INPGA Right Switch", DA7210_OUTMIX_R, 3, 1, 0),
Ashish Chavan6950c602011-10-21 18:16:08 +0530480 SOC_DAPM_SINGLE("DAC Right Switch", DA7210_OUTMIX_R, 4, 1, 0),
481};
482
Ashish Chavan52082d82011-10-21 19:06:23 +0530483/* Mono Mixer */
484static const struct snd_kcontrol_new da7210_dapm_monomix_controls[] = {
Ashish Chavan24b6f262012-01-02 17:35:52 +0530485 SOC_DAPM_SINGLE("INPGA Right Switch", DA7210_OUT2, 3, 1, 0),
486 SOC_DAPM_SINGLE("INPGA Left Switch", DA7210_OUT2, 4, 1, 0),
Ashish Chavan52082d82011-10-21 19:06:23 +0530487 SOC_DAPM_SINGLE("Outmix Right Switch", DA7210_OUT2, 5, 1, 0),
488 SOC_DAPM_SINGLE("Outmix Left Switch", DA7210_OUT2, 6, 1, 0),
489};
490
Ashish Chavan6950c602011-10-21 18:16:08 +0530491/* DAPM widgets */
492static const struct snd_soc_dapm_widget da7210_dapm_widgets[] = {
493 /* Input Side */
494 /* Input Lines */
495 SND_SOC_DAPM_INPUT("MICL"),
496 SND_SOC_DAPM_INPUT("MICR"),
Ashish Chavan24b6f262012-01-02 17:35:52 +0530497 SND_SOC_DAPM_INPUT("AUX1L"),
498 SND_SOC_DAPM_INPUT("AUX1R"),
499 SND_SOC_DAPM_INPUT("AUX2"),
Ashish Chavan6950c602011-10-21 18:16:08 +0530500
501 /* Input PGAs */
502 SND_SOC_DAPM_PGA("Mic Left", DA7210_STARTUP3, 0, 1, NULL, 0),
503 SND_SOC_DAPM_PGA("Mic Right", DA7210_STARTUP3, 1, 1, NULL, 0),
Ashish Chavan24b6f262012-01-02 17:35:52 +0530504 SND_SOC_DAPM_PGA("Aux1 Left", DA7210_STARTUP3, 2, 1, NULL, 0),
505 SND_SOC_DAPM_PGA("Aux1 Right", DA7210_STARTUP3, 3, 1, NULL, 0),
506 SND_SOC_DAPM_PGA("Aux2 Mono", DA7210_STARTUP3, 4, 1, NULL, 0),
Ashish Chavan6950c602011-10-21 18:16:08 +0530507
508 SND_SOC_DAPM_PGA("INPGA Left", DA7210_INMIX_L, 7, 0, NULL, 0),
509 SND_SOC_DAPM_PGA("INPGA Right", DA7210_INMIX_R, 7, 0, NULL, 0),
510
Ashish Chavan24b6f262012-01-02 17:35:52 +0530511 /* MICBIAS */
512 SND_SOC_DAPM_SUPPLY("Mic Bias", DA7210_MIC_L, 6, 0, NULL, 0),
513
Ashish Chavan6950c602011-10-21 18:16:08 +0530514 /* Input Mixers */
515 SND_SOC_DAPM_MIXER("In Mixer Left", SND_SOC_NOPM, 0, 0,
516 &da7210_dapm_inmixl_controls[0],
517 ARRAY_SIZE(da7210_dapm_inmixl_controls)),
518
519 SND_SOC_DAPM_MIXER("In Mixer Right", SND_SOC_NOPM, 0, 0,
520 &da7210_dapm_inmixr_controls[0],
521 ARRAY_SIZE(da7210_dapm_inmixr_controls)),
522
523 /* ADCs */
524 SND_SOC_DAPM_ADC("ADC Left", "Capture", DA7210_STARTUP3, 5, 1),
525 SND_SOC_DAPM_ADC("ADC Right", "Capture", DA7210_STARTUP3, 6, 1),
526
527 /* Output Side */
528 /* DACs */
529 SND_SOC_DAPM_DAC("DAC Left", "Playback", DA7210_STARTUP2, 5, 1),
530 SND_SOC_DAPM_DAC("DAC Right", "Playback", DA7210_STARTUP2, 6, 1),
531
532 /* Output Mixers */
533 SND_SOC_DAPM_MIXER("Out Mixer Left", SND_SOC_NOPM, 0, 0,
534 &da7210_dapm_outmixl_controls[0],
535 ARRAY_SIZE(da7210_dapm_outmixl_controls)),
536
537 SND_SOC_DAPM_MIXER("Out Mixer Right", SND_SOC_NOPM, 0, 0,
538 &da7210_dapm_outmixr_controls[0],
539 ARRAY_SIZE(da7210_dapm_outmixr_controls)),
540
Ashish Chavan52082d82011-10-21 19:06:23 +0530541 SND_SOC_DAPM_MIXER("Mono Mixer", SND_SOC_NOPM, 0, 0,
542 &da7210_dapm_monomix_controls[0],
543 ARRAY_SIZE(da7210_dapm_monomix_controls)),
544
Ashish Chavan6950c602011-10-21 18:16:08 +0530545 /* Output PGAs */
546 SND_SOC_DAPM_PGA("OUTPGA Left Enable", DA7210_OUTMIX_L, 7, 0, NULL, 0),
547 SND_SOC_DAPM_PGA("OUTPGA Right Enable", DA7210_OUTMIX_R, 7, 0, NULL, 0),
548
Ashish Chavan52082d82011-10-21 19:06:23 +0530549 SND_SOC_DAPM_PGA("Out1 Left", DA7210_STARTUP2, 0, 1, NULL, 0),
550 SND_SOC_DAPM_PGA("Out1 Right", DA7210_STARTUP2, 1, 1, NULL, 0),
551 SND_SOC_DAPM_PGA("Out2 Mono", DA7210_STARTUP2, 2, 1, NULL, 0),
Ashish Chavan6950c602011-10-21 18:16:08 +0530552 SND_SOC_DAPM_PGA("Headphone Left", DA7210_STARTUP2, 3, 1, NULL, 0),
553 SND_SOC_DAPM_PGA("Headphone Right", DA7210_STARTUP2, 4, 1, NULL, 0),
554
555 /* Output Lines */
Ashish Chavan52082d82011-10-21 19:06:23 +0530556 SND_SOC_DAPM_OUTPUT("OUT1L"),
557 SND_SOC_DAPM_OUTPUT("OUT1R"),
Ashish Chavan6950c602011-10-21 18:16:08 +0530558 SND_SOC_DAPM_OUTPUT("HPL"),
559 SND_SOC_DAPM_OUTPUT("HPR"),
Ashish Chavan52082d82011-10-21 19:06:23 +0530560 SND_SOC_DAPM_OUTPUT("OUT2"),
Ashish Chavan6950c602011-10-21 18:16:08 +0530561};
562
563/* DAPM audio route definition */
564static const struct snd_soc_dapm_route da7210_audio_map[] = {
565 /* Dest Connecting Widget source */
566 /* Input path */
567 {"Mic Left", NULL, "MICL"},
568 {"Mic Right", NULL, "MICR"},
Ashish Chavan24b6f262012-01-02 17:35:52 +0530569 {"Aux1 Left", NULL, "AUX1L"},
570 {"Aux1 Right", NULL, "AUX1R"},
571 {"Aux2 Mono", NULL, "AUX2"},
Ashish Chavan6950c602011-10-21 18:16:08 +0530572
573 {"In Mixer Left", "Mic Left Switch", "Mic Left"},
574 {"In Mixer Left", "Mic Right Switch", "Mic Right"},
Ashish Chavan24b6f262012-01-02 17:35:52 +0530575 {"In Mixer Left", "Aux1 Left Switch", "Aux1 Left"},
576 {"In Mixer Left", "Aux2 Switch", "Aux2 Mono"},
577 {"In Mixer Left", "Outmix Left Switch", "Out Mixer Left"},
Ashish Chavan6950c602011-10-21 18:16:08 +0530578
579 {"In Mixer Right", "Mic Right Switch", "Mic Right"},
580 {"In Mixer Right", "Mic Left Switch", "Mic Left"},
Ashish Chavan24b6f262012-01-02 17:35:52 +0530581 {"In Mixer Right", "Aux1 Right Switch", "Aux1 Right"},
582 {"In Mixer Right", "Aux2 Switch", "Aux2 Mono"},
583 {"In Mixer Right", "Outmix Right Switch", "Out Mixer Right"},
Ashish Chavan6950c602011-10-21 18:16:08 +0530584
585 {"INPGA Left", NULL, "In Mixer Left"},
586 {"ADC Left", NULL, "INPGA Left"},
587
588 {"INPGA Right", NULL, "In Mixer Right"},
589 {"ADC Right", NULL, "INPGA Right"},
590
591 /* Output path */
Ashish Chavan24b6f262012-01-02 17:35:52 +0530592 {"Out Mixer Left", "Aux1 Left Switch", "Aux1 Left"},
593 {"Out Mixer Left", "Aux2 Switch", "Aux2 Mono"},
594 {"Out Mixer Left", "INPGA Left Switch", "INPGA Left"},
595 {"Out Mixer Left", "INPGA Right Switch", "INPGA Right"},
Ashish Chavan6950c602011-10-21 18:16:08 +0530596 {"Out Mixer Left", "DAC Left Switch", "DAC Left"},
Ashish Chavan24b6f262012-01-02 17:35:52 +0530597
598 {"Out Mixer Right", "Aux1 Right Switch", "Aux1 Right"},
599 {"Out Mixer Right", "Aux2 Switch", "Aux2 Mono"},
600 {"Out Mixer Right", "INPGA Right Switch", "INPGA Right"},
601 {"Out Mixer Right", "INPGA Left Switch", "INPGA Left"},
Ashish Chavan6950c602011-10-21 18:16:08 +0530602 {"Out Mixer Right", "DAC Right Switch", "DAC Right"},
603
Ashish Chavan24b6f262012-01-02 17:35:52 +0530604 {"Mono Mixer", "INPGA Right Switch", "INPGA Right"},
605 {"Mono Mixer", "INPGA Left Switch", "INPGA Left"},
Ashish Chavan52082d82011-10-21 19:06:23 +0530606 {"Mono Mixer", "Outmix Right Switch", "Out Mixer Right"},
607 {"Mono Mixer", "Outmix Left Switch", "Out Mixer Left"},
608
Ashish Chavan6950c602011-10-21 18:16:08 +0530609 {"OUTPGA Left Enable", NULL, "Out Mixer Left"},
610 {"OUTPGA Right Enable", NULL, "Out Mixer Right"},
611
Ashish Chavan52082d82011-10-21 19:06:23 +0530612 {"Out1 Left", NULL, "OUTPGA Left Enable"},
613 {"OUT1L", NULL, "Out1 Left"},
614
615 {"Out1 Right", NULL, "OUTPGA Right Enable"},
616 {"OUT1R", NULL, "Out1 Right"},
617
Ashish Chavan6950c602011-10-21 18:16:08 +0530618 {"Headphone Left", NULL, "OUTPGA Left Enable"},
619 {"HPL", NULL, "Headphone Left"},
620
621 {"Headphone Right", NULL, "OUTPGA Right Enable"},
622 {"HPR", NULL, "Headphone Right"},
Ashish Chavan52082d82011-10-21 19:06:23 +0530623
624 {"Out2 Mono", NULL, "Mono Mixer"},
625 {"OUT2", NULL, "Out2 Mono"},
Ashish Chavan6950c602011-10-21 18:16:08 +0530626};
627
Kuninori Morimoto98615452009-12-14 13:21:56 +0900628/* Codec private data */
629struct da7210_priv {
Ashish Chavan33593b52012-03-08 19:04:56 +0530630 struct regmap *regmap;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900631};
632
Ashish Chavan33593b52012-03-08 19:04:56 +0530633static struct reg_default da7210_reg_defaults[] = {
Ashish Chavan33593b52012-03-08 19:04:56 +0530634 { 0x01, 0x11 },
Ashish Chavan33593b52012-03-08 19:04:56 +0530635 { 0x03, 0x00 },
636 { 0x04, 0x00 },
637 { 0x05, 0x00 },
638 { 0x06, 0x00 },
639 { 0x07, 0x00 },
640 { 0x08, 0x00 },
641 { 0x09, 0x00 },
642 { 0x0a, 0x00 },
643 { 0x0b, 0x00 },
644 { 0x0c, 0x00 },
645 { 0x0d, 0x00 },
646 { 0x0e, 0x00 },
647 { 0x0f, 0x08 },
648 { 0x10, 0x00 },
649 { 0x11, 0x00 },
650 { 0x12, 0x00 },
651 { 0x13, 0x00 },
652 { 0x14, 0x08 },
653 { 0x15, 0x10 },
654 { 0x16, 0x10 },
655 { 0x17, 0x54 },
656 { 0x18, 0x40 },
657 { 0x19, 0x00 },
658 { 0x1a, 0x00 },
659 { 0x1b, 0x00 },
660 { 0x1c, 0x00 },
661 { 0x1d, 0x00 },
662 { 0x1e, 0x00 },
663 { 0x1f, 0x00 },
664 { 0x20, 0x00 },
665 { 0x21, 0x00 },
666 { 0x22, 0x00 },
667 { 0x23, 0x02 },
668 { 0x24, 0x00 },
669 { 0x25, 0x76 },
670 { 0x26, 0x00 },
671 { 0x27, 0x00 },
672 { 0x28, 0x04 },
673 { 0x29, 0x00 },
674 { 0x2a, 0x00 },
675 { 0x2b, 0x30 },
676 { 0x2c, 0x2A },
Ashish Chavan33593b52012-03-08 19:04:56 +0530677 { 0x83, 0x00 },
678 { 0x84, 0x00 },
679 { 0x85, 0x00 },
680 { 0x86, 0x00 },
681 { 0x87, 0x00 },
682 { 0x88, 0x00 },
Kuninori Morimoto98615452009-12-14 13:21:56 +0900683};
684
Ashish Chavan33593b52012-03-08 19:04:56 +0530685static bool da7210_readable_register(struct device *dev, unsigned int reg)
686{
687 switch (reg) {
688 case DA7210_A_HID_UNLOCK:
689 case DA7210_A_TEST_UNLOCK:
690 case DA7210_A_PLL1:
691 case DA7210_A_CP_MODE:
692 return false;
693 default:
694 return true;
695 }
696}
697
698static bool da7210_volatile_register(struct device *dev,
Axel Lin40a49712011-10-12 07:16:25 +0800699 unsigned int reg)
Kuninori Morimoto98615452009-12-14 13:21:56 +0900700{
Axel Lin40a49712011-10-12 07:16:25 +0800701 switch (reg) {
702 case DA7210_STATUS:
Ashish Chavan33593b52012-03-08 19:04:56 +0530703 return true;
Axel Lin40a49712011-10-12 07:16:25 +0800704 default:
Ashish Chavan33593b52012-03-08 19:04:56 +0530705 return false;
Axel Lin40a49712011-10-12 07:16:25 +0800706 }
Kuninori Morimoto98615452009-12-14 13:21:56 +0900707}
Kuninori Morimoto98615452009-12-14 13:21:56 +0900708
709/*
710 * Set PCM DAI word length.
711 */
712static int da7210_hw_params(struct snd_pcm_substream *substream,
713 struct snd_pcm_hw_params *params,
714 struct snd_soc_dai *dai)
715{
716 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000717 struct snd_soc_codec *codec = rtd->codec;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900718 u32 dai_cfg1;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900719 u32 fs, bypass;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900720
721 /* set DAI source to Left and Right ADC */
Axel Lin40a49712011-10-12 07:16:25 +0800722 snd_soc_write(codec, DA7210_DAI_SRC_SEL,
Kuninori Morimoto98615452009-12-14 13:21:56 +0900723 DA7210_DAI_OUT_R_SRC | DA7210_DAI_OUT_L_SRC);
724
725 /* Enable DAI */
Axel Lin40a49712011-10-12 07:16:25 +0800726 snd_soc_write(codec, DA7210_DAI_CFG3, DA7210_DAI_OE | DA7210_DAI_EN);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900727
Axel Lin40a49712011-10-12 07:16:25 +0800728 dai_cfg1 = 0xFC & snd_soc_read(codec, DA7210_DAI_CFG1);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900729
730 switch (params_format(params)) {
731 case SNDRV_PCM_FORMAT_S16_LE:
732 dai_cfg1 |= DA7210_DAI_WORD_S16_LE;
733 break;
Ashish Chavan0f8ea582011-10-12 20:33:21 +0530734 case SNDRV_PCM_FORMAT_S20_3LE:
735 dai_cfg1 |= DA7210_DAI_WORD_S20_3LE;
736 break;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900737 case SNDRV_PCM_FORMAT_S24_LE:
738 dai_cfg1 |= DA7210_DAI_WORD_S24_LE;
739 break;
Ashish Chavan0f8ea582011-10-12 20:33:21 +0530740 case SNDRV_PCM_FORMAT_S32_LE:
741 dai_cfg1 |= DA7210_DAI_WORD_S32_LE;
742 break;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900743 default:
744 return -EINVAL;
745 }
746
Axel Lin40a49712011-10-12 07:16:25 +0800747 snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900748
Kuninori Morimoto98615452009-12-14 13:21:56 +0900749 switch (params_rate(params)) {
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900750 case 8000:
751 fs = DA7210_PLL_FS_8000;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900752 bypass = DA7210_PLL_BYP;
753 break;
754 case 11025:
755 fs = DA7210_PLL_FS_11025;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900756 bypass = 0;
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900757 break;
758 case 12000:
759 fs = DA7210_PLL_FS_12000;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900760 bypass = DA7210_PLL_BYP;
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900761 break;
762 case 16000:
763 fs = DA7210_PLL_FS_16000;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900764 bypass = DA7210_PLL_BYP;
765 break;
766 case 22050:
767 fs = DA7210_PLL_FS_22050;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900768 bypass = 0;
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900769 break;
770 case 32000:
771 fs = DA7210_PLL_FS_32000;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900772 bypass = DA7210_PLL_BYP;
773 break;
774 case 44100:
775 fs = DA7210_PLL_FS_44100;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900776 bypass = 0;
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900777 break;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900778 case 48000:
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900779 fs = DA7210_PLL_FS_48000;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900780 bypass = DA7210_PLL_BYP;
781 break;
782 case 88200:
783 fs = DA7210_PLL_FS_88200;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900784 bypass = 0;
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900785 break;
786 case 96000:
787 fs = DA7210_PLL_FS_96000;
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900788 bypass = DA7210_PLL_BYP;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900789 break;
790 default:
791 return -EINVAL;
792 }
793
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900794 /* Disable active mode */
795 snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0);
796
Kuninori Morimoto3a9d6202010-03-01 10:10:43 +0900797 snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs);
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900798 snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, bypass);
799
800 /* Enable active mode */
801 snd_soc_update_bits(codec, DA7210_STARTUP1,
802 DA7210_SC_MST_EN, DA7210_SC_MST_EN);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900803
804 return 0;
805}
806
807/*
808 * Set DAI mode and Format
809 */
810static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt)
811{
812 struct snd_soc_codec *codec = codec_dai->codec;
813 u32 dai_cfg1;
814 u32 dai_cfg3;
815
Axel Lin40a49712011-10-12 07:16:25 +0800816 dai_cfg1 = 0x7f & snd_soc_read(codec, DA7210_DAI_CFG1);
817 dai_cfg3 = 0xfc & snd_soc_read(codec, DA7210_DAI_CFG3);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900818
819 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
820 case SND_SOC_DAIFMT_CBM_CFM:
821 dai_cfg1 |= DA7210_DAI_MODE_MASTER;
822 break;
Ashish Chavan0f8ea582011-10-12 20:33:21 +0530823 case SND_SOC_DAIFMT_CBS_CFS:
824 dai_cfg1 |= DA7210_DAI_MODE_SLAVE;
825 break;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900826 default:
827 return -EINVAL;
828 }
829
830 /* FIXME
831 *
832 * It support I2S only now
833 */
834 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
835 case SND_SOC_DAIFMT_I2S:
836 dai_cfg3 |= DA7210_DAI_FORMAT_I2SMODE;
837 break;
Ashish Chavan0f8ea582011-10-12 20:33:21 +0530838 case SND_SOC_DAIFMT_LEFT_J:
839 dai_cfg3 |= DA7210_DAI_FORMAT_LEFT_J;
840 break;
841 case SND_SOC_DAIFMT_RIGHT_J:
842 dai_cfg3 |= DA7210_DAI_FORMAT_RIGHT_J;
843 break;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900844 default:
845 return -EINVAL;
846 }
847
848 /* FIXME
849 *
850 * It support 64bit data transmission only now
851 */
852 dai_cfg1 |= DA7210_DAI_FLEN_64BIT;
853
Axel Lin40a49712011-10-12 07:16:25 +0800854 snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1);
855 snd_soc_write(codec, DA7210_DAI_CFG3, dai_cfg3);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900856
857 return 0;
858}
859
Ashish Chavan5eda1942011-10-19 14:19:06 +0530860static int da7210_mute(struct snd_soc_dai *dai, int mute)
861{
862 struct snd_soc_codec *codec = dai->codec;
863 u8 mute_reg = snd_soc_read(codec, DA7210_DAC_HPF) & 0xFB;
864
865 if (mute)
866 snd_soc_write(codec, DA7210_DAC_HPF, mute_reg | 0x4);
867 else
868 snd_soc_write(codec, DA7210_DAC_HPF, mute_reg);
869 return 0;
870}
871
Ashish Chavan0f8ea582011-10-12 20:33:21 +0530872#define DA7210_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
873 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
Kuninori Morimoto98615452009-12-14 13:21:56 +0900874
875/* DAI operations */
Lars-Peter Clausen85e76522011-11-23 11:40:40 +0100876static const struct snd_soc_dai_ops da7210_dai_ops = {
Kuninori Morimoto98615452009-12-14 13:21:56 +0900877 .hw_params = da7210_hw_params,
878 .set_fmt = da7210_set_dai_fmt,
Ashish Chavan5eda1942011-10-19 14:19:06 +0530879 .digital_mute = da7210_mute,
Kuninori Morimoto98615452009-12-14 13:21:56 +0900880};
881
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000882static struct snd_soc_dai_driver da7210_dai = {
883 .name = "da7210-hifi",
Kuninori Morimoto98615452009-12-14 13:21:56 +0900884 /* playback capabilities */
885 .playback = {
886 .stream_name = "Playback",
887 .channels_min = 1,
888 .channels_max = 2,
889 .rates = SNDRV_PCM_RATE_8000_96000,
890 .formats = DA7210_FORMATS,
891 },
892 /* capture capabilities */
893 .capture = {
894 .stream_name = "Capture",
895 .channels_min = 1,
896 .channels_max = 2,
897 .rates = SNDRV_PCM_RATE_8000_96000,
898 .formats = DA7210_FORMATS,
899 },
900 .ops = &da7210_dai_ops,
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900901 .symmetric_rates = 1,
Kuninori Morimoto98615452009-12-14 13:21:56 +0900902};
Kuninori Morimoto98615452009-12-14 13:21:56 +0900903
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000904static int da7210_probe(struct snd_soc_codec *codec)
Kuninori Morimoto98615452009-12-14 13:21:56 +0900905{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000906 struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec);
Axel Lin40a49712011-10-12 07:16:25 +0800907 int ret;
Kuninori Morimoto98615452009-12-14 13:21:56 +0900908
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000909 dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900910
Ashish Chavan33593b52012-03-08 19:04:56 +0530911 codec->control_data = da7210->regmap;
912 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
Axel Lin40a49712011-10-12 07:16:25 +0800913 if (ret < 0) {
914 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
915 return ret;
916 }
Kuninori Morimoto98615452009-12-14 13:21:56 +0900917
918 /* FIXME
919 *
920 * This driver use fixed value here
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900921 * And below settings expects MCLK = 12.288MHz
922 *
923 * When you select different MCLK, please check...
924 * DA7210_PLL_DIV1 val
925 * DA7210_PLL_DIV2 val
926 * DA7210_PLL_DIV3 val
927 * DA7210_PLL_DIV3 :: DA7210_MCLK_RANGExxx
Kuninori Morimoto98615452009-12-14 13:21:56 +0900928 */
929
930 /*
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900931 * make sure that DA7210 use bypass mode before start up
932 */
Axel Lin40a49712011-10-12 07:16:25 +0800933 snd_soc_write(codec, DA7210_STARTUP1, 0);
934 snd_soc_write(codec, DA7210_PLL_DIV3,
Kuninori Morimoto960b3b42010-03-11 11:37:44 +0900935 DA7210_MCLK_RANGE_10_20_MHZ | DA7210_PLL_BYP);
936
937 /*
Kuninori Morimoto98615452009-12-14 13:21:56 +0900938 * ADC settings
939 */
940
941 /* Enable Left & Right MIC PGA and Mic Bias */
Axel Lin40a49712011-10-12 07:16:25 +0800942 snd_soc_write(codec, DA7210_MIC_L, DA7210_MIC_L_EN | DA7210_MICBIAS_EN);
943 snd_soc_write(codec, DA7210_MIC_R, DA7210_MIC_R_EN);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900944
945 /* Enable Left and Right input PGA */
Axel Lin40a49712011-10-12 07:16:25 +0800946 snd_soc_write(codec, DA7210_INMIX_L, DA7210_IN_L_EN);
947 snd_soc_write(codec, DA7210_INMIX_R, DA7210_IN_R_EN);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900948
949 /* Enable Left and Right ADC */
Axel Lin40a49712011-10-12 07:16:25 +0800950 snd_soc_write(codec, DA7210_ADC, DA7210_ADC_L_EN | DA7210_ADC_R_EN);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900951
952 /*
953 * DAC settings
954 */
955
956 /* Enable Left and Right DAC */
Axel Lin40a49712011-10-12 07:16:25 +0800957 snd_soc_write(codec, DA7210_DAC_SEL,
Kuninori Morimoto98615452009-12-14 13:21:56 +0900958 DA7210_DAC_L_SRC_DAI_L | DA7210_DAC_L_EN |
959 DA7210_DAC_R_SRC_DAI_R | DA7210_DAC_R_EN);
960
961 /* Enable Left and Right out PGA */
Axel Lin40a49712011-10-12 07:16:25 +0800962 snd_soc_write(codec, DA7210_OUTMIX_L, DA7210_OUT_L_EN);
963 snd_soc_write(codec, DA7210_OUTMIX_R, DA7210_OUT_R_EN);
Kuninori Morimoto98615452009-12-14 13:21:56 +0900964
965 /* Enable Left and Right HeadPhone PGA */
Axel Lin40a49712011-10-12 07:16:25 +0800966 snd_soc_write(codec, DA7210_HP_CFG,
Kuninori Morimoto98615452009-12-14 13:21:56 +0900967 DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN |
968 DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN);
969
Ashish Chavan5eda1942011-10-19 14:19:06 +0530970 /* Enable ramp mode for DAC gain update */
971 snd_soc_write(codec, DA7210_SOFTMUTE, DA7210_RAMP_EN);
972
Ashish Chavan52082d82011-10-21 19:06:23 +0530973 /*
974 * For DA7210 codec, there are two ways to enable/disable analog IOs
975 * and ADC/DAC,
976 * (1) Using "Enable Bit" of register associated with that IO
977 * (or ADC/DAC)
978 * e.g. Mic Left can be enabled using bit 7 of MIC_L(0x7) reg
979 *
980 * (2) Using "Standby Bit" of STARTUP2 or STARTUP3 register
981 * e.g. Mic left can be put to STANDBY using bit 0 of STARTUP3(0x5)
982 *
983 * Out of these two methods, the one using STANDBY bits is preferred
984 * way to enable/disable individual blocks. This is because STANDBY
985 * registers are part of system controller which allows system power
986 * up/down in a controlled, pop-free manner. Also, as per application
987 * note of DA7210, STANDBY register bits are only effective if a
988 * particular IO (or ADC/DAC) is already enabled using enable/disable
989 * register bits. Keeping these things in mind, current DAPM
990 * implementation manipulates only STANDBY bits.
991 *
992 * Overall implementation can be outlined as below,
993 *
994 * - "Enable bit" of an IO or ADC/DAC is used to enable it in probe()
995 * - "STANDBY bit" is controlled by DAPM
996 */
997
998 /* Enable Line out amplifiers */
999 snd_soc_write(codec, DA7210_OUT1_L, DA7210_OUT1_L_EN);
1000 snd_soc_write(codec, DA7210_OUT1_R, DA7210_OUT1_R_EN);
1001 snd_soc_write(codec, DA7210_OUT2, DA7210_OUT2_EN |
1002 DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R);
1003
Ashish Chavan24b6f262012-01-02 17:35:52 +05301004 /* Enable Aux1 */
1005 snd_soc_write(codec, DA7210_AUX1_L, DA7210_AUX1_L_EN);
1006 snd_soc_write(codec, DA7210_AUX1_R, DA7210_AUX1_R_EN);
1007 /* Enable Aux2 */
1008 snd_soc_write(codec, DA7210_AUX2, DA7210_AUX2_EN);
1009
Kuninori Morimoto98615452009-12-14 13:21:56 +09001010 /* Diable PLL and bypass it */
Axel Lin40a49712011-10-12 07:16:25 +08001011 snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000);
Kuninori Morimoto98615452009-12-14 13:21:56 +09001012
Kuninori Morimoto960b3b42010-03-11 11:37:44 +09001013 /*
1014 * If 48kHz sound came, it use bypass mode,
1015 * and when it is 44.1kHz, it use PLL.
1016 *
1017 * This time, this driver sets PLL always ON
1018 * and controls bypass/PLL mode by switching
1019 * DA7210_PLL_DIV3 :: DA7210_PLL_BYP bit.
1020 * see da7210_hw_params
1021 */
Axel Lin40a49712011-10-12 07:16:25 +08001022 snd_soc_write(codec, DA7210_PLL_DIV1, 0xE5); /* MCLK = 12.288MHz */
1023 snd_soc_write(codec, DA7210_PLL_DIV2, 0x99);
1024 snd_soc_write(codec, DA7210_PLL_DIV3, 0x0A |
Kuninori Morimoto98615452009-12-14 13:21:56 +09001025 DA7210_MCLK_RANGE_10_20_MHZ | DA7210_PLL_BYP);
Kuninori Morimoto960b3b42010-03-11 11:37:44 +09001026 snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_EN, DA7210_PLL_EN);
1027
1028 /* As suggested by Dialog */
Ashish Chavan33593b52012-03-08 19:04:56 +05301029 /* unlock */
1030 regmap_write(da7210->regmap, DA7210_A_HID_UNLOCK, 0x8B);
1031 regmap_write(da7210->regmap, DA7210_A_TEST_UNLOCK, 0xB4);
1032 regmap_write(da7210->regmap, DA7210_A_PLL1, 0x01);
1033 regmap_write(da7210->regmap, DA7210_A_CP_MODE, 0x7C);
1034 /* re-lock */
1035 regmap_write(da7210->regmap, DA7210_A_HID_UNLOCK, 0x00);
1036 regmap_write(da7210->regmap, DA7210_A_TEST_UNLOCK, 0x00);
Kuninori Morimoto98615452009-12-14 13:21:56 +09001037
1038 /* Activate all enabled subsystem */
Axel Lin40a49712011-10-12 07:16:25 +08001039 snd_soc_write(codec, DA7210_STARTUP1, DA7210_SC_MST_EN);
Kuninori Morimoto98615452009-12-14 13:21:56 +09001040
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001041 dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION);
Kuninori Morimoto98615452009-12-14 13:21:56 +09001042
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001043 return 0;
Kuninori Morimoto98615452009-12-14 13:21:56 +09001044}
1045
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001046static struct snd_soc_codec_driver soc_codec_dev_da7210 = {
Kuninori Morimoto4c62ed92010-09-16 13:07:06 +09001047 .probe = da7210_probe,
Mark Browna6f096f2011-10-14 20:18:49 +01001048
1049 .controls = da7210_snd_controls,
1050 .num_controls = ARRAY_SIZE(da7210_snd_controls),
Ashish Chavan6950c602011-10-21 18:16:08 +05301051
1052 .dapm_widgets = da7210_dapm_widgets,
1053 .num_dapm_widgets = ARRAY_SIZE(da7210_dapm_widgets),
1054 .dapm_routes = da7210_audio_map,
1055 .num_dapm_routes = ARRAY_SIZE(da7210_audio_map),
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001056};
1057
Ashish Chavan33593b52012-03-08 19:04:56 +05301058static struct regmap_config da7210_regmap = {
1059 .reg_bits = 8,
1060 .val_bits = 8,
1061
1062 .reg_defaults = da7210_reg_defaults,
1063 .num_reg_defaults = ARRAY_SIZE(da7210_reg_defaults),
1064 .volatile_reg = da7210_volatile_register,
1065 .readable_reg = da7210_readable_register,
1066 .cache_type = REGCACHE_RBTREE,
1067};
1068
Kuninori Morimoto98615452009-12-14 13:21:56 +09001069#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
Mark Brown735fe4c2010-01-12 14:13:00 +00001070static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
1071 const struct i2c_device_id *id)
Kuninori Morimoto98615452009-12-14 13:21:56 +09001072{
1073 struct da7210_priv *da7210;
Kuninori Morimoto98615452009-12-14 13:21:56 +09001074 int ret;
1075
Axel Lin306bf6b2011-12-26 20:54:04 +08001076 da7210 = devm_kzalloc(&i2c->dev, sizeof(struct da7210_priv),
1077 GFP_KERNEL);
Kuninori Morimoto98615452009-12-14 13:21:56 +09001078 if (!da7210)
1079 return -ENOMEM;
1080
Kuninori Morimoto98615452009-12-14 13:21:56 +09001081 i2c_set_clientdata(i2c, da7210);
Ashish Chavan33593b52012-03-08 19:04:56 +05301082
1083 da7210->regmap = regmap_init_i2c(i2c, &da7210_regmap);
1084 if (IS_ERR(da7210->regmap)) {
1085 ret = PTR_ERR(da7210->regmap);
1086 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret);
1087 return ret;
1088 }
Kuninori Morimoto98615452009-12-14 13:21:56 +09001089
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001090 ret = snd_soc_register_codec(&i2c->dev,
1091 &soc_codec_dev_da7210, &da7210_dai, 1);
Ashish Chavan33593b52012-03-08 19:04:56 +05301092 if (ret < 0) {
1093 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
1094 goto err_regmap;
1095 }
1096 return ret;
1097
1098err_regmap:
1099 regmap_exit(da7210->regmap);
1100
Kuninori Morimoto98615452009-12-14 13:21:56 +09001101 return ret;
1102}
1103
Mark Brown735fe4c2010-01-12 14:13:00 +00001104static int __devexit da7210_i2c_remove(struct i2c_client *client)
Kuninori Morimoto98615452009-12-14 13:21:56 +09001105{
Ashish Chavan33593b52012-03-08 19:04:56 +05301106 struct da7210_priv *da7210 = i2c_get_clientdata(client);
1107
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001108 snd_soc_unregister_codec(&client->dev);
Ashish Chavan33593b52012-03-08 19:04:56 +05301109 regmap_exit(da7210->regmap);
Kuninori Morimoto98615452009-12-14 13:21:56 +09001110 return 0;
1111}
1112
1113static const struct i2c_device_id da7210_i2c_id[] = {
1114 { "da7210", 0 },
1115 { }
1116};
1117MODULE_DEVICE_TABLE(i2c, da7210_i2c_id);
1118
1119/* I2C codec control layer */
1120static struct i2c_driver da7210_i2c_driver = {
1121 .driver = {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001122 .name = "da7210-codec",
Kuninori Morimoto98615452009-12-14 13:21:56 +09001123 .owner = THIS_MODULE,
1124 },
Kuninori Morimoto4c62ed92010-09-16 13:07:06 +09001125 .probe = da7210_i2c_probe,
1126 .remove = __devexit_p(da7210_i2c_remove),
1127 .id_table = da7210_i2c_id,
Kuninori Morimoto98615452009-12-14 13:21:56 +09001128};
1129#endif
1130
Kuninori Morimoto98615452009-12-14 13:21:56 +09001131static int __init da7210_modinit(void)
1132{
1133 int ret = 0;
1134#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1135 ret = i2c_add_driver(&da7210_i2c_driver);
1136#endif
1137 return ret;
1138}
1139module_init(da7210_modinit);
1140
1141static void __exit da7210_exit(void)
1142{
1143#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1144 i2c_del_driver(&da7210_i2c_driver);
1145#endif
1146}
1147module_exit(da7210_exit);
1148
1149MODULE_DESCRIPTION("ASoC DA7210 driver");
1150MODULE_AUTHOR("David Chen, Kuninori Morimoto");
1151MODULE_LICENSE("GPL");