2 * es8316.c -- es8316 ALSA SoC audio driver
3 * Copyright Everest Semiconductor Co.,Ltd
5 * Author: David Yang <yangxiaohua@everest-semi.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/module.h>
14 #include <linux/moduleparam.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
18 #include <linux/i2c.h>
19 #include <linux/spi/spi.h>
20 #include <linux/platform_device.h>
21 #include <linux/slab.h>
22 #include <linux/of_gpio.h>
23 #include <sound/core.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
26 #include <sound/tlv.h>
27 #include <sound/soc.h>
28 #include <sound/soc-dapm.h>
29 #include <sound/initval.h>
30 #include <linux/proc_fs.h>
31 #include <linux/gpio.h>
32 #include <linux/interrupt.h>
33 #include <linux/irq.h>
34 #include <linux/regmap.h>
38 #define DBG(x...) printk(x)
40 #define DBG(x...) do { } while (0)
47 #define INVALID_GPIO -1
48 int es8316_spk_con_gpio = INVALID_GPIO;
49 int es8316_hp_con_gpio = INVALID_GPIO;
50 int es8316_hp_det_gpio = INVALID_GPIO;
53 int es8316_init_reg = 0;
57 #ifndef es8316_DEF_VOL
58 #define es8316_DEF_VOL 0x1e
61 struct snd_soc_codec *es8316_codec;
62 static int es8316_init_regs(struct snd_soc_codec *codec);
63 static int es8316_set_bias_level(struct snd_soc_codec *codec,
64 enum snd_soc_bias_level level);
66 static const struct reg_default es8316_reg_defaults[] = {
67 {0x00, 0x03}, {0x01, 0x03}, {0x02, 0x00}, {0x03, 0x20},
68 {0x04, 0x11}, {0x05, 0x00}, {0x06, 0x11}, {0x07, 0x00},
69 {0x08, 0x00}, {0x09, 0x01}, {0x0a, 0x00}, {0x0b, 0x00},
70 {0x0c, 0xf8}, {0x0d, 0x3f}, {0x0e, 0x00}, {0x0f, 0x00},
71 {0x10, 0x01}, {0x11, 0xfc}, {0x12, 0x28}, {0x13, 0x00},
72 {0x14, 0x00}, {0x15, 0x33}, {0x16, 0x00}, {0x17, 0x00},
73 {0x18, 0x88}, {0x19, 0x06}, {0x1a, 0x22}, {0x1b, 0x03},
74 {0x1c, 0x0f}, {0x1d, 0x00}, {0x1e, 0x80}, {0x1f, 0x80},
75 {0x20, 0x00}, {0x21, 0x00}, {0x22, 0xc0}, {0x23, 0x00},
76 {0x24, 0x01}, {0x25, 0x08}, {0x26, 0x10}, {0x27, 0xc0},
77 {0x28, 0x00}, {0x29, 0x1c}, {0x2a, 0x00}, {0x2b, 0xb0},
78 {0x2c, 0x32}, {0x2d, 0x03}, {0x2e, 0x00}, {0x2f, 0x11},
79 {0x30, 0x10}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0xc0},
80 {0x34, 0xc0}, {0x35, 0x1f}, {0x36, 0xf7}, {0x37, 0xfd},
81 {0x38, 0xff}, {0x39, 0x1f}, {0x3a, 0xf7}, {0x3b, 0xfd},
82 {0x3c, 0xff}, {0x3d, 0x1f}, {0x3e, 0xf7}, {0x3f, 0xfd},
83 {0x40, 0xff}, {0x41, 0x1f}, {0x42, 0xf7}, {0x43, 0xfd},
84 {0x44, 0xff}, {0x45, 0x1f}, {0x46, 0xf7}, {0x47, 0xfd},
85 {0x48, 0xff}, {0x49, 0x1f}, {0x4a, 0xf7}, {0x4b, 0xfd},
86 {0x4c, 0xff}, {0x4d, 0x00}, {0x4e, 0x00}, {0x4f, 0xff},
87 {0x50, 0x00}, {0x51, 0x00}, {0x52, 0x00}, {0x53, 0x00},
90 static inline unsigned int es8316_readable(struct device *dev, unsigned int reg)
97 static inline unsigned int es8316_volatile(struct device *dev, unsigned int reg)
104 /* codec private data */
106 struct regmap *regmap;
107 unsigned int dmic_amic;
109 struct snd_pcm_hw_constraint_list *sysclk_constraints;
115 /*#define DECLARE_TLV_DB_SCALE(name, min, step, mute) */
116 /*static const DECLARE_TLV_DB_SCALE(hpout_vol_tlv, -4800, 1200, 0);*/
117 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -9600, 50, 1);
118 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -9600, 50, 1);
119 static const DECLARE_TLV_DB_SCALE(hpmixer_gain_tlv, -1200, 150, 0);
120 static const DECLARE_TLV_DB_SCALE(mic_bst_tlv, 0, 1200, 0);
121 /*static const DECLARE_TLV_DB_SCALE(linin_pga_tlv, 0, 300, 0);*/
122 /* {0, +3, +6, +9, +12, +15, +18, +21, +24,+27,+30,+33} dB */
123 static unsigned int linin_pga_tlv[] = {
124 TLV_DB_RANGE_HEAD(12),
125 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
126 1, 1, TLV_DB_SCALE_ITEM(300, 0, 0),
127 2, 2, TLV_DB_SCALE_ITEM(600, 0, 0),
128 3, 3, TLV_DB_SCALE_ITEM(900, 0, 0),
129 4, 4, TLV_DB_SCALE_ITEM(1200, 0, 0),
130 5, 5, TLV_DB_SCALE_ITEM(1500, 0, 0),
131 6, 6, TLV_DB_SCALE_ITEM(1800, 0, 0),
132 7, 7, TLV_DB_SCALE_ITEM(2100, 0, 0),
133 8, 8, TLV_DB_SCALE_ITEM(2400, 0, 0),
135 static unsigned int hpout_vol_tlv[] = {
136 TLV_DB_RANGE_HEAD(1),
137 0, 3, TLV_DB_SCALE_ITEM(-4800, 1200, 0),
139 static const char *const alc_func_txt[] = {"Off", "On"};
140 static const struct soc_enum alc_func =
141 SOC_ENUM_SINGLE(ES8316_ADC_ALC1_REG29, 6, 2, alc_func_txt);
143 static const char *const ng_type_txt[] = {"Constant PGA Gain",
145 static const struct soc_enum ng_type =
146 SOC_ENUM_SINGLE(ES8316_ADC_ALC6_REG2E, 6, 2, ng_type_txt);
148 static const char *const adcpol_txt[] = {"Normal", "Invert"};
149 static const struct soc_enum adcpol =
150 SOC_ENUM_SINGLE(ES8316_ADC_MUTE_REG26, 1, 2, adcpol_txt);
151 static const char *const dacpol_txt[] = {"Normal", "R Invert", "L Invert",
153 static const struct soc_enum dacpol =
154 SOC_ENUM_SINGLE(ES8316_DAC_SET1_REG30, 0, 4, dacpol_txt);
156 static const struct snd_kcontrol_new es8316_snd_controls[] = {
158 SOC_DOUBLE_TLV("HP Playback Volume", ES8316_CPHP_ICAL_VOL_REG18,
159 4, 0, 0, 1, hpout_vol_tlv),
160 /* HPMIXER VOLUME Control */
161 SOC_DOUBLE_TLV("HPMixer Gain", ES8316_HPMIX_VOL_REG16,
162 0, 4, 7, 0, hpmixer_gain_tlv),
164 /* DAC Digital controls */
165 SOC_DOUBLE_R_TLV("DAC Playback Volume", ES8316_DAC_VOLL_REG33,
166 ES8316_DAC_VOLR_REG34, 0, 0xC0, 1, dac_vol_tlv),
168 SOC_SINGLE("Enable DAC Soft Ramp", ES8316_DAC_SET1_REG30, 4, 1, 1),
169 SOC_SINGLE("DAC Soft Ramp Rate", ES8316_DAC_SET1_REG30, 2, 4, 0),
171 SOC_ENUM("Playback Polarity", dacpol),
172 SOC_SINGLE("DAC Notch Filter", ES8316_DAC_SET2_REG31, 6, 1, 0),
173 SOC_SINGLE("DAC Double Fs Mode", ES8316_DAC_SET2_REG31, 7, 1, 0),
174 SOC_SINGLE("DAC Volume Control-LeR", ES8316_DAC_SET2_REG31, 2, 1, 0),
175 SOC_SINGLE("DAC Stereo Enhancement", ES8316_DAC_SET3_REG32, 0, 7, 0),
177 /* +20dB D2SE PGA Control */
178 SOC_SINGLE_TLV("MIC Boost", ES8316_ADC_D2SEPGA_REG24,
179 0, 1, 0, mic_bst_tlv),
180 /* 0-+24dB Lineinput PGA Control */
181 SOC_SINGLE_TLV("Input PGA", ES8316_ADC_PGAGAIN_REG23,
182 4, 8, 0, linin_pga_tlv),
184 /* ADC Digital Control */
185 SOC_SINGLE_TLV("ADC Capture Volume", ES8316_ADC_VOLUME_REG27,
186 0, 0xC0, 1, adc_vol_tlv),
187 SOC_SINGLE("ADC Soft Ramp", ES8316_ADC_MUTE_REG26, 4, 1, 0),
188 SOC_ENUM("Capture Polarity", adcpol),
189 SOC_SINGLE("ADC Double FS Mode", ES8316_ADC_DMIC_REG25, 4, 1, 0),
190 /* ADC ALC Control */
191 SOC_SINGLE("ALC Capture Target Volume",
192 ES8316_ADC_ALC3_REG2B, 4, 10, 0),
193 SOC_SINGLE("ALC Capture Max PGA", ES8316_ADC_ALC1_REG29, 0, 28, 0),
194 SOC_SINGLE("ALC Capture Min PGA", ES8316_ADC_ALC2_REG2A, 0, 28, 0),
195 SOC_ENUM("ALC Capture Function", alc_func),
196 SOC_SINGLE("ALC Capture Hold Time", ES8316_ADC_ALC3_REG2B, 0, 10, 0),
197 SOC_SINGLE("ALC Capture Decay Time", ES8316_ADC_ALC4_REG2C, 4, 10, 0),
198 SOC_SINGLE("ALC Capture Attack Time", ES8316_ADC_ALC4_REG2C, 0, 10, 0),
199 SOC_SINGLE("ALC Capture NG Threshold", ES8316_ADC_ALC6_REG2E, 0, 31, 0),
200 SOC_ENUM("ALC Capture NG Type", ng_type),
201 SOC_SINGLE("ALC Capture NG Switch", ES8316_ADC_ALC6_REG2E, 5, 1, 0),
204 /* Analog Input MUX */
205 static const char * const es8316_analog_in_txt[] = {
208 "lin1-rin1 with 20db Boost",
209 "lin2-rin2 with 20db Boost"
211 static const unsigned int es8316_analog_in_values[] = {
217 static const struct soc_enum es8316_analog_input_enum =
218 SOC_VALUE_ENUM_SINGLE(ES8316_ADC_PDN_LINSEL_REG22, 4, 3,
219 ARRAY_SIZE(es8316_analog_in_txt),
220 es8316_analog_in_txt,
221 es8316_analog_in_values);
222 static const struct snd_kcontrol_new es8316_analog_in_mux_controls =
223 SOC_DAPM_ENUM("Route", es8316_analog_input_enum);
226 static const char * const es8316_dmic_txt[] = {
228 "dmic data at high level",
229 "dmic data at low level",
231 static const unsigned int es8316_dmic_values[] = {
236 static const struct soc_enum es8316_dmic_src_enum =
237 SOC_VALUE_ENUM_SINGLE(ES8316_ADC_DMIC_REG25, 0, 3,
238 ARRAY_SIZE(es8316_dmic_txt),
241 static const struct snd_kcontrol_new es8316_dmic_src_controls =
242 SOC_DAPM_ENUM("Route", es8316_dmic_src_enum);
245 static const char *const es8316_hpmux_texts[] = {
248 "lin-rin with Boost",
249 "lin-rin with Boost and PGA"
252 static const unsigned int es8316_hpmux_values[] = {0, 1, 2, 3};
254 static const struct soc_enum es8316_left_hpmux_enum =
255 SOC_VALUE_ENUM_SINGLE(ES8316_HPMIX_SEL_REG13, 4, 7,
256 ARRAY_SIZE(es8316_hpmux_texts),
258 es8316_hpmux_values);
259 static const struct snd_kcontrol_new es8316_left_hpmux_controls =
260 SOC_DAPM_VALUE_ENUM("Route", es8316_left_hpmux_enum);
262 static const struct soc_enum es8316_right_hpmux_enum =
263 SOC_VALUE_ENUM_SINGLE(ES8316_HPMIX_SEL_REG13, 0, 7,
264 ARRAY_SIZE(es8316_hpmux_texts),
266 es8316_hpmux_values);
267 static const struct snd_kcontrol_new es8316_right_hpmux_controls =
268 SOC_DAPM_VALUE_ENUM("Route", es8316_right_hpmux_enum);
270 /* headphone Output Mixer */
271 static const struct snd_kcontrol_new es8316_out_left_mix[] = {
272 SOC_DAPM_SINGLE("LLIN Switch", ES8316_HPMIX_SWITCH_REG14,
274 SOC_DAPM_SINGLE("Left DAC Switch", ES8316_HPMIX_SWITCH_REG14,
277 static const struct snd_kcontrol_new es8316_out_right_mix[] = {
278 SOC_DAPM_SINGLE("RLIN Switch", ES8316_HPMIX_SWITCH_REG14,
280 SOC_DAPM_SINGLE("Right DAC Switch", ES8316_HPMIX_SWITCH_REG14,
284 /* DAC data source mux */
285 static const char * const es8316_dacsrc_texts[] = {
286 "LDATA TO LDAC, RDATA TO RDAC",
287 "LDATA TO LDAC, LDATA TO RDAC",
288 "RDATA TO LDAC, RDATA TO RDAC",
289 "RDATA TO LDAC, LDATA TO RDAC",
292 static const unsigned int es8316_dacsrc_values[] = {
295 static const struct soc_enum es8316_dacsrc_mux_enum =
296 SOC_VALUE_ENUM_SINGLE(ES8316_DAC_SET1_REG30, 6, 4,
297 ARRAY_SIZE(es8316_dacsrc_texts),
299 es8316_dacsrc_values);
300 static const struct snd_kcontrol_new es8316_dacsrc_mux_controls =
301 SOC_DAPM_VALUE_ENUM("Route", es8316_dacsrc_mux_enum);
304 static const struct snd_soc_dapm_widget es8316_dapm_widgets[] = {
306 SND_SOC_DAPM_INPUT("DMIC"),
307 SND_SOC_DAPM_INPUT("MIC1"),
308 SND_SOC_DAPM_INPUT("MIC2"),
310 SND_SOC_DAPM_MICBIAS("micbias", SND_SOC_NOPM,
313 SND_SOC_DAPM_MUX("Differential Mux", SND_SOC_NOPM, 0, 0,
314 &es8316_analog_in_mux_controls),
315 SND_SOC_DAPM_PGA("Line input PGA", SND_SOC_NOPM,
319 SND_SOC_DAPM_ADC("Mono ADC", NULL, SND_SOC_NOPM, 0, 0),
322 SND_SOC_DAPM_MUX("Digital Mic Mux", SND_SOC_NOPM, 0, 0,
323 &es8316_dmic_src_controls),
325 /* Digital Interface */
326 SND_SOC_DAPM_AIF_OUT("I2S OUT", "I2S1 Capture", 1,
328 SND_SOC_DAPM_AIF_IN("I2S IN", "I2S1 Playback", 0,
331 /* DACs DATA SRC MUX */
332 SND_SOC_DAPM_MUX("DAC SRC Mux", SND_SOC_NOPM, 0, 0,
333 &es8316_dacsrc_mux_controls),
335 SND_SOC_DAPM_DAC("Right DAC", NULL, SND_SOC_NOPM, 0, 0),
337 /*SND_SOC_DAPM_DAC("Left DAC", NULL, ES8316_DAC_PDN_REG2F, 4, 0),*/
338 SND_SOC_DAPM_DAC("Left DAC", NULL, SND_SOC_NOPM, 0, 0),
340 /* Headphone Output Side */
341 /* hpmux for hp mixer */
342 SND_SOC_DAPM_MUX("Left Hp mux", SND_SOC_NOPM, 0, 0,
343 &es8316_left_hpmux_controls),
344 SND_SOC_DAPM_MUX("Right Hp mux", SND_SOC_NOPM, 0, 0,
345 &es8316_right_hpmux_controls),
347 SND_SOC_DAPM_MIXER("Left Hp mixer", ES8316_HPMIX_PDN_REG15,
348 4, 0, &es8316_out_left_mix[0],
349 ARRAY_SIZE(es8316_out_left_mix)),
350 SND_SOC_DAPM_MIXER("Right Hp mixer", ES8316_HPMIX_PDN_REG15,
351 0, 0, &es8316_out_right_mix[0],
352 ARRAY_SIZE(es8316_out_right_mix)),
355 /* Ouput charge pump */
357 SND_SOC_DAPM_PGA("HPCP L", SND_SOC_NOPM,
359 SND_SOC_DAPM_PGA("HPCP R", SND_SOC_NOPM,
363 SND_SOC_DAPM_PGA("HPVOL L", SND_SOC_NOPM,
365 SND_SOC_DAPM_PGA("HPVOL R", SND_SOC_NOPM,
369 SND_SOC_DAPM_OUTPUT("HPOL"),
370 SND_SOC_DAPM_OUTPUT("HPOR"),
373 static const struct snd_soc_dapm_route es8316_dapm_routes[] = {
377 {"MIC1", NULL, "micbias"},
378 {"MIC2", NULL, "micbias"},
379 {"DMIC", NULL, "micbias"},
381 {"Differential Mux", "lin1-rin1", "MIC1"},
382 {"Differential Mux", "lin2-rin2", "MIC2"},
383 {"Line input PGA", NULL, "Differential Mux"},
385 {"Mono ADC", NULL, "Line input PGA"},
387 {"Digital Mic Mux", "dmic disable", "Mono ADC"},
388 {"Digital Mic Mux", "dmic data at high level", "DMIC"},
389 {"Digital Mic Mux", "dmic data at low level", "DMIC"},
391 {"I2S OUT", NULL, "Digital Mic Mux"},
395 {"DAC SRC Mux", "LDATA TO LDAC, RDATA TO RDAC", "I2S IN"},
396 {"DAC SRC Mux", "LDATA TO LDAC, LDATA TO RDAC", "I2S IN"},
397 {"DAC SRC Mux", "RDATA TO LDAC, RDATA TO RDAC", "I2S IN"},
398 {"DAC SRC Mux", "RDATA TO LDAC, LDATA TO RDAC", "I2S IN"},
400 {"Left DAC", NULL, "DAC SRC Mux"},
401 {"Right DAC", NULL, "DAC SRC Mux"},
403 {"Left Hp mux", "lin1-rin1", "MIC1"},
404 {"Left Hp mux", "lin2-rin2", "MIC2"},
405 {"Left Hp mux", "lin-rin with Boost", "Differential Mux"},
406 {"Left Hp mux", "lin-rin with Boost and PGA", "Line input PGA"},
408 {"Right Hp mux", "lin1-rin1", "MIC1"},
409 {"Right Hp mux", "lin2-rin2", "MIC2"},
410 {"Right Hp mux", "lin-rin with Boost", "Differential Mux"},
411 {"Right Hp mux", "lin-rin with Boost and PGA", "Line input PGA"},
413 {"Left Hp mixer", "LLIN Switch", "Left Hp mux"},
414 {"Left Hp mixer", "Left DAC Switch", "Left DAC"},
416 {"Right Hp mixer", "RLIN Switch", "Right Hp mux"},
417 {"Right Hp mixer", "Right DAC Switch", "Right DAC"},
419 {"HPCP L", NULL, "Left Hp mixer"},
420 {"HPCP R", NULL, "Right Hp mixer"},
422 {"HPVOL L", NULL, "HPCP L"},
423 {"HPVOL R", NULL, "HPCP R"},
425 {"HPOL", NULL, "HPVOL L"},
426 {"HPOR", NULL, "HPVOL R"},
430 u32 mclk; /*mclk frequency*/
431 u32 rate; /*sample rate*/
432 u8 div; /*adcclk and dacclk divider*/
433 u8 lrck_h; /*adclrck divider and daclrck divider*/
435 u8 sr; /*sclk divider*/
440 /* codec hifi mclk clock divider coefficients */
441 static const struct _coeff_div coeff_div[] = {
443 {12288000, 8000 , 6 , 0x06, 0x00, 21, 32},
444 {11289600, 8000 , 6 , 0x05, 0x83, 20, 29},
445 {18432000, 8000 , 9 , 0x09, 0x00, 27, 32},
446 {16934400, 8000 , 8 , 0x08, 0x44, 25, 33},
447 {12000000, 8000 , 7 , 0x05, 0xdc, 21, 25},
448 {19200000, 8000 , 12, 0x09, 0x60, 27, 25},
451 {11289600, 11025, 4 , 0x04, 0x00, 16, 32},
452 {16934400, 11025, 6 , 0x06, 0x00, 21, 32},
453 {12000000, 11025, 4 , 0x04, 0x40, 17, 34},
456 {12288000, 16000, 3 , 0x03, 0x00, 12, 32},
457 {18432000, 16000, 5 , 0x04, 0x80, 18, 25},
458 {12000000, 16000, 3 , 0x02, 0xee, 12, 31},
459 {19200000, 16000, 6 , 0x04, 0xb0, 18, 25},
462 {11289600, 22050, 2 , 0x02, 0x00, 8 , 32},
463 {16934400, 22050, 3 , 0x03, 0x00, 12, 32},
464 {12000000, 22050, 2 , 0x02, 0x20, 8 , 34},
467 {12288000, 32000, 1 , 0x01, 0x80, 6 , 48},
468 {18432000, 32000, 2 , 0x02, 0x40, 9 , 32},
469 {12000000, 32000, 1 , 0x01, 0x77, 6 , 31},
470 {19200000, 32000, 3 , 0x02, 0x58, 10, 25},
473 {11289600, 44100, 1 , 0x01, 0x00, 4 , 32},
474 {16934400, 44100, 1 , 0x01, 0x80, 6 , 32},
475 {12000000, 44100, 1 , 0x01, 0x10, 4 , 34},
478 {12288000, 48000, 1 , 0x01, 0x00, 4 , 32},
479 {18432000, 48000, 1 , 0x01, 0x80, 6 , 32},
480 {12000000, 48000, 1 , 0x00, 0xfa, 4 , 31},
481 {19200000, 48000, 2 , 0x01, 0x90, 6, 25},
484 {11289600, 88200, 1 , 0x00, 0x80, 2 , 32},
485 {16934400, 88200, 1 , 0x00, 0xc0, 3 , 48},
486 {12000000, 88200, 1 , 0x00, 0x88, 2 , 34},
489 {12288000, 96000, 1 , 0x00, 0x80, 2 , 32},
490 {18432000, 96000, 1 , 0x00, 0xc0, 3 , 48},
491 {12000000, 96000, 1 , 0x00, 0x7d, 1 , 31},
492 {19200000, 96000, 1 , 0x00, 0xc8, 3 , 25},
494 static inline int get_coeff(int mclk, int rate)
498 for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
499 if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
506 /* The set of rates we can generate from the above for each SYSCLK */
508 static unsigned int rates_12288[] = {
509 8000, 12000, 16000, 24000, 24000, 32000, 48000, 96000,
512 static struct snd_pcm_hw_constraint_list constraints_12288 = {
513 .count = ARRAY_SIZE(rates_12288),
517 static unsigned int rates_112896[] = {
518 8000, 11025, 22050, 44100,
521 static struct snd_pcm_hw_constraint_list constraints_112896 = {
522 .count = ARRAY_SIZE(rates_112896),
523 .list = rates_112896,
526 static unsigned int rates_12[] = {
527 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
531 static struct snd_pcm_hw_constraint_list constraints_12 = {
532 .count = ARRAY_SIZE(rates_12),
537 * Note that this should be called from init rather than from hw_params.
539 static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai,
540 int clk_id, unsigned int freq, int dir)
542 struct snd_soc_codec *codec = codec_dai->codec;
543 struct es8316_priv *es8316 = snd_soc_codec_get_drvdata(codec);
550 es8316->sysclk_constraints = &constraints_112896;
551 es8316->sysclk = freq;
558 es8316->sysclk_constraints = &constraints_12288;
559 es8316->sysclk = freq;
563 es8316->sysclk_constraints = &constraints_12;
564 es8316->sysclk = freq;
570 static int es8316_set_dai_fmt(struct snd_soc_dai *codec_dai,
573 struct snd_soc_codec *codec = codec_dai->codec;
578 alsa_dbg("%s----%d, fmt[%02x]\n", __func__, __LINE__, fmt);
580 iface = snd_soc_read(codec, ES8316_IFACE);
581 adciface = snd_soc_read(codec, ES8316_ADC_IFACE);
582 daciface = snd_soc_read(codec, ES8316_DAC_IFACE);
584 /* set master/slave audio interface */
585 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
586 case SND_SOC_DAIFMT_CBM_CFM:
587 alsa_dbg("es8316 in master mode");
590 case SND_SOC_DAIFMT_CBS_CFS:
591 alsa_dbg("es8316 in slave mode");
599 /* interface format */
601 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
602 case SND_SOC_DAIFMT_I2S:
606 case SND_SOC_DAIFMT_RIGHT_J:
608 case SND_SOC_DAIFMT_LEFT_J:
614 case SND_SOC_DAIFMT_DSP_A:
620 case SND_SOC_DAIFMT_DSP_B:
631 /* clock inversion */
632 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
633 case SND_SOC_DAIFMT_NB_NF:
638 case SND_SOC_DAIFMT_IB_IF:
643 case SND_SOC_DAIFMT_IB_NF:
648 case SND_SOC_DAIFMT_NB_IF:
656 snd_soc_write(codec, ES8316_IFACE, iface);
657 snd_soc_write(codec, ES8316_ADC_IFACE, adciface);
658 snd_soc_write(codec, ES8316_DAC_IFACE, daciface);
662 static int es8316_pcm_startup(struct snd_pcm_substream *substream,
663 struct snd_soc_dai *dai)
665 struct snd_soc_codec *codec = dai->codec;
666 struct es8316_priv *es8316 = snd_soc_codec_get_drvdata(codec);
668 DBG("Enter::%s----%d es8316->sysclk=%d\n",
669 __func__, __LINE__, es8316->sysclk);
671 /* The set of sample rates that can be supported depends on the
672 * MCLK supplied to the CODEC - enforce this.
674 if (!es8316->sysclk) {
676 "No MCLK configured, call set_sysclk() on init\n");
680 snd_pcm_hw_constraint_list(substream->runtime, 0,
681 SNDRV_PCM_HW_PARAM_RATE,
682 es8316->sysclk_constraints);
686 static int es8316_pcm_hw_params(struct snd_pcm_substream *substream,
687 struct snd_pcm_hw_params *params,
688 struct snd_soc_dai *dai)
690 struct snd_soc_pcm_runtime *rtd = substream->private_data;
691 struct snd_soc_codec *codec = rtd->codec;
692 struct es8316_priv *es8316 = snd_soc_codec_get_drvdata(codec);
695 u16 osrate = snd_soc_read(codec,
696 ES8316_CLKMGR_ADCOSR_REG03) & 0xc0;
697 u16 mclkdiv = snd_soc_read(codec,
698 ES8316_CLKMGR_CLKSW_REG01) & 0x7f;
699 u16 srate = snd_soc_read(codec,
700 ES8316_SDP_MS_BCKDIV_REG09) & 0xE0;
701 u16 adciface = snd_soc_read(codec,
702 ES8316_SDP_ADCFMT_REG0A) & 0xE3;
703 u16 daciface = snd_soc_read(codec,
704 ES8316_SDP_DACFMT_REG0B) & 0xE3;
705 u16 adcdiv = snd_soc_read(codec,
706 ES8316_CLKMGR_ADCDIV1_REG04);
707 u16 adclrckdiv_l = snd_soc_read(codec,
708 ES8316_CLKMGR_ADCDIV2_REG05) & 0x00;
709 u16 dacdiv = snd_soc_read(codec, ES8316_CLKMGR_DACDIV1_REG06);
710 u16 daclrckdiv_l = snd_soc_read(codec,
711 ES8316_CLKMGR_DACDIV2_REG07) & 0x00;
713 u16 adclrckdiv_h = adcdiv & 0xf0;
714 u16 daclrckdiv_h = dacdiv & 0xf0;
720 coeff = get_coeff(es8316->sysclk, params_rate(params));
722 coeff = get_coeff(es8316->sysclk / 2, params_rate(params));
727 "Unable to configure sample rate %dHz with %dHz MCLK\n",
728 params_rate(params), es8316->sysclk);
733 switch (params_format(params)) {
734 case SNDRV_PCM_FORMAT_S16_LE:
738 case SNDRV_PCM_FORMAT_S20_3LE:
742 case SNDRV_PCM_FORMAT_S24_LE:
744 case SNDRV_PCM_FORMAT_S32_LE:
750 /* set iface & srate*/
751 snd_soc_update_bits(codec, ES8316_SDP_DACFMT_REG0B, 0xe3, daciface);
752 snd_soc_update_bits(codec, ES8316_SDP_ADCFMT_REG0A, 0xe3, adciface);
753 snd_soc_update_bits(codec, ES8316_CLKMGR_CLKSW_REG01, 0x80, mclkdiv);
755 osrate = coeff_div[coeff].osr;
758 srate |= coeff_div[coeff].sr;
761 adcdiv |= (coeff_div[coeff].div << 4);
762 adclrckdiv_h |= coeff_div[coeff].lrck_h;
764 adclrckdiv_h &= 0x0f;
765 adcdiv |= adclrckdiv_h;
766 adclrckdiv_l = coeff_div[coeff].lrck_l;
768 dacdiv |= (coeff_div[coeff].div << 4);
769 daclrckdiv_h |= coeff_div[coeff].lrck_h;
771 daclrckdiv_h &= 0x0f;
772 dacdiv |= daclrckdiv_h;
773 daclrckdiv_l = coeff_div[coeff].lrck_l;
775 retv = snd_soc_read(codec, ES8316_CLKMGR_ADCDIV2_REG05);
777 es8316_init_regs(codec);
778 if (es8316->dmic_amic == dmic_used)
779 snd_soc_write(codec, ES8316_GPIO_SEL_REG4D,
782 snd_soc_write(codec, ES8316_GPIO_SEL_REG4D,
784 snd_soc_write(codec, ES8316_GPIO_DEBUNCE_INT_REG4E,
786 es8316_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
791 retv = snd_soc_read(codec, ES8316_GPIO_FLAG);
795 static int es8316_mute(struct snd_soc_dai *dai, int mute)
797 struct snd_soc_codec *codec = dai->codec;
799 dev_dbg(codec->dev, "%s %d\n", __func__, mute);
801 snd_soc_write(codec, ES8316_DAC_SET1_REG30, 0x20);
802 else if (dai->playback_active)
803 snd_soc_write(codec, ES8316_DAC_SET1_REG30, 0x00);
807 static int es8316_set_bias_level(struct snd_soc_codec *codec,
808 enum snd_soc_bias_level level)
812 case SND_SOC_BIAS_ON:
813 dev_dbg(codec->dev, "%s on\n", __func__);
815 case SND_SOC_BIAS_PREPARE:
816 dev_dbg(codec->dev, "%s prepare\n", __func__);
817 if (es8316_init_reg > 0) {
818 snd_soc_write(codec, ES8316_CLKMGR_CLKSW_REG01, 0x7F);
819 snd_soc_write(codec, ES8316_SYS_PDN_REG0D, 0x00);
820 snd_soc_write(codec, ES8316_ADC_PDN_LINSEL_REG22, 0x00);
821 snd_soc_write(codec, ES8316_DAC_PDN_REG2F, 0x00);
822 snd_soc_write(codec, ES8316_HPMIX_SWITCH_REG14, 0x88);
823 snd_soc_write(codec, ES8316_HPMIX_PDN_REG15, 0x88);
824 snd_soc_write(codec, ES8316_HPMIX_VOL_REG16, 0xBB);
825 snd_soc_write(codec, ES8316_CPHP_PDN2_REG1A, 0x10);
826 snd_soc_write(codec, ES8316_CPHP_LDOCTL_REG1B, 0x30);
827 snd_soc_write(codec, ES8316_CPHP_PDN1_REG19, 0x02);
828 snd_soc_write(codec, ES8316_CPHP_ICAL_VOL_REG18, 0x00);
829 snd_soc_write(codec, ES8316_RESET_REG00, 0xC0);
830 snd_soc_write(codec, ES8316_CPHP_OUTEN_REG17, 0x66);
833 case SND_SOC_BIAS_STANDBY:
834 dev_dbg(codec->dev, "%s standby\n", __func__);
835 if (es8316_init_reg > 0) {
837 ES8316_CLKMGR_CLKSW_REG01, 0x7F);
838 snd_soc_write(codec, ES8316_SYS_PDN_REG0D, 0x00);
840 ES8316_ADC_PDN_LINSEL_REG22, 0x00);
841 snd_soc_write(codec, ES8316_DAC_PDN_REG2F, 0x00);
843 ES8316_HPMIX_SWITCH_REG14, 0x88);
845 ES8316_HPMIX_PDN_REG15, 0x88);
847 ES8316_HPMIX_VOL_REG16, 0xBB);
848 snd_soc_write(codec, ES8316_CPHP_PDN2_REG1A, 0x10);
849 snd_soc_write(codec, ES8316_CPHP_LDOCTL_REG1B, 0x30);
850 snd_soc_write(codec, ES8316_CPHP_PDN1_REG19, 0x02);
851 snd_soc_write(codec, ES8316_CPHP_ICAL_VOL_REG18, 0x00);
852 snd_soc_write(codec, ES8316_RESET_REG00, 0xC0);
853 snd_soc_write(codec, ES8316_CPHP_OUTEN_REG17, 0x66);
856 case SND_SOC_BIAS_OFF:
857 dev_dbg(codec->dev, "%s off\n", __func__);
858 snd_soc_write(codec, ES8316_CPHP_ICAL_VOL_REG18, 0x33);
859 snd_soc_write(codec, ES8316_CPHP_OUTEN_REG17, 0x00);
860 snd_soc_write(codec, ES8316_CPHP_LDOCTL_REG1B, 0x03);
861 snd_soc_write(codec, ES8316_CPHP_PDN2_REG1A, 0x22);
862 snd_soc_write(codec, ES8316_CPHP_PDN1_REG19, 0x06);
863 snd_soc_write(codec, ES8316_HPMIX_SWITCH_REG14, 0x00);
864 snd_soc_write(codec, ES8316_HPMIX_PDN_REG15, 0x33);
865 snd_soc_write(codec, ES8316_HPMIX_VOL_REG16, 0x00);
866 snd_soc_write(codec, ES8316_ADC_PDN_LINSEL_REG22, 0xC0);
867 snd_soc_write(codec, ES8316_DAC_PDN_REG2F, 0x11);
868 snd_soc_write(codec, ES8316_SYS_PDN_REG0D, 0x3F);
869 snd_soc_write(codec, ES8316_CLKMGR_CLKSW_REG01, 0x03);
870 snd_soc_write(codec, ES8316_RESET_REG00, 0x7F);
873 codec->dapm.bias_level = level;
878 #define es8316_RATES SNDRV_PCM_RATE_8000_96000
880 #define es8316_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
881 SNDRV_PCM_FMTBIT_S24_LE)
883 static struct snd_soc_dai_ops es8316_ops = {
884 .startup = es8316_pcm_startup,
885 .hw_params = es8316_pcm_hw_params,
886 .set_fmt = es8316_set_dai_fmt,
887 .set_sysclk = es8316_set_dai_sysclk,
888 .digital_mute = es8316_mute,
891 static struct snd_soc_dai_driver es8316_dai = {
892 .name = "ES8316 HiFi",
894 .stream_name = "Playback",
897 .rates = es8316_RATES,
898 .formats = es8316_FORMATS,
901 .stream_name = "Capture",
904 .rates = es8316_RATES,
905 .formats = es8316_FORMATS,
908 .symmetric_rates = 1,
912 static int es8316_init_regs(struct snd_soc_codec *codec)
914 dev_dbg(codec->dev, "%s\n", __func__);
915 snd_soc_write(codec, ES8316_ADC_VOLUME_REG27, 0x00);
916 snd_soc_write(codec, ES8316_DAC_SET2_REG31, 0x00);
917 snd_soc_write(codec, ES8316_DAC_VOLL_REG33, 0x00);
918 snd_soc_write(codec, ES8316_DAC_VOLR_REG34, 0x00);
919 snd_soc_write(codec, ES8316_SDP_ADCFMT_REG0A, 0x0C);
920 snd_soc_write(codec, ES8316_SDP_DACFMT_REG0B, 0x0C);
921 snd_soc_write(codec, ES8316_CLKMGR_CLKSEL_REG02, 0x09);
922 snd_soc_write(codec, 0x03, 0x19);
923 snd_soc_write(codec, 0x04, 0x21);
924 snd_soc_write(codec, 0x05, 0x90);
925 snd_soc_write(codec, 0x06, 0x21);
926 snd_soc_write(codec, 0x07, 0x90);
927 snd_soc_write(codec, 0x09, 0x06);
928 snd_soc_write(codec, ES8316_CLKMGR_CPDIV_REG08, 0x00);
929 snd_soc_write(codec, ES8316_CLKMGR_CLKSW_REG01, 0x7F);
930 snd_soc_write(codec, ES8316_SYS_VMIDSEL_REG0C, 0xFa);
931 snd_soc_write(codec, ES8316_SYS_PDN_REG0D, 0x00);
932 snd_soc_write(codec, ES8316_RESET_REG00, 0xC0);
934 snd_soc_write(codec, ES8316_ADC_PDN_LINSEL_REG22, 0x20);
935 snd_soc_write(codec, ES8316_DAC_PDN_REG2F, 0x00);
936 snd_soc_write(codec, ES8316_HPMIX_SEL_REG13, 0x00);
937 snd_soc_write(codec, ES8316_HPMIX_SWITCH_REG14, 0x88);
938 snd_soc_write(codec, ES8316_HPMIX_PDN_REG15, 0x00);
939 snd_soc_write(codec, ES8316_HPMIX_VOL_REG16, 0xBB);
940 snd_soc_write(codec, ES8316_CPHP_PDN2_REG1A, 0x10);
941 snd_soc_write(codec, ES8316_CPHP_LDOCTL_REG1B, 0x00);
942 snd_soc_write(codec, ES8316_CPHP_PDN1_REG19, 0x03);
943 snd_soc_write(codec, ES8316_CPHP_ICAL_VOL_REG18, 0x00);
944 snd_soc_write(codec, ES8316_SYS_VMIDLOW_REG10, 0x09);
946 snd_soc_write(codec, ES8316_CPHP_OUTEN_REG17, 0x66);
948 snd_soc_write(codec, ES8316_GPIO_DEBUNCE_INT_REG4E, 0xf3);
949 snd_soc_write(codec, ES8316_TESTMODE_REG50, 0xA0);
950 snd_soc_write(codec, ES8316_TEST2_REG52, 0x03);
952 snd_soc_write(codec, ES8316_ADC_PGAGAIN_REG23, 0x60);
953 snd_soc_write(codec, ES8316_ADC_D2SEPGA_REG24, 0x01);
954 /*adc ds mode, HPF enable*/
955 snd_soc_write(codec, ES8316_ADC_DMIC_REG25, 0x08);
956 snd_soc_write(codec, ES8316_ADC_ALC1_REG29, 0xcd);
957 snd_soc_write(codec, ES8316_ADC_ALC2_REG2A, 0x08);
958 snd_soc_write(codec, ES8316_ADC_ALC3_REG2B, 0xa0);
959 snd_soc_write(codec, ES8316_ADC_ALC4_REG2C, 0x05);
960 snd_soc_write(codec, ES8316_ADC_ALC5_REG2D, 0x06);
961 snd_soc_write(codec, ES8316_ADC_ALC6_REG2E, 0x61);
965 static int es8316_suspend(struct snd_soc_codec *codec)
967 snd_soc_write(codec, ES8316_CPHP_ICAL_VOL_REG18, 0x33);
968 snd_soc_write(codec, ES8316_CPHP_OUTEN_REG17, 0x00);
969 snd_soc_write(codec, ES8316_CPHP_LDOCTL_REG1B, 0x03);
970 snd_soc_write(codec, ES8316_CPHP_PDN2_REG1A, 0x22);
971 snd_soc_write(codec, ES8316_CPHP_PDN1_REG19, 0x06);
972 snd_soc_write(codec, ES8316_HPMIX_SWITCH_REG14, 0x00);
973 snd_soc_write(codec, ES8316_HPMIX_PDN_REG15, 0x33);
974 snd_soc_write(codec, ES8316_HPMIX_VOL_REG16, 0x00);
975 snd_soc_write(codec, ES8316_ADC_PDN_LINSEL_REG22, 0xC0);
976 snd_soc_write(codec, ES8316_CLKMGR_CLKSW_REG01, 0x03);
980 static int es8316_resume(struct snd_soc_codec *codec)
982 snd_soc_write(codec, ES8316_CPHP_ICAL_VOL_REG18, 0x00);
983 snd_soc_write(codec, ES8316_CPHP_LDOCTL_REG1B, 0x30);
984 snd_soc_write(codec, ES8316_CPHP_PDN2_REG1A, 0x10);
985 snd_soc_write(codec, ES8316_CPHP_PDN1_REG19, 0x02);
986 snd_soc_write(codec, ES8316_HPMIX_SWITCH_REG14, 0x88);
987 snd_soc_write(codec, ES8316_HPMIX_PDN_REG15, 0x88);
988 snd_soc_write(codec, ES8316_HPMIX_VOL_REG16, 0xbb);
989 snd_soc_write(codec, ES8316_ADC_PDN_LINSEL_REG22, 0x20);
990 snd_soc_write(codec, ES8316_CLKMGR_CLKSW_REG01, 0x7f);
991 snd_soc_write(codec, ES8316_CPHP_OUTEN_REG17, 0x66);
995 static int es8316_probe(struct snd_soc_codec *codec)
998 struct es8316_priv *es8316 = snd_soc_codec_get_drvdata(codec);
1000 DBG("---%s--start--\n", __func__);
1002 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
1005 dev_err(codec->dev, "fail to reset audio (%d)\n", ret);
1008 retv = snd_soc_read(codec, ES8316_CLKMGR_ADCDIV2_REG05);
1010 snd_soc_write(codec, ES8316_GPIO_DEBUNCE_INT_REG4E, 0xf0);
1011 snd_soc_write(codec, 0x01, 0x7f);
1012 snd_soc_write(codec, 0x00, 0xc3);
1014 if (es8316->dmic_amic == dmic_used)
1015 snd_soc_write(codec, ES8316_GPIO_SEL_REG4D, 0x02);
1017 snd_soc_write(codec, ES8316_GPIO_SEL_REG4D, 0x00);
1018 snd_soc_write(codec, ES8316_GPIO_DEBUNCE_INT_REG4E, 0xf3);
1020 codec->dapm.idle_bias_off = 0;
1023 #elif defined(HS_TIMER)
1030 static int es8316_remove(struct snd_soc_codec *codec)
1032 es8316_set_bias_level(codec, SND_SOC_BIAS_OFF);
1036 static struct snd_soc_codec_driver soc_codec_dev_es8316 = {
1037 .probe = es8316_probe,
1038 .remove = es8316_remove,
1039 .suspend = es8316_suspend,
1040 .resume = es8316_resume,
1041 .set_bias_level = es8316_set_bias_level,
1042 .reg_cache_size = ARRAY_SIZE(es8316_reg_defaults),
1043 .reg_word_size = sizeof(u8),
1044 .reg_cache_default = es8316_reg_defaults,
1046 .controls = es8316_snd_controls,
1047 .num_controls = ARRAY_SIZE(es8316_snd_controls),
1048 .dapm_widgets = es8316_dapm_widgets,
1049 .num_dapm_widgets = ARRAY_SIZE(es8316_dapm_widgets),
1050 .dapm_routes = es8316_dapm_routes,
1051 .num_dapm_routes = ARRAY_SIZE(es8316_dapm_routes),
1054 #if defined(CONFIG_SPI_MASTER)
1055 static int es8316_spi_probe(struct spi_device *spi)
1057 struct es8316_priv *es8316;
1060 es8316 = kzalloc(sizeof(*es8316), GFP_KERNEL);
1064 spi_set_drvdata(spi, es8316);
1065 ret = snd_soc_register_codec(&spi->dev,
1066 &soc_codec_dev_es8316,
1073 static int es8316_spi_remove(struct spi_device *spi)
1075 snd_soc_unregister_codec(&spi->dev);
1076 kfree(spi_get_drvdata(spi));
1080 static struct spi_driver es8316_spi_driver = {
1083 .owner = THIS_MODULE,
1085 .probe = es8316_spi_probe,
1086 .remove = es8316_spi_remove,
1088 #endif /* CONFIG_SPI_MASTER */
1090 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1092 static void es8316_i2c_shutdown(struct i2c_client *i2c)
1094 struct snd_soc_codec *codec;
1098 codec = es8316_codec;
1099 snd_soc_write(codec, ES8316_CPHP_ICAL_VOL_REG18, 0x33);
1100 snd_soc_write(codec, ES8316_CPHP_OUTEN_REG17, 0x00);
1101 snd_soc_write(codec, ES8316_CPHP_LDOCTL_REG1B, 0x03);
1102 snd_soc_write(codec, ES8316_CPHP_PDN2_REG1A, 0x22);
1103 snd_soc_write(codec, ES8316_CPHP_PDN1_REG19, 0x06);
1104 snd_soc_write(codec, ES8316_HPMIX_SWITCH_REG14, 0x00);
1105 snd_soc_write(codec, ES8316_HPMIX_PDN_REG15, 0x33);
1106 snd_soc_write(codec, ES8316_HPMIX_VOL_REG16, 0x00);
1107 snd_soc_write(codec, ES8316_ADC_PDN_LINSEL_REG22, 0xC0);
1108 snd_soc_write(codec, ES8316_DAC_PDN_REG2F, 0x11);
1109 snd_soc_write(codec, ES8316_SYS_PDN_REG0D, 0x3F);
1110 snd_soc_write(codec, ES8316_CLKMGR_CLKSW_REG01, 0x03);
1111 snd_soc_write(codec, ES8316_RESET_REG00, 0x7F);
1116 static int es8316_i2c_probe(struct i2c_client *i2c_client,
1117 const struct i2c_device_id *id)
1119 struct es8316_priv *es8316;
1122 DBG("---%s---probe start\n", __func__);
1124 es8316 = kzalloc(sizeof(*es8316), GFP_KERNEL);
1127 es8316->dmic_amic = amic_used; /*if internal mic is amic*/
1128 i2c_set_clientdata(i2c_client, es8316);
1129 ret = snd_soc_register_codec(&i2c_client->dev,
1130 &soc_codec_dev_es8316,
1140 static int es8316_i2c_remove(struct i2c_client *client)
1142 snd_soc_unregister_codec(&client->dev);
1143 kfree(i2c_get_clientdata(client));
1147 static const unsigned short normal_i2c[] = {0x10, I2C_CLIENT_END};
1148 static const struct i2c_device_id es8316_i2c_id[] = {
1154 MODULE_DEVICE_TABLE(i2c, es8316_i2c_id);
1156 static struct i2c_driver es8316_i2c_driver = {
1159 .owner = THIS_MODULE,
1161 .shutdown = es8316_i2c_shutdown,
1162 .probe = es8316_i2c_probe,
1163 .remove = es8316_i2c_remove,
1164 .id_table = es8316_i2c_id,
1165 .class = I2C_CLASS_HWMON,
1166 .address_list = normal_i2c,
1170 static int __init es8316_init(void)
1172 DBG("--%s--start--\n", __func__);
1173 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1174 return i2c_add_driver(&es8316_i2c_driver);
1176 #if defined(CONFIG_SPI_MASTER)
1177 return spi_register_driver(&es8316_spi_driver);
1181 static void __exit es8316_exit(void)
1183 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1184 return i2c_del_driver(&es8316_i2c_driver);
1186 #if defined(CONFIG_SPI_MASTER)
1187 return spi_unregister_driver(&es8316_spi_driver);
1192 module_init(es8316_init);
1193 module_exit(es8316_exit);
1195 MODULE_DESCRIPTION("ASoC es8316 driver");
1196 MODULE_AUTHOR("Will <will@everset-semi.com>");
1197 MODULE_LICENSE("GPL");