aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 23:03:13 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:48:38 -0500
commit2918d9ccc46a408707bc8939ba1777f7211798c3 (patch)
tree05107458591d08036f1354d4a0f80bfab7d693a6
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: da7213: replace codec to component
Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/da7213.c328
1 files changed, 161 insertions, 167 deletions
diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c
index b2b4e90fc02a..54cb5f24969f 100644
--- a/sound/soc/codecs/da7213.c
+++ b/sound/soc/codecs/da7213.c
@@ -194,7 +194,7 @@ static SOC_ENUM_SINGLE_DECL(da7213_alc_integ_release_rate,
194 * Control Functions 194 * Control Functions
195 */ 195 */
196 196
197static int da7213_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) 197static int da7213_get_alc_data(struct snd_soc_component *component, u8 reg_val)
198{ 198{
199 int mid_data, top_data; 199 int mid_data, top_data;
200 int sum = 0; 200 int sum = 0;
@@ -203,17 +203,17 @@ static int da7213_get_alc_data(struct snd_soc_codec *codec, u8 reg_val)
203 for (iteration = 0; iteration < DA7213_ALC_AVG_ITERATIONS; 203 for (iteration = 0; iteration < DA7213_ALC_AVG_ITERATIONS;
204 iteration++) { 204 iteration++) {
205 /* Select the left or right channel and capture data */ 205 /* Select the left or right channel and capture data */
206 snd_soc_write(codec, DA7213_ALC_CIC_OP_LVL_CTRL, reg_val); 206 snd_soc_component_write(component, DA7213_ALC_CIC_OP_LVL_CTRL, reg_val);
207 207
208 /* Select middle 8 bits for read back from data register */ 208 /* Select middle 8 bits for read back from data register */
209 snd_soc_write(codec, DA7213_ALC_CIC_OP_LVL_CTRL, 209 snd_soc_component_write(component, DA7213_ALC_CIC_OP_LVL_CTRL,
210 reg_val | DA7213_ALC_DATA_MIDDLE); 210 reg_val | DA7213_ALC_DATA_MIDDLE);
211 mid_data = snd_soc_read(codec, DA7213_ALC_CIC_OP_LVL_DATA); 211 mid_data = snd_soc_component_read32(component, DA7213_ALC_CIC_OP_LVL_DATA);
212 212
213 /* Select top 8 bits for read back from data register */ 213 /* Select top 8 bits for read back from data register */
214 snd_soc_write(codec, DA7213_ALC_CIC_OP_LVL_CTRL, 214 snd_soc_component_write(component, DA7213_ALC_CIC_OP_LVL_CTRL,
215 reg_val | DA7213_ALC_DATA_TOP); 215 reg_val | DA7213_ALC_DATA_TOP);
216 top_data = snd_soc_read(codec, DA7213_ALC_CIC_OP_LVL_DATA); 216 top_data = snd_soc_component_read32(component, DA7213_ALC_CIC_OP_LVL_DATA);
217 217
218 sum += ((mid_data << 8) | (top_data << 16)); 218 sum += ((mid_data << 8) | (top_data << 16));
219 } 219 }
@@ -221,17 +221,17 @@ static int da7213_get_alc_data(struct snd_soc_codec *codec, u8 reg_val)
221 return sum / DA7213_ALC_AVG_ITERATIONS; 221 return sum / DA7213_ALC_AVG_ITERATIONS;
222} 222}
223 223
224static void da7213_alc_calib_man(struct snd_soc_codec *codec) 224static void da7213_alc_calib_man(struct snd_soc_component *component)
225{ 225{
226 u8 reg_val; 226 u8 reg_val;
227 int avg_left_data, avg_right_data, offset_l, offset_r; 227 int avg_left_data, avg_right_data, offset_l, offset_r;
228 228
229 /* Calculate average for Left and Right data */ 229 /* Calculate average for Left and Right data */
230 /* Left Data */ 230 /* Left Data */
231 avg_left_data = da7213_get_alc_data(codec, 231 avg_left_data = da7213_get_alc_data(component,
232 DA7213_ALC_CIC_OP_CHANNEL_LEFT); 232 DA7213_ALC_CIC_OP_CHANNEL_LEFT);
233 /* Right Data */ 233 /* Right Data */
234 avg_right_data = da7213_get_alc_data(codec, 234 avg_right_data = da7213_get_alc_data(component,
235 DA7213_ALC_CIC_OP_CHANNEL_RIGHT); 235 DA7213_ALC_CIC_OP_CHANNEL_RIGHT);
236 236
237 /* Calculate DC offset */ 237 /* Calculate DC offset */
@@ -239,122 +239,122 @@ static void da7213_alc_calib_man(struct snd_soc_codec *codec)
239 offset_r = -avg_right_data; 239 offset_r = -avg_right_data;
240 240
241 reg_val = (offset_l & DA7213_ALC_OFFSET_15_8) >> 8; 241 reg_val = (offset_l & DA7213_ALC_OFFSET_15_8) >> 8;
242 snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_M_L, reg_val); 242 snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_M_L, reg_val);
243 reg_val = (offset_l & DA7213_ALC_OFFSET_19_16) >> 16; 243 reg_val = (offset_l & DA7213_ALC_OFFSET_19_16) >> 16;
244 snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_U_L, reg_val); 244 snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_U_L, reg_val);
245 245
246 reg_val = (offset_r & DA7213_ALC_OFFSET_15_8) >> 8; 246 reg_val = (offset_r & DA7213_ALC_OFFSET_15_8) >> 8;
247 snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_M_R, reg_val); 247 snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_M_R, reg_val);
248 reg_val = (offset_r & DA7213_ALC_OFFSET_19_16) >> 16; 248 reg_val = (offset_r & DA7213_ALC_OFFSET_19_16) >> 16;
249 snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_U_R, reg_val); 249 snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_U_R, reg_val);
250 250
251 /* Enable analog/digital gain mode & offset cancellation */ 251 /* Enable analog/digital gain mode & offset cancellation */
252 snd_soc_update_bits(codec, DA7213_ALC_CTRL1, 252 snd_soc_component_update_bits(component, DA7213_ALC_CTRL1,
253 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, 253 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE,
254 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE); 254 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE);
255} 255}
256 256
257static void da7213_alc_calib_auto(struct snd_soc_codec *codec) 257static void da7213_alc_calib_auto(struct snd_soc_component *component)
258{ 258{
259 u8 alc_ctrl1; 259 u8 alc_ctrl1;
260 260
261 /* Begin auto calibration and wait for completion */ 261 /* Begin auto calibration and wait for completion */
262 snd_soc_update_bits(codec, DA7213_ALC_CTRL1, DA7213_ALC_AUTO_CALIB_EN, 262 snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, DA7213_ALC_AUTO_CALIB_EN,
263 DA7213_ALC_AUTO_CALIB_EN); 263 DA7213_ALC_AUTO_CALIB_EN);
264 do { 264 do {
265 alc_ctrl1 = snd_soc_read(codec, DA7213_ALC_CTRL1); 265 alc_ctrl1 = snd_soc_component_read32(component, DA7213_ALC_CTRL1);
266 } while (alc_ctrl1 & DA7213_ALC_AUTO_CALIB_EN); 266 } while (alc_ctrl1 & DA7213_ALC_AUTO_CALIB_EN);
267 267
268 /* If auto calibration fails, fall back to digital gain only mode */ 268 /* If auto calibration fails, fall back to digital gain only mode */
269 if (alc_ctrl1 & DA7213_ALC_CALIB_OVERFLOW) { 269 if (alc_ctrl1 & DA7213_ALC_CALIB_OVERFLOW) {
270 dev_warn(codec->dev, 270 dev_warn(component->dev,
271 "ALC auto calibration failed with overflow\n"); 271 "ALC auto calibration failed with overflow\n");
272 snd_soc_update_bits(codec, DA7213_ALC_CTRL1, 272 snd_soc_component_update_bits(component, DA7213_ALC_CTRL1,
273 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, 273 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE,
274 0); 274 0);
275 } else { 275 } else {
276 /* Enable analog/digital gain mode & offset cancellation */ 276 /* Enable analog/digital gain mode & offset cancellation */
277 snd_soc_update_bits(codec, DA7213_ALC_CTRL1, 277 snd_soc_component_update_bits(component, DA7213_ALC_CTRL1,
278 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, 278 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE,
279 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE); 279 DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE);
280 } 280 }
281 281
282} 282}
283 283
284static void da7213_alc_calib(struct snd_soc_codec *codec) 284static void da7213_alc_calib(struct snd_soc_component *component)
285{ 285{
286 struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); 286 struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
287 u8 adc_l_ctrl, adc_r_ctrl; 287 u8 adc_l_ctrl, adc_r_ctrl;
288 u8 mixin_l_sel, mixin_r_sel; 288 u8 mixin_l_sel, mixin_r_sel;
289 u8 mic_1_ctrl, mic_2_ctrl; 289 u8 mic_1_ctrl, mic_2_ctrl;
290 290
291 /* Save current values from ADC control registers */ 291 /* Save current values from ADC control registers */
292 adc_l_ctrl = snd_soc_read(codec, DA7213_ADC_L_CTRL); 292 adc_l_ctrl = snd_soc_component_read32(component, DA7213_ADC_L_CTRL);
293 adc_r_ctrl = snd_soc_read(codec, DA7213_ADC_R_CTRL); 293 adc_r_ctrl = snd_soc_component_read32(component, DA7213_ADC_R_CTRL);
294 294
295 /* Save current values from MIXIN_L/R_SELECT registers */ 295 /* Save current values from MIXIN_L/R_SELECT registers */
296 mixin_l_sel = snd_soc_read(codec, DA7213_MIXIN_L_SELECT); 296 mixin_l_sel = snd_soc_component_read32(component, DA7213_MIXIN_L_SELECT);
297 mixin_r_sel = snd_soc_read(codec, DA7213_MIXIN_R_SELECT); 297 mixin_r_sel = snd_soc_component_read32(component, DA7213_MIXIN_R_SELECT);
298 298
299 /* Save current values from MIC control registers */ 299 /* Save current values from MIC control registers */
300 mic_1_ctrl = snd_soc_read(codec, DA7213_MIC_1_CTRL); 300 mic_1_ctrl = snd_soc_component_read32(component, DA7213_MIC_1_CTRL);
301 mic_2_ctrl = snd_soc_read(codec, DA7213_MIC_2_CTRL); 301 mic_2_ctrl = snd_soc_component_read32(component, DA7213_MIC_2_CTRL);
302 302
303 /* Enable ADC Left and Right */ 303 /* Enable ADC Left and Right */
304 snd_soc_update_bits(codec, DA7213_ADC_L_CTRL, DA7213_ADC_EN, 304 snd_soc_component_update_bits(component, DA7213_ADC_L_CTRL, DA7213_ADC_EN,
305 DA7213_ADC_EN); 305 DA7213_ADC_EN);
306 snd_soc_update_bits(codec, DA7213_ADC_R_CTRL, DA7213_ADC_EN, 306 snd_soc_component_update_bits(component, DA7213_ADC_R_CTRL, DA7213_ADC_EN,
307 DA7213_ADC_EN); 307 DA7213_ADC_EN);
308 308
309 /* Enable MIC paths */ 309 /* Enable MIC paths */
310 snd_soc_update_bits(codec, DA7213_MIXIN_L_SELECT, 310 snd_soc_component_update_bits(component, DA7213_MIXIN_L_SELECT,
311 DA7213_MIXIN_L_MIX_SELECT_MIC_1 | 311 DA7213_MIXIN_L_MIX_SELECT_MIC_1 |
312 DA7213_MIXIN_L_MIX_SELECT_MIC_2, 312 DA7213_MIXIN_L_MIX_SELECT_MIC_2,
313 DA7213_MIXIN_L_MIX_SELECT_MIC_1 | 313 DA7213_MIXIN_L_MIX_SELECT_MIC_1 |
314 DA7213_MIXIN_L_MIX_SELECT_MIC_2); 314 DA7213_MIXIN_L_MIX_SELECT_MIC_2);
315 snd_soc_update_bits(codec, DA7213_MIXIN_R_SELECT, 315 snd_soc_component_update_bits(component, DA7213_MIXIN_R_SELECT,
316 DA7213_MIXIN_R_MIX_SELECT_MIC_2 | 316 DA7213_MIXIN_R_MIX_SELECT_MIC_2 |
317 DA7213_MIXIN_R_MIX_SELECT_MIC_1, 317 DA7213_MIXIN_R_MIX_SELECT_MIC_1,
318 DA7213_MIXIN_R_MIX_SELECT_MIC_2 | 318 DA7213_MIXIN_R_MIX_SELECT_MIC_2 |
319 DA7213_MIXIN_R_MIX_SELECT_MIC_1); 319 DA7213_MIXIN_R_MIX_SELECT_MIC_1);
320 320
321 /* Mute MIC PGAs */ 321 /* Mute MIC PGAs */
322 snd_soc_update_bits(codec, DA7213_MIC_1_CTRL, DA7213_MUTE_EN, 322 snd_soc_component_update_bits(component, DA7213_MIC_1_CTRL, DA7213_MUTE_EN,
323 DA7213_MUTE_EN); 323 DA7213_MUTE_EN);
324 snd_soc_update_bits(codec, DA7213_MIC_2_CTRL, DA7213_MUTE_EN, 324 snd_soc_component_update_bits(component, DA7213_MIC_2_CTRL, DA7213_MUTE_EN,
325 DA7213_MUTE_EN); 325 DA7213_MUTE_EN);
326 326
327 /* Perform calibration */ 327 /* Perform calibration */
328 if (da7213->alc_calib_auto) 328 if (da7213->alc_calib_auto)
329 da7213_alc_calib_auto(codec); 329 da7213_alc_calib_auto(component);
330 else 330 else
331 da7213_alc_calib_man(codec); 331 da7213_alc_calib_man(component);
332 332
333 /* Restore MIXIN_L/R_SELECT registers to their original states */ 333 /* Restore MIXIN_L/R_SELECT registers to their original states */
334 snd_soc_write(codec, DA7213_MIXIN_L_SELECT, mixin_l_sel); 334 snd_soc_component_write(component, DA7213_MIXIN_L_SELECT, mixin_l_sel);
335 snd_soc_write(codec, DA7213_MIXIN_R_SELECT, mixin_r_sel); 335 snd_soc_component_write(component, DA7213_MIXIN_R_SELECT, mixin_r_sel);
336 336
337 /* Restore ADC control registers to their original states */ 337 /* Restore ADC control registers to their original states */
338 snd_soc_write(codec, DA7213_ADC_L_CTRL, adc_l_ctrl); 338 snd_soc_component_write(component, DA7213_ADC_L_CTRL, adc_l_ctrl);
339 snd_soc_write(codec, DA7213_ADC_R_CTRL, adc_r_ctrl); 339 snd_soc_component_write(component, DA7213_ADC_R_CTRL, adc_r_ctrl);
340 340
341 /* Restore original values of MIC control registers */ 341 /* Restore original values of MIC control registers */
342 snd_soc_write(codec, DA7213_MIC_1_CTRL, mic_1_ctrl); 342 snd_soc_component_write(component, DA7213_MIC_1_CTRL, mic_1_ctrl);
343 snd_soc_write(codec, DA7213_MIC_2_CTRL, mic_2_ctrl); 343 snd_soc_component_write(component, DA7213_MIC_2_CTRL, mic_2_ctrl);
344} 344}
345 345
346static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, 346static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol,
347 struct snd_ctl_elem_value *ucontrol) 347 struct snd_ctl_elem_value *ucontrol)
348{ 348{
349 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 349 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
350 struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); 350 struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
351 int ret; 351 int ret;
352 352
353 ret = snd_soc_put_volsw_2r(kcontrol, ucontrol); 353 ret = snd_soc_put_volsw_2r(kcontrol, ucontrol);
354 354
355 /* If ALC in operation, make sure calibrated offsets are updated */ 355 /* If ALC in operation, make sure calibrated offsets are updated */
356 if ((!ret) && (da7213->alc_en)) 356 if ((!ret) && (da7213->alc_en))
357 da7213_alc_calib(codec); 357 da7213_alc_calib(component);
358 358
359 return ret; 359 return ret;
360} 360}
@@ -362,14 +362,14 @@ static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol,
362static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol, 362static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol,
363 struct snd_ctl_elem_value *ucontrol) 363 struct snd_ctl_elem_value *ucontrol)
364{ 364{
365 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 365 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
366 struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); 366 struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
367 367
368 /* Force ALC offset calibration if enabling ALC */ 368 /* Force ALC offset calibration if enabling ALC */
369 if (ucontrol->value.integer.value[0] || 369 if (ucontrol->value.integer.value[0] ||
370 ucontrol->value.integer.value[1]) { 370 ucontrol->value.integer.value[1]) {
371 if (!da7213->alc_en) { 371 if (!da7213->alc_en) {
372 da7213_alc_calib(codec); 372 da7213_alc_calib(component);
373 da7213->alc_en = true; 373 da7213->alc_en = true;
374 } 374 }
375 } else { 375 } else {
@@ -735,8 +735,8 @@ static const struct snd_kcontrol_new da7213_dapm_mixoutr_controls[] = {
735static int da7213_dai_event(struct snd_soc_dapm_widget *w, 735static int da7213_dai_event(struct snd_soc_dapm_widget *w,
736 struct snd_kcontrol *kcontrol, int event) 736 struct snd_kcontrol *kcontrol, int event)
737{ 737{
738 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 738 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
739 struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); 739 struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
740 u8 pll_ctrl, pll_status; 740 u8 pll_ctrl, pll_status;
741 int i = 0; 741 int i = 0;
742 bool srm_lock = false; 742 bool srm_lock = false;
@@ -745,29 +745,29 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w,
745 case SND_SOC_DAPM_PRE_PMU: 745 case SND_SOC_DAPM_PRE_PMU:
746 /* Enable DAI clks for master mode */ 746 /* Enable DAI clks for master mode */
747 if (da7213->master) 747 if (da7213->master)
748 snd_soc_update_bits(codec, DA7213_DAI_CLK_MODE, 748 snd_soc_component_update_bits(component, DA7213_DAI_CLK_MODE,
749 DA7213_DAI_CLK_EN_MASK, 749 DA7213_DAI_CLK_EN_MASK,
750 DA7213_DAI_CLK_EN_MASK); 750 DA7213_DAI_CLK_EN_MASK);
751 751
752 /* PC synchronised to DAI */ 752 /* PC synchronised to DAI */
753 snd_soc_update_bits(codec, DA7213_PC_COUNT, 753 snd_soc_component_update_bits(component, DA7213_PC_COUNT,
754 DA7213_PC_FREERUN_MASK, 0); 754 DA7213_PC_FREERUN_MASK, 0);
755 755
756 /* If SRM not enabled then nothing more to do */ 756 /* If SRM not enabled then nothing more to do */
757 pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL); 757 pll_ctrl = snd_soc_component_read32(component, DA7213_PLL_CTRL);
758 if (!(pll_ctrl & DA7213_PLL_SRM_EN)) 758 if (!(pll_ctrl & DA7213_PLL_SRM_EN))
759 return 0; 759 return 0;
760 760
761 /* Assist 32KHz mode PLL lock */ 761 /* Assist 32KHz mode PLL lock */
762 if (pll_ctrl & DA7213_PLL_32K_MODE) { 762 if (pll_ctrl & DA7213_PLL_32K_MODE) {
763 snd_soc_write(codec, 0xF0, 0x8B); 763 snd_soc_component_write(component, 0xF0, 0x8B);
764 snd_soc_write(codec, 0xF2, 0x03); 764 snd_soc_component_write(component, 0xF2, 0x03);
765 snd_soc_write(codec, 0xF0, 0x00); 765 snd_soc_component_write(component, 0xF0, 0x00);
766 } 766 }
767 767
768 /* Check SRM has locked */ 768 /* Check SRM has locked */
769 do { 769 do {
770 pll_status = snd_soc_read(codec, DA7213_PLL_STATUS); 770 pll_status = snd_soc_component_read32(component, DA7213_PLL_STATUS);
771 if (pll_status & DA7219_PLL_SRM_LOCK) { 771 if (pll_status & DA7219_PLL_SRM_LOCK) {
772 srm_lock = true; 772 srm_lock = true;
773 } else { 773 } else {
@@ -777,26 +777,26 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w,
777 } while ((i < DA7213_SRM_CHECK_RETRIES) && (!srm_lock)); 777 } while ((i < DA7213_SRM_CHECK_RETRIES) && (!srm_lock));
778 778
779 if (!srm_lock) 779 if (!srm_lock)
780 dev_warn(codec->dev, "SRM failed to lock\n"); 780 dev_warn(component->dev, "SRM failed to lock\n");
781 781
782 return 0; 782 return 0;
783 case SND_SOC_DAPM_POST_PMD: 783 case SND_SOC_DAPM_POST_PMD:
784 /* Revert 32KHz PLL lock udpates if applied previously */ 784 /* Revert 32KHz PLL lock udpates if applied previously */
785 pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL); 785 pll_ctrl = snd_soc_component_read32(component, DA7213_PLL_CTRL);
786 if (pll_ctrl & DA7213_PLL_32K_MODE) { 786 if (pll_ctrl & DA7213_PLL_32K_MODE) {
787 snd_soc_write(codec, 0xF0, 0x8B); 787 snd_soc_component_write(component, 0xF0, 0x8B);
788 snd_soc_write(codec, 0xF2, 0x01); 788 snd_soc_component_write(component, 0xF2, 0x01);
789 snd_soc_write(codec, 0xF0, 0x00); 789 snd_soc_component_write(component, 0xF0, 0x00);
790 } 790 }
791 791
792 /* PC free-running */ 792 /* PC free-running */
793 snd_soc_update_bits(codec, DA7213_PC_COUNT, 793 snd_soc_component_update_bits(component, DA7213_PC_COUNT,
794 DA7213_PC_FREERUN_MASK, 794 DA7213_PC_FREERUN_MASK,
795 DA7213_PC_FREERUN_MASK); 795 DA7213_PC_FREERUN_MASK);
796 796
797 /* Disable DAI clks if in master mode */ 797 /* Disable DAI clks if in master mode */
798 if (da7213->master) 798 if (da7213->master)
799 snd_soc_update_bits(codec, DA7213_DAI_CLK_MODE, 799 snd_soc_component_update_bits(component, DA7213_DAI_CLK_MODE,
800 DA7213_DAI_CLK_EN_MASK, 0); 800 DA7213_DAI_CLK_EN_MASK, 0);
801 return 0; 801 return 0;
802 default: 802 default:
@@ -1150,7 +1150,7 @@ static int da7213_hw_params(struct snd_pcm_substream *substream,
1150 struct snd_pcm_hw_params *params, 1150 struct snd_pcm_hw_params *params,
1151 struct snd_soc_dai *dai) 1151 struct snd_soc_dai *dai)
1152{ 1152{
1153 struct snd_soc_codec *codec = dai->codec; 1153 struct snd_soc_component *component = dai->component;
1154 u8 dai_ctrl = 0; 1154 u8 dai_ctrl = 0;
1155 u8 fs; 1155 u8 fs;
1156 1156
@@ -1208,17 +1208,17 @@ static int da7213_hw_params(struct snd_pcm_substream *substream,
1208 return -EINVAL; 1208 return -EINVAL;
1209 } 1209 }
1210 1210
1211 snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_WORD_LENGTH_MASK, 1211 snd_soc_component_update_bits(component, DA7213_DAI_CTRL, DA7213_DAI_WORD_LENGTH_MASK,
1212 dai_ctrl); 1212 dai_ctrl);
1213 snd_soc_write(codec, DA7213_SR, fs); 1213 snd_soc_component_write(component, DA7213_SR, fs);
1214 1214
1215 return 0; 1215 return 0;
1216} 1216}
1217 1217
1218static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) 1218static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
1219{ 1219{
1220 struct snd_soc_codec *codec = codec_dai->codec; 1220 struct snd_soc_component *component = codec_dai->component;
1221 struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); 1221 struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
1222 u8 dai_clk_mode = 0, dai_ctrl = 0; 1222 u8 dai_clk_mode = 0, dai_ctrl = 0;
1223 u8 dai_offset = 0; 1223 u8 dai_offset = 0;
1224 1224
@@ -1305,27 +1305,27 @@ static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
1305 /* By default only 64 BCLK per WCLK is supported */ 1305 /* By default only 64 BCLK per WCLK is supported */
1306 dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_64; 1306 dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_64;
1307 1307
1308 snd_soc_write(codec, DA7213_DAI_CLK_MODE, dai_clk_mode); 1308 snd_soc_component_write(component, DA7213_DAI_CLK_MODE, dai_clk_mode);
1309 snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, 1309 snd_soc_component_update_bits(component, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK,
1310 dai_ctrl); 1310 dai_ctrl);
1311 snd_soc_write(codec, DA7213_DAI_OFFSET, dai_offset); 1311 snd_soc_component_write(component, DA7213_DAI_OFFSET, dai_offset);
1312 1312
1313 return 0; 1313 return 0;
1314} 1314}
1315 1315
1316static int da7213_mute(struct snd_soc_dai *dai, int mute) 1316static int da7213_mute(struct snd_soc_dai *dai, int mute)
1317{ 1317{
1318 struct snd_soc_codec *codec = dai->codec; 1318 struct snd_soc_component *component = dai->component;
1319 1319
1320 if (mute) { 1320 if (mute) {
1321 snd_soc_update_bits(codec, DA7213_DAC_L_CTRL, 1321 snd_soc_component_update_bits(component, DA7213_DAC_L_CTRL,
1322 DA7213_MUTE_EN, DA7213_MUTE_EN); 1322 DA7213_MUTE_EN, DA7213_MUTE_EN);
1323 snd_soc_update_bits(codec, DA7213_DAC_R_CTRL, 1323 snd_soc_component_update_bits(component, DA7213_DAC_R_CTRL,
1324 DA7213_MUTE_EN, DA7213_MUTE_EN); 1324 DA7213_MUTE_EN, DA7213_MUTE_EN);
1325 } else { 1325 } else {
1326 snd_soc_update_bits(codec, DA7213_DAC_L_CTRL, 1326 snd_soc_component_update_bits(component, DA7213_DAC_L_CTRL,
1327 DA7213_MUTE_EN, 0); 1327 DA7213_MUTE_EN, 0);
1328 snd_soc_update_bits(codec, DA7213_DAC_R_CTRL, 1328 snd_soc_component_update_bits(component, DA7213_DAC_R_CTRL,
1329 DA7213_MUTE_EN, 0); 1329 DA7213_MUTE_EN, 0);
1330 } 1330 }
1331 1331
@@ -1338,8 +1338,8 @@ static int da7213_mute(struct snd_soc_dai *dai, int mute)
1338static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai, 1338static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1339 int clk_id, unsigned int freq, int dir) 1339 int clk_id, unsigned int freq, int dir)
1340{ 1340{
1341 struct snd_soc_codec *codec = codec_dai->codec; 1341 struct snd_soc_component *component = codec_dai->component;
1342 struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); 1342 struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
1343 int ret = 0; 1343 int ret = 0;
1344 1344
1345 if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq)) 1345 if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq))
@@ -1353,11 +1353,11 @@ static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1353 1353
1354 switch (clk_id) { 1354 switch (clk_id) {
1355 case DA7213_CLKSRC_MCLK: 1355 case DA7213_CLKSRC_MCLK:
1356 snd_soc_update_bits(codec, DA7213_PLL_CTRL, 1356 snd_soc_component_update_bits(component, DA7213_PLL_CTRL,
1357 DA7213_PLL_MCLK_SQR_EN, 0); 1357 DA7213_PLL_MCLK_SQR_EN, 0);
1358 break; 1358 break;
1359 case DA7213_CLKSRC_MCLK_SQR: 1359 case DA7213_CLKSRC_MCLK_SQR:
1360 snd_soc_update_bits(codec, DA7213_PLL_CTRL, 1360 snd_soc_component_update_bits(component, DA7213_PLL_CTRL,
1361 DA7213_PLL_MCLK_SQR_EN, 1361 DA7213_PLL_MCLK_SQR_EN,
1362 DA7213_PLL_MCLK_SQR_EN); 1362 DA7213_PLL_MCLK_SQR_EN);
1363 break; 1363 break;
@@ -1387,8 +1387,8 @@ static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1387static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, 1387static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1388 int source, unsigned int fref, unsigned int fout) 1388 int source, unsigned int fref, unsigned int fout)
1389{ 1389{
1390 struct snd_soc_codec *codec = codec_dai->codec; 1390 struct snd_soc_component *component = codec_dai->component;
1391 struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); 1391 struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
1392 1392
1393 u8 pll_ctrl, indiv_bits, indiv; 1393 u8 pll_ctrl, indiv_bits, indiv;
1394 u8 pll_frac_top, pll_frac_bot, pll_integer; 1394 u8 pll_frac_top, pll_frac_bot, pll_integer;
@@ -1398,7 +1398,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1398 /* Workout input divider based on MCLK rate */ 1398 /* Workout input divider based on MCLK rate */
1399 if (da7213->mclk_rate == 32768) { 1399 if (da7213->mclk_rate == 32768) {
1400 if (!da7213->master) { 1400 if (!da7213->master) {
1401 dev_err(codec->dev, 1401 dev_err(component->dev,
1402 "32KHz only valid if codec is clock master\n"); 1402 "32KHz only valid if codec is clock master\n");
1403 return -EINVAL; 1403 return -EINVAL;
1404 } 1404 }
@@ -1411,7 +1411,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1411 1411
1412 } else { 1412 } else {
1413 if (da7213->mclk_rate < 5000000) { 1413 if (da7213->mclk_rate < 5000000) {
1414 dev_err(codec->dev, 1414 dev_err(component->dev,
1415 "PLL input clock %d below valid range\n", 1415 "PLL input clock %d below valid range\n",
1416 da7213->mclk_rate); 1416 da7213->mclk_rate);
1417 return -EINVAL; 1417 return -EINVAL;
@@ -1428,7 +1428,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1428 indiv_bits = DA7213_PLL_INDIV_36_TO_54_MHZ; 1428 indiv_bits = DA7213_PLL_INDIV_36_TO_54_MHZ;
1429 indiv = DA7213_PLL_INDIV_36_TO_54_MHZ_VAL; 1429 indiv = DA7213_PLL_INDIV_36_TO_54_MHZ_VAL;
1430 } else { 1430 } else {
1431 dev_err(codec->dev, 1431 dev_err(component->dev,
1432 "PLL input clock %d above valid range\n", 1432 "PLL input clock %d above valid range\n",
1433 da7213->mclk_rate); 1433 da7213->mclk_rate);
1434 return -EINVAL; 1434 return -EINVAL;
@@ -1441,7 +1441,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1441 /* Configure PLL */ 1441 /* Configure PLL */
1442 switch (source) { 1442 switch (source) {
1443 case DA7213_SYSCLK_MCLK: 1443 case DA7213_SYSCLK_MCLK:
1444 snd_soc_update_bits(codec, DA7213_PLL_CTRL, 1444 snd_soc_component_update_bits(component, DA7213_PLL_CTRL,
1445 DA7213_PLL_INDIV_MASK | 1445 DA7213_PLL_INDIV_MASK |
1446 DA7213_PLL_MODE_MASK, pll_ctrl); 1446 DA7213_PLL_MODE_MASK, pll_ctrl);
1447 return 0; 1447 return 0;
@@ -1453,7 +1453,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1453 break; 1453 break;
1454 case DA7213_SYSCLK_PLL_32KHZ: 1454 case DA7213_SYSCLK_PLL_32KHZ:
1455 if (da7213->mclk_rate != 32768) { 1455 if (da7213->mclk_rate != 32768) {
1456 dev_err(codec->dev, 1456 dev_err(component->dev,
1457 "32KHz mode only valid with 32KHz MCLK\n"); 1457 "32KHz mode only valid with 32KHz MCLK\n");
1458 return -EINVAL; 1458 return -EINVAL;
1459 } 1459 }
@@ -1462,7 +1462,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1462 fout = DA7213_PLL_FREQ_OUT_94310400; 1462 fout = DA7213_PLL_FREQ_OUT_94310400;
1463 break; 1463 break;
1464 default: 1464 default:
1465 dev_err(codec->dev, "Invalid PLL config\n"); 1465 dev_err(component->dev, "Invalid PLL config\n");
1466 return -EINVAL; 1466 return -EINVAL;
1467 } 1467 }
1468 1468
@@ -1474,22 +1474,22 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1474 pll_frac_bot = (frac_div) & DA7213_BYTE_MASK; 1474 pll_frac_bot = (frac_div) & DA7213_BYTE_MASK;
1475 1475
1476 /* Write PLL dividers */ 1476 /* Write PLL dividers */
1477 snd_soc_write(codec, DA7213_PLL_FRAC_TOP, pll_frac_top); 1477 snd_soc_component_write(component, DA7213_PLL_FRAC_TOP, pll_frac_top);
1478 snd_soc_write(codec, DA7213_PLL_FRAC_BOT, pll_frac_bot); 1478 snd_soc_component_write(component, DA7213_PLL_FRAC_BOT, pll_frac_bot);
1479 snd_soc_write(codec, DA7213_PLL_INTEGER, pll_integer); 1479 snd_soc_component_write(component, DA7213_PLL_INTEGER, pll_integer);
1480 1480
1481 /* Enable PLL */ 1481 /* Enable PLL */
1482 pll_ctrl |= DA7213_PLL_EN; 1482 pll_ctrl |= DA7213_PLL_EN;
1483 snd_soc_update_bits(codec, DA7213_PLL_CTRL, 1483 snd_soc_component_update_bits(component, DA7213_PLL_CTRL,
1484 DA7213_PLL_INDIV_MASK | DA7213_PLL_MODE_MASK, 1484 DA7213_PLL_INDIV_MASK | DA7213_PLL_MODE_MASK,
1485 pll_ctrl); 1485 pll_ctrl);
1486 1486
1487 /* Assist 32KHz mode PLL lock */ 1487 /* Assist 32KHz mode PLL lock */
1488 if (source == DA7213_SYSCLK_PLL_32KHZ) { 1488 if (source == DA7213_SYSCLK_PLL_32KHZ) {
1489 snd_soc_write(codec, 0xF0, 0x8B); 1489 snd_soc_component_write(component, 0xF0, 0x8B);
1490 snd_soc_write(codec, 0xF1, 0x03); 1490 snd_soc_component_write(component, 0xF1, 0x03);
1491 snd_soc_write(codec, 0xF1, 0x01); 1491 snd_soc_component_write(component, 0xF1, 0x01);
1492 snd_soc_write(codec, 0xF0, 0x00); 1492 snd_soc_component_write(component, 0xF0, 0x00);
1493 } 1493 }
1494 1494
1495 return 0; 1495 return 0;
@@ -1526,10 +1526,10 @@ static struct snd_soc_dai_driver da7213_dai = {
1526 .symmetric_rates = 1, 1526 .symmetric_rates = 1,
1527}; 1527};
1528 1528
1529static int da7213_set_bias_level(struct snd_soc_codec *codec, 1529static int da7213_set_bias_level(struct snd_soc_component *component,
1530 enum snd_soc_bias_level level) 1530 enum snd_soc_bias_level level)
1531{ 1531{
1532 struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); 1532 struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
1533 int ret; 1533 int ret;
1534 1534
1535 switch (level) { 1535 switch (level) {
@@ -1537,11 +1537,11 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec,
1537 break; 1537 break;
1538 case SND_SOC_BIAS_PREPARE: 1538 case SND_SOC_BIAS_PREPARE:
1539 /* Enable MCLK for transition to ON state */ 1539 /* Enable MCLK for transition to ON state */
1540 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { 1540 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) {
1541 if (da7213->mclk) { 1541 if (da7213->mclk) {
1542 ret = clk_prepare_enable(da7213->mclk); 1542 ret = clk_prepare_enable(da7213->mclk);
1543 if (ret) { 1543 if (ret) {
1544 dev_err(codec->dev, 1544 dev_err(component->dev,
1545 "Failed to enable mclk\n"); 1545 "Failed to enable mclk\n");
1546 return ret; 1546 return ret;
1547 } 1547 }
@@ -1549,9 +1549,9 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec,
1549 } 1549 }
1550 break; 1550 break;
1551 case SND_SOC_BIAS_STANDBY: 1551 case SND_SOC_BIAS_STANDBY:
1552 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 1552 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
1553 /* Enable VMID reference & master bias */ 1553 /* Enable VMID reference & master bias */
1554 snd_soc_update_bits(codec, DA7213_REFERENCES, 1554 snd_soc_component_update_bits(component, DA7213_REFERENCES,
1555 DA7213_VMID_EN | DA7213_BIAS_EN, 1555 DA7213_VMID_EN | DA7213_BIAS_EN,
1556 DA7213_VMID_EN | DA7213_BIAS_EN); 1556 DA7213_VMID_EN | DA7213_BIAS_EN);
1557 } else { 1557 } else {
@@ -1562,7 +1562,7 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec,
1562 break; 1562 break;
1563 case SND_SOC_BIAS_OFF: 1563 case SND_SOC_BIAS_OFF:
1564 /* Disable VMID reference & master bias */ 1564 /* Disable VMID reference & master bias */
1565 snd_soc_update_bits(codec, DA7213_REFERENCES, 1565 snd_soc_component_update_bits(component, DA7213_REFERENCES,
1566 DA7213_VMID_EN | DA7213_BIAS_EN, 0); 1566 DA7213_VMID_EN | DA7213_BIAS_EN, 0);
1567 break; 1567 break;
1568 } 1568 }
@@ -1588,7 +1588,7 @@ MODULE_DEVICE_TABLE(acpi, da7213_acpi_match);
1588#endif 1588#endif
1589 1589
1590static enum da7213_micbias_voltage 1590static enum da7213_micbias_voltage
1591 da7213_of_micbias_lvl(struct snd_soc_codec *codec, u32 val) 1591 da7213_of_micbias_lvl(struct snd_soc_component *component, u32 val)
1592{ 1592{
1593 switch (val) { 1593 switch (val) {
1594 case 1600: 1594 case 1600:
@@ -1600,39 +1600,39 @@ static enum da7213_micbias_voltage
1600 case 3000: 1600 case 3000:
1601 return DA7213_MICBIAS_3_0V; 1601 return DA7213_MICBIAS_3_0V;
1602 default: 1602 default:
1603 dev_warn(codec->dev, "Invalid micbias level\n"); 1603 dev_warn(component->dev, "Invalid micbias level\n");
1604 return DA7213_MICBIAS_2_2V; 1604 return DA7213_MICBIAS_2_2V;
1605 } 1605 }
1606} 1606}
1607 1607
1608static enum da7213_dmic_data_sel 1608static enum da7213_dmic_data_sel
1609 da7213_of_dmic_data_sel(struct snd_soc_codec *codec, const char *str) 1609 da7213_of_dmic_data_sel(struct snd_soc_component *component, const char *str)
1610{ 1610{
1611 if (!strcmp(str, "lrise_rfall")) { 1611 if (!strcmp(str, "lrise_rfall")) {
1612 return DA7213_DMIC_DATA_LRISE_RFALL; 1612 return DA7213_DMIC_DATA_LRISE_RFALL;
1613 } else if (!strcmp(str, "lfall_rrise")) { 1613 } else if (!strcmp(str, "lfall_rrise")) {
1614 return DA7213_DMIC_DATA_LFALL_RRISE; 1614 return DA7213_DMIC_DATA_LFALL_RRISE;
1615 } else { 1615 } else {
1616 dev_warn(codec->dev, "Invalid DMIC data select type\n"); 1616 dev_warn(component->dev, "Invalid DMIC data select type\n");
1617 return DA7213_DMIC_DATA_LRISE_RFALL; 1617 return DA7213_DMIC_DATA_LRISE_RFALL;
1618 } 1618 }
1619} 1619}
1620 1620
1621static enum da7213_dmic_samplephase 1621static enum da7213_dmic_samplephase
1622 da7213_of_dmic_samplephase(struct snd_soc_codec *codec, const char *str) 1622 da7213_of_dmic_samplephase(struct snd_soc_component *component, const char *str)
1623{ 1623{
1624 if (!strcmp(str, "on_clkedge")) { 1624 if (!strcmp(str, "on_clkedge")) {
1625 return DA7213_DMIC_SAMPLE_ON_CLKEDGE; 1625 return DA7213_DMIC_SAMPLE_ON_CLKEDGE;
1626 } else if (!strcmp(str, "between_clkedge")) { 1626 } else if (!strcmp(str, "between_clkedge")) {
1627 return DA7213_DMIC_SAMPLE_BETWEEN_CLKEDGE; 1627 return DA7213_DMIC_SAMPLE_BETWEEN_CLKEDGE;
1628 } else { 1628 } else {
1629 dev_warn(codec->dev, "Invalid DMIC sample phase\n"); 1629 dev_warn(component->dev, "Invalid DMIC sample phase\n");
1630 return DA7213_DMIC_SAMPLE_ON_CLKEDGE; 1630 return DA7213_DMIC_SAMPLE_ON_CLKEDGE;
1631 } 1631 }
1632} 1632}
1633 1633
1634static enum da7213_dmic_clk_rate 1634static enum da7213_dmic_clk_rate
1635 da7213_of_dmic_clkrate(struct snd_soc_codec *codec, u32 val) 1635 da7213_of_dmic_clkrate(struct snd_soc_component *component, u32 val)
1636{ 1636{
1637 switch (val) { 1637 switch (val) {
1638 case 1500000: 1638 case 1500000:
@@ -1640,46 +1640,46 @@ static enum da7213_dmic_clk_rate
1640 case 3000000: 1640 case 3000000:
1641 return DA7213_DMIC_CLK_3_0MHZ; 1641 return DA7213_DMIC_CLK_3_0MHZ;
1642 default: 1642 default:
1643 dev_warn(codec->dev, "Invalid DMIC clock rate\n"); 1643 dev_warn(component->dev, "Invalid DMIC clock rate\n");
1644 return DA7213_DMIC_CLK_1_5MHZ; 1644 return DA7213_DMIC_CLK_1_5MHZ;
1645 } 1645 }
1646} 1646}
1647 1647
1648static struct da7213_platform_data 1648static struct da7213_platform_data
1649 *da7213_fw_to_pdata(struct snd_soc_codec *codec) 1649 *da7213_fw_to_pdata(struct snd_soc_component *component)
1650{ 1650{
1651 struct device *dev = codec->dev; 1651 struct device *dev = component->dev;
1652 struct da7213_platform_data *pdata; 1652 struct da7213_platform_data *pdata;
1653 const char *fw_str; 1653 const char *fw_str;
1654 u32 fw_val32; 1654 u32 fw_val32;
1655 1655
1656 pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); 1656 pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL);
1657 if (!pdata) 1657 if (!pdata)
1658 return NULL; 1658 return NULL;
1659 1659
1660 if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0) 1660 if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0)
1661 pdata->micbias1_lvl = da7213_of_micbias_lvl(codec, fw_val32); 1661 pdata->micbias1_lvl = da7213_of_micbias_lvl(component, fw_val32);
1662 else 1662 else
1663 pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; 1663 pdata->micbias1_lvl = DA7213_MICBIAS_2_2V;
1664 1664
1665 if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0) 1665 if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0)
1666 pdata->micbias2_lvl = da7213_of_micbias_lvl(codec, fw_val32); 1666 pdata->micbias2_lvl = da7213_of_micbias_lvl(component, fw_val32);
1667 else 1667 else
1668 pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; 1668 pdata->micbias2_lvl = DA7213_MICBIAS_2_2V;
1669 1669
1670 if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str)) 1670 if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str))
1671 pdata->dmic_data_sel = da7213_of_dmic_data_sel(codec, fw_str); 1671 pdata->dmic_data_sel = da7213_of_dmic_data_sel(component, fw_str);
1672 else 1672 else
1673 pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; 1673 pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL;
1674 1674
1675 if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str)) 1675 if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str))
1676 pdata->dmic_samplephase = 1676 pdata->dmic_samplephase =
1677 da7213_of_dmic_samplephase(codec, fw_str); 1677 da7213_of_dmic_samplephase(component, fw_str);
1678 else 1678 else
1679 pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; 1679 pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE;
1680 1680
1681 if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0) 1681 if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0)
1682 pdata->dmic_clk_rate = da7213_of_dmic_clkrate(codec, fw_val32); 1682 pdata->dmic_clk_rate = da7213_of_dmic_clkrate(component, fw_val32);
1683 else 1683 else
1684 pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; 1684 pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ;
1685 1685
@@ -1687,41 +1687,41 @@ static struct da7213_platform_data
1687} 1687}
1688 1688
1689 1689
1690static int da7213_probe(struct snd_soc_codec *codec) 1690static int da7213_probe(struct snd_soc_component *component)
1691{ 1691{
1692 struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); 1692 struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
1693 1693
1694 /* Default to using ALC auto offset calibration mode. */ 1694 /* Default to using ALC auto offset calibration mode. */
1695 snd_soc_update_bits(codec, DA7213_ALC_CTRL1, 1695 snd_soc_component_update_bits(component, DA7213_ALC_CTRL1,
1696 DA7213_ALC_CALIB_MODE_MAN, 0); 1696 DA7213_ALC_CALIB_MODE_MAN, 0);
1697 da7213->alc_calib_auto = true; 1697 da7213->alc_calib_auto = true;
1698 1698
1699 /* Default PC counter to free-running */ 1699 /* Default PC counter to free-running */
1700 snd_soc_update_bits(codec, DA7213_PC_COUNT, DA7213_PC_FREERUN_MASK, 1700 snd_soc_component_update_bits(component, DA7213_PC_COUNT, DA7213_PC_FREERUN_MASK,
1701 DA7213_PC_FREERUN_MASK); 1701 DA7213_PC_FREERUN_MASK);
1702 1702
1703 /* Enable all Gain Ramps */ 1703 /* Enable all Gain Ramps */
1704 snd_soc_update_bits(codec, DA7213_AUX_L_CTRL, 1704 snd_soc_component_update_bits(component, DA7213_AUX_L_CTRL,
1705 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1705 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1706 snd_soc_update_bits(codec, DA7213_AUX_R_CTRL, 1706 snd_soc_component_update_bits(component, DA7213_AUX_R_CTRL,
1707 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1707 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1708 snd_soc_update_bits(codec, DA7213_MIXIN_L_CTRL, 1708 snd_soc_component_update_bits(component, DA7213_MIXIN_L_CTRL,
1709 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1709 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1710 snd_soc_update_bits(codec, DA7213_MIXIN_R_CTRL, 1710 snd_soc_component_update_bits(component, DA7213_MIXIN_R_CTRL,
1711 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1711 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1712 snd_soc_update_bits(codec, DA7213_ADC_L_CTRL, 1712 snd_soc_component_update_bits(component, DA7213_ADC_L_CTRL,
1713 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1713 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1714 snd_soc_update_bits(codec, DA7213_ADC_R_CTRL, 1714 snd_soc_component_update_bits(component, DA7213_ADC_R_CTRL,
1715 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1715 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1716 snd_soc_update_bits(codec, DA7213_DAC_L_CTRL, 1716 snd_soc_component_update_bits(component, DA7213_DAC_L_CTRL,
1717 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1717 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1718 snd_soc_update_bits(codec, DA7213_DAC_R_CTRL, 1718 snd_soc_component_update_bits(component, DA7213_DAC_R_CTRL,
1719 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1719 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1720 snd_soc_update_bits(codec, DA7213_HP_L_CTRL, 1720 snd_soc_component_update_bits(component, DA7213_HP_L_CTRL,
1721 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1721 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1722 snd_soc_update_bits(codec, DA7213_HP_R_CTRL, 1722 snd_soc_component_update_bits(component, DA7213_HP_R_CTRL,
1723 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1723 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1724 snd_soc_update_bits(codec, DA7213_LINE_CTRL, 1724 snd_soc_component_update_bits(component, DA7213_LINE_CTRL,
1725 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); 1725 DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN);
1726 1726
1727 /* 1727 /*
@@ -1732,28 +1732,28 @@ static int da7213_probe(struct snd_soc_codec *codec)
1732 * being managed by DAPM while other (non power related) bits are 1732 * being managed by DAPM while other (non power related) bits are
1733 * enabled here 1733 * enabled here
1734 */ 1734 */
1735 snd_soc_update_bits(codec, DA7213_MIXIN_L_CTRL, 1735 snd_soc_component_update_bits(component, DA7213_MIXIN_L_CTRL,
1736 DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN); 1736 DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN);
1737 snd_soc_update_bits(codec, DA7213_MIXIN_R_CTRL, 1737 snd_soc_component_update_bits(component, DA7213_MIXIN_R_CTRL,
1738 DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN); 1738 DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN);
1739 1739
1740 snd_soc_update_bits(codec, DA7213_MIXOUT_L_CTRL, 1740 snd_soc_component_update_bits(component, DA7213_MIXOUT_L_CTRL,
1741 DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN); 1741 DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN);
1742 snd_soc_update_bits(codec, DA7213_MIXOUT_R_CTRL, 1742 snd_soc_component_update_bits(component, DA7213_MIXOUT_R_CTRL,
1743 DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN); 1743 DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN);
1744 1744
1745 snd_soc_update_bits(codec, DA7213_HP_L_CTRL, 1745 snd_soc_component_update_bits(component, DA7213_HP_L_CTRL,
1746 DA7213_HP_AMP_OE, DA7213_HP_AMP_OE); 1746 DA7213_HP_AMP_OE, DA7213_HP_AMP_OE);
1747 snd_soc_update_bits(codec, DA7213_HP_R_CTRL, 1747 snd_soc_component_update_bits(component, DA7213_HP_R_CTRL,
1748 DA7213_HP_AMP_OE, DA7213_HP_AMP_OE); 1748 DA7213_HP_AMP_OE, DA7213_HP_AMP_OE);
1749 1749
1750 snd_soc_update_bits(codec, DA7213_LINE_CTRL, 1750 snd_soc_component_update_bits(component, DA7213_LINE_CTRL,
1751 DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE); 1751 DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE);
1752 1752
1753 /* Handle DT/Platform data */ 1753 /* Handle DT/Platform data */
1754 da7213->pdata = dev_get_platdata(codec->dev); 1754 da7213->pdata = dev_get_platdata(component->dev);
1755 if (!da7213->pdata) 1755 if (!da7213->pdata)
1756 da7213->pdata = da7213_fw_to_pdata(codec); 1756 da7213->pdata = da7213_fw_to_pdata(component);
1757 1757
1758 /* Set platform data values */ 1758 /* Set platform data values */
1759 if (da7213->pdata) { 1759 if (da7213->pdata) {
@@ -1779,7 +1779,7 @@ static int da7213_probe(struct snd_soc_codec *codec)
1779 DA7213_MICBIAS2_LEVEL_SHIFT); 1779 DA7213_MICBIAS2_LEVEL_SHIFT);
1780 break; 1780 break;
1781 } 1781 }
1782 snd_soc_update_bits(codec, DA7213_MICBIAS_CTRL, 1782 snd_soc_component_update_bits(component, DA7213_MICBIAS_CTRL,
1783 DA7213_MICBIAS1_LEVEL_MASK | 1783 DA7213_MICBIAS1_LEVEL_MASK |
1784 DA7213_MICBIAS2_LEVEL_MASK, micbias_lvl); 1784 DA7213_MICBIAS2_LEVEL_MASK, micbias_lvl);
1785 1785
@@ -1805,14 +1805,14 @@ static int da7213_probe(struct snd_soc_codec *codec)
1805 DA7213_DMIC_CLK_RATE_SHIFT); 1805 DA7213_DMIC_CLK_RATE_SHIFT);
1806 break; 1806 break;
1807 } 1807 }
1808 snd_soc_update_bits(codec, DA7213_MIC_CONFIG, 1808 snd_soc_component_update_bits(component, DA7213_MIC_CONFIG,
1809 DA7213_DMIC_DATA_SEL_MASK | 1809 DA7213_DMIC_DATA_SEL_MASK |
1810 DA7213_DMIC_SAMPLEPHASE_MASK | 1810 DA7213_DMIC_SAMPLEPHASE_MASK |
1811 DA7213_DMIC_CLK_RATE_MASK, dmic_cfg); 1811 DA7213_DMIC_CLK_RATE_MASK, dmic_cfg);
1812 } 1812 }
1813 1813
1814 /* Check if MCLK provided */ 1814 /* Check if MCLK provided */
1815 da7213->mclk = devm_clk_get(codec->dev, "mclk"); 1815 da7213->mclk = devm_clk_get(component->dev, "mclk");
1816 if (IS_ERR(da7213->mclk)) { 1816 if (IS_ERR(da7213->mclk)) {
1817 if (PTR_ERR(da7213->mclk) != -ENOENT) 1817 if (PTR_ERR(da7213->mclk) != -ENOENT)
1818 return PTR_ERR(da7213->mclk); 1818 return PTR_ERR(da7213->mclk);
@@ -1823,18 +1823,19 @@ static int da7213_probe(struct snd_soc_codec *codec)
1823 return 0; 1823 return 0;
1824} 1824}
1825 1825
1826static const struct snd_soc_codec_driver soc_codec_dev_da7213 = { 1826static const struct snd_soc_component_driver soc_component_dev_da7213 = {
1827 .probe = da7213_probe, 1827 .probe = da7213_probe,
1828 .set_bias_level = da7213_set_bias_level, 1828 .set_bias_level = da7213_set_bias_level,
1829 1829 .controls = da7213_snd_controls,
1830 .component_driver = { 1830 .num_controls = ARRAY_SIZE(da7213_snd_controls),
1831 .controls = da7213_snd_controls, 1831 .dapm_widgets = da7213_dapm_widgets,
1832 .num_controls = ARRAY_SIZE(da7213_snd_controls), 1832 .num_dapm_widgets = ARRAY_SIZE(da7213_dapm_widgets),
1833 .dapm_widgets = da7213_dapm_widgets, 1833 .dapm_routes = da7213_audio_map,
1834 .num_dapm_widgets = ARRAY_SIZE(da7213_dapm_widgets), 1834 .num_dapm_routes = ARRAY_SIZE(da7213_audio_map),
1835 .dapm_routes = da7213_audio_map, 1835 .idle_bias_on = 1,
1836 .num_dapm_routes = ARRAY_SIZE(da7213_audio_map), 1836 .use_pmdown_time = 1,
1837 }, 1837 .endianness = 1,
1838 .non_legacy_dai_naming = 1,
1838}; 1839};
1839 1840
1840static const struct regmap_config da7213_regmap_config = { 1841static const struct regmap_config da7213_regmap_config = {
@@ -1866,21 +1867,15 @@ static int da7213_i2c_probe(struct i2c_client *i2c,
1866 return ret; 1867 return ret;
1867 } 1868 }
1868 1869
1869 ret = snd_soc_register_codec(&i2c->dev, 1870 ret = devm_snd_soc_register_component(&i2c->dev,
1870 &soc_codec_dev_da7213, &da7213_dai, 1); 1871 &soc_component_dev_da7213, &da7213_dai, 1);
1871 if (ret < 0) { 1872 if (ret < 0) {
1872 dev_err(&i2c->dev, "Failed to register da7213 codec: %d\n", 1873 dev_err(&i2c->dev, "Failed to register da7213 component: %d\n",
1873 ret); 1874 ret);
1874 } 1875 }
1875 return ret; 1876 return ret;
1876} 1877}
1877 1878
1878static int da7213_remove(struct i2c_client *client)
1879{
1880 snd_soc_unregister_codec(&client->dev);
1881 return 0;
1882}
1883
1884static const struct i2c_device_id da7213_i2c_id[] = { 1879static const struct i2c_device_id da7213_i2c_id[] = {
1885 { "da7213", 0 }, 1880 { "da7213", 0 },
1886 { } 1881 { }
@@ -1895,7 +1890,6 @@ static struct i2c_driver da7213_i2c_driver = {
1895 .acpi_match_table = ACPI_PTR(da7213_acpi_match), 1890 .acpi_match_table = ACPI_PTR(da7213_acpi_match),
1896 }, 1891 },
1897 .probe = da7213_i2c_probe, 1892 .probe = da7213_i2c_probe,
1898 .remove = da7213_remove,
1899 .id_table = da7213_i2c_id, 1893 .id_table = da7213_i2c_id,
1900}; 1894};
1901 1895