17 #include <linux/i2c.h>
19 #include <linux/slab.h>
20 #include <linux/module.h>
31 #define DA9055_STATUS1 0x02
32 #define DA9055_PLL_STATUS 0x03
33 #define DA9055_AUX_L_GAIN_STATUS 0x04
34 #define DA9055_AUX_R_GAIN_STATUS 0x05
35 #define DA9055_MIC_L_GAIN_STATUS 0x06
36 #define DA9055_MIC_R_GAIN_STATUS 0x07
37 #define DA9055_MIXIN_L_GAIN_STATUS 0x08
38 #define DA9055_MIXIN_R_GAIN_STATUS 0x09
39 #define DA9055_ADC_L_GAIN_STATUS 0x0A
40 #define DA9055_ADC_R_GAIN_STATUS 0x0B
41 #define DA9055_DAC_L_GAIN_STATUS 0x0C
42 #define DA9055_DAC_R_GAIN_STATUS 0x0D
43 #define DA9055_HP_L_GAIN_STATUS 0x0E
44 #define DA9055_HP_R_GAIN_STATUS 0x0F
45 #define DA9055_LINE_GAIN_STATUS 0x10
48 #define DA9055_CIF_CTRL 0x20
49 #define DA9055_DIG_ROUTING_AIF 0X21
50 #define DA9055_SR 0x22
51 #define DA9055_REFERENCES 0x23
52 #define DA9055_PLL_FRAC_TOP 0x24
53 #define DA9055_PLL_FRAC_BOT 0x25
54 #define DA9055_PLL_INTEGER 0x26
55 #define DA9055_PLL_CTRL 0x27
56 #define DA9055_AIF_CLK_MODE 0x28
57 #define DA9055_AIF_CTRL 0x29
58 #define DA9055_DIG_ROUTING_DAC 0x2A
59 #define DA9055_ALC_CTRL1 0x2B
62 #define DA9055_AUX_L_GAIN 0x30
63 #define DA9055_AUX_R_GAIN 0x31
64 #define DA9055_MIXIN_L_SELECT 0x32
65 #define DA9055_MIXIN_R_SELECT 0x33
66 #define DA9055_MIXIN_L_GAIN 0x34
67 #define DA9055_MIXIN_R_GAIN 0x35
68 #define DA9055_ADC_L_GAIN 0x36
69 #define DA9055_ADC_R_GAIN 0x37
70 #define DA9055_ADC_FILTERS1 0x38
71 #define DA9055_MIC_L_GAIN 0x39
72 #define DA9055_MIC_R_GAIN 0x3A
75 #define DA9055_DAC_FILTERS5 0x40
76 #define DA9055_DAC_FILTERS2 0x41
77 #define DA9055_DAC_FILTERS3 0x42
78 #define DA9055_DAC_FILTERS4 0x43
79 #define DA9055_DAC_FILTERS1 0x44
80 #define DA9055_DAC_L_GAIN 0x45
81 #define DA9055_DAC_R_GAIN 0x46
82 #define DA9055_CP_CTRL 0x47
83 #define DA9055_HP_L_GAIN 0x48
84 #define DA9055_HP_R_GAIN 0x49
85 #define DA9055_LINE_GAIN 0x4A
86 #define DA9055_MIXOUT_L_SELECT 0x4B
87 #define DA9055_MIXOUT_R_SELECT 0x4C
90 #define DA9055_SYSTEM_MODES_INPUT 0x50
91 #define DA9055_SYSTEM_MODES_OUTPUT 0x51
94 #define DA9055_AUX_L_CTRL 0x60
95 #define DA9055_AUX_R_CTRL 0x61
96 #define DA9055_MIC_BIAS_CTRL 0x62
97 #define DA9055_MIC_L_CTRL 0x63
98 #define DA9055_MIC_R_CTRL 0x64
99 #define DA9055_MIXIN_L_CTRL 0x65
100 #define DA9055_MIXIN_R_CTRL 0x66
101 #define DA9055_ADC_L_CTRL 0x67
102 #define DA9055_ADC_R_CTRL 0x68
103 #define DA9055_DAC_L_CTRL 0x69
104 #define DA9055_DAC_R_CTRL 0x6A
105 #define DA9055_HP_L_CTRL 0x6B
106 #define DA9055_HP_R_CTRL 0x6C
107 #define DA9055_LINE_CTRL 0x6D
108 #define DA9055_MIXOUT_L_CTRL 0x6E
109 #define DA9055_MIXOUT_R_CTRL 0x6F
112 #define DA9055_LDO_CTRL 0x90
113 #define DA9055_IO_CTRL 0x91
114 #define DA9055_GAIN_RAMP_CTRL 0x92
115 #define DA9055_MIC_CONFIG 0x93
116 #define DA9055_PC_COUNT 0x94
117 #define DA9055_CP_VOL_THRESHOLD1 0x95
118 #define DA9055_CP_DELAY 0x96
119 #define DA9055_CP_DETECTOR 0x97
120 #define DA9055_AIF_OFFSET 0x98
121 #define DA9055_DIG_CTRL 0x99
122 #define DA9055_ALC_CTRL2 0x9A
123 #define DA9055_ALC_CTRL3 0x9B
124 #define DA9055_ALC_NOISE 0x9C
125 #define DA9055_ALC_TARGET_MIN 0x9D
126 #define DA9055_ALC_TARGET_MAX 0x9E
127 #define DA9055_ALC_GAIN_LIMITS 0x9F
128 #define DA9055_ALC_ANA_GAIN_LIMITS 0xA0
129 #define DA9055_ALC_ANTICLIP_CTRL 0xA1
130 #define DA9055_ALC_ANTICLIP_LEVEL 0xA2
131 #define DA9055_ALC_OFFSET_OP2M_L 0xA6
132 #define DA9055_ALC_OFFSET_OP2U_L 0xA7
133 #define DA9055_ALC_OFFSET_OP2M_R 0xAB
134 #define DA9055_ALC_OFFSET_OP2U_R 0xAC
135 #define DA9055_ALC_CIC_OP_LVL_CTRL 0xAD
136 #define DA9055_ALC_CIC_OP_LVL_DATA 0xAE
137 #define DA9055_DAC_NG_SETUP_TIME 0xAF
138 #define DA9055_DAC_NG_OFF_THRESHOLD 0xB0
139 #define DA9055_DAC_NG_ON_THRESHOLD 0xB1
140 #define DA9055_DAC_NG_CTRL 0xB2
143 #define DA9055_SR_8000 (0x1 << 0)
144 #define DA9055_SR_11025 (0x2 << 0)
145 #define DA9055_SR_12000 (0x3 << 0)
146 #define DA9055_SR_16000 (0x5 << 0)
147 #define DA9055_SR_22050 (0x6 << 0)
148 #define DA9055_SR_24000 (0x7 << 0)
149 #define DA9055_SR_32000 (0x9 << 0)
150 #define DA9055_SR_44100 (0xA << 0)
151 #define DA9055_SR_48000 (0xB << 0)
152 #define DA9055_SR_88200 (0xE << 0)
153 #define DA9055_SR_96000 (0xF << 0)
156 #define DA9055_BIAS_EN (1 << 3)
157 #define DA9055_VMID_EN (1 << 7)
160 #define DA9055_PLL_INDIV_10_20_MHZ (1 << 2)
161 #define DA9055_PLL_SRM_EN (1 << 6)
162 #define DA9055_PLL_EN (1 << 7)
165 #define DA9055_AIF_BCLKS_PER_WCLK_32 (0 << 0)
166 #define DA9055_AIF_BCLKS_PER_WCLK_64 (1 << 0)
167 #define DA9055_AIF_BCLKS_PER_WCLK_128 (2 << 0)
168 #define DA9055_AIF_BCLKS_PER_WCLK_256 (3 << 0)
169 #define DA9055_AIF_CLK_EN_SLAVE_MODE (0 << 7)
170 #define DA9055_AIF_CLK_EN_MASTER_MODE (1 << 7)
173 #define DA9055_AIF_FORMAT_I2S_MODE (0 << 0)
174 #define DA9055_AIF_FORMAT_LEFT_J (1 << 0)
175 #define DA9055_AIF_FORMAT_RIGHT_J (2 << 0)
176 #define DA9055_AIF_WORD_S16_LE (0 << 2)
177 #define DA9055_AIF_WORD_S20_3LE (1 << 2)
178 #define DA9055_AIF_WORD_S24_LE (2 << 2)
179 #define DA9055_AIF_WORD_S32_LE (3 << 2)
182 #define DA9055_MIC_L_MUTE_EN (1 << 6)
185 #define DA9055_MIC_R_MUTE_EN (1 << 6)
188 #define DA9055_MIXIN_L_MIX_EN (1 << 3)
191 #define DA9055_MIXIN_R_MIX_EN (1 << 3)
194 #define DA9055_ADC_L_EN (1 << 7)
197 #define DA9055_ADC_R_EN (1 << 7)
200 #define DA9055_DAC_L_MUTE_EN (1 << 6)
203 #define DA9055_DAC_R_MUTE_EN (1 << 6)
206 #define DA9055_HP_L_AMP_OE (1 << 3)
209 #define DA9055_HP_R_AMP_OE (1 << 3)
212 #define DA9055_LINE_AMP_OE (1 << 3)
215 #define DA9055_MIXOUT_L_MIX_EN (1 << 3)
218 #define DA9055_MIXOUT_R_MIX_EN (1 << 3)
221 #define DA9055_MICBIAS2_EN (1 << 6)
224 #define DA9055_ALC_DATA_MIDDLE (2 << 0)
225 #define DA9055_ALC_DATA_TOP (3 << 0)
226 #define DA9055_ALC_CIC_OP_CHANNEL_LEFT (0 << 7)
227 #define DA9055_ALC_CIC_OP_CHANNEL_RIGHT (1 << 7)
229 #define DA9055_AIF_BCLK_MASK (3 << 0)
230 #define DA9055_AIF_CLK_MODE_MASK (1 << 7)
231 #define DA9055_AIF_FORMAT_MASK (3 << 0)
232 #define DA9055_AIF_WORD_LENGTH_MASK (3 << 2)
233 #define DA9055_GAIN_RAMPING_EN (1 << 5)
234 #define DA9055_MICBIAS_LEVEL_MASK (3 << 4)
236 #define DA9055_ALC_OFFSET_15_8 0x00FF00
237 #define DA9055_ALC_OFFSET_17_16 0x030000
238 #define DA9055_ALC_AVG_ITERATIONS 5
250 static const struct pll_div da9055_pll_div[] = {
252 {11289600, 2822400, 0x00, 0x00, 0x20, 1},
253 {12000000, 2822400, 0x03, 0x61, 0x1E, 1},
254 {12288000, 2822400, 0x0C, 0xCC, 0x1D, 1},
255 {13000000, 2822400, 0x19, 0x45, 0x1B, 1},
256 {13500000, 2822400, 0x18, 0x56, 0x1A, 1},
257 {14400000, 2822400, 0x02, 0xD0, 0x19, 1},
258 {19200000, 2822400, 0x1A, 0x1C, 0x12, 1},
259 {19680000, 2822400, 0x0B, 0x6D, 0x12, 1},
260 {19800000, 2822400, 0x07, 0xDD, 0x12, 1},
262 {11289600, 3072000, 0x1A, 0x8E, 0x22, 1},
263 {12000000, 3072000, 0x18, 0x93, 0x20, 1},
264 {12288000, 3072000, 0x00, 0x00, 0x20, 1},
265 {13000000, 3072000, 0x07, 0xEA, 0x1E, 1},
266 {13500000, 3072000, 0x04, 0x11, 0x1D, 1},
267 {14400000, 3072000, 0x09, 0xD0, 0x1B, 1},
268 {19200000, 3072000, 0x0F, 0x5C, 0x14, 1},
269 {19680000, 3072000, 0x1F, 0x60, 0x13, 1},
270 {19800000, 3072000, 0x1B, 0x80, 0x13, 1},
272 {11289600, 2822400, 0x0D, 0x47, 0x21, 0},
273 {12000000, 2822400, 0x0D, 0xFA, 0x1F, 0},
274 {12288000, 2822400, 0x16, 0x66, 0x1E, 0},
275 {13000000, 2822400, 0x00, 0x98, 0x1D, 0},
276 {13500000, 2822400, 0x1E, 0x33, 0x1B, 0},
277 {14400000, 2822400, 0x06, 0x50, 0x1A, 0},
278 {19200000, 2822400, 0x14, 0xBC, 0x13, 0},
279 {19680000, 2822400, 0x05, 0x66, 0x13, 0},
280 {19800000, 2822400, 0x01, 0xAE, 0x13, 0},
289 static const unsigned int aux_vol_tlv[] = {
296 static const unsigned int digital_gain_tlv[] = {
303 static const unsigned int alc_analog_gain_tlv[] = {
319 static const char *
const da9055_hpf_cutoff_txt[] = {
320 "Fs/24000",
"Fs/12000",
"Fs/6000",
"Fs/3000"
323 static const struct soc_enum da9055_dac_hpf_cutoff =
326 static const struct soc_enum da9055_adc_hpf_cutoff =
330 static const char *
const da9055_vf_cutoff_txt[] = {
331 "2.5Hz",
"25Hz",
"50Hz",
"100Hz",
"150Hz",
"200Hz",
"300Hz",
"400Hz"
334 static const struct soc_enum da9055_dac_vf_cutoff =
337 static const struct soc_enum da9055_adc_vf_cutoff =
341 static const char *
const da9055_gain_ramping_txt[] = {
342 "nominal rate",
"nominal rate * 4",
"nominal rate * 8",
346 static const struct soc_enum da9055_gain_ramping_rate =
350 static const char *
const da9055_dac_ng_setup_time_txt[] = {
351 "256 samples",
"512 samples",
"1024 samples",
"2048 samples"
354 static const struct soc_enum da9055_dac_ng_setup_time =
356 da9055_dac_ng_setup_time_txt);
359 static const char *
const da9055_dac_ng_rampup_txt[] = {
360 "0.02 ms/dB",
"0.16 ms/dB"
363 static const struct soc_enum da9055_dac_ng_rampup_rate =
365 da9055_dac_ng_rampup_txt);
368 static const char *
const da9055_dac_ng_rampdown_txt[] = {
369 "0.64 ms/dB",
"20.48 ms/dB"
372 static const struct soc_enum da9055_dac_ng_rampdown_rate =
374 da9055_dac_ng_rampdown_txt);
377 static const char *
const da9055_dac_soft_mute_rate_txt[] = {
378 "1",
"2",
"4",
"8",
"16",
"32",
"64"
381 static const struct soc_enum da9055_dac_soft_mute_rate =
383 da9055_dac_soft_mute_rate_txt);
386 static const char *
const da9055_dac_src_txt[] = {
387 "ADC output left",
"ADC output right",
"AIF input left",
391 static const struct soc_enum da9055_dac_l_src =
394 static const struct soc_enum da9055_dac_r_src =
398 static const char *
const da9055_mic_l_src_txt[] = {
399 "MIC1_P_N",
"MIC1_P",
"MIC1_N",
"MIC2_L"
402 static const struct soc_enum da9055_mic_l_src =
406 static const char *
const da9055_mic_r_src_txt[] = {
407 "MIC2_R_L",
"MIC2_R",
"MIC2_L"
410 static const struct soc_enum da9055_mic_r_src =
414 static const char *
const da9055_signal_tracking_rate_txt[] = {
415 "1/4",
"1/16",
"1/256",
"1/65536"
418 static const struct soc_enum da9055_integ_attack_rate =
420 da9055_signal_tracking_rate_txt);
422 static const struct soc_enum da9055_integ_release_rate =
424 da9055_signal_tracking_rate_txt);
427 static const char *
const da9055_attack_rate_txt[] = {
428 "44/fs",
"88/fs",
"176/fs",
"352/fs",
"704/fs",
"1408/fs",
"2816/fs",
429 "5632/fs",
"11264/fs",
"22528/fs",
"45056/fs",
"90112/fs",
"180224/fs"
432 static const struct soc_enum da9055_attack_rate =
436 static const char *
const da9055_release_rate_txt[] = {
437 "176/fs",
"352/fs",
"704/fs",
"1408/fs",
"2816/fs",
"5632/fs",
438 "11264/fs",
"22528/fs",
"45056/fs",
"90112/fs",
"180224/fs"
441 static const struct soc_enum da9055_release_rate =
445 static const char *
const da9055_hold_time_txt[] = {
446 "62/fs",
"124/fs",
"248/fs",
"496/fs",
"992/fs",
"1984/fs",
"3968/fs",
447 "7936/fs",
"15872/fs",
"31744/fs",
"63488/fs",
"126976/fs",
448 "253952/fs",
"507904/fs",
"1015808/fs",
"2031616/fs"
451 static const struct soc_enum da9055_hold_time =
456 int mid_data, top_data;
475 sum += ((mid_data << 8) | (top_data << 16));
481 static int da9055_put_alc_sw(
struct snd_kcontrol *kcontrol,
485 u8 reg_val, adc_left, adc_right, mic_left, mic_right;
486 int avg_left_data, avg_right_data, offset_l, offset_r;
488 if (ucontrol->
value.integer.value[0]) {
516 avg_left_data = da9055_get_alc_data(codec,
519 avg_right_data = da9055_get_alc_data(codec,
523 offset_l = -avg_left_data;
524 offset_r = -avg_right_data;
553 0, 0x7, 0, mic_vol_tlv),
556 0, 0x3f, 0, aux_vol_tlv),
559 0, 0xf, 0, mixin_gain_tlv),
562 0, 0x7f, 0, digital_gain_tlv),
566 0, 0x7f, 0, digital_gain_tlv),
569 0, 0x3f, 0, hp_vol_tlv),
588 SOC_ENUM(
"ADC HPF Cutoff", da9055_adc_hpf_cutoff),
590 SOC_ENUM(
"ADC Voice Cutoff", da9055_adc_vf_cutoff),
593 SOC_ENUM(
"DAC HPF Cutoff", da9055_dac_hpf_cutoff),
595 SOC_ENUM(
"DAC Voice Cutoff", da9055_dac_vf_cutoff),
610 SOC_ENUM(
"DAC Soft Mute Rate", da9055_dac_soft_mute_rate),
633 SOC_ENUM(
"Gain Ramping Rate", da9055_gain_ramping_rate),
641 SOC_ENUM(
"DAC NG Setup Time", da9055_dac_ng_setup_time),
642 SOC_ENUM(
"DAC NG Rampup Rate", da9055_dac_ng_rampup_rate),
643 SOC_ENUM(
"DAC NG Rampdown Rate", da9055_dac_ng_rampdown_rate),
664 0, 0x3f, 1, alc_threshold_tlv),
666 0, 0x3f, 1, alc_threshold_tlv),
668 0, 0x3f, 1, alc_threshold_tlv),
670 4, 0xf, 0, alc_gain_tlv),
672 0, 0xf, 0, alc_gain_tlv),
675 0, 0x7, 0, alc_analog_gain_tlv),
678 4, 0x7, 0, alc_analog_gain_tlv),
679 SOC_ENUM(
"ALC Attack Rate", da9055_attack_rate),
680 SOC_ENUM(
"ALC Release Rate", da9055_release_rate),
681 SOC_ENUM(
"ALC Hold Time", da9055_hold_time),
686 SOC_ENUM(
"ALC Integ Attack Rate", da9055_integ_attack_rate),
691 SOC_ENUM(
"ALC Integ Release Rate", da9055_integ_release_rate),
767 &da9055_mic_l_mux_controls),
769 &da9055_mic_r_mux_controls),
785 &da9055_dapm_mixinl_controls[0],
788 &da9055_dapm_mixinr_controls[0],
799 &da9055_dac_l_mux_controls),
801 &da9055_dac_r_mux_controls),
813 &da9055_dapm_mixoutl_controls[0],
816 &da9055_dapm_mixoutr_controls[0],
837 {
"Mic Left Source",
"MIC1_P_N",
"MIC1"},
838 {
"Mic Left Source",
"MIC1_P",
"MIC1"},
839 {
"Mic Left Source",
"MIC1_N",
"MIC1"},
840 {
"Mic Left Source",
"MIC2_L",
"MIC2"},
842 {
"Mic Right Source",
"MIC2_R_L",
"MIC2"},
843 {
"Mic Right Source",
"MIC2_R",
"MIC2"},
844 {
"Mic Right Source",
"MIC2_L",
"MIC2"},
846 {
"Mic Left",
NULL,
"Mic Left Source"},
847 {
"Mic Right",
NULL,
"Mic Right Source"},
849 {
"Aux Left",
NULL,
"AUXL"},
850 {
"Aux Right",
NULL,
"AUXR"},
852 {
"In Mixer Left",
"Mic Left Switch",
"Mic Left"},
853 {
"In Mixer Left",
"Mic Right Switch",
"Mic Right"},
854 {
"In Mixer Left",
"Aux Left Switch",
"Aux Left"},
856 {
"In Mixer Right",
"Mic Right Switch",
"Mic Right"},
857 {
"In Mixer Right",
"Mic Left Switch",
"Mic Left"},
858 {
"In Mixer Right",
"Aux Right Switch",
"Aux Right"},
859 {
"In Mixer Right",
"Mixin Left Switch",
"MIXIN Left"},
861 {
"MIXIN Left",
NULL,
"In Mixer Left"},
862 {
"ADC Left",
NULL,
"MIXIN Left"},
864 {
"MIXIN Right",
NULL,
"In Mixer Right"},
865 {
"ADC Right",
NULL,
"MIXIN Right"},
867 {
"ADC Left",
NULL,
"AIF"},
868 {
"ADC Right",
NULL,
"AIF"},
871 {
"AIFIN Left",
NULL,
"AIF"},
872 {
"AIFIN Right",
NULL,
"AIF"},
874 {
"DAC Left Source",
"ADC output left",
"ADC Left"},
875 {
"DAC Left Source",
"ADC output right",
"ADC Right"},
876 {
"DAC Left Source",
"AIF input left",
"AIFIN Left"},
877 {
"DAC Left Source",
"AIF input right",
"AIFIN Right"},
879 {
"DAC Right Source",
"ADC output left",
"ADC Left"},
880 {
"DAC Right Source",
"ADC output right",
"ADC Right"},
881 {
"DAC Right Source",
"AIF input left",
"AIFIN Left"},
882 {
"DAC Right Source",
"AIF input right",
"AIFIN Right"},
884 {
"DAC Left",
NULL,
"DAC Left Source"},
885 {
"DAC Right",
NULL,
"DAC Right Source"},
887 {
"Out Mixer Left",
"Aux Left Switch",
"Aux Left"},
888 {
"Out Mixer Left",
"Mixin Left Switch",
"MIXIN Left"},
889 {
"Out Mixer Left",
"Mixin Right Switch",
"MIXIN Right"},
890 {
"Out Mixer Left",
"Aux Left Invert Switch",
"Aux Left"},
891 {
"Out Mixer Left",
"Mixin Left Invert Switch",
"MIXIN Left"},
892 {
"Out Mixer Left",
"Mixin Right Invert Switch",
"MIXIN Right"},
893 {
"Out Mixer Left",
"DAC Left Switch",
"DAC Left"},
895 {
"Out Mixer Right",
"Aux Right Switch",
"Aux Right"},
896 {
"Out Mixer Right",
"Mixin Right Switch",
"MIXIN Right"},
897 {
"Out Mixer Right",
"Mixin Left Switch",
"MIXIN Left"},
898 {
"Out Mixer Right",
"Aux Right Invert Switch",
"Aux Right"},
899 {
"Out Mixer Right",
"Mixin Right Invert Switch",
"MIXIN Right"},
900 {
"Out Mixer Right",
"Mixin Left Invert Switch",
"MIXIN Left"},
901 {
"Out Mixer Right",
"DAC Right Switch",
"DAC Right"},
903 {
"MIXOUT Left",
NULL,
"Out Mixer Left"},
904 {
"Headphone Left",
NULL,
"MIXOUT Left"},
905 {
"Headphone Left",
NULL,
"Charge Pump"},
906 {
"HPL",
NULL,
"Headphone Left"},
908 {
"MIXOUT Right",
NULL,
"Out Mixer Right"},
909 {
"Headphone Right",
NULL,
"MIXOUT Right"},
910 {
"Headphone Right",
NULL,
"Charge Pump"},
911 {
"HPR",
NULL,
"Headphone Right"},
913 {
"MIXOUT Right",
NULL,
"Out Mixer Right"},
914 {
"Lineout",
NULL,
"MIXOUT Right"},
915 {
"LINE",
NULL,
"Lineout"},
926 static struct reg_default da9055_reg_defaults[] = {
1002 static bool da9055_volatile_register(
struct device *
dev,
1139 static int da9055_set_dai_fmt(
struct snd_soc_dai *codec_dai,
unsigned int fmt)
1142 struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec);
1143 u8 aif_clk_mode, aif_ctrl,
mode;
1162 (da9055->
master != mode))
1212 #define DA9055_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1213 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
1215 static int da9055_set_dai_sysclk(
struct snd_soc_dai *codec_dai,
1216 int clk_id,
unsigned int freq,
int dir)
1219 struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec);
1236 dev_err(codec_dai->
dev,
"Unsupported MCLK value %d\n",
1242 dev_err(codec_dai->
dev,
"Unknown clock source %d\n", clk_id);
1258 static int da9055_set_dai_pll(
struct snd_soc_dai *codec_dai,
int pll_id,
1259 int source,
unsigned int fref,
unsigned int fout)
1262 struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec);
1264 u8 pll_frac_top, pll_frac_bot, pll_integer,
cnt;
1270 if (!da9055->
master && (fout != 2822400))
1274 for (cnt = 0; cnt <
ARRAY_SIZE(da9055_pll_div); cnt++) {
1276 if ((fref == da9055_pll_div[cnt].fref) &&
1278 (fout == da9055_pll_div[cnt].fout)) {
1296 dev_err(codec_dai->
dev,
"Error in setting up PLL\n");
1302 .hw_params = da9055_hw_params,
1303 .set_fmt = da9055_set_dai_fmt,
1304 .set_sysclk = da9055_set_dai_sysclk,
1305 .set_pll = da9055_set_dai_pll,
1306 .digital_mute = da9055_mute,
1310 .name =
"da9055-hifi",
1313 .stream_name =
"Playback",
1321 .stream_name =
"Capture",
1327 .ops = &da9055_dai_ops,
1328 .symmetric_rates = 1,
1331 static int da9055_set_bias_level(
struct snd_soc_codec *codec,
1359 struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec);
1364 dev_err(codec->
dev,
"Failed to set cache I/O: %d\n", ret);
1422 if (da9055->
pdata) {
1424 if (da9055->
pdata->micbias_source) {
1433 switch (da9055->
pdata->micbias) {
1440 (da9055->
pdata->micbias) << 4);
1448 .probe = da9055_probe,
1449 .set_bias_level = da9055_set_bias_level,
1451 .controls = da9055_snd_controls,
1452 .num_controls =
ARRAY_SIZE(da9055_snd_controls),
1454 .dapm_widgets = da9055_dapm_widgets,
1455 .num_dapm_widgets =
ARRAY_SIZE(da9055_dapm_widgets),
1456 .dapm_routes = da9055_audio_map,
1457 .num_dapm_routes =
ARRAY_SIZE(da9055_audio_map),
1464 .reg_defaults = da9055_reg_defaults,
1465 .num_reg_defaults =
ARRAY_SIZE(da9055_reg_defaults),
1466 .volatile_reg = da9055_volatile_register,
1485 i2c_set_clientdata(i2c, da9055);
1488 if (IS_ERR(da9055->
regmap)) {
1489 ret = PTR_ERR(da9055->
regmap);
1490 dev_err(&i2c->
dev,
"regmap_init() failed: %d\n", ret);
1495 &soc_codec_dev_da9055, &da9055_dai, 1);
1497 dev_err(&i2c->
dev,
"Failed to register da9055 codec: %d\n",
1516 static struct i2c_driver da9055_i2c_driver = {
1521 .probe = da9055_i2c_probe,
1523 .id_table = da9055_i2c_id,