Lines Matching +full:out +full:- +full:of +full:- +full:band
1 // SPDX-License-Identifier: GPL-2.0-only
3 * max98090.c -- MAX98090 ALSA SoC Audio driver
5 * Copyright 2011-2012 Maxim Integrated Products
11 #include <linux/of.h>
100 { 0x46, 0x00 }, /* 46 Equalizer Band 1 Coefficient B0 */
101 { 0x47, 0x00 }, /* 47 Equalizer Band 1 Coefficient B0 */
102 { 0x48, 0x00 }, /* 48 Equalizer Band 1 Coefficient B0 */
103 { 0x49, 0x00 }, /* 49 Equalizer Band 1 Coefficient B1 */
104 { 0x4A, 0x00 }, /* 4A Equalizer Band 1 Coefficient B1 */
105 { 0x4B, 0x00 }, /* 4B Equalizer Band 1 Coefficient B1 */
106 { 0x4C, 0x00 }, /* 4C Equalizer Band 1 Coefficient B2 */
107 { 0x4D, 0x00 }, /* 4D Equalizer Band 1 Coefficient B2 */
108 { 0x4E, 0x00 }, /* 4E Equalizer Band 1 Coefficient B2 */
109 { 0x4F, 0x00 }, /* 4F Equalizer Band 1 Coefficient A1 */
111 { 0x50, 0x00 }, /* 50 Equalizer Band 1 Coefficient A1 */
112 { 0x51, 0x00 }, /* 51 Equalizer Band 1 Coefficient A1 */
113 { 0x52, 0x00 }, /* 52 Equalizer Band 1 Coefficient A2 */
114 { 0x53, 0x00 }, /* 53 Equalizer Band 1 Coefficient A2 */
115 { 0x54, 0x00 }, /* 54 Equalizer Band 1 Coefficient A2 */
116 { 0x55, 0x00 }, /* 55 Equalizer Band 2 Coefficient B0 */
117 { 0x56, 0x00 }, /* 56 Equalizer Band 2 Coefficient B0 */
118 { 0x57, 0x00 }, /* 57 Equalizer Band 2 Coefficient B0 */
119 { 0x58, 0x00 }, /* 58 Equalizer Band 2 Coefficient B1 */
120 { 0x59, 0x00 }, /* 59 Equalizer Band 2 Coefficient B1 */
121 { 0x5A, 0x00 }, /* 5A Equalizer Band 2 Coefficient B1 */
122 { 0x5B, 0x00 }, /* 5B Equalizer Band 2 Coefficient B2 */
123 { 0x5C, 0x00 }, /* 5C Equalizer Band 2 Coefficient B2 */
124 { 0x5D, 0x00 }, /* 5D Equalizer Band 2 Coefficient B2 */
125 { 0x5E, 0x00 }, /* 5E Equalizer Band 2 Coefficient A1 */
126 { 0x5F, 0x00 }, /* 5F Equalizer Band 2 Coefficient A1 */
128 { 0x60, 0x00 }, /* 60 Equalizer Band 2 Coefficient A1 */
129 { 0x61, 0x00 }, /* 61 Equalizer Band 2 Coefficient A2 */
130 { 0x62, 0x00 }, /* 62 Equalizer Band 2 Coefficient A2 */
131 { 0x63, 0x00 }, /* 63 Equalizer Band 2 Coefficient A2 */
132 { 0x64, 0x00 }, /* 64 Equalizer Band 3 Coefficient B0 */
133 { 0x65, 0x00 }, /* 65 Equalizer Band 3 Coefficient B0 */
134 { 0x66, 0x00 }, /* 66 Equalizer Band 3 Coefficient B0 */
135 { 0x67, 0x00 }, /* 67 Equalizer Band 3 Coefficient B1 */
136 { 0x68, 0x00 }, /* 68 Equalizer Band 3 Coefficient B1 */
137 { 0x69, 0x00 }, /* 69 Equalizer Band 3 Coefficient B1 */
138 { 0x6A, 0x00 }, /* 6A Equalizer Band 3 Coefficient B2 */
139 { 0x6B, 0x00 }, /* 6B Equalizer Band 3 Coefficient B2 */
140 { 0x6C, 0x00 }, /* 6C Equalizer Band 3 Coefficient B2 */
141 { 0x6D, 0x00 }, /* 6D Equalizer Band 3 Coefficient A1 */
142 { 0x6E, 0x00 }, /* 6E Equalizer Band 3 Coefficient A1 */
143 { 0x6F, 0x00 }, /* 6F Equalizer Band 3 Coefficient A1 */
145 { 0x70, 0x00 }, /* 70 Equalizer Band 3 Coefficient A2 */
146 { 0x71, 0x00 }, /* 71 Equalizer Band 3 Coefficient A2 */
147 { 0x72, 0x00 }, /* 72 Equalizer Band 3 Coefficient A2 */
148 { 0x73, 0x00 }, /* 73 Equalizer Band 4 Coefficient B0 */
149 { 0x74, 0x00 }, /* 74 Equalizer Band 4 Coefficient B0 */
150 { 0x75, 0x00 }, /* 75 Equalizer Band 4 Coefficient B0 */
151 { 0x76, 0x00 }, /* 76 Equalizer Band 4 Coefficient B1 */
152 { 0x77, 0x00 }, /* 77 Equalizer Band 4 Coefficient B1 */
153 { 0x78, 0x00 }, /* 78 Equalizer Band 4 Coefficient B1 */
154 { 0x79, 0x00 }, /* 79 Equalizer Band 4 Coefficient B2 */
155 { 0x7A, 0x00 }, /* 7A Equalizer Band 4 Coefficient B2 */
156 { 0x7B, 0x00 }, /* 7B Equalizer Band 4 Coefficient B2 */
157 { 0x7C, 0x00 }, /* 7C Equalizer Band 4 Coefficient A1 */
158 { 0x7D, 0x00 }, /* 7D Equalizer Band 4 Coefficient A1 */
159 { 0x7E, 0x00 }, /* 7E Equalizer Band 4 Coefficient A1 */
160 { 0x7F, 0x00 }, /* 7F Equalizer Band 4 Coefficient A2 */
162 { 0x80, 0x00 }, /* 80 Equalizer Band 4 Coefficient A2 */
163 { 0x81, 0x00 }, /* 81 Equalizer Band 4 Coefficient A2 */
164 { 0x82, 0x00 }, /* 82 Equalizer Band 5 Coefficient B0 */
165 { 0x83, 0x00 }, /* 83 Equalizer Band 5 Coefficient B0 */
166 { 0x84, 0x00 }, /* 84 Equalizer Band 5 Coefficient B0 */
167 { 0x85, 0x00 }, /* 85 Equalizer Band 5 Coefficient B1 */
168 { 0x86, 0x00 }, /* 86 Equalizer Band 5 Coefficient B1 */
169 { 0x87, 0x00 }, /* 87 Equalizer Band 5 Coefficient B1 */
170 { 0x88, 0x00 }, /* 88 Equalizer Band 5 Coefficient B2 */
171 { 0x89, 0x00 }, /* 89 Equalizer Band 5 Coefficient B2 */
172 { 0x8A, 0x00 }, /* 8A Equalizer Band 5 Coefficient B2 */
173 { 0x8B, 0x00 }, /* 8B Equalizer Band 5 Coefficient A1 */
174 { 0x8C, 0x00 }, /* 8C Equalizer Band 5 Coefficient A1 */
175 { 0x8D, 0x00 }, /* 8D Equalizer Band 5 Coefficient A1 */
176 { 0x8E, 0x00 }, /* 8E Equalizer Band 5 Coefficient A2 */
177 { 0x8F, 0x00 }, /* 8F Equalizer Band 5 Coefficient A2 */
179 { 0x90, 0x00 }, /* 90 Equalizer Band 5 Coefficient A2 */
180 { 0x91, 0x00 }, /* 91 Equalizer Band 6 Coefficient B0 */
181 { 0x92, 0x00 }, /* 92 Equalizer Band 6 Coefficient B0 */
182 { 0x93, 0x00 }, /* 93 Equalizer Band 6 Coefficient B0 */
183 { 0x94, 0x00 }, /* 94 Equalizer Band 6 Coefficient B1 */
184 { 0x95, 0x00 }, /* 95 Equalizer Band 6 Coefficient B1 */
185 { 0x96, 0x00 }, /* 96 Equalizer Band 6 Coefficient B1 */
186 { 0x97, 0x00 }, /* 97 Equalizer Band 6 Coefficient B2 */
187 { 0x98, 0x00 }, /* 98 Equalizer Band 6 Coefficient B2 */
188 { 0x99, 0x00 }, /* 99 Equalizer Band 6 Coefficient B2 */
189 { 0x9A, 0x00 }, /* 9A Equalizer Band 6 Coefficient A1 */
190 { 0x9B, 0x00 }, /* 9B Equalizer Band 6 Coefficient A1 */
191 { 0x9C, 0x00 }, /* 9C Equalizer Band 6 Coefficient A1 */
192 { 0x9D, 0x00 }, /* 9D Equalizer Band 6 Coefficient A2 */
193 { 0x9E, 0x00 }, /* 9E Equalizer Band 6 Coefficient A2 */
194 { 0x9F, 0x00 }, /* 9F Equalizer Band 6 Coefficient A2 */
196 { 0xA0, 0x00 }, /* A0 Equalizer Band 7 Coefficient B0 */
197 { 0xA1, 0x00 }, /* A1 Equalizer Band 7 Coefficient B0 */
198 { 0xA2, 0x00 }, /* A2 Equalizer Band 7 Coefficient B0 */
199 { 0xA3, 0x00 }, /* A3 Equalizer Band 7 Coefficient B1 */
200 { 0xA4, 0x00 }, /* A4 Equalizer Band 7 Coefficient B1 */
201 { 0xA5, 0x00 }, /* A5 Equalizer Band 7 Coefficient B1 */
202 { 0xA6, 0x00 }, /* A6 Equalizer Band 7 Coefficient B2 */
203 { 0xA7, 0x00 }, /* A7 Equalizer Band 7 Coefficient B2 */
204 { 0xA8, 0x00 }, /* A8 Equalizer Band 7 Coefficient B2 */
205 { 0xA9, 0x00 }, /* A9 Equalizer Band 7 Coefficient A1 */
206 { 0xAA, 0x00 }, /* AA Equalizer Band 7 Coefficient A1 */
207 { 0xAB, 0x00 }, /* AB Equalizer Band 7 Coefficient A1 */
208 { 0xAC, 0x00 }, /* AC Equalizer Band 7 Coefficient A2 */
209 { 0xAD, 0x00 }, /* AD Equalizer Band 7 Coefficient A2 */
210 { 0xAE, 0x00 }, /* AE Equalizer Band 7 Coefficient A2 */
280 /* Reset the codec by writing to this write-only reset register */ in max98090_reset()
281 ret = regmap_write(max98090->regmap, M98090_REG_SOFTWARE_RESET, in max98090_reset()
284 dev_err(max98090->component->dev, in max98090_reset()
301 -600, 600, 0);
304 0, 3, TLV_DB_SCALE_ITEM(-600, 300, 0),
309 static const DECLARE_TLV_DB_SCALE(max98090_av_tlv, -1200, 100, 0);
312 static const DECLARE_TLV_DB_SCALE(max98090_dv_tlv, -1500, 100, 0);
315 static const DECLARE_TLV_DB_SCALE(max98090_alccomp_tlv, -3100, 100, 0);
316 static const DECLARE_TLV_DB_SCALE(max98090_drcexp_tlv, -6600, 100, 0);
320 0, 1, TLV_DB_SCALE_ITEM(-1200, 250, 0),
321 2, 3, TLV_DB_SCALE_ITEM(-600, 600, 0)
325 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0),
326 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0),
327 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0),
328 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0),
333 0, 4, TLV_DB_SCALE_ITEM(-4800, 400, 0),
334 5, 10, TLV_DB_SCALE_ITEM(-2900, 300, 0),
335 11, 14, TLV_DB_SCALE_ITEM(-1200, 200, 0),
336 15, 29, TLV_DB_SCALE_ITEM(-500, 100, 0),
341 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0),
342 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0),
343 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0),
354 (struct soc_mixer_control *)kcontrol->private_value; in max98090_get_enab_tlv()
355 unsigned int mask = (1 << fls(mc->max)) - 1; in max98090_get_enab_tlv()
356 unsigned int val = snd_soc_component_read32(component, mc->reg); in max98090_get_enab_tlv()
359 switch (mc->reg) { in max98090_get_enab_tlv()
361 select = &(max98090->pa1en); in max98090_get_enab_tlv()
364 select = &(max98090->pa2en); in max98090_get_enab_tlv()
367 select = &(max98090->sidetone); in max98090_get_enab_tlv()
370 return -EINVAL; in max98090_get_enab_tlv()
373 val = (val >> mc->shift) & mask; in max98090_get_enab_tlv()
377 val = val - 1; in max98090_get_enab_tlv()
384 ucontrol->value.integer.value[0] = val; in max98090_get_enab_tlv()
394 (struct soc_mixer_control *)kcontrol->private_value; in max98090_put_enab_tlv()
395 unsigned int mask = (1 << fls(mc->max)) - 1; in max98090_put_enab_tlv()
396 unsigned int sel = ucontrol->value.integer.value[0]; in max98090_put_enab_tlv()
397 unsigned int val = snd_soc_component_read32(component, mc->reg); in max98090_put_enab_tlv()
400 switch (mc->reg) { in max98090_put_enab_tlv()
402 select = &(max98090->pa1en); in max98090_put_enab_tlv()
405 select = &(max98090->pa2en); in max98090_put_enab_tlv()
408 select = &(max98090->sidetone); in max98090_put_enab_tlv()
411 return -EINVAL; in max98090_put_enab_tlv()
414 val = (val >> mc->shift) & mask; in max98090_put_enab_tlv()
426 snd_soc_component_update_bits(component, mc->reg, in max98090_put_enab_tlv()
427 mask << mc->shift, in max98090_put_enab_tlv()
428 sel << mc->shift); in max98090_put_enab_tlv()
512 M98090_DMIC_COMP_SHIFT, M98090_DMIC_COMP_NUM - 1, 0),
516 M98090_MIC_PA1EN_NUM - 1, 0, max98090_get_enab_tlv,
521 M98090_MIC_PA2EN_NUM - 1, 0, max98090_get_enab_tlv,
525 M98090_MIC_PGAM1_SHIFT, M98090_MIC_PGAM1_NUM - 1, 1,
529 M98090_MIC_PGAM2_SHIFT, M98090_MIC_PGAM2_NUM - 1, 1,
534 M98090_MIXG135_NUM - 1, 1, max98090_line_single_ended_tlv),
538 M98090_MIXG246_NUM - 1, 1, max98090_line_single_ended_tlv),
541 M98090_LINAPGA_SHIFT, 0, M98090_LINAPGA_NUM - 1, 1,
545 M98090_LINBPGA_SHIFT, 0, M98090_LINBPGA_NUM - 1, 1,
549 M98090_EXTBUFA_SHIFT, M98090_EXTBUFA_NUM - 1, 0),
551 M98090_EXTBUFB_SHIFT, M98090_EXTBUFB_NUM - 1, 0),
554 M98090_AVLG_SHIFT, M98090_AVLG_NUM - 1, 0,
557 M98090_AVRG_SHIFT, M98090_AVLG_NUM - 1, 0,
561 M98090_AVL_SHIFT, M98090_AVL_NUM - 1, 1,
564 M98090_AVR_SHIFT, M98090_AVR_NUM - 1, 1,
569 M98090_ADCDITHER_SHIFT, M98090_ADCDITHER_NUM - 1, 0),
573 M98090_DMONO_SHIFT, M98090_DMONO_NUM - 1, 0),
575 M98090_SDIEN_SHIFT, M98090_SDIEN_NUM - 1, 0),
577 M98090_SDOEN_SHIFT, M98090_SDOEN_NUM - 1, 0),
578 SOC_SINGLE("SDOUT Hi-Z Mode", M98090_REG_IO_CONFIGURATION,
579 M98090_HIZOFF_SHIFT, M98090_HIZOFF_NUM - 1, 1),
582 M98090_AHPF_SHIFT, M98090_AHPF_NUM - 1, 0),
584 M98090_DHPF_SHIFT, M98090_DHPF_NUM - 1, 0),
586 M98090_AVBQ_SHIFT, M98090_AVBQ_NUM - 1, 1, max98090_dv_tlv),
589 M98090_DVST_NUM - 1, 1, max98090_get_enab_tlv,
592 M98090_DVG_SHIFT, M98090_DVG_NUM - 1, 0,
595 M98090_DV_SHIFT, M98090_DV_NUM - 1, 1,
598 SOC_SINGLE("Digital EQ 3 Band Switch", M98090_REG_DSP_FILTER_ENABLE,
599 M98090_EQ3BANDEN_SHIFT, M98090_EQ3BANDEN_NUM - 1, 0),
600 SOC_SINGLE("Digital EQ 5 Band Switch", M98090_REG_DSP_FILTER_ENABLE,
601 M98090_EQ5BANDEN_SHIFT, M98090_EQ5BANDEN_NUM - 1, 0),
602 SOC_SINGLE("Digital EQ 7 Band Switch", M98090_REG_DSP_FILTER_ENABLE,
603 M98090_EQ7BANDEN_SHIFT, M98090_EQ7BANDEN_NUM - 1, 0),
605 M98090_EQCLPN_SHIFT, M98090_EQCLPN_NUM - 1,
608 M98090_DVEQ_SHIFT, M98090_DVEQ_NUM - 1, 1,
612 M98090_DRCEN_SHIFT, M98090_DRCEN_NUM - 1, 0),
616 M98090_DRCG_SHIFT, M98090_DRCG_NUM - 1, 0,
622 M98090_DRCTHC_NUM - 1, 1, max98090_alccomp_tlv),
625 M98090_DRCTHE_NUM - 1, 1, max98090_drcexp_tlv),
633 M98090_MIXHPLG_NUM - 1, 1, max98090_mixout_tlv),
636 M98090_MIXHPRG_NUM - 1, 1, max98090_mixout_tlv),
640 M98090_MIXSPLG_NUM - 1, 1, max98090_mixout_tlv),
643 M98090_MIXSPRG_NUM - 1, 1, max98090_mixout_tlv),
647 M98090_MIXRCVLG_NUM - 1, 1, max98090_mixout_tlv),
650 M98090_MIXRCVRG_NUM - 1, 1, max98090_mixout_tlv),
654 M98090_HPVOLL_NUM - 1, 0, max98090_hp_tlv),
658 M98090_SPVOLL_SHIFT, 24, M98090_SPVOLL_NUM - 1 + 24,
663 M98090_RCVLVOL_NUM - 1, 0, max98090_rcv_lout_tlv),
680 SOC_SINGLE("Zero-Crossing Detection", M98090_REG_LEVEL_CONTROL,
681 M98090_ZDENN_SHIFT, M98090_ZDENN_NUM - 1, 1),
683 M98090_VS2ENN_SHIFT, M98090_VS2ENN_NUM - 1, 1),
685 M98090_VSENN_SHIFT, M98090_VSENN_NUM - 1, 1),
689 M98090_ADCBQEN_SHIFT, M98090_ADCBQEN_NUM - 1, 0),
696 M98090_DMIC34_ZEROPAD_NUM - 1, 0),
701 M98090_FLT_DMIC34HPF_NUM - 1, 0),
704 M98090_DMIC_AV3G_SHIFT, M98090_DMIC_AV3G_NUM - 1, 0,
707 M98090_DMIC_AV4G_SHIFT, M98090_DMIC_AV4G_NUM - 1, 0,
711 M98090_DMIC_AV3_SHIFT, M98090_DMIC_AV3_NUM - 1, 1,
714 M98090_DMIC_AV4_SHIFT, M98090_DMIC_AV4_NUM - 1, 1,
720 M98090_DMIC34BQEN_SHIFT, M98090_DMIC34BQEN_NUM - 1, 0),
724 M98090_AV34BQ_NUM - 1, 1, max98090_dv_tlv),
730 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98090_micinput_event()
733 unsigned int val = snd_soc_component_read32(component, w->reg); in max98090_micinput_event()
735 if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) in max98090_micinput_event()
741 if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) { in max98090_micinput_event()
742 max98090->pa1en = val - 1; /* Update for volatile */ in max98090_micinput_event()
744 max98090->pa2en = val - 1; /* Update for volatile */ in max98090_micinput_event()
751 if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) in max98090_micinput_event()
752 val = max98090->pa1en + 1; in max98090_micinput_event()
754 val = max98090->pa2en + 1; in max98090_micinput_event()
761 return -EINVAL; in max98090_micinput_event()
764 if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) in max98090_micinput_event()
765 snd_soc_component_update_bits(component, w->reg, M98090_MIC_PA1EN_MASK, in max98090_micinput_event()
768 snd_soc_component_update_bits(component, w->reg, M98090_MIC_PA2EN_MASK, in max98090_micinput_event()
777 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98090_shdn_event()
781 max98090->shdn_pending = true; in max98090_shdn_event()
1092 * Note: Sysclk and misc power supplies are taken care of by SHDN
1203 SND_SOC_DAPM_PGA("HP Left Out", M98090_REG_OUTPUT_ENABLE,
1205 SND_SOC_DAPM_PGA("HP Right Out", M98090_REG_OUTPUT_ENABLE,
1208 SND_SOC_DAPM_PGA("SPK Left Out", M98090_REG_OUTPUT_ENABLE,
1210 SND_SOC_DAPM_PGA("SPK Right Out", M98090_REG_OUTPUT_ENABLE,
1213 SND_SOC_DAPM_PGA("RCV Left Out", M98090_REG_OUTPUT_ENABLE,
1215 SND_SOC_DAPM_PGA("RCV Right Out", M98090_REG_OUTPUT_ENABLE,
1390 {"HP Left Out", NULL, "DACL"},
1391 {"HP Left Out", NULL, "MIXHPLSEL Mux"},
1399 {"HP Right Out", NULL, "DACR"},
1400 {"HP Right Out", NULL, "MIXHPRSEL Mux"},
1402 {"SPK Left Out", NULL, "Left Speaker Mixer"},
1403 {"SPK Right Out", NULL, "Right Speaker Mixer"},
1404 {"RCV Left Out", NULL, "Left Receiver Mixer"},
1408 {"RCV Right Out", NULL, "LINMOD Mux"},
1410 {"HPL", NULL, "HP Left Out"},
1411 {"HPR", NULL, "HP Right Out"},
1412 {"SPKL", NULL, "SPK Left Out"},
1413 {"SPKR", NULL, "SPK Right Out"},
1414 {"RCVL", NULL, "RCV Left Out"},
1415 {"RCVR", NULL, "RCV Right Out"},
1434 if (max98090->devtype == MAX98091) { in max98090_add_widgets()
1445 if (max98090->devtype == MAX98091) { in max98090_add_widgets()
1488 if (!max98090->sysclk) { in max98090_configure_bclk()
1489 dev_err(component->dev, "No SYSCLK configured\n"); in max98090_configure_bclk()
1493 if (!max98090->bclk || !max98090->lrclk) { in max98090_configure_bclk()
1494 dev_err(component->dev, "No audio clocks configured\n"); in max98090_configure_bclk()
1506 if ((pclk_rates[i] == max98090->sysclk) && in max98090_configure_bclk()
1507 (lrclk_rates[i] == max98090->lrclk)) { in max98090_configure_bclk()
1508 dev_dbg(component->dev, in max98090_configure_bclk()
1523 if ((user_pclk_rates[i] == max98090->sysclk) && in max98090_configure_bclk()
1524 (user_lrclk_rates[i] == max98090->lrclk)) { in max98090_configure_bclk()
1525 dev_dbg(component->dev, in max98090_configure_bclk()
1527 dev_dbg(component->dev, "i %d ni %lld mi %lld\n", in max98090_configure_bclk()
1562 ni = 65536ULL * (max98090->lrclk < 50000 ? 96ULL : 48ULL) in max98090_configure_bclk()
1563 * (unsigned long long int)max98090->lrclk; in max98090_configure_bclk()
1564 do_div(ni, (unsigned long long int)max98090->sysclk); in max98090_configure_bclk()
1565 dev_info(component->dev, "No better method found\n"); in max98090_configure_bclk()
1566 dev_info(component->dev, "Calculating ni %lld with mi 65536\n", ni); in max98090_configure_bclk()
1575 struct snd_soc_component *component = codec_dai->component; in max98090_dai_set_fmt()
1580 max98090->dai_fmt = fmt; in max98090_dai_set_fmt()
1581 cdata = &max98090->dai[0]; in max98090_dai_set_fmt()
1583 if (fmt != cdata->fmt) { in max98090_dai_set_fmt()
1584 cdata->fmt = fmt; in max98090_dai_set_fmt()
1589 /* Set to slave mode PLL - MAS mode off */ in max98090_dai_set_fmt()
1596 max98090->master = false; in max98090_dai_set_fmt()
1600 if (max98090->tdm_slots == 4) { in max98090_dai_set_fmt()
1604 } else if (max98090->tdm_slots == 3) { in max98090_dai_set_fmt()
1613 max98090->master = true; in max98090_dai_set_fmt()
1618 dev_err(component->dev, "DAI clock mode unsupported"); in max98090_dai_set_fmt()
1619 return -EINVAL; in max98090_dai_set_fmt()
1636 dev_err(component->dev, "DAI format unsupported"); in max98090_dai_set_fmt()
1637 return -EINVAL; in max98090_dai_set_fmt()
1653 dev_err(component->dev, "DAI invert mode unsupported"); in max98090_dai_set_fmt()
1654 return -EINVAL; in max98090_dai_set_fmt()
1660 * seen for the case of TDM mode. The remaining cases have in max98090_dai_set_fmt()
1663 if (max98090->tdm_slots > 1) in max98090_dai_set_fmt()
1676 struct snd_soc_component *component = codec_dai->component; in max98090_set_tdm_slot()
1679 cdata = &max98090->dai[0]; in max98090_set_tdm_slot()
1682 return -EINVAL; in max98090_set_tdm_slot()
1684 max98090->tdm_slots = slots; in max98090_set_tdm_slot()
1685 max98090->tdm_width = slot_width; in max98090_set_tdm_slot()
1687 if (max98090->tdm_slots > 1) { in max98090_set_tdm_slot()
1703 cdata->fmt = 0; in max98090_set_tdm_slot()
1704 max98090_dai_set_fmt(codec_dai, max98090->dai_fmt); in max98090_set_tdm_slot()
1727 if (IS_ERR(max98090->mclk)) in max98090_set_bias_level()
1731 clk_disable_unprepare(max98090->mclk); in max98090_set_bias_level()
1733 ret = clk_prepare_enable(max98090->mclk); in max98090_set_bias_level()
1741 ret = regcache_sync(max98090->regmap); in max98090_set_bias_level()
1743 dev_err(component->dev, in max98090_set_bias_level()
1751 /* Set internal pull-up to lowest power mode */ in max98090_set_bias_level()
1754 regcache_mark_dirty(max98090->regmap); in max98090_set_bias_level()
1840 test_diff = abs(target_freq - (pclk / dmic_divisors[i])); in max98090_find_divisor()
1862 m1 = pclk - dmic_table[i-1].pclk; in max98090_find_closest_pclk()
1863 m2 = dmic_table[i].pclk - pclk; in max98090_find_closest_pclk()
1865 return i - 1; in max98090_find_closest_pclk()
1871 return -EINVAL; in max98090_find_closest_pclk()
1889 for (i = 0; i < ARRAY_SIZE(comp_lrclk_rates) - 1; i++) { in max98090_configure_dmic()
1897 regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_ENABLE, in max98090_configure_dmic()
1901 regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_CONFIG, in max98090_configure_dmic()
1912 struct snd_soc_component *component = dai->component; in max98090_dai_startup()
1914 unsigned int fmt = max98090->dai_fmt; in max98090_dai_startup()
1916 /* Remove 24-bit format support if it is not in right justified mode. */ in max98090_dai_startup()
1918 substream->runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; in max98090_dai_startup()
1919 snd_pcm_hw_constraint_msbits(substream->runtime, 0, 16, 16); in max98090_dai_startup()
1928 struct snd_soc_component *component = dai->component; in max98090_dai_hw_params()
1932 cdata = &max98090->dai[0]; in max98090_dai_hw_params()
1933 max98090->bclk = snd_soc_params_to_bclk(params); in max98090_dai_hw_params()
1935 max98090->bclk *= 2; in max98090_dai_hw_params()
1937 max98090->lrclk = params_rate(params); in max98090_dai_hw_params()
1945 return -EINVAL; in max98090_dai_hw_params()
1948 if (max98090->master) in max98090_dai_hw_params()
1951 cdata->rate = max98090->lrclk; in max98090_dai_hw_params()
1954 if (max98090->lrclk < 24000) in max98090_dai_hw_params()
1962 if (max98090->lrclk < 50000) in max98090_dai_hw_params()
1969 max98090_configure_dmic(max98090, max98090->dmic_freq, max98090->pclk, in max98090_dai_hw_params()
1970 max98090->lrclk); in max98090_dai_hw_params()
1981 struct snd_soc_component *component = dai->component; in max98090_dai_set_sysclk()
1985 if (freq == max98090->sysclk) in max98090_dai_set_sysclk()
1988 if (!IS_ERR(max98090->mclk)) { in max98090_dai_set_sysclk()
1989 freq = clk_round_rate(max98090->mclk, freq); in max98090_dai_set_sysclk()
1990 clk_set_rate(max98090->mclk, freq); in max98090_dai_set_sysclk()
2001 max98090->pclk = freq; in max98090_dai_set_sysclk()
2005 max98090->pclk = freq >> 1; in max98090_dai_set_sysclk()
2009 max98090->pclk = freq >> 2; in max98090_dai_set_sysclk()
2011 dev_err(component->dev, "Invalid master clock frequency\n"); in max98090_dai_set_sysclk()
2012 return -EINVAL; in max98090_dai_set_sysclk()
2015 max98090->sysclk = freq; in max98090_dai_set_sysclk()
2022 struct snd_soc_component *component = codec_dai->component; in max98090_dai_digital_mute()
2035 struct snd_soc_component *component = dai->component; in max98090_dai_trigger()
2042 if (!max98090->master && dai->active == 1) in max98090_dai_trigger()
2044 &max98090->pll_det_enable_work, in max98090_dai_trigger()
2050 if (!max98090->master && dai->active == 1) in max98090_dai_trigger()
2051 schedule_work(&max98090->pll_det_disable_work); in max98090_dai_trigger()
2065 struct snd_soc_component *component = max98090->component; in max98090_pll_det_enable_work()
2074 regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status); in max98090_pll_det_enable_work()
2080 regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); in max98090_pll_det_enable_work()
2084 &max98090->jack_work, in max98090_pll_det_enable_work()
2097 struct snd_soc_component *component = max98090->component; in max98090_pll_det_disable_work()
2099 cancel_delayed_work_sync(&max98090->pll_det_enable_work); in max98090_pll_det_disable_work()
2110 struct snd_soc_component *component = max98090->component; in max98090_pll_work()
2115 dev_info_ratelimited(component->dev, "PLL unlocked\n"); in max98090_pll_work()
2133 struct snd_soc_component *component = max98090->component; in max98090_jack_work()
2138 if (max98090->jack_state == M98090_JACK_STATE_NO_HEADSET) { in max98090_jack_work()
2159 dev_dbg(component->dev, "No Headset Detected\n"); in max98090_jack_work()
2161 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; in max98090_jack_work()
2168 if (max98090->jack_state == in max98090_jack_work()
2171 dev_dbg(component->dev, in max98090_jack_work()
2188 dev_dbg(component->dev, "Headphone Detected\n"); in max98090_jack_work()
2190 max98090->jack_state = M98090_JACK_STATE_HEADPHONE; in max98090_jack_work()
2197 dev_dbg(component->dev, "Headset Detected\n"); in max98090_jack_work()
2199 max98090->jack_state = M98090_JACK_STATE_HEADSET; in max98090_jack_work()
2206 dev_dbg(component->dev, "Unrecognized Jack Status\n"); in max98090_jack_work()
2210 snd_soc_jack_report(max98090->jack, status, in max98090_jack_work()
2217 struct snd_soc_component *component = max98090->component; in max98090_interrupt()
2226 dev_dbg(component->dev, "***** max98090_interrupt *****\n"); in max98090_interrupt()
2228 ret = regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); in max98090_interrupt()
2231 dev_err(component->dev, in max98090_interrupt()
2237 ret = regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &active); in max98090_interrupt()
2240 dev_err(component->dev, in max98090_interrupt()
2246 dev_dbg(component->dev, "active=0x%02x mask=0x%02x -> active=0x%02x\n", in max98090_interrupt()
2255 dev_err(component->dev, "M98090_CLD_MASK\n"); in max98090_interrupt()
2258 dev_dbg(component->dev, "M98090_SLD_MASK\n"); in max98090_interrupt()
2261 dev_dbg(component->dev, "M98090_ULK_MASK\n"); in max98090_interrupt()
2262 schedule_work(&max98090->pll_work); in max98090_interrupt()
2266 dev_dbg(component->dev, "M98090_JDET_MASK\n"); in max98090_interrupt()
2268 pm_wakeup_event(component->dev, 100); in max98090_interrupt()
2271 &max98090->jack_work, in max98090_interrupt()
2276 dev_dbg(component->dev, "M98090_DRCACT_MASK\n"); in max98090_interrupt()
2279 dev_err(component->dev, "M98090_DRCCLP_MASK\n"); in max98090_interrupt()
2285 * max98090_mic_detect - Enable microphone detection via the MAX98090 IRQ
2291 * being used to bring out signals to the processor then only platform
2302 dev_dbg(component->dev, "max98090_mic_detect\n"); in max98090_mic_detect()
2304 max98090->jack = jack; in max98090_mic_detect()
2316 snd_soc_jack_report(max98090->jack, 0, in max98090_mic_detect()
2320 &max98090->jack_work, in max98090_mic_detect()
2370 dev_dbg(component->dev, "max98090_probe\n"); in max98090_probe()
2372 max98090->mclk = devm_clk_get(component->dev, "mclk"); in max98090_probe()
2373 if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER) in max98090_probe()
2374 return -EPROBE_DEFER; in max98090_probe()
2376 max98090->component = component; in max98090_probe()
2383 max98090->sysclk = (unsigned)-1; in max98090_probe()
2384 max98090->pclk = (unsigned)-1; in max98090_probe()
2385 max98090->master = false; in max98090_probe()
2387 cdata = &max98090->dai[0]; in max98090_probe()
2388 cdata->rate = (unsigned)-1; in max98090_probe()
2389 cdata->fmt = (unsigned)-1; in max98090_probe()
2391 max98090->lin_state = 0; in max98090_probe()
2392 max98090->pa1en = 0; in max98090_probe()
2393 max98090->pa2en = 0; in max98090_probe()
2397 dev_err(component->dev, "Failed to read device revision: %d\n", in max98090_probe()
2404 dev_info(component->dev, "MAX98090 REVID=0x%02x\n", ret); in max98090_probe()
2407 dev_info(component->dev, "MAX98091 REVID=0x%02x\n", ret); in max98090_probe()
2410 dev_err(component->dev, "Unrecognized revision 0x%02x\n", ret); in max98090_probe()
2413 if (max98090->devtype != devtype) { in max98090_probe()
2414 dev_warn(component->dev, "Mismatch in DT specified CODEC type.\n"); in max98090_probe()
2415 max98090->devtype = devtype; in max98090_probe()
2418 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; in max98090_probe()
2420 INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work); in max98090_probe()
2421 INIT_DELAYED_WORK(&max98090->pll_det_enable_work, in max98090_probe()
2423 INIT_WORK(&max98090->pll_det_disable_work, in max98090_probe()
2425 INIT_WORK(&max98090->pll_work, max98090_pll_work); in max98090_probe()
2453 err = device_property_read_u32(component->dev, "maxim,micbias", &micbias); in max98090_probe()
2456 dev_info(component->dev, "use default 2.8v micbias\n"); in max98090_probe()
2458 dev_err(component->dev, "micbias out of range 0x%x\n", micbias); in max98090_probe()
2475 cancel_delayed_work_sync(&max98090->jack_work); in max98090_remove()
2476 cancel_delayed_work_sync(&max98090->pll_det_enable_work); in max98090_remove()
2477 cancel_work_sync(&max98090->pll_det_disable_work); in max98090_remove()
2478 cancel_work_sync(&max98090->pll_work); in max98090_remove()
2479 max98090->component = NULL; in max98090_remove()
2487 if (max98090->shdn_pending) { in max98090_seq_notifier()
2493 max98090->shdn_pending = false; in max98090_seq_notifier()
2530 max98090 = devm_kzalloc(&i2c->dev, sizeof(struct max98090_priv), in max98090_i2c_probe()
2533 return -ENOMEM; in max98090_i2c_probe()
2535 if (ACPI_HANDLE(&i2c->dev)) { in max98090_i2c_probe()
2536 acpi_id = acpi_match_device(i2c->dev.driver->acpi_match_table, in max98090_i2c_probe()
2537 &i2c->dev); in max98090_i2c_probe()
2539 dev_err(&i2c->dev, "No driver data\n"); in max98090_i2c_probe()
2540 return -EINVAL; in max98090_i2c_probe()
2542 driver_data = acpi_id->driver_data; in max98090_i2c_probe()
2544 driver_data = i2c_id->driver_data; in max98090_i2c_probe()
2547 max98090->devtype = driver_data; in max98090_i2c_probe()
2549 max98090->pdata = i2c->dev.platform_data; in max98090_i2c_probe()
2551 ret = of_property_read_u32(i2c->dev.of_node, "maxim,dmic-freq", in max98090_i2c_probe()
2552 &max98090->dmic_freq); in max98090_i2c_probe()
2554 max98090->dmic_freq = MAX98090_DEFAULT_DMIC_FREQ; in max98090_i2c_probe()
2556 max98090->regmap = devm_regmap_init_i2c(i2c, &max98090_regmap); in max98090_i2c_probe()
2557 if (IS_ERR(max98090->regmap)) { in max98090_i2c_probe()
2558 ret = PTR_ERR(max98090->regmap); in max98090_i2c_probe()
2559 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); in max98090_i2c_probe()
2563 ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, in max98090_i2c_probe()
2567 dev_err(&i2c->dev, "request_irq failed: %d\n", in max98090_i2c_probe()
2572 ret = devm_snd_soc_register_component(&i2c->dev, in max98090_i2c_probe()
2581 struct max98090_priv *max98090 = dev_get_drvdata(&i2c->dev); in max98090_i2c_shutdown()
2587 regmap_write(max98090->regmap, in max98090_i2c_shutdown()
2589 regmap_write(max98090->regmap, in max98090_i2c_shutdown()
2606 regcache_cache_only(max98090->regmap, false); in max98090_runtime_resume()
2610 regcache_sync(max98090->regmap); in max98090_runtime_resume()
2619 regcache_cache_only(max98090->regmap, true); in max98090_runtime_suspend()
2631 regcache_mark_dirty(max98090->regmap); in max98090_resume()
2636 regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status); in max98090_resume()
2638 regcache_sync(max98090->regmap); in max98090_resume()
2667 MODULE_DEVICE_TABLE(of, max98090_of_match);