10 #include <linux/module.h>
14 #include <linux/i2c.h>
15 #include <linux/slab.h>
38 #define ADAU1373_INPUT_MODE 0x00
39 #define ADAU1373_AINL_CTRL(x) (0x01 + (x) * 2)
40 #define ADAU1373_AINR_CTRL(x) (0x02 + (x) * 2)
41 #define ADAU1373_LLINE_OUT(x) (0x9 + (x) * 2)
42 #define ADAU1373_RLINE_OUT(x) (0xa + (x) * 2)
43 #define ADAU1373_LSPK_OUT 0x0d
44 #define ADAU1373_RSPK_OUT 0x0e
45 #define ADAU1373_LHP_OUT 0x0f
46 #define ADAU1373_RHP_OUT 0x10
47 #define ADAU1373_ADC_GAIN 0x11
48 #define ADAU1373_LADC_MIXER 0x12
49 #define ADAU1373_RADC_MIXER 0x13
50 #define ADAU1373_LLINE1_MIX 0x14
51 #define ADAU1373_RLINE1_MIX 0x15
52 #define ADAU1373_LLINE2_MIX 0x16
53 #define ADAU1373_RLINE2_MIX 0x17
54 #define ADAU1373_LSPK_MIX 0x18
55 #define ADAU1373_RSPK_MIX 0x19
56 #define ADAU1373_LHP_MIX 0x1a
57 #define ADAU1373_RHP_MIX 0x1b
58 #define ADAU1373_EP_MIX 0x1c
59 #define ADAU1373_HP_CTRL 0x1d
60 #define ADAU1373_HP_CTRL2 0x1e
61 #define ADAU1373_LS_CTRL 0x1f
62 #define ADAU1373_EP_CTRL 0x21
63 #define ADAU1373_MICBIAS_CTRL1 0x22
64 #define ADAU1373_MICBIAS_CTRL2 0x23
65 #define ADAU1373_OUTPUT_CTRL 0x24
66 #define ADAU1373_PWDN_CTRL1 0x25
67 #define ADAU1373_PWDN_CTRL2 0x26
68 #define ADAU1373_PWDN_CTRL3 0x27
69 #define ADAU1373_DPLL_CTRL(x) (0x28 + (x) * 7)
70 #define ADAU1373_PLL_CTRL1(x) (0x29 + (x) * 7)
71 #define ADAU1373_PLL_CTRL2(x) (0x2a + (x) * 7)
72 #define ADAU1373_PLL_CTRL3(x) (0x2b + (x) * 7)
73 #define ADAU1373_PLL_CTRL4(x) (0x2c + (x) * 7)
74 #define ADAU1373_PLL_CTRL5(x) (0x2d + (x) * 7)
75 #define ADAU1373_PLL_CTRL6(x) (0x2e + (x) * 7)
76 #define ADAU1373_PLL_CTRL7(x) (0x2f + (x) * 7)
77 #define ADAU1373_HEADDECT 0x36
78 #define ADAU1373_ADC_DAC_STATUS 0x37
79 #define ADAU1373_ADC_CTRL 0x3c
80 #define ADAU1373_DAI(x) (0x44 + (x))
81 #define ADAU1373_CLK_SRC_DIV(x) (0x40 + (x) * 2)
82 #define ADAU1373_BCLKDIV(x) (0x47 + (x))
83 #define ADAU1373_SRC_RATIOA(x) (0x4a + (x) * 2)
84 #define ADAU1373_SRC_RATIOB(x) (0x4b + (x) * 2)
85 #define ADAU1373_DEEMP_CTRL 0x50
86 #define ADAU1373_SRC_DAI_CTRL(x) (0x51 + (x))
87 #define ADAU1373_DIN_MIX_CTRL(x) (0x56 + (x))
88 #define ADAU1373_DOUT_MIX_CTRL(x) (0x5b + (x))
89 #define ADAU1373_DAI_PBL_VOL(x) (0x62 + (x) * 2)
90 #define ADAU1373_DAI_PBR_VOL(x) (0x63 + (x) * 2)
91 #define ADAU1373_DAI_RECL_VOL(x) (0x68 + (x) * 2)
92 #define ADAU1373_DAI_RECR_VOL(x) (0x69 + (x) * 2)
93 #define ADAU1373_DAC1_PBL_VOL 0x6e
94 #define ADAU1373_DAC1_PBR_VOL 0x6f
95 #define ADAU1373_DAC2_PBL_VOL 0x70
96 #define ADAU1373_DAC2_PBR_VOL 0x71
97 #define ADAU1373_ADC_RECL_VOL 0x72
98 #define ADAU1373_ADC_RECR_VOL 0x73
99 #define ADAU1373_DMIC_RECL_VOL 0x74
100 #define ADAU1373_DMIC_RECR_VOL 0x75
101 #define ADAU1373_VOL_GAIN1 0x76
102 #define ADAU1373_VOL_GAIN2 0x77
103 #define ADAU1373_VOL_GAIN3 0x78
104 #define ADAU1373_HPF_CTRL 0x7d
105 #define ADAU1373_BASS1 0x7e
106 #define ADAU1373_BASS2 0x7f
107 #define ADAU1373_DRC(x) (0x80 + (x) * 0x10)
108 #define ADAU1373_3D_CTRL1 0xc0
109 #define ADAU1373_3D_CTRL2 0xc1
110 #define ADAU1373_FDSP_SEL1 0xdc
111 #define ADAU1373_FDSP_SEL2 0xdd
112 #define ADAU1373_FDSP_SEL3 0xde
113 #define ADAU1373_FDSP_SEL4 0xdf
114 #define ADAU1373_DIGMICCTRL 0xe2
115 #define ADAU1373_DIGEN 0xeb
116 #define ADAU1373_SOFT_RESET 0xff
119 #define ADAU1373_PLL_CTRL6_DPLL_BYPASS BIT(1)
120 #define ADAU1373_PLL_CTRL6_PLL_EN BIT(0)
122 #define ADAU1373_DAI_INVERT_BCLK BIT(7)
123 #define ADAU1373_DAI_MASTER BIT(6)
124 #define ADAU1373_DAI_INVERT_LRCLK BIT(4)
125 #define ADAU1373_DAI_WLEN_16 0x0
126 #define ADAU1373_DAI_WLEN_20 0x4
127 #define ADAU1373_DAI_WLEN_24 0x8
128 #define ADAU1373_DAI_WLEN_32 0xc
129 #define ADAU1373_DAI_WLEN_MASK 0xc
130 #define ADAU1373_DAI_FORMAT_RIGHT_J 0x0
131 #define ADAU1373_DAI_FORMAT_LEFT_J 0x1
132 #define ADAU1373_DAI_FORMAT_I2S 0x2
133 #define ADAU1373_DAI_FORMAT_DSP 0x3
135 #define ADAU1373_BCLKDIV_SOURCE BIT(5)
136 #define ADAU1373_BCLKDIV_32 0x03
137 #define ADAU1373_BCLKDIV_64 0x02
138 #define ADAU1373_BCLKDIV_128 0x01
139 #define ADAU1373_BCLKDIV_256 0x00
141 #define ADAU1373_ADC_CTRL_PEAK_DETECT BIT(0)
142 #define ADAU1373_ADC_CTRL_RESET BIT(1)
143 #define ADAU1373_ADC_CTRL_RESET_FORCE BIT(2)
145 #define ADAU1373_OUTPUT_CTRL_LDIFF BIT(3)
146 #define ADAU1373_OUTPUT_CTRL_LNFBEN BIT(2)
148 #define ADAU1373_PWDN_CTRL3_PWR_EN BIT(0)
150 #define ADAU1373_EP_CTRL_MICBIAS1_OFFSET 4
151 #define ADAU1373_EP_CTRL_MICBIAS2_OFFSET 2
153 static const uint8_t adau1373_default_regs[] = {
154 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
160 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
161 0x00, 0x00, 0x00, 0x80, 0x00, 0x01, 0x00, 0x00,
162 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00,
163 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
164 0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00,
165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
166 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
168 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
170 0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
171 0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00,
172 0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
173 0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00,
174 0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
175 0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00,
176 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
177 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00,
178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
183 0x00, 0x1f, 0x0f, 0x00, 0x00,
186 static const unsigned int adau1373_out_tlv[] = {
202 static const char *adau1373_fdsp_sel_text[] = {
222 static const char *adau1373_hpf_cutoff_text[] = {
223 "3.7Hz",
"50Hz",
"100Hz",
"150Hz",
"200Hz",
"250Hz",
"300Hz",
"350Hz",
224 "400Hz",
"450Hz",
"500Hz",
"550Hz",
"600Hz",
"650Hz",
"700Hz",
"750Hz",
231 static const char *adau1373_bass_lpf_cutoff_text[] = {
235 static const char *adau1373_bass_clip_level_text[] = {
236 "0.125",
"0.250",
"0.370",
"0.500",
"0.625",
"0.750",
"0.875",
239 static const unsigned int adau1373_bass_clip_level_values[] = {
243 static const char *adau1373_bass_hpf_cutoff_text[] = {
244 "158Hz",
"232Hz",
"347Hz",
"520Hz",
247 static const unsigned int adau1373_bass_tlv[] = {
259 adau1373_bass_clip_level_values);
264 static const char *adau1373_3d_level_text[] = {
265 "0%",
"6.67%",
"13.33%",
"20%",
"26.67%",
"33.33%",
266 "40%",
"46.67%",
"53.33%",
"60%",
"66.67%",
"73.33%",
267 "80%",
"86.67",
"99.33%",
"100%"
270 static const char *adau1373_3d_cutoff_text[] = {
271 "No 3D",
"0.03125 fs",
"0.04583 fs",
"0.075 fs",
"0.11458 fs",
272 "0.16875 fs",
"0.27083 fs"
280 static const unsigned int adau1373_3d_tlv[] = {
286 static const char *adau1373_lr_mux_text[] = {
288 "Right Channel (L+R)",
289 "Left Channel (L+R)",
345 1, 0, adau1373_gain_boost_tlv),
347 1, 0, adau1373_gain_boost_tlv),
349 1, 0, adau1373_gain_boost_tlv),
351 1, 0, adau1373_gain_boost_tlv),
353 1, 0, adau1373_gain_boost_tlv),
355 1, 0, adau1373_gain_boost_tlv),
357 1, 0, adau1373_gain_boost_tlv),
359 1, 0, adau1373_gain_boost_tlv),
361 1, 0, adau1373_gain_boost_tlv),
363 1, 0, adau1373_gain_boost_tlv),
366 1, 0, adau1373_input_boost_tlv),
368 1, 0, adau1373_input_boost_tlv),
370 1, 0, adau1373_input_boost_tlv),
372 1, 0, adau1373_input_boost_tlv),
375 1, 0, adau1373_speaker_boost_tlv),
377 SOC_ENUM(
"Lineout1 LR Mux", adau1373_lineout1_lr_mux_enum),
378 SOC_ENUM(
"Speaker LR Mux", adau1373_speaker_lr_mux_enum),
380 SOC_ENUM(
"HPF Cutoff", adau1373_hpf_cutoff_enum),
382 SOC_ENUM(
"HPF Channel", adau1373_hpf_channel_enum),
384 SOC_ENUM(
"Bass HPF Cutoff", adau1373_bass_hpf_cutoff_enum),
386 adau1373_bass_clip_level_enum),
387 SOC_ENUM(
"Bass LPF Cutoff", adau1373_bass_lpf_cutoff_enum),
391 SOC_ENUM(
"Bass Channel", adau1373_bass_channel_enum),
393 SOC_ENUM(
"3D Freq", adau1373_3d_cutoff_enum),
394 SOC_ENUM(
"3D Level", adau1373_3d_level_enum),
398 SOC_ENUM(
"3D Channel", adau1373_bass_channel_enum),
406 SOC_ENUM(
"Lineout2 LR Mux", adau1373_lineout2_lr_mux_enum),
410 SOC_ENUM(
"DRC1 Channel", adau1373_drc1_channel_enum),
411 SOC_ENUM(
"DRC2 Channel", adau1373_drc2_channel_enum),
412 SOC_ENUM(
"DRC3 Channel", adau1373_drc3_channel_enum),
419 unsigned int pll_id = w->
name[3] -
'1';
436 static const char *adau1373_decimator_text[] = {
441 static const struct soc_enum adau1373_decimator_enum =
455 static const struct snd_kcontrol_new adau1373_right_adc_mixer_controls[] = {
463 #define DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(_name, _reg) \
464 const struct snd_kcontrol_new _name[] = { \
465 SOC_DAPM_SINGLE("Left DAC2 Switch", _reg, 7, 1, 0), \
466 SOC_DAPM_SINGLE("Right DAC2 Switch", _reg, 6, 1, 0), \
467 SOC_DAPM_SINGLE("Left DAC1 Switch", _reg, 5, 1, 0), \
468 SOC_DAPM_SINGLE("Right DAC1 Switch", _reg, 4, 1, 0), \
469 SOC_DAPM_SINGLE("Input 4 Bypass Switch", _reg, 3, 1, 0), \
470 SOC_DAPM_SINGLE("Input 3 Bypass Switch", _reg, 2, 1, 0), \
471 SOC_DAPM_SINGLE("Input 2 Bypass Switch", _reg, 1, 1, 0), \
472 SOC_DAPM_SINGLE("Input 1 Bypass Switch", _reg, 0, 1, 0), \
508 #define DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(_name, _reg) \
509 const struct snd_kcontrol_new _name[] = { \
510 SOC_DAPM_SINGLE("DMIC2 Swapped Switch", _reg, 6, 1, 0), \
511 SOC_DAPM_SINGLE("DMIC2 Switch", _reg, 5, 1, 0), \
512 SOC_DAPM_SINGLE("ADC/DMIC1 Swapped Switch", _reg, 4, 1, 0), \
513 SOC_DAPM_SINGLE("ADC/DMIC1 Switch", _reg, 3, 1, 0), \
514 SOC_DAPM_SINGLE("AIF3 Switch", _reg, 2, 1, 0), \
515 SOC_DAPM_SINGLE("AIF2 Switch", _reg, 1, 1, 0), \
516 SOC_DAPM_SINGLE("AIF1 Switch", _reg, 0, 1, 0), \
530 #define DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(_name, _reg) \
531 const struct snd_kcontrol_new _name[] = { \
532 SOC_DAPM_SINGLE("DSP Channel5 Switch", _reg, 4, 1, 0), \
533 SOC_DAPM_SINGLE("DSP Channel4 Switch", _reg, 3, 1, 0), \
534 SOC_DAPM_SINGLE("DSP Channel3 Switch", _reg, 2, 1, 0), \
535 SOC_DAPM_SINGLE("DSP Channel2 Switch", _reg, 1, 1, 0), \
536 SOC_DAPM_SINGLE("DSP Channel1 Switch", _reg, 0, 1, 0), \
560 &adau1373_decimator_mux),
576 adau1373_left_adc_mixer_controls),
578 adau1373_right_adc_mixer_controls),
581 adau1373_left_line2_mixer_controls),
583 adau1373_right_line2_mixer_controls),
585 adau1373_left_line1_mixer_controls),
587 adau1373_right_line1_mixer_controls),
590 adau1373_ep_mixer_controls),
592 adau1373_left_spk_mixer_controls),
594 adau1373_right_spk_mixer_controls),
596 adau1373_left_hp_mixer_controls),
598 adau1373_right_hp_mixer_controls),
629 adau1373_dsp_channel1_mixer_controls),
631 adau1373_dsp_channel2_mixer_controls),
633 adau1373_dsp_channel3_mixer_controls),
635 adau1373_dsp_channel4_mixer_controls),
637 adau1373_dsp_channel5_mixer_controls),
640 adau1373_aif1_mixer_controls),
642 adau1373_aif2_mixer_controls),
644 adau1373_aif3_mixer_controls),
646 adau1373_dac1_mixer_controls),
648 adau1373_dac2_mixer_controls),
694 dai = sink->
name[3] -
'1';
696 if (!adau1373->
dais[dai].master)
711 struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec);
714 dai = sink->
name[3] -
'1';
716 return adau1373->
dais[dai].enable_src;
719 #define DSP_CHANNEL_MIXER_ROUTES(_sink) \
720 { _sink, "DMIC2 Swapped Switch", "DMIC2" }, \
721 { _sink, "DMIC2 Switch", "DMIC2" }, \
722 { _sink, "ADC/DMIC1 Swapped Switch", "Decimator Mux" }, \
723 { _sink, "ADC/DMIC1 Switch", "Decimator Mux" }, \
724 { _sink, "AIF1 Switch", "AIF1 IN" }, \
725 { _sink, "AIF2 Switch", "AIF2 IN" }, \
726 { _sink, "AIF3 Switch", "AIF3 IN" }
728 #define DSP_OUTPUT_MIXER_ROUTES(_sink) \
729 { _sink, "DSP Channel1 Switch", "DSP Channel1 Mixer" }, \
730 { _sink, "DSP Channel2 Switch", "DSP Channel2 Mixer" }, \
731 { _sink, "DSP Channel3 Switch", "DSP Channel3 Mixer" }, \
732 { _sink, "DSP Channel4 Switch", "DSP Channel4 Mixer" }, \
733 { _sink, "DSP Channel5 Switch", "DSP Channel5 Mixer" }
735 #define LEFT_OUTPUT_MIXER_ROUTES(_sink) \
736 { _sink, "Right DAC2 Switch", "Right DAC2" }, \
737 { _sink, "Left DAC2 Switch", "Left DAC2" }, \
738 { _sink, "Right DAC1 Switch", "Right DAC1" }, \
739 { _sink, "Left DAC1 Switch", "Left DAC1" }, \
740 { _sink, "Input 1 Bypass Switch", "IN1PGA" }, \
741 { _sink, "Input 2 Bypass Switch", "IN2PGA" }, \
742 { _sink, "Input 3 Bypass Switch", "IN3PGA" }, \
743 { _sink, "Input 4 Bypass Switch", "IN4PGA" }
745 #define RIGHT_OUTPUT_MIXER_ROUTES(_sink) \
746 { _sink, "Right DAC2 Switch", "Right DAC2" }, \
747 { _sink, "Left DAC2 Switch", "Left DAC2" }, \
748 { _sink, "Right DAC1 Switch", "Right DAC1" }, \
749 { _sink, "Left DAC1 Switch", "Left DAC1" }, \
750 { _sink, "Input 1 Bypass Switch", "IN1PGA" }, \
751 { _sink, "Input 2 Bypass Switch", "IN2PGA" }, \
752 { _sink, "Input 3 Bypass Switch", "IN3PGA" }, \
753 { _sink, "Input 4 Bypass Switch", "IN4PGA" }
756 {
"Left ADC Mixer",
"DAC1 Switch",
"Left DAC1" },
757 {
"Left ADC Mixer",
"Input 1 Switch",
"IN1PGA" },
758 {
"Left ADC Mixer",
"Input 2 Switch",
"IN2PGA" },
759 {
"Left ADC Mixer",
"Input 3 Switch",
"IN3PGA" },
760 {
"Left ADC Mixer",
"Input 4 Switch",
"IN4PGA" },
762 {
"Right ADC Mixer",
"DAC1 Switch",
"Right DAC1" },
763 {
"Right ADC Mixer",
"Input 1 Switch",
"IN1PGA" },
764 {
"Right ADC Mixer",
"Input 2 Switch",
"IN2PGA" },
765 {
"Right ADC Mixer",
"Input 3 Switch",
"IN3PGA" },
766 {
"Right ADC Mixer",
"Input 4 Switch",
"IN4PGA" },
768 {
"Left ADC",
NULL,
"Left ADC Mixer" },
769 {
"Right ADC",
NULL,
"Right ADC Mixer" },
771 {
"Decimator Mux",
"ADC",
"Left ADC" },
772 {
"Decimator Mux",
"ADC",
"Right ADC" },
773 {
"Decimator Mux",
"DMIC1",
"DMIC1" },
787 {
"AIF1 OUT",
NULL,
"AIF1 Mixer" },
788 {
"AIF2 OUT",
NULL,
"AIF2 Mixer" },
789 {
"AIF3 OUT",
NULL,
"AIF3 Mixer" },
790 {
"Left DAC1",
NULL,
"DAC1 Mixer" },
791 {
"Right DAC1",
NULL,
"DAC1 Mixer" },
792 {
"Left DAC2",
NULL,
"DAC2 Mixer" },
793 {
"Right DAC2",
NULL,
"DAC2 Mixer" },
802 {
"Left Headphone Mixer",
"Left DAC2 Switch",
"Left DAC2" },
803 {
"Left Headphone Mixer",
"Left DAC1 Switch",
"Left DAC1" },
804 {
"Left Headphone Mixer",
"Input 1 Bypass Switch",
"IN1PGA" },
805 {
"Left Headphone Mixer",
"Input 2 Bypass Switch",
"IN2PGA" },
806 {
"Left Headphone Mixer",
"Input 3 Bypass Switch",
"IN3PGA" },
807 {
"Left Headphone Mixer",
"Input 4 Bypass Switch",
"IN4PGA" },
808 {
"Right Headphone Mixer",
"Right DAC2 Switch",
"Right DAC2" },
809 {
"Right Headphone Mixer",
"Right DAC1 Switch",
"Right DAC1" },
810 {
"Right Headphone Mixer",
"Input 1 Bypass Switch",
"IN1PGA" },
811 {
"Right Headphone Mixer",
"Input 2 Bypass Switch",
"IN2PGA" },
812 {
"Right Headphone Mixer",
"Input 3 Bypass Switch",
"IN3PGA" },
813 {
"Right Headphone Mixer",
"Input 4 Bypass Switch",
"IN4PGA" },
815 {
"Left Headphone Mixer",
NULL,
"Headphone Enable" },
816 {
"Right Headphone Mixer",
NULL,
"Headphone Enable" },
818 {
"Earpiece Mixer",
"Right DAC2 Switch",
"Right DAC2" },
819 {
"Earpiece Mixer",
"Left DAC2 Switch",
"Left DAC2" },
820 {
"Earpiece Mixer",
"Right DAC1 Switch",
"Right DAC1" },
821 {
"Earpiece Mixer",
"Left DAC1 Switch",
"Left DAC1" },
822 {
"Earpiece Mixer",
"Input 1 Bypass Switch",
"IN1PGA" },
823 {
"Earpiece Mixer",
"Input 2 Bypass Switch",
"IN2PGA" },
824 {
"Earpiece Mixer",
"Input 3 Bypass Switch",
"IN3PGA" },
825 {
"Earpiece Mixer",
"Input 4 Bypass Switch",
"IN4PGA" },
827 {
"LOUT1L",
NULL,
"Left Lineout1 Mixer" },
828 {
"LOUT1R",
NULL,
"Right Lineout1 Mixer" },
829 {
"LOUT2L",
NULL,
"Left Lineout2 Mixer" },
830 {
"LOUT2R",
NULL,
"Right Lineout2 Mixer" },
831 {
"SPKL",
NULL,
"Left Speaker Mixer" },
832 {
"SPKR",
NULL,
"Right Speaker Mixer" },
833 {
"HPL",
NULL,
"Left Headphone Mixer" },
834 {
"HPR",
NULL,
"Right Headphone Mixer" },
835 {
"EP",
NULL,
"Earpiece Mixer" },
837 {
"IN1PGA",
NULL,
"AIN1L" },
838 {
"IN2PGA",
NULL,
"AIN2L" },
839 {
"IN3PGA",
NULL,
"AIN3L" },
840 {
"IN4PGA",
NULL,
"AIN4L" },
841 {
"IN1PGA",
NULL,
"AIN1R" },
842 {
"IN2PGA",
NULL,
"AIN2R" },
843 {
"IN3PGA",
NULL,
"AIN3R" },
844 {
"IN4PGA",
NULL,
"AIN4R" },
846 {
"SYSCLK1",
NULL,
"PLL1" },
847 {
"SYSCLK2",
NULL,
"PLL2" },
849 {
"Left DAC1",
NULL,
"SYSCLK1" },
850 {
"Right DAC1",
NULL,
"SYSCLK1" },
851 {
"Left DAC2",
NULL,
"SYSCLK1" },
852 {
"Right DAC2",
NULL,
"SYSCLK1" },
853 {
"Left ADC",
NULL,
"SYSCLK1" },
854 {
"Right ADC",
NULL,
"SYSCLK1" },
856 {
"DSP",
NULL,
"SYSCLK1" },
858 {
"AIF1 Mixer",
NULL,
"DSP" },
859 {
"AIF2 Mixer",
NULL,
"DSP" },
860 {
"AIF3 Mixer",
NULL,
"DSP" },
861 {
"DAC1 Mixer",
NULL,
"DSP" },
862 {
"DAC2 Mixer",
NULL,
"DSP" },
863 {
"DAC1 Mixer",
NULL,
"Playback Engine A" },
864 {
"DAC2 Mixer",
NULL,
"Playback Engine B" },
865 {
"Left ADC Mixer",
NULL,
"Recording Engine A" },
866 {
"Right ADC Mixer",
NULL,
"Recording Engine A" },
868 {
"AIF1 CLK",
NULL,
"SYSCLK1", adau1373_check_aif_clk },
869 {
"AIF2 CLK",
NULL,
"SYSCLK1", adau1373_check_aif_clk },
870 {
"AIF3 CLK",
NULL,
"SYSCLK1", adau1373_check_aif_clk },
871 {
"AIF1 CLK",
NULL,
"SYSCLK2", adau1373_check_aif_clk },
872 {
"AIF2 CLK",
NULL,
"SYSCLK2", adau1373_check_aif_clk },
873 {
"AIF3 CLK",
NULL,
"SYSCLK2", adau1373_check_aif_clk },
875 {
"AIF1 IN",
NULL,
"AIF1 CLK" },
876 {
"AIF1 OUT",
NULL,
"AIF1 CLK" },
877 {
"AIF2 IN",
NULL,
"AIF2 CLK" },
878 {
"AIF2 OUT",
NULL,
"AIF2 CLK" },
879 {
"AIF3 IN",
NULL,
"AIF3 CLK" },
880 {
"AIF3 OUT",
NULL,
"AIF3 CLK" },
881 {
"AIF1 IN",
NULL,
"AIF1 IN SRC", adau1373_check_src },
882 {
"AIF1 OUT",
NULL,
"AIF1 OUT SRC", adau1373_check_src },
883 {
"AIF2 IN",
NULL,
"AIF2 IN SRC", adau1373_check_src },
884 {
"AIF2 OUT",
NULL,
"AIF2 OUT SRC", adau1373_check_src },
885 {
"AIF3 IN",
NULL,
"AIF3 IN SRC", adau1373_check_src },
886 {
"AIF3 OUT",
NULL,
"AIF3 OUT SRC", adau1373_check_src },
888 {
"DMIC1",
NULL,
"DMIC1DAT" },
889 {
"DMIC1",
NULL,
"SYSCLK1" },
890 {
"DMIC1",
NULL,
"Recording Engine A" },
891 {
"DMIC2",
NULL,
"DMIC2DAT" },
892 {
"DMIC2",
NULL,
"SYSCLK1" },
893 {
"DMIC2",
NULL,
"Recording Engine B" },
900 struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec);
906 freq = adau1373_dai->
sysclk;
963 static int adau1373_set_dai_fmt(
struct snd_soc_dai *dai,
unsigned int fmt)
966 struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec);
967 struct adau1373_dai *adau1373_dai = &adau1373->
dais[dai->
id];
973 adau1373_dai->
master =
true;
977 adau1373_dai->
master =
false;
1022 static int adau1373_set_dai_sysclk(
struct snd_soc_dai *dai,
1023 int clk_id,
unsigned int freq,
int dir)
1025 struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(dai->
codec);
1026 struct adau1373_dai *adau1373_dai = &adau1373->
dais[dai->
id];
1037 adau1373_dai->
clk_src = clk_id;
1046 .hw_params = adau1373_hw_params,
1047 .set_sysclk = adau1373_set_dai_sysclk,
1048 .set_fmt = adau1373_set_dai_fmt,
1051 #define ADAU1373_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
1052 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
1057 .name =
"adau1373-aif1",
1059 .stream_name =
"AIF1 Playback",
1066 .stream_name =
"AIF1 Capture",
1072 .ops = &adau1373_dai_ops,
1073 .symmetric_rates = 1,
1077 .name =
"adau1373-aif2",
1079 .stream_name =
"AIF2 Playback",
1086 .stream_name =
"AIF2 Capture",
1092 .ops = &adau1373_dai_ops,
1093 .symmetric_rates = 1,
1097 .name =
"adau1373-aif3",
1099 .stream_name =
"AIF3 Playback",
1106 .stream_name =
"AIF3 Capture",
1112 .ops = &adau1373_dai_ops,
1113 .symmetric_rates = 1,
1117 static int adau1373_set_pll(
struct snd_soc_codec *codec,
int pll_id,
1118 int source,
unsigned int freq_in,
unsigned int freq_out)
1120 unsigned int dpll_div = 0;
1149 if (freq_in < 7813 || freq_in > 27000000)
1152 if (freq_out < 45158000 || freq_out > 49152000)
1157 while (freq_in < 8000000) {
1162 if (freq_out % freq_in != 0) {
1166 r = freq_out / freq_in;
1167 i = freq_out % freq_in;
1168 j =
gcd(i, freq_in);
1175 r = freq_out / freq_in;
1182 if (r < 2 || r > 8 || x > 3 || m > 0xffff || n > 0xffff)
1186 dpll_div = 11 - dpll_div;
1196 (source << 4) | dpll_div);
1202 (r << 3) | (x << 1) | mode);
1210 static void adau1373_load_drc_settings(
struct snd_soc_codec *codec,
1243 dev_err(codec->
dev,
"failed to set cache I/O: %d\n", ret);
1251 if (!adau1373_valid_micbias(pdata->
micbias1) ||
1252 !adau1373_valid_micbias(pdata->
micbias2))
1255 for (i = 0; i < pdata->
num_drc; ++
i) {
1256 adau1373_load_drc_settings(codec, i,
1264 for (i = 0; i < 4; ++
i) {
1284 if (!lineout_differential) {
1295 static int adau1373_set_bias_level(
struct snd_soc_codec *codec,
1336 .probe = adau1373_probe,
1337 .remove = adau1373_remove,
1338 .suspend = adau1373_suspend,
1339 .resume = adau1373_resume,
1340 .set_bias_level = adau1373_set_bias_level,
1341 .idle_bias_off =
true,
1342 .reg_cache_size =
ARRAY_SIZE(adau1373_default_regs),
1343 .reg_cache_default = adau1373_default_regs,
1344 .reg_word_size =
sizeof(
uint8_t),
1350 .dapm_widgets = adau1373_dapm_widgets,
1351 .num_dapm_widgets =
ARRAY_SIZE(adau1373_dapm_widgets),
1352 .dapm_routes = adau1373_dapm_routes,
1353 .num_dapm_routes =
ARRAY_SIZE(adau1373_dapm_routes),
1359 struct adau1373 *adau1373;
1369 adau1373_dai_driver,
ARRAY_SIZE(adau1373_dai_driver));
1385 static struct i2c_driver adau1373_i2c_driver = {
1390 .probe = adau1373_i2c_probe,
1392 .id_table = adau1373_i2c_id,