diff options
-rw-r--r-- | Documentation/devicetree/bindings/sound/tda7419.txt | 38 | ||||
-rw-r--r-- | sound/soc/codecs/Kconfig | 6 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/codecs/tda7419.c | 654 | ||||
-rw-r--r-- | sound/soc/codecs/tfa9879.c | 50 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320aic23-i2c.c | 7 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320aic23-spi.c | 7 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320aic23.c | 120 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320aic26.c | 83 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320aic31xx.c | 339 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320aic31xx.h | 1 |
11 files changed, 1030 insertions, 277 deletions
diff --git a/Documentation/devicetree/bindings/sound/tda7419.txt b/Documentation/devicetree/bindings/sound/tda7419.txt new file mode 100644 index 000000000000..6b85ec38dd56 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/tda7419.txt | |||
@@ -0,0 +1,38 @@ | |||
1 | TDA7419 audio processor | ||
2 | |||
3 | This device supports I2C only. | ||
4 | |||
5 | Required properties: | ||
6 | |||
7 | - compatible : "st,tda7419" | ||
8 | - reg : the I2C address of the device. | ||
9 | - vdd-supply : a regulator spec for the common power supply (8-10V) | ||
10 | |||
11 | Optional properties: | ||
12 | |||
13 | - st,mute-gpios : a GPIO spec for the MUTE pin. | ||
14 | |||
15 | Pins on the device (for linking into audio routes): | ||
16 | |||
17 | * SE3L | ||
18 | * SE3R | ||
19 | * SE2L | ||
20 | * SE2R | ||
21 | * SE1L | ||
22 | * SE1R | ||
23 | * DIFFL | ||
24 | * DIFFR | ||
25 | * MIX | ||
26 | * OUTLF | ||
27 | * OUTRF | ||
28 | * OUTLR | ||
29 | * OUTRR | ||
30 | * OUTSW | ||
31 | |||
32 | Example: | ||
33 | |||
34 | ap: tda7419@44 { | ||
35 | compatible = "st,tda7419"; | ||
36 | reg = <0x44>; | ||
37 | vdd-supply = <&vdd_9v0_reg>; | ||
38 | }; | ||
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 0314a9faae36..9548f63ca531 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -156,6 +156,7 @@ config SND_SOC_ALL_CODECS | |||
156 | select SND_SOC_TAS571X if I2C | 156 | select SND_SOC_TAS571X if I2C |
157 | select SND_SOC_TAS5720 if I2C | 157 | select SND_SOC_TAS5720 if I2C |
158 | select SND_SOC_TAS6424 if I2C | 158 | select SND_SOC_TAS6424 if I2C |
159 | select SND_SOC_TDA7419 if I2C | ||
159 | select SND_SOC_TFA9879 if I2C | 160 | select SND_SOC_TFA9879 if I2C |
160 | select SND_SOC_TLV320AIC23_I2C if I2C | 161 | select SND_SOC_TLV320AIC23_I2C if I2C |
161 | select SND_SOC_TLV320AIC23_SPI if SPI_MASTER | 162 | select SND_SOC_TLV320AIC23_SPI if SPI_MASTER |
@@ -948,6 +949,11 @@ config SND_SOC_TAS6424 | |||
948 | Enable support for Texas Instruments TAS6424 high-efficiency | 949 | Enable support for Texas Instruments TAS6424 high-efficiency |
949 | digital input quad-channel Class-D audio power amplifiers. | 950 | digital input quad-channel Class-D audio power amplifiers. |
950 | 951 | ||
952 | config SND_SOC_TDA7419 | ||
953 | tristate "ST TDA7419 audio processor" | ||
954 | depends on I2C | ||
955 | select REGMAP_I2C | ||
956 | |||
951 | config SND_SOC_TFA9879 | 957 | config SND_SOC_TFA9879 |
952 | tristate "NXP Semiconductors TFA9879 amplifier" | 958 | tristate "NXP Semiconductors TFA9879 amplifier" |
953 | depends on I2C | 959 | depends on I2C |
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index b1654909582f..e849d1495308 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -167,6 +167,7 @@ snd-soc-tas5086-objs := tas5086.o | |||
167 | snd-soc-tas571x-objs := tas571x.o | 167 | snd-soc-tas571x-objs := tas571x.o |
168 | snd-soc-tas5720-objs := tas5720.o | 168 | snd-soc-tas5720-objs := tas5720.o |
169 | snd-soc-tas6424-objs := tas6424.o | 169 | snd-soc-tas6424-objs := tas6424.o |
170 | snd-soc-tda7419-objs := tda7419.o | ||
170 | snd-soc-tfa9879-objs := tfa9879.o | 171 | snd-soc-tfa9879-objs := tfa9879.o |
171 | snd-soc-tlv320aic23-objs := tlv320aic23.o | 172 | snd-soc-tlv320aic23-objs := tlv320aic23.o |
172 | snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o | 173 | snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o |
@@ -418,6 +419,7 @@ obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o | |||
418 | obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o | 419 | obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o |
419 | obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o | 420 | obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o |
420 | obj-$(CONFIG_SND_SOC_TAS6424) += snd-soc-tas6424.o | 421 | obj-$(CONFIG_SND_SOC_TAS6424) += snd-soc-tas6424.o |
422 | obj-$(CONFIG_SND_SOC_TDA7419) += snd-soc-tda7419.o | ||
421 | obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o | 423 | obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o |
422 | obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o | 424 | obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o |
423 | obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o | 425 | obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o |
diff --git a/sound/soc/codecs/tda7419.c b/sound/soc/codecs/tda7419.c new file mode 100644 index 000000000000..225c210ac38f --- /dev/null +++ b/sound/soc/codecs/tda7419.c | |||
@@ -0,0 +1,654 @@ | |||
1 | /* | ||
2 | * TDA7419 audio processor driver | ||
3 | * | ||
4 | * Copyright 2018 Konsulko Group | ||
5 | * | ||
6 | * Author: Matt Porter <mporter@konsulko.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * version 2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | */ | ||
17 | |||
18 | #include <linux/i2c.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/regmap.h> | ||
22 | #include <sound/core.h> | ||
23 | #include <sound/control.h> | ||
24 | #include <sound/soc.h> | ||
25 | #include <sound/tlv.h> | ||
26 | |||
27 | #define TDA7419_MAIN_SRC_REG 0x00 | ||
28 | #define TDA7419_LOUDNESS_REG 0x01 | ||
29 | #define TDA7419_MUTE_CLK_REG 0x02 | ||
30 | #define TDA7419_VOLUME_REG 0x03 | ||
31 | #define TDA7419_TREBLE_REG 0x04 | ||
32 | #define TDA7419_MIDDLE_REG 0x05 | ||
33 | #define TDA7419_BASS_REG 0x06 | ||
34 | #define TDA7419_SECOND_SRC_REG 0x07 | ||
35 | #define TDA7419_SUB_MID_BASS_REG 0x08 | ||
36 | #define TDA7419_MIXING_GAIN_REG 0x09 | ||
37 | #define TDA7419_ATTENUATOR_LF_REG 0x0a | ||
38 | #define TDA7419_ATTENUATOR_RF_REG 0x0b | ||
39 | #define TDA7419_ATTENUATOR_LR_REG 0x0c | ||
40 | #define TDA7419_ATTENUATOR_RR_REG 0x0d | ||
41 | #define TDA7419_MIXING_LEVEL_REG 0x0e | ||
42 | #define TDA7419_ATTENUATOR_SUB_REG 0x0f | ||
43 | #define TDA7419_SA_CLK_AC_REG 0x10 | ||
44 | #define TDA7419_TESTING_REG 0x11 | ||
45 | |||
46 | #define TDA7419_MAIN_SRC_SEL 0 | ||
47 | #define TDA7419_MAIN_SRC_GAIN 3 | ||
48 | #define TDA7419_MAIN_SRC_AUTOZERO 7 | ||
49 | |||
50 | #define TDA7419_LOUDNESS_ATTEN 0 | ||
51 | #define TDA7419_LOUDNESS_CENTER_FREQ 4 | ||
52 | #define TDA7419_LOUDNESS_BOOST 6 | ||
53 | #define TDA7419_LOUDNESS_SOFT_STEP 7 | ||
54 | |||
55 | #define TDA7419_VOLUME_SOFT_STEP 7 | ||
56 | |||
57 | #define TDA7419_SOFT_MUTE 0 | ||
58 | #define TDA7419_MUTE_INFLUENCE 1 | ||
59 | #define TDA7419_SOFT_MUTE_TIME 2 | ||
60 | #define TDA7419_SOFT_STEP_TIME 4 | ||
61 | #define TDA7419_CLK_FAST_MODE 7 | ||
62 | |||
63 | #define TDA7419_TREBLE_CENTER_FREQ 5 | ||
64 | #define TDA7419_REF_OUT_SELECT 7 | ||
65 | |||
66 | #define TDA7419_MIDDLE_Q_FACTOR 5 | ||
67 | #define TDA7419_MIDDLE_SOFT_STEP 7 | ||
68 | |||
69 | #define TDA7419_BASS_Q_FACTOR 5 | ||
70 | #define TDA7419_BASS_SOFT_STEP 7 | ||
71 | |||
72 | #define TDA7419_SECOND_SRC_SEL 0 | ||
73 | #define TDA7419_SECOND_SRC_GAIN 3 | ||
74 | #define TDA7419_REAR_SPKR_SRC 7 | ||
75 | |||
76 | #define TDA7419_SUB_CUT_OFF_FREQ 0 | ||
77 | #define TDA7419_MIDDLE_CENTER_FREQ 2 | ||
78 | #define TDA7419_BASS_CENTER_FREQ 4 | ||
79 | #define TDA7419_BASS_DC_MODE 6 | ||
80 | #define TDA7419_SMOOTHING_FILTER 7 | ||
81 | |||
82 | #define TDA7419_MIX_LF 0 | ||
83 | #define TDA7419_MIX_RF 1 | ||
84 | #define TDA7419_MIX_ENABLE 2 | ||
85 | #define TDA7419_SUB_ENABLE 3 | ||
86 | #define TDA7419_HPF_GAIN 4 | ||
87 | |||
88 | #define TDA7419_SA_Q_FACTOR 0 | ||
89 | #define TDA7419_RESET_MODE 1 | ||
90 | #define TDA7419_SA_SOURCE 2 | ||
91 | #define TDA7419_SA_RUN 3 | ||
92 | #define TDA7419_RESET 4 | ||
93 | #define TDA7419_CLK_SOURCE 5 | ||
94 | #define TDA7419_COUPLING_MODE 6 | ||
95 | |||
96 | struct tda7419_data { | ||
97 | struct regmap *regmap; | ||
98 | }; | ||
99 | |||
100 | static bool tda7419_readable_reg(struct device *dev, unsigned int reg) | ||
101 | { | ||
102 | return false; | ||
103 | } | ||
104 | |||
105 | static const struct reg_default tda7419_regmap_defaults[] = { | ||
106 | { TDA7419_MAIN_SRC_REG, 0xfe }, | ||
107 | { TDA7419_LOUDNESS_REG, 0xfe }, | ||
108 | { TDA7419_MUTE_CLK_REG, 0xfe }, | ||
109 | { TDA7419_VOLUME_REG, 0xfe }, | ||
110 | { TDA7419_TREBLE_REG, 0xfe }, | ||
111 | { TDA7419_MIDDLE_REG, 0xfe }, | ||
112 | { TDA7419_BASS_REG, 0xfe }, | ||
113 | { TDA7419_SECOND_SRC_REG, 0xfe }, | ||
114 | { TDA7419_SUB_MID_BASS_REG, 0xfe }, | ||
115 | { TDA7419_MIXING_GAIN_REG, 0xfe }, | ||
116 | { TDA7419_ATTENUATOR_LF_REG, 0xfe }, | ||
117 | { TDA7419_ATTENUATOR_RF_REG, 0xfe }, | ||
118 | { TDA7419_ATTENUATOR_LR_REG, 0xfe }, | ||
119 | { TDA7419_ATTENUATOR_RR_REG, 0xfe }, | ||
120 | { TDA7419_MIXING_LEVEL_REG, 0xfe }, | ||
121 | { TDA7419_ATTENUATOR_SUB_REG, 0xfe }, | ||
122 | { TDA7419_SA_CLK_AC_REG, 0xfe }, | ||
123 | { TDA7419_TESTING_REG, 0xfe }, | ||
124 | }; | ||
125 | |||
126 | static const struct regmap_config tda7419_regmap_config = { | ||
127 | .reg_bits = 8, | ||
128 | .val_bits = 8, | ||
129 | .max_register = TDA7419_TESTING_REG, | ||
130 | .cache_type = REGCACHE_RBTREE, | ||
131 | .readable_reg = tda7419_readable_reg, | ||
132 | .reg_defaults = tda7419_regmap_defaults, | ||
133 | .num_reg_defaults = ARRAY_SIZE(tda7419_regmap_defaults), | ||
134 | }; | ||
135 | |||
136 | struct tda7419_vol_control { | ||
137 | int min, max; | ||
138 | unsigned int reg, rreg, mask, thresh; | ||
139 | unsigned int invert:1; | ||
140 | }; | ||
141 | |||
142 | static inline bool tda7419_vol_is_stereo(struct tda7419_vol_control *tvc) | ||
143 | { | ||
144 | if (tvc->reg == tvc->rreg) | ||
145 | return 0; | ||
146 | |||
147 | return 1; | ||
148 | } | ||
149 | |||
150 | static int tda7419_vol_info(struct snd_kcontrol *kcontrol, | ||
151 | struct snd_ctl_elem_info *uinfo) | ||
152 | { | ||
153 | struct tda7419_vol_control *tvc = | ||
154 | (struct tda7419_vol_control *)kcontrol->private_value; | ||
155 | |||
156 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
157 | uinfo->count = tda7419_vol_is_stereo(tvc) ? 2 : 1; | ||
158 | uinfo->value.integer.min = tvc->min; | ||
159 | uinfo->value.integer.max = tvc->max; | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static inline int tda7419_vol_get_value(int val, unsigned int mask, | ||
165 | int min, int thresh, | ||
166 | unsigned int invert) | ||
167 | { | ||
168 | val &= mask; | ||
169 | if (val < thresh) { | ||
170 | if (invert) | ||
171 | val = 0 - val; | ||
172 | } else if (val > thresh) { | ||
173 | if (invert) | ||
174 | val = val - thresh; | ||
175 | else | ||
176 | val = thresh - val; | ||
177 | } | ||
178 | |||
179 | if (val < min) | ||
180 | val = min; | ||
181 | |||
182 | return val; | ||
183 | } | ||
184 | |||
185 | static int tda7419_vol_get(struct snd_kcontrol *kcontrol, | ||
186 | struct snd_ctl_elem_value *ucontrol) | ||
187 | { | ||
188 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
189 | struct tda7419_vol_control *tvc = | ||
190 | (struct tda7419_vol_control *)kcontrol->private_value; | ||
191 | unsigned int reg = tvc->reg; | ||
192 | unsigned int rreg = tvc->rreg; | ||
193 | unsigned int mask = tvc->mask; | ||
194 | int min = tvc->min; | ||
195 | int thresh = tvc->thresh; | ||
196 | unsigned int invert = tvc->invert; | ||
197 | int val; | ||
198 | int ret; | ||
199 | |||
200 | ret = snd_soc_component_read(component, reg, &val); | ||
201 | if (ret < 0) | ||
202 | return ret; | ||
203 | ucontrol->value.integer.value[0] = | ||
204 | tda7419_vol_get_value(val, mask, min, thresh, invert); | ||
205 | |||
206 | if (tda7419_vol_is_stereo(tvc)) { | ||
207 | ret = snd_soc_component_read(component, rreg, &val); | ||
208 | if (ret < 0) | ||
209 | return ret; | ||
210 | ucontrol->value.integer.value[1] = | ||
211 | tda7419_vol_get_value(val, mask, min, thresh, invert); | ||
212 | } | ||
213 | |||
214 | return 0; | ||
215 | } | ||
216 | |||
217 | static inline int tda7419_vol_put_value(int val, int thresh, | ||
218 | unsigned int invert) | ||
219 | { | ||
220 | if (val < 0) { | ||
221 | if (invert) | ||
222 | val = abs(val); | ||
223 | else | ||
224 | val = thresh - val; | ||
225 | } else if ((val > 0) && invert) { | ||
226 | val += thresh; | ||
227 | } | ||
228 | |||
229 | return val; | ||
230 | } | ||
231 | |||
232 | static int tda7419_vol_put(struct snd_kcontrol *kcontrol, | ||
233 | struct snd_ctl_elem_value *ucontrol) | ||
234 | { | ||
235 | struct snd_soc_component *component = | ||
236 | snd_kcontrol_chip(kcontrol); | ||
237 | struct tda7419_vol_control *tvc = | ||
238 | (struct tda7419_vol_control *)kcontrol->private_value; | ||
239 | unsigned int reg = tvc->reg; | ||
240 | unsigned int rreg = tvc->rreg; | ||
241 | unsigned int mask = tvc->mask; | ||
242 | int thresh = tvc->thresh; | ||
243 | unsigned int invert = tvc->invert; | ||
244 | int val; | ||
245 | int ret; | ||
246 | |||
247 | val = tda7419_vol_put_value(ucontrol->value.integer.value[0], | ||
248 | thresh, invert); | ||
249 | ret = snd_soc_component_update_bits(component, reg, | ||
250 | mask, val); | ||
251 | if (ret < 0) | ||
252 | return ret; | ||
253 | |||
254 | if (tda7419_vol_is_stereo(tvc)) { | ||
255 | val = tda7419_vol_put_value(ucontrol->value.integer.value[1], | ||
256 | thresh, invert); | ||
257 | ret = snd_soc_component_update_bits(component, rreg, | ||
258 | mask, val); | ||
259 | } | ||
260 | |||
261 | return ret; | ||
262 | } | ||
263 | |||
264 | #define TDA7419_SINGLE_VALUE(xreg, xmask, xmin, xmax, xthresh, xinvert) \ | ||
265 | ((unsigned long)&(struct tda7419_vol_control) \ | ||
266 | {.reg = xreg, .rreg = xreg, .mask = xmask, .min = xmin, \ | ||
267 | .max = xmax, .thresh = xthresh, .invert = xinvert}) | ||
268 | |||
269 | #define TDA7419_DOUBLE_R_VALUE(xregl, xregr, xmask, xmin, xmax, xthresh, \ | ||
270 | xinvert) \ | ||
271 | ((unsigned long)&(struct tda7419_vol_control) \ | ||
272 | {.reg = xregl, .rreg = xregr, .mask = xmask, .min = xmin, \ | ||
273 | .max = xmax, .thresh = xthresh, .invert = xinvert}) | ||
274 | |||
275 | #define TDA7419_SINGLE_TLV(xname, xreg, xmask, xmin, xmax, xthresh, \ | ||
276 | xinvert, xtlv_array) \ | ||
277 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
278 | .name = xname, \ | ||
279 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | ||
280 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | ||
281 | .tlv.p = (xtlv_array), \ | ||
282 | .info = tda7419_vol_info, \ | ||
283 | .get = tda7419_vol_get, \ | ||
284 | .put = tda7419_vol_put, \ | ||
285 | .private_value = TDA7419_SINGLE_VALUE(xreg, xmask, xmin, \ | ||
286 | xmax, xthresh, xinvert), \ | ||
287 | } | ||
288 | |||
289 | #define TDA7419_DOUBLE_R_TLV(xname, xregl, xregr, xmask, xmin, xmax, \ | ||
290 | xthresh, xinvert, xtlv_array) \ | ||
291 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
292 | .name = xname, \ | ||
293 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | ||
294 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | ||
295 | .tlv.p = (xtlv_array), \ | ||
296 | .info = tda7419_vol_info, \ | ||
297 | .get = tda7419_vol_get, \ | ||
298 | .put = tda7419_vol_put, \ | ||
299 | .private_value = TDA7419_DOUBLE_R_VALUE(xregl, xregr, xmask, \ | ||
300 | xmin, xmax, xthresh, \ | ||
301 | xinvert), \ | ||
302 | } | ||
303 | |||
304 | static const char * const enum_src_sel[] = { | ||
305 | "QD", "SE1", "SE2", "SE3", "SE", "Mute", "Mute", "Mute"}; | ||
306 | static SOC_ENUM_SINGLE_DECL(soc_enum_main_src_sel, | ||
307 | TDA7419_MAIN_SRC_REG, TDA7419_MAIN_SRC_SEL, enum_src_sel); | ||
308 | static const struct snd_kcontrol_new soc_mux_main_src_sel = | ||
309 | SOC_DAPM_ENUM("Main Source Select", soc_enum_main_src_sel); | ||
310 | static DECLARE_TLV_DB_SCALE(tlv_src_gain, 0, 100, 0); | ||
311 | static DECLARE_TLV_DB_SCALE(tlv_loudness_atten, -1500, 100, 0); | ||
312 | static const char * const enum_loudness_center_freq[] = { | ||
313 | "Flat", "400 Hz", "800 Hz", "2400 Hz"}; | ||
314 | static SOC_ENUM_SINGLE_DECL(soc_enum_loudness_center_freq, | ||
315 | TDA7419_LOUDNESS_REG, TDA7419_LOUDNESS_CENTER_FREQ, | ||
316 | enum_loudness_center_freq); | ||
317 | static const char * const enum_mute_influence[] = { | ||
318 | "Pin and IIC", "IIC"}; | ||
319 | static SOC_ENUM_SINGLE_DECL(soc_enum_mute_influence, | ||
320 | TDA7419_MUTE_CLK_REG, TDA7419_MUTE_INFLUENCE, enum_mute_influence); | ||
321 | static const char * const enum_soft_mute_time[] = { | ||
322 | "0.48 ms", "0.96 ms", "123 ms", "123 ms"}; | ||
323 | static SOC_ENUM_SINGLE_DECL(soc_enum_soft_mute_time, | ||
324 | TDA7419_MUTE_CLK_REG, TDA7419_SOFT_MUTE_TIME, enum_soft_mute_time); | ||
325 | static const char * const enum_soft_step_time[] = { | ||
326 | "0.160 ms", "0.321 ms", "0.642 ms", "1.28 ms", | ||
327 | "2.56 ms", "5.12 ms", "10.24 ms", "20.48 ms"}; | ||
328 | static SOC_ENUM_SINGLE_DECL(soc_enum_soft_step_time, | ||
329 | TDA7419_MUTE_CLK_REG, TDA7419_SOFT_STEP_TIME, enum_soft_step_time); | ||
330 | static DECLARE_TLV_DB_SCALE(tlv_volume, -8000, 100, 1); | ||
331 | static const char * const enum_treble_center_freq[] = { | ||
332 | "10.0 kHz", "12.5 kHz", "15.0 kHz", "17.5 kHz"}; | ||
333 | static DECLARE_TLV_DB_SCALE(tlv_filter, -1500, 100, 0); | ||
334 | static SOC_ENUM_SINGLE_DECL(soc_enum_treble_center_freq, | ||
335 | TDA7419_TREBLE_REG, TDA7419_TREBLE_CENTER_FREQ, | ||
336 | enum_treble_center_freq); | ||
337 | static const char * const enum_ref_out_select[] = { | ||
338 | "External Vref (4 V)", "Internal Vref (3.3 V)"}; | ||
339 | static SOC_ENUM_SINGLE_DECL(soc_enum_ref_out_select, | ||
340 | TDA7419_TREBLE_REG, TDA7419_REF_OUT_SELECT, enum_ref_out_select); | ||
341 | static const char * const enum_middle_q_factor[] = { | ||
342 | "0.5", "0.75", "1.0", "1.25"}; | ||
343 | static SOC_ENUM_SINGLE_DECL(soc_enum_middle_q_factor, | ||
344 | TDA7419_MIDDLE_REG, TDA7419_MIDDLE_Q_FACTOR, enum_middle_q_factor); | ||
345 | static const char * const enum_bass_q_factor[] = { | ||
346 | "1.0", "1.25", "1.5", "2.0"}; | ||
347 | static SOC_ENUM_SINGLE_DECL(soc_enum_bass_q_factor, | ||
348 | TDA7419_BASS_REG, TDA7419_BASS_Q_FACTOR, enum_bass_q_factor); | ||
349 | static SOC_ENUM_SINGLE_DECL(soc_enum_second_src_sel, | ||
350 | TDA7419_SECOND_SRC_REG, TDA7419_SECOND_SRC_SEL, enum_src_sel); | ||
351 | static const struct snd_kcontrol_new soc_mux_second_src_sel = | ||
352 | SOC_DAPM_ENUM("Second Source Select", soc_enum_second_src_sel); | ||
353 | static const char * const enum_rear_spkr_src[] = { | ||
354 | "Main", "Second"}; | ||
355 | static SOC_ENUM_SINGLE_DECL(soc_enum_rear_spkr_src, | ||
356 | TDA7419_SECOND_SRC_REG, TDA7419_REAR_SPKR_SRC, enum_rear_spkr_src); | ||
357 | static const struct snd_kcontrol_new soc_mux_rear_spkr_src = | ||
358 | SOC_DAPM_ENUM("Rear Speaker Source", soc_enum_rear_spkr_src); | ||
359 | static const char * const enum_sub_cut_off_freq[] = { | ||
360 | "Flat", "80 Hz", "120 Hz", "160 Hz"}; | ||
361 | static SOC_ENUM_SINGLE_DECL(soc_enum_sub_cut_off_freq, | ||
362 | TDA7419_SUB_MID_BASS_REG, TDA7419_SUB_CUT_OFF_FREQ, | ||
363 | enum_sub_cut_off_freq); | ||
364 | static const char * const enum_middle_center_freq[] = { | ||
365 | "500 Hz", "1000 Hz", "1500 Hz", "2500 Hz"}; | ||
366 | static SOC_ENUM_SINGLE_DECL(soc_enum_middle_center_freq, | ||
367 | TDA7419_SUB_MID_BASS_REG, TDA7419_MIDDLE_CENTER_FREQ, | ||
368 | enum_middle_center_freq); | ||
369 | static const char * const enum_bass_center_freq[] = { | ||
370 | "60 Hz", "80 Hz", "100 Hz", "200 Hz"}; | ||
371 | static SOC_ENUM_SINGLE_DECL(soc_enum_bass_center_freq, | ||
372 | TDA7419_SUB_MID_BASS_REG, TDA7419_BASS_CENTER_FREQ, | ||
373 | enum_bass_center_freq); | ||
374 | static const char * const enum_sa_q_factor[] = { | ||
375 | "3.5", "1.75" }; | ||
376 | static SOC_ENUM_SINGLE_DECL(soc_enum_sa_q_factor, | ||
377 | TDA7419_SA_CLK_AC_REG, TDA7419_SA_Q_FACTOR, enum_sa_q_factor); | ||
378 | static const char * const enum_reset_mode[] = { | ||
379 | "IIC", "Auto" }; | ||
380 | static SOC_ENUM_SINGLE_DECL(soc_enum_reset_mode, | ||
381 | TDA7419_SA_CLK_AC_REG, TDA7419_RESET_MODE, enum_reset_mode); | ||
382 | static const char * const enum_sa_src[] = { | ||
383 | "Bass", "In Gain" }; | ||
384 | static SOC_ENUM_SINGLE_DECL(soc_enum_sa_src, | ||
385 | TDA7419_SA_CLK_AC_REG, TDA7419_SA_SOURCE, enum_sa_src); | ||
386 | static const char * const enum_clk_src[] = { | ||
387 | "Internal", "External" }; | ||
388 | static SOC_ENUM_SINGLE_DECL(soc_enum_clk_src, | ||
389 | TDA7419_SA_CLK_AC_REG, TDA7419_CLK_SOURCE, enum_clk_src); | ||
390 | static const char * const enum_coupling_mode[] = { | ||
391 | "DC Coupling (without HPF)", "AC Coupling after In Gain", | ||
392 | "DC Coupling (with HPF)", "AC Coupling after Bass" }; | ||
393 | static SOC_ENUM_SINGLE_DECL(soc_enum_coupling_mode, | ||
394 | TDA7419_SA_CLK_AC_REG, TDA7419_COUPLING_MODE, enum_coupling_mode); | ||
395 | |||
396 | /* ASoC Controls */ | ||
397 | static struct snd_kcontrol_new tda7419_controls[] = { | ||
398 | SOC_SINGLE_TLV("Main Source Capture Volume", TDA7419_MAIN_SRC_REG, | ||
399 | TDA7419_MAIN_SRC_GAIN, 15, 0, tlv_src_gain), | ||
400 | SOC_SINGLE("Main Source AutoZero Switch", TDA7419_MAIN_SRC_REG, | ||
401 | TDA7419_MAIN_SRC_AUTOZERO, 1, 1), | ||
402 | SOC_SINGLE_TLV("Loudness Playback Volume", TDA7419_LOUDNESS_REG, | ||
403 | TDA7419_LOUDNESS_ATTEN, 15, 1, tlv_loudness_atten), | ||
404 | SOC_ENUM("Loudness Center Frequency", soc_enum_loudness_center_freq), | ||
405 | SOC_SINGLE("Loudness High Boost Switch", TDA7419_LOUDNESS_REG, | ||
406 | TDA7419_LOUDNESS_BOOST, 1, 1), | ||
407 | SOC_SINGLE("Loudness Soft Step Switch", TDA7419_LOUDNESS_REG, | ||
408 | TDA7419_LOUDNESS_SOFT_STEP, 1, 1), | ||
409 | SOC_SINGLE("Soft Mute Switch", TDA7419_MUTE_CLK_REG, TDA7419_SOFT_MUTE, 1, 1), | ||
410 | SOC_ENUM("Mute Influence", soc_enum_mute_influence), | ||
411 | SOC_ENUM("Soft Mute Time", soc_enum_soft_mute_time), | ||
412 | SOC_ENUM("Soft Step Time", soc_enum_soft_step_time), | ||
413 | SOC_SINGLE("Clock Fast Mode Switch", TDA7419_MUTE_CLK_REG, | ||
414 | TDA7419_CLK_FAST_MODE, 1, 1), | ||
415 | TDA7419_SINGLE_TLV("Master Playback Volume", TDA7419_VOLUME_REG, | ||
416 | 0x7f, -80, 15, 0x10, 0, tlv_volume), | ||
417 | SOC_SINGLE("Volume Soft Step Switch", TDA7419_VOLUME_REG, | ||
418 | TDA7419_VOLUME_SOFT_STEP, 1, 1), | ||
419 | TDA7419_SINGLE_TLV("Treble Playback Volume", TDA7419_TREBLE_REG, | ||
420 | 0x1f, -15, 15, 0x10, 1, tlv_filter), | ||
421 | SOC_ENUM("Treble Center Frequency", soc_enum_treble_center_freq), | ||
422 | SOC_ENUM("Reference Output Select", soc_enum_ref_out_select), | ||
423 | TDA7419_SINGLE_TLV("Middle Playback Volume", TDA7419_MIDDLE_REG, | ||
424 | 0x1f, -15, 15, 0x10, 1, tlv_filter), | ||
425 | SOC_ENUM("Middle Q Factor", soc_enum_middle_q_factor), | ||
426 | SOC_SINGLE("Middle Soft Step Switch", TDA7419_MIDDLE_REG, | ||
427 | TDA7419_MIDDLE_SOFT_STEP, 1, 1), | ||
428 | TDA7419_SINGLE_TLV("Bass Playback Volume", TDA7419_BASS_REG, | ||
429 | 0x1f, -15, 15, 0x10, 1, tlv_filter), | ||
430 | SOC_ENUM("Bass Q Factor", soc_enum_bass_q_factor), | ||
431 | SOC_SINGLE("Bass Soft Step Switch", TDA7419_BASS_REG, | ||
432 | TDA7419_BASS_SOFT_STEP, 1, 1), | ||
433 | SOC_SINGLE_TLV("Second Source Capture Volume", TDA7419_SECOND_SRC_REG, | ||
434 | TDA7419_SECOND_SRC_GAIN, 15, 0, tlv_src_gain), | ||
435 | SOC_ENUM("Subwoofer Cut-off Frequency", soc_enum_sub_cut_off_freq), | ||
436 | SOC_ENUM("Middle Center Frequency", soc_enum_middle_center_freq), | ||
437 | SOC_ENUM("Bass Center Frequency", soc_enum_bass_center_freq), | ||
438 | SOC_SINGLE("Bass DC Mode Switch", TDA7419_SUB_MID_BASS_REG, | ||
439 | TDA7419_BASS_DC_MODE, 1, 1), | ||
440 | SOC_SINGLE("Smoothing Filter Switch", TDA7419_SUB_MID_BASS_REG, | ||
441 | TDA7419_SMOOTHING_FILTER, 1, 1), | ||
442 | TDA7419_DOUBLE_R_TLV("Front Speaker Playback Volume", TDA7419_ATTENUATOR_LF_REG, | ||
443 | TDA7419_ATTENUATOR_RF_REG, 0x7f, -80, 15, 0x10, 0, | ||
444 | tlv_volume), | ||
445 | SOC_SINGLE("Left Front Soft Step Switch", TDA7419_ATTENUATOR_LF_REG, | ||
446 | TDA7419_VOLUME_SOFT_STEP, 1, 1), | ||
447 | SOC_SINGLE("Right Front Soft Step Switch", TDA7419_ATTENUATOR_RF_REG, | ||
448 | TDA7419_VOLUME_SOFT_STEP, 1, 1), | ||
449 | TDA7419_DOUBLE_R_TLV("Rear Speaker Playback Volume", TDA7419_ATTENUATOR_LR_REG, | ||
450 | TDA7419_ATTENUATOR_RR_REG, 0x7f, -80, 15, 0x10, 0, | ||
451 | tlv_volume), | ||
452 | SOC_SINGLE("Left Rear Soft Step Switch", TDA7419_ATTENUATOR_LR_REG, | ||
453 | TDA7419_VOLUME_SOFT_STEP, 1, 1), | ||
454 | SOC_SINGLE("Right Rear Soft Step Switch", TDA7419_ATTENUATOR_RR_REG, | ||
455 | TDA7419_VOLUME_SOFT_STEP, 1, 1), | ||
456 | TDA7419_SINGLE_TLV("Mixing Capture Volume", TDA7419_MIXING_LEVEL_REG, | ||
457 | 0x7f, -80, 15, 0x10, 0, tlv_volume), | ||
458 | SOC_SINGLE("Mixing Level Soft Step Switch", TDA7419_MIXING_LEVEL_REG, | ||
459 | TDA7419_VOLUME_SOFT_STEP, 1, 1), | ||
460 | TDA7419_SINGLE_TLV("Subwoofer Playback Volume", TDA7419_ATTENUATOR_SUB_REG, | ||
461 | 0x7f, -80, 15, 0x10, 0, tlv_volume), | ||
462 | SOC_SINGLE("Subwoofer Soft Step Switch", TDA7419_ATTENUATOR_SUB_REG, | ||
463 | TDA7419_VOLUME_SOFT_STEP, 1, 1), | ||
464 | SOC_ENUM("Spectrum Analyzer Q Factor", soc_enum_sa_q_factor), | ||
465 | SOC_ENUM("Spectrum Analyzer Reset Mode", soc_enum_reset_mode), | ||
466 | SOC_ENUM("Spectrum Analyzer Source", soc_enum_sa_src), | ||
467 | SOC_SINGLE("Spectrum Analyzer Run Switch", TDA7419_SA_CLK_AC_REG, | ||
468 | TDA7419_SA_RUN, 1, 1), | ||
469 | SOC_SINGLE("Spectrum Analyzer Reset Switch", TDA7419_SA_CLK_AC_REG, | ||
470 | TDA7419_RESET, 1, 1), | ||
471 | SOC_ENUM("Clock Source", soc_enum_clk_src), | ||
472 | SOC_ENUM("Coupling Mode", soc_enum_coupling_mode), | ||
473 | }; | ||
474 | |||
475 | static const struct snd_kcontrol_new soc_mixer_lf_output_controls[] = { | ||
476 | SOC_DAPM_SINGLE("Mix to LF Speaker Switch", | ||
477 | TDA7419_MIXING_GAIN_REG, | ||
478 | TDA7419_MIX_LF, 1, 1), | ||
479 | }; | ||
480 | |||
481 | static const struct snd_kcontrol_new soc_mixer_rf_output_controls[] = { | ||
482 | SOC_DAPM_SINGLE("Mix to RF Speaker Switch", | ||
483 | TDA7419_MIXING_GAIN_REG, | ||
484 | TDA7419_MIX_RF, 1, 1), | ||
485 | }; | ||
486 | |||
487 | static const struct snd_kcontrol_new soc_mix_enable_switch_controls[] = { | ||
488 | SOC_DAPM_SINGLE("Switch", TDA7419_MIXING_GAIN_REG, | ||
489 | TDA7419_MIX_ENABLE, 1, 1), | ||
490 | }; | ||
491 | |||
492 | static const struct snd_kcontrol_new soc_sub_enable_switch_controls[] = { | ||
493 | SOC_DAPM_SINGLE("Switch", TDA7419_MIXING_GAIN_REG, | ||
494 | TDA7419_MIX_ENABLE, 1, 1), | ||
495 | }; | ||
496 | |||
497 | static const struct snd_soc_dapm_widget tda7419_dapm_widgets[] = { | ||
498 | SND_SOC_DAPM_INPUT("SE3L"), | ||
499 | SND_SOC_DAPM_INPUT("SE3R"), | ||
500 | SND_SOC_DAPM_INPUT("SE2L"), | ||
501 | SND_SOC_DAPM_INPUT("SE2R"), | ||
502 | SND_SOC_DAPM_INPUT("SE1L"), | ||
503 | SND_SOC_DAPM_INPUT("SE1R"), | ||
504 | SND_SOC_DAPM_INPUT("DIFFL"), | ||
505 | SND_SOC_DAPM_INPUT("DIFFR"), | ||
506 | SND_SOC_DAPM_INPUT("MIX"), | ||
507 | |||
508 | SND_SOC_DAPM_MUX("Main Source Select", SND_SOC_NOPM, | ||
509 | 0, 0, &soc_mux_main_src_sel), | ||
510 | SND_SOC_DAPM_MUX("Second Source Select", SND_SOC_NOPM, | ||
511 | 0, 0, &soc_mux_second_src_sel), | ||
512 | SND_SOC_DAPM_MUX("Rear Speaker Source", SND_SOC_NOPM, | ||
513 | 0, 0, &soc_mux_rear_spkr_src), | ||
514 | |||
515 | SND_SOC_DAPM_SWITCH("Mix Enable", SND_SOC_NOPM, | ||
516 | 0, 0, &soc_mix_enable_switch_controls[0]), | ||
517 | SND_SOC_DAPM_MIXER_NAMED_CTL("LF Output Mixer", SND_SOC_NOPM, | ||
518 | 0, 0, &soc_mixer_lf_output_controls[0], | ||
519 | ARRAY_SIZE(soc_mixer_lf_output_controls)), | ||
520 | SND_SOC_DAPM_MIXER_NAMED_CTL("RF Output Mixer", SND_SOC_NOPM, | ||
521 | 0, 0, &soc_mixer_rf_output_controls[0], | ||
522 | ARRAY_SIZE(soc_mixer_rf_output_controls)), | ||
523 | |||
524 | SND_SOC_DAPM_SWITCH("Subwoofer Enable", | ||
525 | SND_SOC_NOPM, 0, 0, | ||
526 | &soc_sub_enable_switch_controls[0]), | ||
527 | |||
528 | SND_SOC_DAPM_OUTPUT("OUTLF"), | ||
529 | SND_SOC_DAPM_OUTPUT("OUTRF"), | ||
530 | SND_SOC_DAPM_OUTPUT("OUTLR"), | ||
531 | SND_SOC_DAPM_OUTPUT("OUTRR"), | ||
532 | SND_SOC_DAPM_OUTPUT("OUTSW"), | ||
533 | }; | ||
534 | |||
535 | static const struct snd_soc_dapm_route tda7419_dapm_routes[] = { | ||
536 | {"Main Source Select", "SE3", "SE3L"}, | ||
537 | {"Main Source Select", "SE3", "SE3R"}, | ||
538 | {"Main Source Select", "SE2", "SE2L"}, | ||
539 | {"Main Source Select", "SE2", "SE2R"}, | ||
540 | {"Main Source Select", "SE1", "SE1L"}, | ||
541 | {"Main Source Select", "SE1", "SE1R"}, | ||
542 | {"Main Source Select", "SE", "DIFFL"}, | ||
543 | {"Main Source Select", "SE", "DIFFR"}, | ||
544 | {"Main Source Select", "QD", "DIFFL"}, | ||
545 | {"Main Source Select", "QD", "DIFFR"}, | ||
546 | |||
547 | {"Second Source Select", "SE3", "SE3L"}, | ||
548 | {"Second Source Select", "SE3", "SE3R"}, | ||
549 | {"Second Source Select", "SE2", "SE2L"}, | ||
550 | {"Second Source Select", "SE2", "SE2R"}, | ||
551 | {"Second Source Select", "SE1", "SE1L"}, | ||
552 | {"Second Source Select", "SE1", "SE1R"}, | ||
553 | {"Second Source Select", "SE", "DIFFL"}, | ||
554 | {"Second Source Select", "SE", "DIFFR"}, | ||
555 | {"Second Source Select", "QD", "DIFFL"}, | ||
556 | {"Second Source Select", "QD", "DIFFR"}, | ||
557 | |||
558 | {"Rear Speaker Source", "Main", "Main Source Select"}, | ||
559 | {"Rear Speaker Source", "Second", "Second Source Select"}, | ||
560 | |||
561 | {"Subwoofer Enable", "Switch", "Main Source Select"}, | ||
562 | |||
563 | {"Mix Enable", "Switch", "MIX"}, | ||
564 | |||
565 | {"LF Output Mixer", NULL, "Main Source Select"}, | ||
566 | {"LF Output Mixer", "Mix to LF Speaker Switch", "Mix Enable"}, | ||
567 | {"RF Output Mixer", NULL, "Main Source Select"}, | ||
568 | {"RF Output Mixer", "Mix to RF Speaker Switch", "Mix Enable"}, | ||
569 | |||
570 | {"OUTLF", NULL, "LF Output Mixer"}, | ||
571 | {"OUTRF", NULL, "RF Output Mixer"}, | ||
572 | {"OUTLR", NULL, "Rear Speaker Source"}, | ||
573 | {"OUTRR", NULL, "Rear Speaker Source"}, | ||
574 | {"OUTSW", NULL, "Subwoofer Enable"}, | ||
575 | }; | ||
576 | |||
577 | static const struct snd_soc_component_driver tda7419_component_driver = { | ||
578 | .name = "tda7419", | ||
579 | .controls = tda7419_controls, | ||
580 | .num_controls = ARRAY_SIZE(tda7419_controls), | ||
581 | .dapm_widgets = tda7419_dapm_widgets, | ||
582 | .num_dapm_widgets = ARRAY_SIZE(tda7419_dapm_widgets), | ||
583 | .dapm_routes = tda7419_dapm_routes, | ||
584 | .num_dapm_routes = ARRAY_SIZE(tda7419_dapm_routes), | ||
585 | }; | ||
586 | |||
587 | static int tda7419_probe(struct i2c_client *i2c, | ||
588 | const struct i2c_device_id *id) | ||
589 | { | ||
590 | struct tda7419_data *tda7419; | ||
591 | int i, ret; | ||
592 | |||
593 | tda7419 = devm_kzalloc(&i2c->dev, | ||
594 | sizeof(struct tda7419_data), | ||
595 | GFP_KERNEL); | ||
596 | if (tda7419 == NULL) | ||
597 | return -ENOMEM; | ||
598 | |||
599 | i2c_set_clientdata(i2c, tda7419); | ||
600 | |||
601 | tda7419->regmap = devm_regmap_init_i2c(i2c, &tda7419_regmap_config); | ||
602 | if (IS_ERR(tda7419->regmap)) { | ||
603 | ret = PTR_ERR(tda7419->regmap); | ||
604 | dev_err(&i2c->dev, "error initializing regmap: %d\n", | ||
605 | ret); | ||
606 | return ret; | ||
607 | } | ||
608 | |||
609 | /* | ||
610 | * Reset registers to power-on defaults. The part does not provide a | ||
611 | * soft-reset function and the registers are not readable. This ensures | ||
612 | * that the cache matches register contents even if the registers have | ||
613 | * been previously initialized and not power cycled before probe. | ||
614 | */ | ||
615 | for (i = 0; i < ARRAY_SIZE(tda7419_regmap_defaults); i++) | ||
616 | regmap_write(tda7419->regmap, | ||
617 | tda7419_regmap_defaults[i].reg, | ||
618 | tda7419_regmap_defaults[i].def); | ||
619 | |||
620 | ret = devm_snd_soc_register_component(&i2c->dev, | ||
621 | &tda7419_component_driver, NULL, 0); | ||
622 | if (ret < 0) { | ||
623 | dev_err(&i2c->dev, "error registering component: %d\n", | ||
624 | ret); | ||
625 | } | ||
626 | |||
627 | return ret; | ||
628 | } | ||
629 | |||
630 | static const struct i2c_device_id tda7419_i2c_id[] = { | ||
631 | { "tda7419", 0 }, | ||
632 | { } | ||
633 | }; | ||
634 | MODULE_DEVICE_TABLE(i2c, tda7419_i2c_id); | ||
635 | |||
636 | static const struct of_device_id tda7419_of_match[] = { | ||
637 | { .compatible = "st,tda7419" }, | ||
638 | { }, | ||
639 | }; | ||
640 | |||
641 | static struct i2c_driver tda7419_driver = { | ||
642 | .driver = { | ||
643 | .name = "tda7419", | ||
644 | .of_match_table = tda7419_of_match, | ||
645 | }, | ||
646 | .probe = tda7419_probe, | ||
647 | .id_table = tda7419_i2c_id, | ||
648 | }; | ||
649 | |||
650 | module_i2c_driver(tda7419_driver); | ||
651 | |||
652 | MODULE_AUTHOR("Matt Porter <mporter@konsulko.com>"); | ||
653 | MODULE_DESCRIPTION("TDA7419 audio processor driver"); | ||
654 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/tfa9879.c b/sound/soc/codecs/tfa9879.c index e7ca764b5729..6d213c6d3920 100644 --- a/sound/soc/codecs/tfa9879.c +++ b/sound/soc/codecs/tfa9879.c | |||
@@ -30,8 +30,8 @@ static int tfa9879_hw_params(struct snd_pcm_substream *substream, | |||
30 | struct snd_pcm_hw_params *params, | 30 | struct snd_pcm_hw_params *params, |
31 | struct snd_soc_dai *dai) | 31 | struct snd_soc_dai *dai) |
32 | { | 32 | { |
33 | struct snd_soc_codec *codec = dai->codec; | 33 | struct snd_soc_component *component = dai->component; |
34 | struct tfa9879_priv *tfa9879 = snd_soc_codec_get_drvdata(codec); | 34 | struct tfa9879_priv *tfa9879 = snd_soc_component_get_drvdata(component); |
35 | int fs; | 35 | int fs; |
36 | int i2s_set = 0; | 36 | int i2s_set = 0; |
37 | 37 | ||
@@ -88,11 +88,11 @@ static int tfa9879_hw_params(struct snd_pcm_substream *substream, | |||
88 | } | 88 | } |
89 | 89 | ||
90 | if (tfa9879->lsb_justified) | 90 | if (tfa9879->lsb_justified) |
91 | snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1, | 91 | snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1, |
92 | TFA9879_I2S_SET_MASK, | 92 | TFA9879_I2S_SET_MASK, |
93 | i2s_set << TFA9879_I2S_SET_SHIFT); | 93 | i2s_set << TFA9879_I2S_SET_SHIFT); |
94 | 94 | ||
95 | snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1, | 95 | snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1, |
96 | TFA9879_I2S_FS_MASK, | 96 | TFA9879_I2S_FS_MASK, |
97 | fs << TFA9879_I2S_FS_SHIFT); | 97 | fs << TFA9879_I2S_FS_SHIFT); |
98 | return 0; | 98 | return 0; |
@@ -100,9 +100,9 @@ static int tfa9879_hw_params(struct snd_pcm_substream *substream, | |||
100 | 100 | ||
101 | static int tfa9879_digital_mute(struct snd_soc_dai *dai, int mute) | 101 | static int tfa9879_digital_mute(struct snd_soc_dai *dai, int mute) |
102 | { | 102 | { |
103 | struct snd_soc_codec *codec = dai->codec; | 103 | struct snd_soc_component *component = dai->component; |
104 | 104 | ||
105 | snd_soc_update_bits(codec, TFA9879_MISC_CONTROL, | 105 | snd_soc_component_update_bits(component, TFA9879_MISC_CONTROL, |
106 | TFA9879_S_MUTE_MASK, | 106 | TFA9879_S_MUTE_MASK, |
107 | !!mute << TFA9879_S_MUTE_SHIFT); | 107 | !!mute << TFA9879_S_MUTE_SHIFT); |
108 | 108 | ||
@@ -111,8 +111,8 @@ static int tfa9879_digital_mute(struct snd_soc_dai *dai, int mute) | |||
111 | 111 | ||
112 | static int tfa9879_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | 112 | static int tfa9879_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
113 | { | 113 | { |
114 | struct snd_soc_codec *codec = dai->codec; | 114 | struct snd_soc_component *component = dai->component; |
115 | struct tfa9879_priv *tfa9879 = snd_soc_codec_get_drvdata(codec); | 115 | struct tfa9879_priv *tfa9879 = snd_soc_component_get_drvdata(component); |
116 | int i2s_set; | 116 | int i2s_set; |
117 | int sck_pol; | 117 | int sck_pol; |
118 | 118 | ||
@@ -151,10 +151,10 @@ static int tfa9879_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
151 | return -EINVAL; | 151 | return -EINVAL; |
152 | } | 152 | } |
153 | 153 | ||
154 | snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1, | 154 | snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1, |
155 | TFA9879_SCK_POL_MASK, | 155 | TFA9879_SCK_POL_MASK, |
156 | sck_pol << TFA9879_SCK_POL_SHIFT); | 156 | sck_pol << TFA9879_SCK_POL_SHIFT); |
157 | snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1, | 157 | snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1, |
158 | TFA9879_I2S_SET_MASK, | 158 | TFA9879_I2S_SET_MASK, |
159 | i2s_set << TFA9879_I2S_SET_SHIFT); | 159 | i2s_set << TFA9879_I2S_SET_SHIFT); |
160 | return 0; | 160 | return 0; |
@@ -230,15 +230,17 @@ static const struct snd_soc_dapm_route tfa9879_dapm_routes[] = { | |||
230 | { "DAC", NULL, "POWER" }, | 230 | { "DAC", NULL, "POWER" }, |
231 | }; | 231 | }; |
232 | 232 | ||
233 | static const struct snd_soc_codec_driver tfa9879_codec = { | 233 | static const struct snd_soc_component_driver tfa9879_component = { |
234 | .component_driver = { | 234 | .controls = tfa9879_controls, |
235 | .controls = tfa9879_controls, | 235 | .num_controls = ARRAY_SIZE(tfa9879_controls), |
236 | .num_controls = ARRAY_SIZE(tfa9879_controls), | 236 | .dapm_widgets = tfa9879_dapm_widgets, |
237 | .dapm_widgets = tfa9879_dapm_widgets, | 237 | .num_dapm_widgets = ARRAY_SIZE(tfa9879_dapm_widgets), |
238 | .num_dapm_widgets = ARRAY_SIZE(tfa9879_dapm_widgets), | 238 | .dapm_routes = tfa9879_dapm_routes, |
239 | .dapm_routes = tfa9879_dapm_routes, | 239 | .num_dapm_routes = ARRAY_SIZE(tfa9879_dapm_routes), |
240 | .num_dapm_routes = ARRAY_SIZE(tfa9879_dapm_routes), | 240 | .idle_bias_on = 1, |
241 | }, | 241 | .use_pmdown_time = 1, |
242 | .endianness = 1, | ||
243 | .non_legacy_dai_naming = 1, | ||
242 | }; | 244 | }; |
243 | 245 | ||
244 | static const struct regmap_config tfa9879_regmap = { | 246 | static const struct regmap_config tfa9879_regmap = { |
@@ -295,17 +297,10 @@ static int tfa9879_i2c_probe(struct i2c_client *i2c, | |||
295 | regmap_write(tfa9879->regmap, | 297 | regmap_write(tfa9879->regmap, |
296 | tfa9879_regs[i].reg, tfa9879_regs[i].def); | 298 | tfa9879_regs[i].reg, tfa9879_regs[i].def); |
297 | 299 | ||
298 | return snd_soc_register_codec(&i2c->dev, &tfa9879_codec, | 300 | return devm_snd_soc_register_component(&i2c->dev, &tfa9879_component, |
299 | &tfa9879_dai, 1); | 301 | &tfa9879_dai, 1); |
300 | } | 302 | } |
301 | 303 | ||
302 | static int tfa9879_i2c_remove(struct i2c_client *client) | ||
303 | { | ||
304 | snd_soc_unregister_codec(&client->dev); | ||
305 | |||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | static const struct i2c_device_id tfa9879_i2c_id[] = { | 304 | static const struct i2c_device_id tfa9879_i2c_id[] = { |
310 | { "tfa9879", 0 }, | 305 | { "tfa9879", 0 }, |
311 | { } | 306 | { } |
@@ -324,7 +319,6 @@ static struct i2c_driver tfa9879_i2c_driver = { | |||
324 | .of_match_table = tfa9879_of_match, | 319 | .of_match_table = tfa9879_of_match, |
325 | }, | 320 | }, |
326 | .probe = tfa9879_i2c_probe, | 321 | .probe = tfa9879_i2c_probe, |
327 | .remove = tfa9879_i2c_remove, | ||
328 | .id_table = tfa9879_i2c_id, | 322 | .id_table = tfa9879_i2c_id, |
329 | }; | 323 | }; |
330 | 324 | ||
diff --git a/sound/soc/codecs/tlv320aic23-i2c.c b/sound/soc/codecs/tlv320aic23-i2c.c index 78a94af65518..1d7c117316fb 100644 --- a/sound/soc/codecs/tlv320aic23-i2c.c +++ b/sound/soc/codecs/tlv320aic23-i2c.c | |||
@@ -31,12 +31,6 @@ static int tlv320aic23_i2c_probe(struct i2c_client *i2c, | |||
31 | return tlv320aic23_probe(&i2c->dev, regmap); | 31 | return tlv320aic23_probe(&i2c->dev, regmap); |
32 | } | 32 | } |
33 | 33 | ||
34 | static int tlv320aic23_i2c_remove(struct i2c_client *i2c) | ||
35 | { | ||
36 | snd_soc_unregister_codec(&i2c->dev); | ||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | static const struct i2c_device_id tlv320aic23_id[] = { | 34 | static const struct i2c_device_id tlv320aic23_id[] = { |
41 | {"tlv320aic23", 0}, | 35 | {"tlv320aic23", 0}, |
42 | {} | 36 | {} |
@@ -56,7 +50,6 @@ static struct i2c_driver tlv320aic23_i2c_driver = { | |||
56 | .of_match_table = of_match_ptr(tlv320aic23_of_match), | 50 | .of_match_table = of_match_ptr(tlv320aic23_of_match), |
57 | }, | 51 | }, |
58 | .probe = tlv320aic23_i2c_probe, | 52 | .probe = tlv320aic23_i2c_probe, |
59 | .remove = tlv320aic23_i2c_remove, | ||
60 | .id_table = tlv320aic23_id, | 53 | .id_table = tlv320aic23_id, |
61 | }; | 54 | }; |
62 | 55 | ||
diff --git a/sound/soc/codecs/tlv320aic23-spi.c b/sound/soc/codecs/tlv320aic23-spi.c index f801ae051658..d8c9ec1e9201 100644 --- a/sound/soc/codecs/tlv320aic23-spi.c +++ b/sound/soc/codecs/tlv320aic23-spi.c | |||
@@ -34,18 +34,11 @@ static int aic23_spi_probe(struct spi_device *spi) | |||
34 | return tlv320aic23_probe(&spi->dev, regmap); | 34 | return tlv320aic23_probe(&spi->dev, regmap); |
35 | } | 35 | } |
36 | 36 | ||
37 | static int aic23_spi_remove(struct spi_device *spi) | ||
38 | { | ||
39 | snd_soc_unregister_codec(&spi->dev); | ||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | static struct spi_driver aic23_spi = { | 37 | static struct spi_driver aic23_spi = { |
44 | .driver = { | 38 | .driver = { |
45 | .name = "tlv320aic23", | 39 | .name = "tlv320aic23", |
46 | }, | 40 | }, |
47 | .probe = aic23_spi_probe, | 41 | .probe = aic23_spi_probe, |
48 | .remove = aic23_spi_remove, | ||
49 | }; | 42 | }; |
50 | 43 | ||
51 | module_spi_driver(aic23_spi); | 44 | module_spi_driver(aic23_spi); |
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 74909211c608..47480cb4d078 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c | |||
@@ -82,7 +82,7 @@ static const DECLARE_TLV_DB_SCALE(sidetone_vol_tlv, -1800, 300, 0); | |||
82 | static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, | 82 | static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, |
83 | struct snd_ctl_elem_value *ucontrol) | 83 | struct snd_ctl_elem_value *ucontrol) |
84 | { | 84 | { |
85 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 85 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
86 | u16 val, reg; | 86 | u16 val, reg; |
87 | 87 | ||
88 | val = (ucontrol->value.integer.value[0] & 0x07); | 88 | val = (ucontrol->value.integer.value[0] & 0x07); |
@@ -96,8 +96,8 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, | |||
96 | */ | 96 | */ |
97 | val = (val >= 4) ? 4 : (3 - val); | 97 | val = (val >= 4) ? 4 : (3 - val); |
98 | 98 | ||
99 | reg = snd_soc_read(codec, TLV320AIC23_ANLG) & (~0x1C0); | 99 | reg = snd_soc_component_read32(component, TLV320AIC23_ANLG) & (~0x1C0); |
100 | snd_soc_write(codec, TLV320AIC23_ANLG, reg | (val << 6)); | 100 | snd_soc_component_write(component, TLV320AIC23_ANLG, reg | (val << 6)); |
101 | 101 | ||
102 | return 0; | 102 | return 0; |
103 | } | 103 | } |
@@ -105,10 +105,10 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, | |||
105 | static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol, | 105 | static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol, |
106 | struct snd_ctl_elem_value *ucontrol) | 106 | struct snd_ctl_elem_value *ucontrol) |
107 | { | 107 | { |
108 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 108 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
109 | u16 val; | 109 | u16 val; |
110 | 110 | ||
111 | val = snd_soc_read(codec, TLV320AIC23_ANLG) & (0x1C0); | 111 | val = snd_soc_component_read32(component, TLV320AIC23_ANLG) & (0x1C0); |
112 | val = val >> 6; | 112 | val = val >> 6; |
113 | val = (val >= 4) ? 4 : (3 - val); | 113 | val = (val >= 4) ? 4 : (3 - val); |
114 | ucontrol->value.integer.value[0] = val; | 114 | ucontrol->value.integer.value[0] = val; |
@@ -296,10 +296,10 @@ static int find_rate(int mclk, u32 need_adc, u32 need_dac) | |||
296 | } | 296 | } |
297 | 297 | ||
298 | #ifdef DEBUG | 298 | #ifdef DEBUG |
299 | static void get_current_sample_rates(struct snd_soc_codec *codec, int mclk, | 299 | static void get_current_sample_rates(struct snd_soc_component *component, int mclk, |
300 | u32 *sample_rate_adc, u32 *sample_rate_dac) | 300 | u32 *sample_rate_adc, u32 *sample_rate_dac) |
301 | { | 301 | { |
302 | int src = snd_soc_read(codec, TLV320AIC23_SRATE); | 302 | int src = snd_soc_component_read32(component, TLV320AIC23_SRATE); |
303 | int sr = (src >> 2) & 0x0f; | 303 | int sr = (src >> 2) & 0x0f; |
304 | int val = (mclk / bosr_usb_divisor_table[src & 3]); | 304 | int val = (mclk / bosr_usb_divisor_table[src & 3]); |
305 | int adc = (val * sr_adc_mult_table[sr]) / SR_MULT; | 305 | int adc = (val * sr_adc_mult_table[sr]) / SR_MULT; |
@@ -313,7 +313,7 @@ static void get_current_sample_rates(struct snd_soc_codec *codec, int mclk, | |||
313 | } | 313 | } |
314 | #endif | 314 | #endif |
315 | 315 | ||
316 | static int set_sample_rate_control(struct snd_soc_codec *codec, int mclk, | 316 | static int set_sample_rate_control(struct snd_soc_component *component, int mclk, |
317 | u32 sample_rate_adc, u32 sample_rate_dac) | 317 | u32 sample_rate_adc, u32 sample_rate_dac) |
318 | { | 318 | { |
319 | /* Search for the right sample rate */ | 319 | /* Search for the right sample rate */ |
@@ -323,11 +323,11 @@ static int set_sample_rate_control(struct snd_soc_codec *codec, int mclk, | |||
323 | __func__, sample_rate_adc, sample_rate_dac); | 323 | __func__, sample_rate_adc, sample_rate_dac); |
324 | return -EINVAL; | 324 | return -EINVAL; |
325 | } | 325 | } |
326 | snd_soc_write(codec, TLV320AIC23_SRATE, data); | 326 | snd_soc_component_write(component, TLV320AIC23_SRATE, data); |
327 | #ifdef DEBUG | 327 | #ifdef DEBUG |
328 | { | 328 | { |
329 | u32 adc, dac; | 329 | u32 adc, dac; |
330 | get_current_sample_rates(codec, mclk, &adc, &dac); | 330 | get_current_sample_rates(component, mclk, &adc, &dac); |
331 | printk(KERN_DEBUG "actual samplerate = %u,%u reg=%x\n", | 331 | printk(KERN_DEBUG "actual samplerate = %u,%u reg=%x\n", |
332 | adc, dac, data); | 332 | adc, dac, data); |
333 | } | 333 | } |
@@ -339,10 +339,10 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, | |||
339 | struct snd_pcm_hw_params *params, | 339 | struct snd_pcm_hw_params *params, |
340 | struct snd_soc_dai *dai) | 340 | struct snd_soc_dai *dai) |
341 | { | 341 | { |
342 | struct snd_soc_codec *codec = dai->codec; | 342 | struct snd_soc_component *component = dai->component; |
343 | u16 iface_reg; | 343 | u16 iface_reg; |
344 | int ret; | 344 | int ret; |
345 | struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); | 345 | struct aic23 *aic23 = snd_soc_component_get_drvdata(component); |
346 | u32 sample_rate_adc = aic23->requested_adc; | 346 | u32 sample_rate_adc = aic23->requested_adc; |
347 | u32 sample_rate_dac = aic23->requested_dac; | 347 | u32 sample_rate_dac = aic23->requested_dac; |
348 | u32 sample_rate = params_rate(params); | 348 | u32 sample_rate = params_rate(params); |
@@ -356,12 +356,12 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, | |||
356 | if (!sample_rate_dac) | 356 | if (!sample_rate_dac) |
357 | sample_rate_dac = sample_rate; | 357 | sample_rate_dac = sample_rate; |
358 | } | 358 | } |
359 | ret = set_sample_rate_control(codec, aic23->mclk, sample_rate_adc, | 359 | ret = set_sample_rate_control(component, aic23->mclk, sample_rate_adc, |
360 | sample_rate_dac); | 360 | sample_rate_dac); |
361 | if (ret < 0) | 361 | if (ret < 0) |
362 | return ret; | 362 | return ret; |
363 | 363 | ||
364 | iface_reg = snd_soc_read(codec, TLV320AIC23_DIGT_FMT) & ~(0x03 << 2); | 364 | iface_reg = snd_soc_component_read32(component, TLV320AIC23_DIGT_FMT) & ~(0x03 << 2); |
365 | 365 | ||
366 | switch (params_width(params)) { | 366 | switch (params_width(params)) { |
367 | case 16: | 367 | case 16: |
@@ -376,7 +376,7 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, | |||
376 | iface_reg |= (0x03 << 2); | 376 | iface_reg |= (0x03 << 2); |
377 | break; | 377 | break; |
378 | } | 378 | } |
379 | snd_soc_write(codec, TLV320AIC23_DIGT_FMT, iface_reg); | 379 | snd_soc_component_write(component, TLV320AIC23_DIGT_FMT, iface_reg); |
380 | 380 | ||
381 | return 0; | 381 | return 0; |
382 | } | 382 | } |
@@ -384,10 +384,10 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, | |||
384 | static int tlv320aic23_pcm_prepare(struct snd_pcm_substream *substream, | 384 | static int tlv320aic23_pcm_prepare(struct snd_pcm_substream *substream, |
385 | struct snd_soc_dai *dai) | 385 | struct snd_soc_dai *dai) |
386 | { | 386 | { |
387 | struct snd_soc_codec *codec = dai->codec; | 387 | struct snd_soc_component *component = dai->component; |
388 | 388 | ||
389 | /* set active */ | 389 | /* set active */ |
390 | snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0001); | 390 | snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0001); |
391 | 391 | ||
392 | return 0; | 392 | return 0; |
393 | } | 393 | } |
@@ -395,13 +395,13 @@ static int tlv320aic23_pcm_prepare(struct snd_pcm_substream *substream, | |||
395 | static void tlv320aic23_shutdown(struct snd_pcm_substream *substream, | 395 | static void tlv320aic23_shutdown(struct snd_pcm_substream *substream, |
396 | struct snd_soc_dai *dai) | 396 | struct snd_soc_dai *dai) |
397 | { | 397 | { |
398 | struct snd_soc_codec *codec = dai->codec; | 398 | struct snd_soc_component *component = dai->component; |
399 | struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); | 399 | struct aic23 *aic23 = snd_soc_component_get_drvdata(component); |
400 | 400 | ||
401 | /* deactivate */ | 401 | /* deactivate */ |
402 | if (!snd_soc_codec_is_active(codec)) { | 402 | if (!snd_soc_component_is_active(component)) { |
403 | udelay(50); | 403 | udelay(50); |
404 | snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0); | 404 | snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0); |
405 | } | 405 | } |
406 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 406 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
407 | aic23->requested_dac = 0; | 407 | aic23->requested_dac = 0; |
@@ -411,17 +411,17 @@ static void tlv320aic23_shutdown(struct snd_pcm_substream *substream, | |||
411 | 411 | ||
412 | static int tlv320aic23_mute(struct snd_soc_dai *dai, int mute) | 412 | static int tlv320aic23_mute(struct snd_soc_dai *dai, int mute) |
413 | { | 413 | { |
414 | struct snd_soc_codec *codec = dai->codec; | 414 | struct snd_soc_component *component = dai->component; |
415 | u16 reg; | 415 | u16 reg; |
416 | 416 | ||
417 | reg = snd_soc_read(codec, TLV320AIC23_DIGT); | 417 | reg = snd_soc_component_read32(component, TLV320AIC23_DIGT); |
418 | if (mute) | 418 | if (mute) |
419 | reg |= TLV320AIC23_DACM_MUTE; | 419 | reg |= TLV320AIC23_DACM_MUTE; |
420 | 420 | ||
421 | else | 421 | else |
422 | reg &= ~TLV320AIC23_DACM_MUTE; | 422 | reg &= ~TLV320AIC23_DACM_MUTE; |
423 | 423 | ||
424 | snd_soc_write(codec, TLV320AIC23_DIGT, reg); | 424 | snd_soc_component_write(component, TLV320AIC23_DIGT, reg); |
425 | 425 | ||
426 | return 0; | 426 | return 0; |
427 | } | 427 | } |
@@ -429,10 +429,10 @@ static int tlv320aic23_mute(struct snd_soc_dai *dai, int mute) | |||
429 | static int tlv320aic23_set_dai_fmt(struct snd_soc_dai *codec_dai, | 429 | static int tlv320aic23_set_dai_fmt(struct snd_soc_dai *codec_dai, |
430 | unsigned int fmt) | 430 | unsigned int fmt) |
431 | { | 431 | { |
432 | struct snd_soc_codec *codec = codec_dai->codec; | 432 | struct snd_soc_component *component = codec_dai->component; |
433 | u16 iface_reg; | 433 | u16 iface_reg; |
434 | 434 | ||
435 | iface_reg = snd_soc_read(codec, TLV320AIC23_DIGT_FMT) & (~0x03); | 435 | iface_reg = snd_soc_component_read32(component, TLV320AIC23_DIGT_FMT) & (~0x03); |
436 | 436 | ||
437 | /* set master/slave audio interface */ | 437 | /* set master/slave audio interface */ |
438 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 438 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
@@ -468,7 +468,7 @@ static int tlv320aic23_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
468 | 468 | ||
469 | } | 469 | } |
470 | 470 | ||
471 | snd_soc_write(codec, TLV320AIC23_DIGT_FMT, iface_reg); | 471 | snd_soc_component_write(component, TLV320AIC23_DIGT_FMT, iface_reg); |
472 | 472 | ||
473 | return 0; | 473 | return 0; |
474 | } | 474 | } |
@@ -481,29 +481,29 @@ static int tlv320aic23_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
481 | return 0; | 481 | return 0; |
482 | } | 482 | } |
483 | 483 | ||
484 | static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec, | 484 | static int tlv320aic23_set_bias_level(struct snd_soc_component *component, |
485 | enum snd_soc_bias_level level) | 485 | enum snd_soc_bias_level level) |
486 | { | 486 | { |
487 | u16 reg = snd_soc_read(codec, TLV320AIC23_PWR) & 0x17f; | 487 | u16 reg = snd_soc_component_read32(component, TLV320AIC23_PWR) & 0x17f; |
488 | 488 | ||
489 | switch (level) { | 489 | switch (level) { |
490 | case SND_SOC_BIAS_ON: | 490 | case SND_SOC_BIAS_ON: |
491 | /* vref/mid, osc on, dac unmute */ | 491 | /* vref/mid, osc on, dac unmute */ |
492 | reg &= ~(TLV320AIC23_DEVICE_PWR_OFF | TLV320AIC23_OSC_OFF | \ | 492 | reg &= ~(TLV320AIC23_DEVICE_PWR_OFF | TLV320AIC23_OSC_OFF | \ |
493 | TLV320AIC23_DAC_OFF); | 493 | TLV320AIC23_DAC_OFF); |
494 | snd_soc_write(codec, TLV320AIC23_PWR, reg); | 494 | snd_soc_component_write(component, TLV320AIC23_PWR, reg); |
495 | break; | 495 | break; |
496 | case SND_SOC_BIAS_PREPARE: | 496 | case SND_SOC_BIAS_PREPARE: |
497 | break; | 497 | break; |
498 | case SND_SOC_BIAS_STANDBY: | 498 | case SND_SOC_BIAS_STANDBY: |
499 | /* everything off except vref/vmid, */ | 499 | /* everything off except vref/vmid, */ |
500 | snd_soc_write(codec, TLV320AIC23_PWR, | 500 | snd_soc_component_write(component, TLV320AIC23_PWR, |
501 | reg | TLV320AIC23_CLK_OFF); | 501 | reg | TLV320AIC23_CLK_OFF); |
502 | break; | 502 | break; |
503 | case SND_SOC_BIAS_OFF: | 503 | case SND_SOC_BIAS_OFF: |
504 | /* everything off, dac mute, inactive */ | 504 | /* everything off, dac mute, inactive */ |
505 | snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0); | 505 | snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0); |
506 | snd_soc_write(codec, TLV320AIC23_PWR, 0x1ff); | 506 | snd_soc_component_write(component, TLV320AIC23_PWR, 0x1ff); |
507 | break; | 507 | break; |
508 | } | 508 | } |
509 | return 0; | 509 | return 0; |
@@ -539,58 +539,59 @@ static struct snd_soc_dai_driver tlv320aic23_dai = { | |||
539 | .ops = &tlv320aic23_dai_ops, | 539 | .ops = &tlv320aic23_dai_ops, |
540 | }; | 540 | }; |
541 | 541 | ||
542 | static int tlv320aic23_resume(struct snd_soc_codec *codec) | 542 | static int tlv320aic23_resume(struct snd_soc_component *component) |
543 | { | 543 | { |
544 | struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); | 544 | struct aic23 *aic23 = snd_soc_component_get_drvdata(component); |
545 | regcache_mark_dirty(aic23->regmap); | 545 | regcache_mark_dirty(aic23->regmap); |
546 | regcache_sync(aic23->regmap); | 546 | regcache_sync(aic23->regmap); |
547 | 547 | ||
548 | return 0; | 548 | return 0; |
549 | } | 549 | } |
550 | 550 | ||
551 | static int tlv320aic23_codec_probe(struct snd_soc_codec *codec) | 551 | static int tlv320aic23_component_probe(struct snd_soc_component *component) |
552 | { | 552 | { |
553 | /* Reset codec */ | 553 | /* Reset codec */ |
554 | snd_soc_write(codec, TLV320AIC23_RESET, 0); | 554 | snd_soc_component_write(component, TLV320AIC23_RESET, 0); |
555 | 555 | ||
556 | snd_soc_write(codec, TLV320AIC23_DIGT, TLV320AIC23_DEEMP_44K); | 556 | snd_soc_component_write(component, TLV320AIC23_DIGT, TLV320AIC23_DEEMP_44K); |
557 | 557 | ||
558 | /* Unmute input */ | 558 | /* Unmute input */ |
559 | snd_soc_update_bits(codec, TLV320AIC23_LINVOL, | 559 | snd_soc_component_update_bits(component, TLV320AIC23_LINVOL, |
560 | TLV320AIC23_LIM_MUTED, TLV320AIC23_LRS_ENABLED); | 560 | TLV320AIC23_LIM_MUTED, TLV320AIC23_LRS_ENABLED); |
561 | 561 | ||
562 | snd_soc_update_bits(codec, TLV320AIC23_RINVOL, | 562 | snd_soc_component_update_bits(component, TLV320AIC23_RINVOL, |
563 | TLV320AIC23_LIM_MUTED, TLV320AIC23_LRS_ENABLED); | 563 | TLV320AIC23_LIM_MUTED, TLV320AIC23_LRS_ENABLED); |
564 | 564 | ||
565 | snd_soc_update_bits(codec, TLV320AIC23_ANLG, | 565 | snd_soc_component_update_bits(component, TLV320AIC23_ANLG, |
566 | TLV320AIC23_BYPASS_ON | TLV320AIC23_MICM_MUTED, | 566 | TLV320AIC23_BYPASS_ON | TLV320AIC23_MICM_MUTED, |
567 | 0); | 567 | 0); |
568 | 568 | ||
569 | /* Default output volume */ | 569 | /* Default output volume */ |
570 | snd_soc_write(codec, TLV320AIC23_LCHNVOL, | 570 | snd_soc_component_write(component, TLV320AIC23_LCHNVOL, |
571 | TLV320AIC23_DEFAULT_OUT_VOL & TLV320AIC23_OUT_VOL_MASK); | 571 | TLV320AIC23_DEFAULT_OUT_VOL & TLV320AIC23_OUT_VOL_MASK); |
572 | snd_soc_write(codec, TLV320AIC23_RCHNVOL, | 572 | snd_soc_component_write(component, TLV320AIC23_RCHNVOL, |
573 | TLV320AIC23_DEFAULT_OUT_VOL & TLV320AIC23_OUT_VOL_MASK); | 573 | TLV320AIC23_DEFAULT_OUT_VOL & TLV320AIC23_OUT_VOL_MASK); |
574 | 574 | ||
575 | snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x1); | 575 | snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x1); |
576 | 576 | ||
577 | return 0; | 577 | return 0; |
578 | } | 578 | } |
579 | 579 | ||
580 | static const struct snd_soc_codec_driver soc_codec_dev_tlv320aic23 = { | 580 | static const struct snd_soc_component_driver soc_component_dev_tlv320aic23 = { |
581 | .probe = tlv320aic23_codec_probe, | 581 | .probe = tlv320aic23_component_probe, |
582 | .resume = tlv320aic23_resume, | 582 | .resume = tlv320aic23_resume, |
583 | .set_bias_level = tlv320aic23_set_bias_level, | 583 | .set_bias_level = tlv320aic23_set_bias_level, |
584 | .suspend_bias_off = true, | 584 | .controls = tlv320aic23_snd_controls, |
585 | 585 | .num_controls = ARRAY_SIZE(tlv320aic23_snd_controls), | |
586 | .component_driver = { | 586 | .dapm_widgets = tlv320aic23_dapm_widgets, |
587 | .controls = tlv320aic23_snd_controls, | 587 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets), |
588 | .num_controls = ARRAY_SIZE(tlv320aic23_snd_controls), | 588 | .dapm_routes = tlv320aic23_intercon, |
589 | .dapm_widgets = tlv320aic23_dapm_widgets, | 589 | .num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon), |
590 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets), | 590 | .suspend_bias_off = 1, |
591 | .dapm_routes = tlv320aic23_intercon, | 591 | .idle_bias_on = 1, |
592 | .num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon), | 592 | .use_pmdown_time = 1, |
593 | }, | 593 | .endianness = 1, |
594 | .non_legacy_dai_naming = 1, | ||
594 | }; | 595 | }; |
595 | 596 | ||
596 | int tlv320aic23_probe(struct device *dev, struct regmap *regmap) | 597 | int tlv320aic23_probe(struct device *dev, struct regmap *regmap) |
@@ -608,7 +609,8 @@ int tlv320aic23_probe(struct device *dev, struct regmap *regmap) | |||
608 | 609 | ||
609 | dev_set_drvdata(dev, aic23); | 610 | dev_set_drvdata(dev, aic23); |
610 | 611 | ||
611 | return snd_soc_register_codec(dev, &soc_codec_dev_tlv320aic23, | 612 | return devm_snd_soc_register_component(dev, |
613 | &soc_component_dev_tlv320aic23, | ||
612 | &tlv320aic23_dai, 1); | 614 | &tlv320aic23_dai, 1); |
613 | } | 615 | } |
614 | EXPORT_SYMBOL(tlv320aic23_probe); | 616 | EXPORT_SYMBOL(tlv320aic23_probe); |
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 89421caaeb70..b91b8d5f1ba3 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c | |||
@@ -30,7 +30,7 @@ MODULE_LICENSE("GPL"); | |||
30 | struct aic26 { | 30 | struct aic26 { |
31 | struct spi_device *spi; | 31 | struct spi_device *spi; |
32 | struct regmap *regmap; | 32 | struct regmap *regmap; |
33 | struct snd_soc_codec *codec; | 33 | struct snd_soc_component *component; |
34 | int master; | 34 | int master; |
35 | int datfm; | 35 | int datfm; |
36 | int mclk; | 36 | int mclk; |
@@ -64,8 +64,8 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, | |||
64 | struct snd_pcm_hw_params *params, | 64 | struct snd_pcm_hw_params *params, |
65 | struct snd_soc_dai *dai) | 65 | struct snd_soc_dai *dai) |
66 | { | 66 | { |
67 | struct snd_soc_codec *codec = dai->codec; | 67 | struct snd_soc_component *component = dai->component; |
68 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | 68 | struct aic26 *aic26 = snd_soc_component_get_drvdata(component); |
69 | int fsref, divisor, wlen, pval, jval, dval, qval; | 69 | int fsref, divisor, wlen, pval, jval, dval, qval; |
70 | u16 reg; | 70 | u16 reg; |
71 | 71 | ||
@@ -112,20 +112,20 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, | |||
112 | dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval); | 112 | dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval); |
113 | qval = 0; | 113 | qval = 0; |
114 | reg = 0x8000 | qval << 11 | pval << 8 | jval << 2; | 114 | reg = 0x8000 | qval << 11 | pval << 8 | jval << 2; |
115 | snd_soc_write(codec, AIC26_REG_PLL_PROG1, reg); | 115 | snd_soc_component_write(component, AIC26_REG_PLL_PROG1, reg); |
116 | reg = dval << 2; | 116 | reg = dval << 2; |
117 | snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg); | 117 | snd_soc_component_write(component, AIC26_REG_PLL_PROG2, reg); |
118 | 118 | ||
119 | /* Audio Control 3 (master mode, fsref rate) */ | 119 | /* Audio Control 3 (master mode, fsref rate) */ |
120 | if (aic26->master) | 120 | if (aic26->master) |
121 | reg = 0x0800; | 121 | reg = 0x0800; |
122 | if (fsref == 48000) | 122 | if (fsref == 48000) |
123 | reg = 0x2000; | 123 | reg = 0x2000; |
124 | snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL3, 0xf800, reg); | 124 | snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL3, 0xf800, reg); |
125 | 125 | ||
126 | /* Audio Control 1 (FSref divisor) */ | 126 | /* Audio Control 1 (FSref divisor) */ |
127 | reg = wlen | aic26->datfm | (divisor << 3) | divisor; | 127 | reg = wlen | aic26->datfm | (divisor << 3) | divisor; |
128 | snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL1, 0xfff, reg); | 128 | snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL1, 0xfff, reg); |
129 | 129 | ||
130 | return 0; | 130 | return 0; |
131 | } | 131 | } |
@@ -135,8 +135,8 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, | |||
135 | */ | 135 | */ |
136 | static int aic26_mute(struct snd_soc_dai *dai, int mute) | 136 | static int aic26_mute(struct snd_soc_dai *dai, int mute) |
137 | { | 137 | { |
138 | struct snd_soc_codec *codec = dai->codec; | 138 | struct snd_soc_component *component = dai->component; |
139 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | 139 | struct aic26 *aic26 = snd_soc_component_get_drvdata(component); |
140 | u16 reg; | 140 | u16 reg; |
141 | 141 | ||
142 | dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", | 142 | dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", |
@@ -146,7 +146,7 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute) | |||
146 | reg = 0x8080; | 146 | reg = 0x8080; |
147 | else | 147 | else |
148 | reg = 0; | 148 | reg = 0; |
149 | snd_soc_update_bits(codec, AIC26_REG_DAC_GAIN, 0x8000, reg); | 149 | snd_soc_component_update_bits(component, AIC26_REG_DAC_GAIN, 0x8000, reg); |
150 | 150 | ||
151 | return 0; | 151 | return 0; |
152 | } | 152 | } |
@@ -154,8 +154,8 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute) | |||
154 | static int aic26_set_sysclk(struct snd_soc_dai *codec_dai, | 154 | static int aic26_set_sysclk(struct snd_soc_dai *codec_dai, |
155 | int clk_id, unsigned int freq, int dir) | 155 | int clk_id, unsigned int freq, int dir) |
156 | { | 156 | { |
157 | struct snd_soc_codec *codec = codec_dai->codec; | 157 | struct snd_soc_component *component = codec_dai->component; |
158 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | 158 | struct aic26 *aic26 = snd_soc_component_get_drvdata(component); |
159 | 159 | ||
160 | dev_dbg(&aic26->spi->dev, "aic26_set_sysclk(dai=%p, clk_id==%i," | 160 | dev_dbg(&aic26->spi->dev, "aic26_set_sysclk(dai=%p, clk_id==%i," |
161 | " freq=%i, dir=%i)\n", | 161 | " freq=%i, dir=%i)\n", |
@@ -171,8 +171,8 @@ static int aic26_set_sysclk(struct snd_soc_dai *codec_dai, | |||
171 | 171 | ||
172 | static int aic26_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | 172 | static int aic26_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
173 | { | 173 | { |
174 | struct snd_soc_codec *codec = codec_dai->codec; | 174 | struct snd_soc_component *component = codec_dai->component; |
175 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | 175 | struct aic26 *aic26 = snd_soc_component_get_drvdata(component); |
176 | 176 | ||
177 | dev_dbg(&aic26->spi->dev, "aic26_set_fmt(dai=%p, fmt==%i)\n", | 177 | dev_dbg(&aic26->spi->dev, "aic26_set_fmt(dai=%p, fmt==%i)\n", |
178 | codec_dai, fmt); | 178 | codec_dai, fmt); |
@@ -265,7 +265,7 @@ static ssize_t aic26_keyclick_show(struct device *dev, | |||
265 | struct aic26 *aic26 = dev_get_drvdata(dev); | 265 | struct aic26 *aic26 = dev_get_drvdata(dev); |
266 | int val, amp, freq, len; | 266 | int val, amp, freq, len; |
267 | 267 | ||
268 | val = snd_soc_read(aic26->codec, AIC26_REG_AUDIO_CTRL2); | 268 | val = snd_soc_component_read32(aic26->component, AIC26_REG_AUDIO_CTRL2); |
269 | amp = (val >> 12) & 0x7; | 269 | amp = (val >> 12) & 0x7; |
270 | freq = (125 << ((val >> 8) & 0x7)) >> 1; | 270 | freq = (125 << ((val >> 8) & 0x7)) >> 1; |
271 | len = 2 * (1 + ((val >> 4) & 0xf)); | 271 | len = 2 * (1 + ((val >> 4) & 0xf)); |
@@ -280,7 +280,7 @@ static ssize_t aic26_keyclick_set(struct device *dev, | |||
280 | { | 280 | { |
281 | struct aic26 *aic26 = dev_get_drvdata(dev); | 281 | struct aic26 *aic26 = dev_get_drvdata(dev); |
282 | 282 | ||
283 | snd_soc_update_bits(aic26->codec, AIC26_REG_AUDIO_CTRL2, | 283 | snd_soc_component_update_bits(aic26->component, AIC26_REG_AUDIO_CTRL2, |
284 | 0x8000, 0x800); | 284 | 0x8000, 0x800); |
285 | 285 | ||
286 | return count; | 286 | return count; |
@@ -291,44 +291,46 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set); | |||
291 | /* --------------------------------------------------------------------- | 291 | /* --------------------------------------------------------------------- |
292 | * SoC CODEC portion of driver: probe and release routines | 292 | * SoC CODEC portion of driver: probe and release routines |
293 | */ | 293 | */ |
294 | static int aic26_probe(struct snd_soc_codec *codec) | 294 | static int aic26_probe(struct snd_soc_component *component) |
295 | { | 295 | { |
296 | struct aic26 *aic26 = dev_get_drvdata(codec->dev); | 296 | struct aic26 *aic26 = dev_get_drvdata(component->dev); |
297 | int ret, reg; | 297 | int ret, reg; |
298 | 298 | ||
299 | aic26->codec = codec; | 299 | aic26->component = component; |
300 | 300 | ||
301 | /* Reset the codec to power on defaults */ | 301 | /* Reset the codec to power on defaults */ |
302 | snd_soc_write(codec, AIC26_REG_RESET, 0xBB00); | 302 | snd_soc_component_write(component, AIC26_REG_RESET, 0xBB00); |
303 | 303 | ||
304 | /* Power up CODEC */ | 304 | /* Power up CODEC */ |
305 | snd_soc_write(codec, AIC26_REG_POWER_CTRL, 0); | 305 | snd_soc_component_write(component, AIC26_REG_POWER_CTRL, 0); |
306 | 306 | ||
307 | /* Audio Control 3 (master mode, fsref rate) */ | 307 | /* Audio Control 3 (master mode, fsref rate) */ |
308 | reg = snd_soc_read(codec, AIC26_REG_AUDIO_CTRL3); | 308 | reg = snd_soc_component_read32(component, AIC26_REG_AUDIO_CTRL3); |
309 | reg &= ~0xf800; | 309 | reg &= ~0xf800; |
310 | reg |= 0x0800; /* set master mode */ | 310 | reg |= 0x0800; /* set master mode */ |
311 | snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); | 311 | snd_soc_component_write(component, AIC26_REG_AUDIO_CTRL3, reg); |
312 | 312 | ||
313 | /* Register the sysfs files for debugging */ | 313 | /* Register the sysfs files for debugging */ |
314 | /* Create SysFS files */ | 314 | /* Create SysFS files */ |
315 | ret = device_create_file(codec->dev, &dev_attr_keyclick); | 315 | ret = device_create_file(component->dev, &dev_attr_keyclick); |
316 | if (ret) | 316 | if (ret) |
317 | dev_info(codec->dev, "error creating sysfs files\n"); | 317 | dev_info(component->dev, "error creating sysfs files\n"); |
318 | 318 | ||
319 | return 0; | 319 | return 0; |
320 | } | 320 | } |
321 | 321 | ||
322 | static const struct snd_soc_codec_driver aic26_soc_codec_dev = { | 322 | static const struct snd_soc_component_driver aic26_soc_component_dev = { |
323 | .probe = aic26_probe, | 323 | .probe = aic26_probe, |
324 | .component_driver = { | 324 | .controls = aic26_snd_controls, |
325 | .controls = aic26_snd_controls, | 325 | .num_controls = ARRAY_SIZE(aic26_snd_controls), |
326 | .num_controls = ARRAY_SIZE(aic26_snd_controls), | 326 | .dapm_widgets = tlv320aic26_dapm_widgets, |
327 | .dapm_widgets = tlv320aic26_dapm_widgets, | 327 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), |
328 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), | 328 | .dapm_routes = tlv320aic26_dapm_routes, |
329 | .dapm_routes = tlv320aic26_dapm_routes, | 329 | .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), |
330 | .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), | 330 | .idle_bias_on = 1, |
331 | }, | 331 | .use_pmdown_time = 1, |
332 | .endianness = 1, | ||
333 | .non_legacy_dai_naming = 1, | ||
332 | }; | 334 | }; |
333 | 335 | ||
334 | static const struct regmap_config aic26_regmap = { | 336 | static const struct regmap_config aic26_regmap = { |
@@ -361,23 +363,16 @@ static int aic26_spi_probe(struct spi_device *spi) | |||
361 | dev_set_drvdata(&spi->dev, aic26); | 363 | dev_set_drvdata(&spi->dev, aic26); |
362 | aic26->master = 1; | 364 | aic26->master = 1; |
363 | 365 | ||
364 | ret = snd_soc_register_codec(&spi->dev, | 366 | ret = devm_snd_soc_register_component(&spi->dev, |
365 | &aic26_soc_codec_dev, &aic26_dai, 1); | 367 | &aic26_soc_component_dev, &aic26_dai, 1); |
366 | return ret; | 368 | return ret; |
367 | } | 369 | } |
368 | 370 | ||
369 | static int aic26_spi_remove(struct spi_device *spi) | ||
370 | { | ||
371 | snd_soc_unregister_codec(&spi->dev); | ||
372 | return 0; | ||
373 | } | ||
374 | |||
375 | static struct spi_driver aic26_spi = { | 371 | static struct spi_driver aic26_spi = { |
376 | .driver = { | 372 | .driver = { |
377 | .name = "tlv320aic26-codec", | 373 | .name = "tlv320aic26-codec", |
378 | }, | 374 | }, |
379 | .probe = aic26_spi_probe, | 375 | .probe = aic26_spi_probe, |
380 | .remove = aic26_spi_remove, | ||
381 | }; | 376 | }; |
382 | 377 | ||
383 | module_spi_driver(aic26_spi); | 378 | module_spi_driver(aic26_spi); |
diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index 858cb8be445f..bf92d36b8f8a 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c | |||
@@ -153,7 +153,7 @@ struct aic31xx_disable_nb { | |||
153 | }; | 153 | }; |
154 | 154 | ||
155 | struct aic31xx_priv { | 155 | struct aic31xx_priv { |
156 | struct snd_soc_codec *codec; | 156 | struct snd_soc_component *component; |
157 | u8 i2c_regs_status; | 157 | u8 i2c_regs_status; |
158 | struct device *dev; | 158 | struct device *dev; |
159 | struct regmap *regmap; | 159 | struct regmap *regmap; |
@@ -166,6 +166,7 @@ struct aic31xx_priv { | |||
166 | unsigned int sysclk; | 166 | unsigned int sysclk; |
167 | u8 p_div; | 167 | u8 p_div; |
168 | int rate_div_line; | 168 | int rate_div_line; |
169 | bool master_dapm_route_applied; | ||
169 | }; | 170 | }; |
170 | 171 | ||
171 | struct aic31xx_rate_divs { | 172 | struct aic31xx_rate_divs { |
@@ -348,8 +349,8 @@ static int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg, | |||
348 | static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, | 349 | static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, |
349 | struct snd_kcontrol *kcontrol, int event) | 350 | struct snd_kcontrol *kcontrol, int event) |
350 | { | 351 | { |
351 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 352 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
352 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 353 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
353 | unsigned int reg = AIC31XX_DACFLAG1; | 354 | unsigned int reg = AIC31XX_DACFLAG1; |
354 | unsigned int mask; | 355 | unsigned int mask; |
355 | 356 | ||
@@ -377,7 +378,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, | |||
377 | reg = AIC31XX_ADCFLAG; | 378 | reg = AIC31XX_ADCFLAG; |
378 | break; | 379 | break; |
379 | default: | 380 | default: |
380 | dev_err(codec->dev, "Unknown widget '%s' calling %s\n", | 381 | dev_err(component->dev, "Unknown widget '%s' calling %s\n", |
381 | w->name, __func__); | 382 | w->name, __func__); |
382 | return -EINVAL; | 383 | return -EINVAL; |
383 | } | 384 | } |
@@ -388,7 +389,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, | |||
388 | case SND_SOC_DAPM_POST_PMD: | 389 | case SND_SOC_DAPM_POST_PMD: |
389 | return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100); | 390 | return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100); |
390 | default: | 391 | default: |
391 | dev_dbg(codec->dev, | 392 | dev_dbg(component->dev, |
392 | "Unhandled dapm widget event %d from %s\n", | 393 | "Unhandled dapm widget event %d from %s\n", |
393 | event, w->name); | 394 | event, w->name); |
394 | } | 395 | } |
@@ -444,30 +445,30 @@ static const struct snd_kcontrol_new aic31xx_dapm_spr_switch = | |||
444 | static int mic_bias_event(struct snd_soc_dapm_widget *w, | 445 | static int mic_bias_event(struct snd_soc_dapm_widget *w, |
445 | struct snd_kcontrol *kcontrol, int event) | 446 | struct snd_kcontrol *kcontrol, int event) |
446 | { | 447 | { |
447 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 448 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
448 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 449 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
449 | 450 | ||
450 | switch (event) { | 451 | switch (event) { |
451 | case SND_SOC_DAPM_POST_PMU: | 452 | case SND_SOC_DAPM_POST_PMU: |
452 | /* change mic bias voltage to user defined */ | 453 | /* change mic bias voltage to user defined */ |
453 | snd_soc_update_bits(codec, AIC31XX_MICBIAS, | 454 | snd_soc_component_update_bits(component, AIC31XX_MICBIAS, |
454 | AIC31XX_MICBIAS_MASK, | 455 | AIC31XX_MICBIAS_MASK, |
455 | aic31xx->micbias_vg << | 456 | aic31xx->micbias_vg << |
456 | AIC31XX_MICBIAS_SHIFT); | 457 | AIC31XX_MICBIAS_SHIFT); |
457 | dev_dbg(codec->dev, "%s: turned on\n", __func__); | 458 | dev_dbg(component->dev, "%s: turned on\n", __func__); |
458 | break; | 459 | break; |
459 | case SND_SOC_DAPM_PRE_PMD: | 460 | case SND_SOC_DAPM_PRE_PMD: |
460 | /* turn mic bias off */ | 461 | /* turn mic bias off */ |
461 | snd_soc_update_bits(codec, AIC31XX_MICBIAS, | 462 | snd_soc_component_update_bits(component, AIC31XX_MICBIAS, |
462 | AIC31XX_MICBIAS_MASK, 0); | 463 | AIC31XX_MICBIAS_MASK, 0); |
463 | dev_dbg(codec->dev, "%s: turned off\n", __func__); | 464 | dev_dbg(component->dev, "%s: turned off\n", __func__); |
464 | break; | 465 | break; |
465 | } | 466 | } |
466 | return 0; | 467 | return 0; |
467 | } | 468 | } |
468 | 469 | ||
469 | static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = { | 470 | static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = { |
470 | SND_SOC_DAPM_AIF_IN("DAC IN", "DAC Playback", 0, SND_SOC_NOPM, 0, 0), | 471 | SND_SOC_DAPM_AIF_IN("AIF IN", "Playback", 0, SND_SOC_NOPM, 0, 0), |
471 | 472 | ||
472 | SND_SOC_DAPM_MUX("DAC Left Input", | 473 | SND_SOC_DAPM_MUX("DAC Left Input", |
473 | SND_SOC_NOPM, 0, 0, &ldac_in_control), | 474 | SND_SOC_NOPM, 0, 0, &ldac_in_control), |
@@ -500,6 +501,10 @@ static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = { | |||
500 | SND_SOC_DAPM_SUPPLY("MICBIAS", SND_SOC_NOPM, 0, 0, mic_bias_event, | 501 | SND_SOC_DAPM_SUPPLY("MICBIAS", SND_SOC_NOPM, 0, 0, mic_bias_event, |
501 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), | 502 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), |
502 | 503 | ||
504 | /* Keep BCLK/WCLK enabled even if DAC/ADC is powered down */ | ||
505 | SND_SOC_DAPM_SUPPLY("Activate I2S clocks", AIC31XX_IFACE2, 2, 0, | ||
506 | NULL, 0), | ||
507 | |||
503 | /* Outputs */ | 508 | /* Outputs */ |
504 | SND_SOC_DAPM_OUTPUT("HPL"), | 509 | SND_SOC_DAPM_OUTPUT("HPL"), |
505 | SND_SOC_DAPM_OUTPUT("HPR"), | 510 | SND_SOC_DAPM_OUTPUT("HPR"), |
@@ -552,6 +557,8 @@ static const struct snd_soc_dapm_widget aic31xx_dapm_widgets[] = { | |||
552 | SND_SOC_DAPM_MIXER("Output Right", SND_SOC_NOPM, 0, 0, | 557 | SND_SOC_DAPM_MIXER("Output Right", SND_SOC_NOPM, 0, 0, |
553 | aic31xx_right_output_switches, | 558 | aic31xx_right_output_switches, |
554 | ARRAY_SIZE(aic31xx_right_output_switches)), | 559 | ARRAY_SIZE(aic31xx_right_output_switches)), |
560 | |||
561 | SND_SOC_DAPM_AIF_OUT("AIF OUT", "Capture", 0, SND_SOC_NOPM, 0, 0), | ||
555 | }; | 562 | }; |
556 | 563 | ||
557 | static const struct snd_soc_dapm_widget aic311x_dapm_widgets[] = { | 564 | static const struct snd_soc_dapm_widget aic311x_dapm_widgets[] = { |
@@ -583,12 +590,12 @@ static const struct snd_soc_dapm_widget aic310x_dapm_widgets[] = { | |||
583 | static const struct snd_soc_dapm_route | 590 | static const struct snd_soc_dapm_route |
584 | common31xx_audio_map[] = { | 591 | common31xx_audio_map[] = { |
585 | /* DAC Input Routing */ | 592 | /* DAC Input Routing */ |
586 | {"DAC Left Input", "Left Data", "DAC IN"}, | 593 | {"DAC Left Input", "Left Data", "AIF IN"}, |
587 | {"DAC Left Input", "Right Data", "DAC IN"}, | 594 | {"DAC Left Input", "Right Data", "AIF IN"}, |
588 | {"DAC Left Input", "Mono", "DAC IN"}, | 595 | {"DAC Left Input", "Mono", "AIF IN"}, |
589 | {"DAC Right Input", "Left Data", "DAC IN"}, | 596 | {"DAC Right Input", "Left Data", "AIF IN"}, |
590 | {"DAC Right Input", "Right Data", "DAC IN"}, | 597 | {"DAC Right Input", "Right Data", "AIF IN"}, |
591 | {"DAC Right Input", "Mono", "DAC IN"}, | 598 | {"DAC Right Input", "Mono", "AIF IN"}, |
592 | {"DAC Left", NULL, "DAC Left Input"}, | 599 | {"DAC Left", NULL, "DAC Left Input"}, |
593 | {"DAC Right", NULL, "DAC Right Input"}, | 600 | {"DAC Right", NULL, "DAC Right Input"}, |
594 | 601 | ||
@@ -639,6 +646,8 @@ aic31xx_audio_map[] = { | |||
639 | 646 | ||
640 | {"ADC", NULL, "MIC_GAIN_CTL"}, | 647 | {"ADC", NULL, "MIC_GAIN_CTL"}, |
641 | 648 | ||
649 | {"AIF OUT", NULL, "ADC"}, | ||
650 | |||
642 | /* Left Output */ | 651 | /* Left Output */ |
643 | {"Output Left", "From Left DAC", "DAC Left"}, | 652 | {"Output Left", "From Left DAC", "DAC Left"}, |
644 | {"Output Left", "From MIC1LP", "MIC1LP"}, | 653 | {"Output Left", "From MIC1LP", "MIC1LP"}, |
@@ -670,34 +679,61 @@ aic310x_audio_map[] = { | |||
670 | {"SPK", NULL, "SPK ClassD"}, | 679 | {"SPK", NULL, "SPK ClassD"}, |
671 | }; | 680 | }; |
672 | 681 | ||
673 | static int aic31xx_add_controls(struct snd_soc_codec *codec) | 682 | /* |
683 | * Always connected DAPM routes for codec clock master modes. | ||
684 | * If the codec is the master on the I2S bus, we need to power up components | ||
685 | * to have valid DAC_CLK. | ||
686 | * | ||
687 | * In order to have the I2S clocks on the bus either the DACs/ADC need to be | ||
688 | * enabled, or the P0/R29/D2 (Keep bclk/wclk in power down) need to be set. | ||
689 | * | ||
690 | * Otherwise the codec will not generate clocks on the bus. | ||
691 | */ | ||
692 | static const struct snd_soc_dapm_route | ||
693 | common31xx_cm_audio_map[] = { | ||
694 | {"HPL", NULL, "AIF IN"}, | ||
695 | {"HPR", NULL, "AIF IN"}, | ||
696 | |||
697 | {"AIF IN", NULL, "Activate I2S clocks"}, | ||
698 | }; | ||
699 | |||
700 | static const struct snd_soc_dapm_route | ||
701 | aic31xx_cm_audio_map[] = { | ||
702 | {"AIF OUT", NULL, "MIC1LP"}, | ||
703 | {"AIF OUT", NULL, "MIC1RP"}, | ||
704 | {"AIF OUT", NULL, "MIC1LM"}, | ||
705 | |||
706 | {"AIF OUT", NULL, "Activate I2S clocks"}, | ||
707 | }; | ||
708 | |||
709 | static int aic31xx_add_controls(struct snd_soc_component *component) | ||
674 | { | 710 | { |
675 | int ret = 0; | 711 | int ret = 0; |
676 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 712 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
677 | 713 | ||
678 | if (!(aic31xx->codec_type & DAC31XX_BIT)) | 714 | if (!(aic31xx->codec_type & DAC31XX_BIT)) |
679 | ret = snd_soc_add_codec_controls( | 715 | ret = snd_soc_add_component_controls( |
680 | codec, aic31xx_snd_controls, | 716 | component, aic31xx_snd_controls, |
681 | ARRAY_SIZE(aic31xx_snd_controls)); | 717 | ARRAY_SIZE(aic31xx_snd_controls)); |
682 | if (ret) | 718 | if (ret) |
683 | return ret; | 719 | return ret; |
684 | 720 | ||
685 | if (aic31xx->codec_type & AIC31XX_STEREO_CLASS_D_BIT) | 721 | if (aic31xx->codec_type & AIC31XX_STEREO_CLASS_D_BIT) |
686 | ret = snd_soc_add_codec_controls( | 722 | ret = snd_soc_add_component_controls( |
687 | codec, aic311x_snd_controls, | 723 | component, aic311x_snd_controls, |
688 | ARRAY_SIZE(aic311x_snd_controls)); | 724 | ARRAY_SIZE(aic311x_snd_controls)); |
689 | else | 725 | else |
690 | ret = snd_soc_add_codec_controls( | 726 | ret = snd_soc_add_component_controls( |
691 | codec, aic310x_snd_controls, | 727 | component, aic310x_snd_controls, |
692 | ARRAY_SIZE(aic310x_snd_controls)); | 728 | ARRAY_SIZE(aic310x_snd_controls)); |
693 | 729 | ||
694 | return ret; | 730 | return ret; |
695 | } | 731 | } |
696 | 732 | ||
697 | static int aic31xx_add_widgets(struct snd_soc_codec *codec) | 733 | static int aic31xx_add_widgets(struct snd_soc_component *component) |
698 | { | 734 | { |
699 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | 735 | struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); |
700 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 736 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
701 | int ret = 0; | 737 | int ret = 0; |
702 | 738 | ||
703 | if (aic31xx->codec_type & DAC31XX_BIT) { | 739 | if (aic31xx->codec_type & DAC31XX_BIT) { |
@@ -751,10 +787,10 @@ static int aic31xx_add_widgets(struct snd_soc_codec *codec) | |||
751 | return 0; | 787 | return 0; |
752 | } | 788 | } |
753 | 789 | ||
754 | static int aic31xx_setup_pll(struct snd_soc_codec *codec, | 790 | static int aic31xx_setup_pll(struct snd_soc_component *component, |
755 | struct snd_pcm_hw_params *params) | 791 | struct snd_pcm_hw_params *params) |
756 | { | 792 | { |
757 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 793 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
758 | int bclk_score = snd_soc_params_to_frame_size(params); | 794 | int bclk_score = snd_soc_params_to_frame_size(params); |
759 | int mclk_p; | 795 | int mclk_p; |
760 | int bclk_n = 0; | 796 | int bclk_n = 0; |
@@ -762,15 +798,15 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec, | |||
762 | int i; | 798 | int i; |
763 | 799 | ||
764 | if (!aic31xx->sysclk || !aic31xx->p_div) { | 800 | if (!aic31xx->sysclk || !aic31xx->p_div) { |
765 | dev_err(codec->dev, "Master clock not supplied\n"); | 801 | dev_err(component->dev, "Master clock not supplied\n"); |
766 | return -EINVAL; | 802 | return -EINVAL; |
767 | } | 803 | } |
768 | mclk_p = aic31xx->sysclk / aic31xx->p_div; | 804 | mclk_p = aic31xx->sysclk / aic31xx->p_div; |
769 | 805 | ||
770 | /* Use PLL as CODEC_CLKIN and DAC_CLK as BDIV_CLKIN */ | 806 | /* Use PLL as CODEC_CLKIN and DAC_CLK as BDIV_CLKIN */ |
771 | snd_soc_update_bits(codec, AIC31XX_CLKMUX, | 807 | snd_soc_component_update_bits(component, AIC31XX_CLKMUX, |
772 | AIC31XX_CODEC_CLKIN_MASK, AIC31XX_CODEC_CLKIN_PLL); | 808 | AIC31XX_CODEC_CLKIN_MASK, AIC31XX_CODEC_CLKIN_PLL); |
773 | snd_soc_update_bits(codec, AIC31XX_IFACE2, | 809 | snd_soc_component_update_bits(component, AIC31XX_IFACE2, |
774 | AIC31XX_BDIVCLK_MASK, AIC31XX_DAC2BCLK); | 810 | AIC31XX_BDIVCLK_MASK, AIC31XX_DAC2BCLK); |
775 | 811 | ||
776 | for (i = 0; i < ARRAY_SIZE(aic31xx_divs); i++) { | 812 | for (i = 0; i < ARRAY_SIZE(aic31xx_divs); i++) { |
@@ -789,14 +825,14 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec, | |||
789 | } | 825 | } |
790 | 826 | ||
791 | if (match == -1) { | 827 | if (match == -1) { |
792 | dev_err(codec->dev, | 828 | dev_err(component->dev, |
793 | "%s: Sample rate (%u) and format not supported\n", | 829 | "%s: Sample rate (%u) and format not supported\n", |
794 | __func__, params_rate(params)); | 830 | __func__, params_rate(params)); |
795 | /* See bellow for details how fix this. */ | 831 | /* See bellow for details how fix this. */ |
796 | return -EINVAL; | 832 | return -EINVAL; |
797 | } | 833 | } |
798 | if (bclk_score != 0) { | 834 | if (bclk_score != 0) { |
799 | dev_warn(codec->dev, "Can not produce exact bitclock"); | 835 | dev_warn(component->dev, "Can not produce exact bitclock"); |
800 | /* This is fine if using dsp format, but if using i2s | 836 | /* This is fine if using dsp format, but if using i2s |
801 | there may be trouble. To fix the issue edit the | 837 | there may be trouble. To fix the issue edit the |
802 | aic31xx_divs table for your mclk and sample | 838 | aic31xx_divs table for your mclk and sample |
@@ -808,39 +844,39 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec, | |||
808 | i = match; | 844 | i = match; |
809 | 845 | ||
810 | /* PLL configuration */ | 846 | /* PLL configuration */ |
811 | snd_soc_update_bits(codec, AIC31XX_PLLPR, AIC31XX_PLL_MASK, | 847 | snd_soc_component_update_bits(component, AIC31XX_PLLPR, AIC31XX_PLL_MASK, |
812 | (aic31xx->p_div << 4) | 0x01); | 848 | (aic31xx->p_div << 4) | 0x01); |
813 | snd_soc_write(codec, AIC31XX_PLLJ, aic31xx_divs[i].pll_j); | 849 | snd_soc_component_write(component, AIC31XX_PLLJ, aic31xx_divs[i].pll_j); |
814 | 850 | ||
815 | snd_soc_write(codec, AIC31XX_PLLDMSB, | 851 | snd_soc_component_write(component, AIC31XX_PLLDMSB, |
816 | aic31xx_divs[i].pll_d >> 8); | 852 | aic31xx_divs[i].pll_d >> 8); |
817 | snd_soc_write(codec, AIC31XX_PLLDLSB, | 853 | snd_soc_component_write(component, AIC31XX_PLLDLSB, |
818 | aic31xx_divs[i].pll_d & 0xff); | 854 | aic31xx_divs[i].pll_d & 0xff); |
819 | 855 | ||
820 | /* DAC dividers configuration */ | 856 | /* DAC dividers configuration */ |
821 | snd_soc_update_bits(codec, AIC31XX_NDAC, AIC31XX_PLL_MASK, | 857 | snd_soc_component_update_bits(component, AIC31XX_NDAC, AIC31XX_PLL_MASK, |
822 | aic31xx_divs[i].ndac); | 858 | aic31xx_divs[i].ndac); |
823 | snd_soc_update_bits(codec, AIC31XX_MDAC, AIC31XX_PLL_MASK, | 859 | snd_soc_component_update_bits(component, AIC31XX_MDAC, AIC31XX_PLL_MASK, |
824 | aic31xx_divs[i].mdac); | 860 | aic31xx_divs[i].mdac); |
825 | 861 | ||
826 | snd_soc_write(codec, AIC31XX_DOSRMSB, aic31xx_divs[i].dosr >> 8); | 862 | snd_soc_component_write(component, AIC31XX_DOSRMSB, aic31xx_divs[i].dosr >> 8); |
827 | snd_soc_write(codec, AIC31XX_DOSRLSB, aic31xx_divs[i].dosr & 0xff); | 863 | snd_soc_component_write(component, AIC31XX_DOSRLSB, aic31xx_divs[i].dosr & 0xff); |
828 | 864 | ||
829 | /* ADC dividers configuration. Write reset value 1 if not used. */ | 865 | /* ADC dividers configuration. Write reset value 1 if not used. */ |
830 | snd_soc_update_bits(codec, AIC31XX_NADC, AIC31XX_PLL_MASK, | 866 | snd_soc_component_update_bits(component, AIC31XX_NADC, AIC31XX_PLL_MASK, |
831 | aic31xx_divs[i].nadc ? aic31xx_divs[i].nadc : 1); | 867 | aic31xx_divs[i].nadc ? aic31xx_divs[i].nadc : 1); |
832 | snd_soc_update_bits(codec, AIC31XX_MADC, AIC31XX_PLL_MASK, | 868 | snd_soc_component_update_bits(component, AIC31XX_MADC, AIC31XX_PLL_MASK, |
833 | aic31xx_divs[i].madc ? aic31xx_divs[i].madc : 1); | 869 | aic31xx_divs[i].madc ? aic31xx_divs[i].madc : 1); |
834 | 870 | ||
835 | snd_soc_write(codec, AIC31XX_AOSR, aic31xx_divs[i].aosr); | 871 | snd_soc_component_write(component, AIC31XX_AOSR, aic31xx_divs[i].aosr); |
836 | 872 | ||
837 | /* Bit clock divider configuration. */ | 873 | /* Bit clock divider configuration. */ |
838 | snd_soc_update_bits(codec, AIC31XX_BCLKN, | 874 | snd_soc_component_update_bits(component, AIC31XX_BCLKN, |
839 | AIC31XX_PLL_MASK, bclk_n); | 875 | AIC31XX_PLL_MASK, bclk_n); |
840 | 876 | ||
841 | aic31xx->rate_div_line = i; | 877 | aic31xx->rate_div_line = i; |
842 | 878 | ||
843 | dev_dbg(codec->dev, | 879 | dev_dbg(component->dev, |
844 | "pll %d.%04d/%d dosr %d n %d m %d aosr %d n %d m %d bclk_n %d\n", | 880 | "pll %d.%04d/%d dosr %d n %d m %d aosr %d n %d m %d bclk_n %d\n", |
845 | aic31xx_divs[i].pll_j, | 881 | aic31xx_divs[i].pll_j, |
846 | aic31xx_divs[i].pll_d, | 882 | aic31xx_divs[i].pll_d, |
@@ -861,10 +897,10 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, | |||
861 | struct snd_pcm_hw_params *params, | 897 | struct snd_pcm_hw_params *params, |
862 | struct snd_soc_dai *dai) | 898 | struct snd_soc_dai *dai) |
863 | { | 899 | { |
864 | struct snd_soc_codec *codec = dai->codec; | 900 | struct snd_soc_component *component = dai->component; |
865 | u8 data = 0; | 901 | u8 data = 0; |
866 | 902 | ||
867 | dev_dbg(codec->dev, "## %s: width %d rate %d\n", | 903 | dev_dbg(component->dev, "## %s: width %d rate %d\n", |
868 | __func__, params_width(params), | 904 | __func__, params_width(params), |
869 | params_rate(params)); | 905 | params_rate(params)); |
870 | 906 | ||
@@ -884,43 +920,90 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, | |||
884 | AIC31XX_IFACE1_DATALEN_SHIFT); | 920 | AIC31XX_IFACE1_DATALEN_SHIFT); |
885 | break; | 921 | break; |
886 | default: | 922 | default: |
887 | dev_err(codec->dev, "%s: Unsupported width %d\n", | 923 | dev_err(component->dev, "%s: Unsupported width %d\n", |
888 | __func__, params_width(params)); | 924 | __func__, params_width(params)); |
889 | return -EINVAL; | 925 | return -EINVAL; |
890 | } | 926 | } |
891 | 927 | ||
892 | snd_soc_update_bits(codec, AIC31XX_IFACE1, | 928 | snd_soc_component_update_bits(component, AIC31XX_IFACE1, |
893 | AIC31XX_IFACE1_DATALEN_MASK, | 929 | AIC31XX_IFACE1_DATALEN_MASK, |
894 | data); | 930 | data); |
895 | 931 | ||
896 | return aic31xx_setup_pll(codec, params); | 932 | return aic31xx_setup_pll(component, params); |
897 | } | 933 | } |
898 | 934 | ||
899 | static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute) | 935 | static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute) |
900 | { | 936 | { |
901 | struct snd_soc_codec *codec = codec_dai->codec; | 937 | struct snd_soc_component *component = codec_dai->component; |
902 | 938 | ||
903 | if (mute) { | 939 | if (mute) { |
904 | snd_soc_update_bits(codec, AIC31XX_DACMUTE, | 940 | snd_soc_component_update_bits(component, AIC31XX_DACMUTE, |
905 | AIC31XX_DACMUTE_MASK, | 941 | AIC31XX_DACMUTE_MASK, |
906 | AIC31XX_DACMUTE_MASK); | 942 | AIC31XX_DACMUTE_MASK); |
907 | } else { | 943 | } else { |
908 | snd_soc_update_bits(codec, AIC31XX_DACMUTE, | 944 | snd_soc_component_update_bits(component, AIC31XX_DACMUTE, |
909 | AIC31XX_DACMUTE_MASK, 0x0); | 945 | AIC31XX_DACMUTE_MASK, 0x0); |
910 | } | 946 | } |
911 | 947 | ||
912 | return 0; | 948 | return 0; |
913 | } | 949 | } |
914 | 950 | ||
951 | static int aic31xx_clock_master_routes(struct snd_soc_component *component, | ||
952 | unsigned int fmt) | ||
953 | { | ||
954 | struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); | ||
955 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); | ||
956 | int ret; | ||
957 | |||
958 | fmt &= SND_SOC_DAIFMT_MASTER_MASK; | ||
959 | if (fmt == SND_SOC_DAIFMT_CBS_CFS && | ||
960 | aic31xx->master_dapm_route_applied) { | ||
961 | /* | ||
962 | * Remove the DAPM route(s) for codec clock master modes, | ||
963 | * if applied | ||
964 | */ | ||
965 | ret = snd_soc_dapm_del_routes(dapm, common31xx_cm_audio_map, | ||
966 | ARRAY_SIZE(common31xx_cm_audio_map)); | ||
967 | if (!ret && !(aic31xx->codec_type & DAC31XX_BIT)) | ||
968 | ret = snd_soc_dapm_del_routes(dapm, | ||
969 | aic31xx_cm_audio_map, | ||
970 | ARRAY_SIZE(aic31xx_cm_audio_map)); | ||
971 | |||
972 | if (ret) | ||
973 | return ret; | ||
974 | |||
975 | aic31xx->master_dapm_route_applied = false; | ||
976 | } else if (fmt != SND_SOC_DAIFMT_CBS_CFS && | ||
977 | !aic31xx->master_dapm_route_applied) { | ||
978 | /* | ||
979 | * Add the needed DAPM route(s) for codec clock master modes, | ||
980 | * if it is not done already | ||
981 | */ | ||
982 | ret = snd_soc_dapm_add_routes(dapm, common31xx_cm_audio_map, | ||
983 | ARRAY_SIZE(common31xx_cm_audio_map)); | ||
984 | if (!ret && !(aic31xx->codec_type & DAC31XX_BIT)) | ||
985 | ret = snd_soc_dapm_add_routes(dapm, | ||
986 | aic31xx_cm_audio_map, | ||
987 | ARRAY_SIZE(aic31xx_cm_audio_map)); | ||
988 | |||
989 | if (ret) | ||
990 | return ret; | ||
991 | |||
992 | aic31xx->master_dapm_route_applied = true; | ||
993 | } | ||
994 | |||
995 | return 0; | ||
996 | } | ||
997 | |||
915 | static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, | 998 | static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, |
916 | unsigned int fmt) | 999 | unsigned int fmt) |
917 | { | 1000 | { |
918 | struct snd_soc_codec *codec = codec_dai->codec; | 1001 | struct snd_soc_component *component = codec_dai->component; |
919 | u8 iface_reg1 = 0; | 1002 | u8 iface_reg1 = 0; |
920 | u8 iface_reg2 = 0; | 1003 | u8 iface_reg2 = 0; |
921 | u8 dsp_a_val = 0; | 1004 | u8 dsp_a_val = 0; |
922 | 1005 | ||
923 | dev_dbg(codec->dev, "## %s: fmt = 0x%x\n", __func__, fmt); | 1006 | dev_dbg(component->dev, "## %s: fmt = 0x%x\n", __func__, fmt); |
924 | 1007 | ||
925 | /* set master/slave audio interface */ | 1008 | /* set master/slave audio interface */ |
926 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 1009 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
@@ -936,7 +1019,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
936 | case SND_SOC_DAIFMT_CBS_CFS: | 1019 | case SND_SOC_DAIFMT_CBS_CFS: |
937 | break; | 1020 | break; |
938 | default: | 1021 | default: |
939 | dev_err(codec->dev, "Invalid DAI master/slave interface\n"); | 1022 | dev_err(component->dev, "Invalid DAI master/slave interface\n"); |
940 | return -EINVAL; | 1023 | return -EINVAL; |
941 | } | 1024 | } |
942 | 1025 | ||
@@ -948,7 +1031,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
948 | iface_reg2 |= AIC31XX_BCLKINV_MASK; | 1031 | iface_reg2 |= AIC31XX_BCLKINV_MASK; |
949 | break; | 1032 | break; |
950 | default: | 1033 | default: |
951 | dev_err(codec->dev, "Invalid DAI clock signal polarity\n"); | 1034 | dev_err(component->dev, "Invalid DAI clock signal polarity\n"); |
952 | return -EINVAL; | 1035 | return -EINVAL; |
953 | } | 1036 | } |
954 | 1037 | ||
@@ -977,32 +1060,32 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
977 | AIC31XX_IFACE1_DATATYPE_SHIFT); | 1060 | AIC31XX_IFACE1_DATATYPE_SHIFT); |
978 | break; | 1061 | break; |
979 | default: | 1062 | default: |
980 | dev_err(codec->dev, "Invalid DAI interface format\n"); | 1063 | dev_err(component->dev, "Invalid DAI interface format\n"); |
981 | return -EINVAL; | 1064 | return -EINVAL; |
982 | } | 1065 | } |
983 | 1066 | ||
984 | snd_soc_update_bits(codec, AIC31XX_IFACE1, | 1067 | snd_soc_component_update_bits(component, AIC31XX_IFACE1, |
985 | AIC31XX_IFACE1_DATATYPE_MASK | | 1068 | AIC31XX_IFACE1_DATATYPE_MASK | |
986 | AIC31XX_IFACE1_MASTER_MASK, | 1069 | AIC31XX_IFACE1_MASTER_MASK, |
987 | iface_reg1); | 1070 | iface_reg1); |
988 | snd_soc_update_bits(codec, AIC31XX_DATA_OFFSET, | 1071 | snd_soc_component_update_bits(component, AIC31XX_DATA_OFFSET, |
989 | AIC31XX_DATA_OFFSET_MASK, | 1072 | AIC31XX_DATA_OFFSET_MASK, |
990 | dsp_a_val); | 1073 | dsp_a_val); |
991 | snd_soc_update_bits(codec, AIC31XX_IFACE2, | 1074 | snd_soc_component_update_bits(component, AIC31XX_IFACE2, |
992 | AIC31XX_BCLKINV_MASK, | 1075 | AIC31XX_BCLKINV_MASK, |
993 | iface_reg2); | 1076 | iface_reg2); |
994 | 1077 | ||
995 | return 0; | 1078 | return aic31xx_clock_master_routes(component, fmt); |
996 | } | 1079 | } |
997 | 1080 | ||
998 | static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 1081 | static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
999 | int clk_id, unsigned int freq, int dir) | 1082 | int clk_id, unsigned int freq, int dir) |
1000 | { | 1083 | { |
1001 | struct snd_soc_codec *codec = codec_dai->codec; | 1084 | struct snd_soc_component *component = codec_dai->component; |
1002 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1085 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1003 | int i; | 1086 | int i; |
1004 | 1087 | ||
1005 | dev_dbg(codec->dev, "## %s: clk_id = %d, freq = %d, dir = %d\n", | 1088 | dev_dbg(component->dev, "## %s: clk_id = %d, freq = %d, dir = %d\n", |
1006 | __func__, clk_id, freq, dir); | 1089 | __func__, clk_id, freq, dir); |
1007 | 1090 | ||
1008 | for (i = 1; i < 8; i++) | 1091 | for (i = 1; i < 8; i++) |
@@ -1025,7 +1108,7 @@ static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1025 | } | 1108 | } |
1026 | 1109 | ||
1027 | /* set clock on MCLK, BCLK, or GPIO1 as PLL input */ | 1110 | /* set clock on MCLK, BCLK, or GPIO1 as PLL input */ |
1028 | snd_soc_update_bits(codec, AIC31XX_CLKMUX, AIC31XX_PLL_CLKIN_MASK, | 1111 | snd_soc_component_update_bits(component, AIC31XX_CLKMUX, AIC31XX_PLL_CLKIN_MASK, |
1029 | clk_id << AIC31XX_PLL_CLKIN_SHIFT); | 1112 | clk_id << AIC31XX_PLL_CLKIN_SHIFT); |
1030 | 1113 | ||
1031 | aic31xx->sysclk = freq; | 1114 | aic31xx->sysclk = freq; |
@@ -1071,42 +1154,42 @@ static int aic31xx_reset(struct aic31xx_priv *aic31xx) | |||
1071 | return ret; | 1154 | return ret; |
1072 | } | 1155 | } |
1073 | 1156 | ||
1074 | static void aic31xx_clk_on(struct snd_soc_codec *codec) | 1157 | static void aic31xx_clk_on(struct snd_soc_component *component) |
1075 | { | 1158 | { |
1076 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1159 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1077 | u8 mask = AIC31XX_PM_MASK; | 1160 | u8 mask = AIC31XX_PM_MASK; |
1078 | u8 on = AIC31XX_PM_MASK; | 1161 | u8 on = AIC31XX_PM_MASK; |
1079 | 1162 | ||
1080 | dev_dbg(codec->dev, "codec clock -> on (rate %d)\n", | 1163 | dev_dbg(component->dev, "codec clock -> on (rate %d)\n", |
1081 | aic31xx_divs[aic31xx->rate_div_line].rate); | 1164 | aic31xx_divs[aic31xx->rate_div_line].rate); |
1082 | snd_soc_update_bits(codec, AIC31XX_PLLPR, mask, on); | 1165 | snd_soc_component_update_bits(component, AIC31XX_PLLPR, mask, on); |
1083 | mdelay(10); | 1166 | mdelay(10); |
1084 | snd_soc_update_bits(codec, AIC31XX_NDAC, mask, on); | 1167 | snd_soc_component_update_bits(component, AIC31XX_NDAC, mask, on); |
1085 | snd_soc_update_bits(codec, AIC31XX_MDAC, mask, on); | 1168 | snd_soc_component_update_bits(component, AIC31XX_MDAC, mask, on); |
1086 | if (aic31xx_divs[aic31xx->rate_div_line].nadc) | 1169 | if (aic31xx_divs[aic31xx->rate_div_line].nadc) |
1087 | snd_soc_update_bits(codec, AIC31XX_NADC, mask, on); | 1170 | snd_soc_component_update_bits(component, AIC31XX_NADC, mask, on); |
1088 | if (aic31xx_divs[aic31xx->rate_div_line].madc) | 1171 | if (aic31xx_divs[aic31xx->rate_div_line].madc) |
1089 | snd_soc_update_bits(codec, AIC31XX_MADC, mask, on); | 1172 | snd_soc_component_update_bits(component, AIC31XX_MADC, mask, on); |
1090 | snd_soc_update_bits(codec, AIC31XX_BCLKN, mask, on); | 1173 | snd_soc_component_update_bits(component, AIC31XX_BCLKN, mask, on); |
1091 | } | 1174 | } |
1092 | 1175 | ||
1093 | static void aic31xx_clk_off(struct snd_soc_codec *codec) | 1176 | static void aic31xx_clk_off(struct snd_soc_component *component) |
1094 | { | 1177 | { |
1095 | u8 mask = AIC31XX_PM_MASK; | 1178 | u8 mask = AIC31XX_PM_MASK; |
1096 | u8 off = 0; | 1179 | u8 off = 0; |
1097 | 1180 | ||
1098 | dev_dbg(codec->dev, "codec clock -> off\n"); | 1181 | dev_dbg(component->dev, "codec clock -> off\n"); |
1099 | snd_soc_update_bits(codec, AIC31XX_BCLKN, mask, off); | 1182 | snd_soc_component_update_bits(component, AIC31XX_BCLKN, mask, off); |
1100 | snd_soc_update_bits(codec, AIC31XX_MADC, mask, off); | 1183 | snd_soc_component_update_bits(component, AIC31XX_MADC, mask, off); |
1101 | snd_soc_update_bits(codec, AIC31XX_NADC, mask, off); | 1184 | snd_soc_component_update_bits(component, AIC31XX_NADC, mask, off); |
1102 | snd_soc_update_bits(codec, AIC31XX_MDAC, mask, off); | 1185 | snd_soc_component_update_bits(component, AIC31XX_MDAC, mask, off); |
1103 | snd_soc_update_bits(codec, AIC31XX_NDAC, mask, off); | 1186 | snd_soc_component_update_bits(component, AIC31XX_NDAC, mask, off); |
1104 | snd_soc_update_bits(codec, AIC31XX_PLLPR, mask, off); | 1187 | snd_soc_component_update_bits(component, AIC31XX_PLLPR, mask, off); |
1105 | } | 1188 | } |
1106 | 1189 | ||
1107 | static int aic31xx_power_on(struct snd_soc_codec *codec) | 1190 | static int aic31xx_power_on(struct snd_soc_component *component) |
1108 | { | 1191 | { |
1109 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1192 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1110 | int ret; | 1193 | int ret; |
1111 | 1194 | ||
1112 | ret = regulator_bulk_enable(ARRAY_SIZE(aic31xx->supplies), | 1195 | ret = regulator_bulk_enable(ARRAY_SIZE(aic31xx->supplies), |
@@ -1123,7 +1206,7 @@ static int aic31xx_power_on(struct snd_soc_codec *codec) | |||
1123 | 1206 | ||
1124 | ret = regcache_sync(aic31xx->regmap); | 1207 | ret = regcache_sync(aic31xx->regmap); |
1125 | if (ret) { | 1208 | if (ret) { |
1126 | dev_err(codec->dev, | 1209 | dev_err(component->dev, |
1127 | "Failed to restore cache: %d\n", ret); | 1210 | "Failed to restore cache: %d\n", ret); |
1128 | regcache_cache_only(aic31xx->regmap, true); | 1211 | regcache_cache_only(aic31xx->regmap, true); |
1129 | regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), | 1212 | regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), |
@@ -1134,57 +1217,57 @@ static int aic31xx_power_on(struct snd_soc_codec *codec) | |||
1134 | return 0; | 1217 | return 0; |
1135 | } | 1218 | } |
1136 | 1219 | ||
1137 | static void aic31xx_power_off(struct snd_soc_codec *codec) | 1220 | static void aic31xx_power_off(struct snd_soc_component *component) |
1138 | { | 1221 | { |
1139 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1222 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1140 | 1223 | ||
1141 | regcache_cache_only(aic31xx->regmap, true); | 1224 | regcache_cache_only(aic31xx->regmap, true); |
1142 | regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), | 1225 | regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), |
1143 | aic31xx->supplies); | 1226 | aic31xx->supplies); |
1144 | } | 1227 | } |
1145 | 1228 | ||
1146 | static int aic31xx_set_bias_level(struct snd_soc_codec *codec, | 1229 | static int aic31xx_set_bias_level(struct snd_soc_component *component, |
1147 | enum snd_soc_bias_level level) | 1230 | enum snd_soc_bias_level level) |
1148 | { | 1231 | { |
1149 | dev_dbg(codec->dev, "## %s: %d -> %d\n", __func__, | 1232 | dev_dbg(component->dev, "## %s: %d -> %d\n", __func__, |
1150 | snd_soc_codec_get_bias_level(codec), level); | 1233 | snd_soc_component_get_bias_level(component), level); |
1151 | 1234 | ||
1152 | switch (level) { | 1235 | switch (level) { |
1153 | case SND_SOC_BIAS_ON: | 1236 | case SND_SOC_BIAS_ON: |
1154 | break; | 1237 | break; |
1155 | case SND_SOC_BIAS_PREPARE: | 1238 | case SND_SOC_BIAS_PREPARE: |
1156 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) | 1239 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) |
1157 | aic31xx_clk_on(codec); | 1240 | aic31xx_clk_on(component); |
1158 | break; | 1241 | break; |
1159 | case SND_SOC_BIAS_STANDBY: | 1242 | case SND_SOC_BIAS_STANDBY: |
1160 | switch (snd_soc_codec_get_bias_level(codec)) { | 1243 | switch (snd_soc_component_get_bias_level(component)) { |
1161 | case SND_SOC_BIAS_OFF: | 1244 | case SND_SOC_BIAS_OFF: |
1162 | aic31xx_power_on(codec); | 1245 | aic31xx_power_on(component); |
1163 | break; | 1246 | break; |
1164 | case SND_SOC_BIAS_PREPARE: | 1247 | case SND_SOC_BIAS_PREPARE: |
1165 | aic31xx_clk_off(codec); | 1248 | aic31xx_clk_off(component); |
1166 | break; | 1249 | break; |
1167 | default: | 1250 | default: |
1168 | BUG(); | 1251 | BUG(); |
1169 | } | 1252 | } |
1170 | break; | 1253 | break; |
1171 | case SND_SOC_BIAS_OFF: | 1254 | case SND_SOC_BIAS_OFF: |
1172 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) | 1255 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) |
1173 | aic31xx_power_off(codec); | 1256 | aic31xx_power_off(component); |
1174 | break; | 1257 | break; |
1175 | } | 1258 | } |
1176 | 1259 | ||
1177 | return 0; | 1260 | return 0; |
1178 | } | 1261 | } |
1179 | 1262 | ||
1180 | static int aic31xx_codec_probe(struct snd_soc_codec *codec) | 1263 | static int aic31xx_codec_probe(struct snd_soc_component *component) |
1181 | { | 1264 | { |
1182 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1265 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1183 | int i, ret; | 1266 | int i, ret; |
1184 | 1267 | ||
1185 | dev_dbg(aic31xx->dev, "## %s\n", __func__); | 1268 | dev_dbg(aic31xx->dev, "## %s\n", __func__); |
1186 | 1269 | ||
1187 | aic31xx->codec = codec; | 1270 | aic31xx->component = component; |
1188 | 1271 | ||
1189 | for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) { | 1272 | for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) { |
1190 | aic31xx->disable_nb[i].nb.notifier_call = | 1273 | aic31xx->disable_nb[i].nb.notifier_call = |
@@ -1193,7 +1276,7 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec) | |||
1193 | ret = regulator_register_notifier(aic31xx->supplies[i].consumer, | 1276 | ret = regulator_register_notifier(aic31xx->supplies[i].consumer, |
1194 | &aic31xx->disable_nb[i].nb); | 1277 | &aic31xx->disable_nb[i].nb); |
1195 | if (ret) { | 1278 | if (ret) { |
1196 | dev_err(codec->dev, | 1279 | dev_err(component->dev, |
1197 | "Failed to request regulator notifier: %d\n", | 1280 | "Failed to request regulator notifier: %d\n", |
1198 | ret); | 1281 | ret); |
1199 | return ret; | 1282 | return ret; |
@@ -1203,43 +1286,42 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec) | |||
1203 | regcache_cache_only(aic31xx->regmap, true); | 1286 | regcache_cache_only(aic31xx->regmap, true); |
1204 | regcache_mark_dirty(aic31xx->regmap); | 1287 | regcache_mark_dirty(aic31xx->regmap); |
1205 | 1288 | ||
1206 | ret = aic31xx_add_controls(codec); | 1289 | ret = aic31xx_add_controls(component); |
1207 | if (ret) | 1290 | if (ret) |
1208 | return ret; | 1291 | return ret; |
1209 | 1292 | ||
1210 | ret = aic31xx_add_widgets(codec); | 1293 | ret = aic31xx_add_widgets(component); |
1211 | if (ret) | 1294 | if (ret) |
1212 | return ret; | 1295 | return ret; |
1213 | 1296 | ||
1214 | return 0; | 1297 | return 0; |
1215 | } | 1298 | } |
1216 | 1299 | ||
1217 | static int aic31xx_codec_remove(struct snd_soc_codec *codec) | 1300 | static void aic31xx_codec_remove(struct snd_soc_component *component) |
1218 | { | 1301 | { |
1219 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 1302 | struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); |
1220 | int i; | 1303 | int i; |
1221 | 1304 | ||
1222 | for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) | 1305 | for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) |
1223 | regulator_unregister_notifier(aic31xx->supplies[i].consumer, | 1306 | regulator_unregister_notifier(aic31xx->supplies[i].consumer, |
1224 | &aic31xx->disable_nb[i].nb); | 1307 | &aic31xx->disable_nb[i].nb); |
1225 | |||
1226 | return 0; | ||
1227 | } | 1308 | } |
1228 | 1309 | ||
1229 | static const struct snd_soc_codec_driver soc_codec_driver_aic31xx = { | 1310 | static const struct snd_soc_component_driver soc_codec_driver_aic31xx = { |
1230 | .probe = aic31xx_codec_probe, | 1311 | .probe = aic31xx_codec_probe, |
1231 | .remove = aic31xx_codec_remove, | 1312 | .remove = aic31xx_codec_remove, |
1232 | .set_bias_level = aic31xx_set_bias_level, | 1313 | .set_bias_level = aic31xx_set_bias_level, |
1233 | .suspend_bias_off = true, | 1314 | .controls = common31xx_snd_controls, |
1234 | 1315 | .num_controls = ARRAY_SIZE(common31xx_snd_controls), | |
1235 | .component_driver = { | 1316 | .dapm_widgets = common31xx_dapm_widgets, |
1236 | .controls = common31xx_snd_controls, | 1317 | .num_dapm_widgets = ARRAY_SIZE(common31xx_dapm_widgets), |
1237 | .num_controls = ARRAY_SIZE(common31xx_snd_controls), | 1318 | .dapm_routes = common31xx_audio_map, |
1238 | .dapm_widgets = common31xx_dapm_widgets, | 1319 | .num_dapm_routes = ARRAY_SIZE(common31xx_audio_map), |
1239 | .num_dapm_widgets = ARRAY_SIZE(common31xx_dapm_widgets), | 1320 | .suspend_bias_off = 1, |
1240 | .dapm_routes = common31xx_audio_map, | 1321 | .idle_bias_on = 1, |
1241 | .num_dapm_routes = ARRAY_SIZE(common31xx_audio_map), | 1322 | .use_pmdown_time = 1, |
1242 | }, | 1323 | .endianness = 1, |
1324 | .non_legacy_dai_naming = 1, | ||
1243 | }; | 1325 | }; |
1244 | 1326 | ||
1245 | static const struct snd_soc_dai_ops aic31xx_dai_ops = { | 1327 | static const struct snd_soc_dai_ops aic31xx_dai_ops = { |
@@ -1375,23 +1457,17 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c, | |||
1375 | } | 1457 | } |
1376 | 1458 | ||
1377 | if (aic31xx->codec_type & DAC31XX_BIT) | 1459 | if (aic31xx->codec_type & DAC31XX_BIT) |
1378 | return snd_soc_register_codec(&i2c->dev, | 1460 | return devm_snd_soc_register_component(&i2c->dev, |
1379 | &soc_codec_driver_aic31xx, | 1461 | &soc_codec_driver_aic31xx, |
1380 | dac31xx_dai_driver, | 1462 | dac31xx_dai_driver, |
1381 | ARRAY_SIZE(dac31xx_dai_driver)); | 1463 | ARRAY_SIZE(dac31xx_dai_driver)); |
1382 | else | 1464 | else |
1383 | return snd_soc_register_codec(&i2c->dev, | 1465 | return devm_snd_soc_register_component(&i2c->dev, |
1384 | &soc_codec_driver_aic31xx, | 1466 | &soc_codec_driver_aic31xx, |
1385 | aic31xx_dai_driver, | 1467 | aic31xx_dai_driver, |
1386 | ARRAY_SIZE(aic31xx_dai_driver)); | 1468 | ARRAY_SIZE(aic31xx_dai_driver)); |
1387 | } | 1469 | } |
1388 | 1470 | ||
1389 | static int aic31xx_i2c_remove(struct i2c_client *i2c) | ||
1390 | { | ||
1391 | snd_soc_unregister_codec(&i2c->dev); | ||
1392 | return 0; | ||
1393 | } | ||
1394 | |||
1395 | static const struct i2c_device_id aic31xx_i2c_id[] = { | 1471 | static const struct i2c_device_id aic31xx_i2c_id[] = { |
1396 | { "tlv320aic310x", AIC3100 }, | 1472 | { "tlv320aic310x", AIC3100 }, |
1397 | { "tlv320aic311x", AIC3110 }, | 1473 | { "tlv320aic311x", AIC3110 }, |
@@ -1412,7 +1488,6 @@ static struct i2c_driver aic31xx_i2c_driver = { | |||
1412 | .acpi_match_table = ACPI_PTR(aic31xx_acpi_match), | 1488 | .acpi_match_table = ACPI_PTR(aic31xx_acpi_match), |
1413 | }, | 1489 | }, |
1414 | .probe = aic31xx_i2c_probe, | 1490 | .probe = aic31xx_i2c_probe, |
1415 | .remove = aic31xx_i2c_remove, | ||
1416 | .id_table = aic31xx_i2c_id, | 1491 | .id_table = aic31xx_i2c_id, |
1417 | }; | 1492 | }; |
1418 | module_i2c_driver(aic31xx_i2c_driver); | 1493 | module_i2c_driver(aic31xx_i2c_driver); |
diff --git a/sound/soc/codecs/tlv320aic31xx.h b/sound/soc/codecs/tlv320aic31xx.h index 15ac7cba86fe..0b587585b38b 100644 --- a/sound/soc/codecs/tlv320aic31xx.h +++ b/sound/soc/codecs/tlv320aic31xx.h | |||
@@ -160,6 +160,7 @@ struct aic31xx_pdata { | |||
160 | #define AIC31XX_DACMOD2BCLK 0x01 | 160 | #define AIC31XX_DACMOD2BCLK 0x01 |
161 | #define AIC31XX_ADC2BCLK 0x02 | 161 | #define AIC31XX_ADC2BCLK 0x02 |
162 | #define AIC31XX_ADCMOD2BCLK 0x03 | 162 | #define AIC31XX_ADCMOD2BCLK 0x03 |
163 | #define AIC31XX_KEEP_I2SCLK BIT(2) | ||
163 | 164 | ||
164 | /* AIC31XX_ADCFLAG */ | 165 | /* AIC31XX_ADCFLAG */ |
165 | #define AIC31XX_ADCPWRSTATUS_MASK BIT(6) | 166 | #define AIC31XX_ADCPWRSTATUS_MASK BIT(6) |