aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 23:01:46 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:48:34 -0500
commitbc596c4256507040743d9bbbf2b78fc82ec45893 (patch)
treeb43dd47ba6da335bd703ee3230302817628c8b2c
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: da7218: 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/da7218.c498
-rw-r--r--sound/soc/codecs/da7218.h2
2 files changed, 246 insertions, 254 deletions
diff --git a/sound/soc/codecs/da7218.c b/sound/soc/codecs/da7218.c
index 96c644a15b11..ddc90ac0b19f 100644
--- a/sound/soc/codecs/da7218.c
+++ b/sound/soc/codecs/da7218.c
@@ -291,7 +291,7 @@ static const struct soc_enum da7218_cp_tau_delay =
291 */ 291 */
292 292
293/* ALC */ 293/* ALC */
294static void da7218_alc_calib(struct snd_soc_codec *codec) 294static void da7218_alc_calib(struct snd_soc_component *component)
295{ 295{
296 u8 mic_1_ctrl, mic_2_ctrl; 296 u8 mic_1_ctrl, mic_2_ctrl;
297 u8 mixin_1_ctrl, mixin_2_ctrl; 297 u8 mixin_1_ctrl, mixin_2_ctrl;
@@ -302,59 +302,59 @@ static void da7218_alc_calib(struct snd_soc_codec *codec)
302 bool calibrated = false; 302 bool calibrated = false;
303 303
304 /* Save current state of MIC control registers */ 304 /* Save current state of MIC control registers */
305 mic_1_ctrl = snd_soc_read(codec, DA7218_MIC_1_CTRL); 305 mic_1_ctrl = snd_soc_component_read32(component, DA7218_MIC_1_CTRL);
306 mic_2_ctrl = snd_soc_read(codec, DA7218_MIC_2_CTRL); 306 mic_2_ctrl = snd_soc_component_read32(component, DA7218_MIC_2_CTRL);
307 307
308 /* Save current state of input mixer control registers */ 308 /* Save current state of input mixer control registers */
309 mixin_1_ctrl = snd_soc_read(codec, DA7218_MIXIN_1_CTRL); 309 mixin_1_ctrl = snd_soc_component_read32(component, DA7218_MIXIN_1_CTRL);
310 mixin_2_ctrl = snd_soc_read(codec, DA7218_MIXIN_2_CTRL); 310 mixin_2_ctrl = snd_soc_component_read32(component, DA7218_MIXIN_2_CTRL);
311 311
312 /* Save current state of input filter control registers */ 312 /* Save current state of input filter control registers */
313 in_1l_filt_ctrl = snd_soc_read(codec, DA7218_IN_1L_FILTER_CTRL); 313 in_1l_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_1L_FILTER_CTRL);
314 in_1r_filt_ctrl = snd_soc_read(codec, DA7218_IN_1R_FILTER_CTRL); 314 in_1r_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_1R_FILTER_CTRL);
315 in_2l_filt_ctrl = snd_soc_read(codec, DA7218_IN_2L_FILTER_CTRL); 315 in_2l_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_2L_FILTER_CTRL);
316 in_2r_filt_ctrl = snd_soc_read(codec, DA7218_IN_2R_FILTER_CTRL); 316 in_2r_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_2R_FILTER_CTRL);
317 317
318 /* Save current state of input HPF control registers */ 318 /* Save current state of input HPF control registers */
319 in_1_hpf_ctrl = snd_soc_read(codec, DA7218_IN_1_HPF_FILTER_CTRL); 319 in_1_hpf_ctrl = snd_soc_component_read32(component, DA7218_IN_1_HPF_FILTER_CTRL);
320 in_2_hpf_ctrl = snd_soc_read(codec, DA7218_IN_2_HPF_FILTER_CTRL); 320 in_2_hpf_ctrl = snd_soc_component_read32(component, DA7218_IN_2_HPF_FILTER_CTRL);
321 321
322 /* Enable then Mute MIC PGAs */ 322 /* Enable then Mute MIC PGAs */
323 snd_soc_update_bits(codec, DA7218_MIC_1_CTRL, DA7218_MIC_1_AMP_EN_MASK, 323 snd_soc_component_update_bits(component, DA7218_MIC_1_CTRL, DA7218_MIC_1_AMP_EN_MASK,
324 DA7218_MIC_1_AMP_EN_MASK); 324 DA7218_MIC_1_AMP_EN_MASK);
325 snd_soc_update_bits(codec, DA7218_MIC_2_CTRL, DA7218_MIC_2_AMP_EN_MASK, 325 snd_soc_component_update_bits(component, DA7218_MIC_2_CTRL, DA7218_MIC_2_AMP_EN_MASK,
326 DA7218_MIC_2_AMP_EN_MASK); 326 DA7218_MIC_2_AMP_EN_MASK);
327 snd_soc_update_bits(codec, DA7218_MIC_1_CTRL, 327 snd_soc_component_update_bits(component, DA7218_MIC_1_CTRL,
328 DA7218_MIC_1_AMP_MUTE_EN_MASK, 328 DA7218_MIC_1_AMP_MUTE_EN_MASK,
329 DA7218_MIC_1_AMP_MUTE_EN_MASK); 329 DA7218_MIC_1_AMP_MUTE_EN_MASK);
330 snd_soc_update_bits(codec, DA7218_MIC_2_CTRL, 330 snd_soc_component_update_bits(component, DA7218_MIC_2_CTRL,
331 DA7218_MIC_2_AMP_MUTE_EN_MASK, 331 DA7218_MIC_2_AMP_MUTE_EN_MASK,
332 DA7218_MIC_2_AMP_MUTE_EN_MASK); 332 DA7218_MIC_2_AMP_MUTE_EN_MASK);
333 333
334 /* Enable input mixers unmuted */ 334 /* Enable input mixers unmuted */
335 snd_soc_update_bits(codec, DA7218_MIXIN_1_CTRL, 335 snd_soc_component_update_bits(component, DA7218_MIXIN_1_CTRL,
336 DA7218_MIXIN_1_AMP_EN_MASK | 336 DA7218_MIXIN_1_AMP_EN_MASK |
337 DA7218_MIXIN_1_AMP_MUTE_EN_MASK, 337 DA7218_MIXIN_1_AMP_MUTE_EN_MASK,
338 DA7218_MIXIN_1_AMP_EN_MASK); 338 DA7218_MIXIN_1_AMP_EN_MASK);
339 snd_soc_update_bits(codec, DA7218_MIXIN_2_CTRL, 339 snd_soc_component_update_bits(component, DA7218_MIXIN_2_CTRL,
340 DA7218_MIXIN_2_AMP_EN_MASK | 340 DA7218_MIXIN_2_AMP_EN_MASK |
341 DA7218_MIXIN_2_AMP_MUTE_EN_MASK, 341 DA7218_MIXIN_2_AMP_MUTE_EN_MASK,
342 DA7218_MIXIN_2_AMP_EN_MASK); 342 DA7218_MIXIN_2_AMP_EN_MASK);
343 343
344 /* Enable input filters unmuted */ 344 /* Enable input filters unmuted */
345 snd_soc_update_bits(codec, DA7218_IN_1L_FILTER_CTRL, 345 snd_soc_component_update_bits(component, DA7218_IN_1L_FILTER_CTRL,
346 DA7218_IN_1L_FILTER_EN_MASK | 346 DA7218_IN_1L_FILTER_EN_MASK |
347 DA7218_IN_1L_MUTE_EN_MASK, 347 DA7218_IN_1L_MUTE_EN_MASK,
348 DA7218_IN_1L_FILTER_EN_MASK); 348 DA7218_IN_1L_FILTER_EN_MASK);
349 snd_soc_update_bits(codec, DA7218_IN_1R_FILTER_CTRL, 349 snd_soc_component_update_bits(component, DA7218_IN_1R_FILTER_CTRL,
350 DA7218_IN_1R_FILTER_EN_MASK | 350 DA7218_IN_1R_FILTER_EN_MASK |
351 DA7218_IN_1R_MUTE_EN_MASK, 351 DA7218_IN_1R_MUTE_EN_MASK,
352 DA7218_IN_1R_FILTER_EN_MASK); 352 DA7218_IN_1R_FILTER_EN_MASK);
353 snd_soc_update_bits(codec, DA7218_IN_2L_FILTER_CTRL, 353 snd_soc_component_update_bits(component, DA7218_IN_2L_FILTER_CTRL,
354 DA7218_IN_2L_FILTER_EN_MASK | 354 DA7218_IN_2L_FILTER_EN_MASK |
355 DA7218_IN_2L_MUTE_EN_MASK, 355 DA7218_IN_2L_MUTE_EN_MASK,
356 DA7218_IN_2L_FILTER_EN_MASK); 356 DA7218_IN_2L_FILTER_EN_MASK);
357 snd_soc_update_bits(codec, DA7218_IN_2R_FILTER_CTRL, 357 snd_soc_component_update_bits(component, DA7218_IN_2R_FILTER_CTRL,
358 DA7218_IN_2R_FILTER_EN_MASK | 358 DA7218_IN_2R_FILTER_EN_MASK |
359 DA7218_IN_2R_MUTE_EN_MASK, 359 DA7218_IN_2R_MUTE_EN_MASK,
360 DA7218_IN_2R_FILTER_EN_MASK); 360 DA7218_IN_2R_FILTER_EN_MASK);
@@ -364,16 +364,16 @@ static void da7218_alc_calib(struct snd_soc_codec *codec)
364 * rates above 32KHz the ADC signals will be stopped and will cause 364 * rates above 32KHz the ADC signals will be stopped and will cause
365 * calibration to lock up. 365 * calibration to lock up.
366 */ 366 */
367 snd_soc_update_bits(codec, DA7218_IN_1_HPF_FILTER_CTRL, 367 snd_soc_component_update_bits(component, DA7218_IN_1_HPF_FILTER_CTRL,
368 DA7218_IN_1_VOICE_EN_MASK, 0); 368 DA7218_IN_1_VOICE_EN_MASK, 0);
369 snd_soc_update_bits(codec, DA7218_IN_2_HPF_FILTER_CTRL, 369 snd_soc_component_update_bits(component, DA7218_IN_2_HPF_FILTER_CTRL,
370 DA7218_IN_2_VOICE_EN_MASK, 0); 370 DA7218_IN_2_VOICE_EN_MASK, 0);
371 371
372 /* Perform auto calibration */ 372 /* Perform auto calibration */
373 snd_soc_update_bits(codec, DA7218_CALIB_CTRL, DA7218_CALIB_AUTO_EN_MASK, 373 snd_soc_component_update_bits(component, DA7218_CALIB_CTRL, DA7218_CALIB_AUTO_EN_MASK,
374 DA7218_CALIB_AUTO_EN_MASK); 374 DA7218_CALIB_AUTO_EN_MASK);
375 do { 375 do {
376 calib_ctrl = snd_soc_read(codec, DA7218_CALIB_CTRL); 376 calib_ctrl = snd_soc_component_read32(component, DA7218_CALIB_CTRL);
377 if (calib_ctrl & DA7218_CALIB_AUTO_EN_MASK) { 377 if (calib_ctrl & DA7218_CALIB_AUTO_EN_MASK) {
378 ++i; 378 ++i;
379 usleep_range(DA7218_ALC_CALIB_DELAY_MIN, 379 usleep_range(DA7218_ALC_CALIB_DELAY_MIN,
@@ -386,51 +386,51 @@ static void da7218_alc_calib(struct snd_soc_codec *codec)
386 386
387 /* If auto calibration fails, disable DC offset, hybrid ALC */ 387 /* If auto calibration fails, disable DC offset, hybrid ALC */
388 if ((!calibrated) || (calib_ctrl & DA7218_CALIB_OVERFLOW_MASK)) { 388 if ((!calibrated) || (calib_ctrl & DA7218_CALIB_OVERFLOW_MASK)) {
389 dev_warn(codec->dev, 389 dev_warn(component->dev,
390 "ALC auto calibration failed - %s\n", 390 "ALC auto calibration failed - %s\n",
391 (calibrated) ? "overflow" : "timeout"); 391 (calibrated) ? "overflow" : "timeout");
392 snd_soc_update_bits(codec, DA7218_CALIB_CTRL, 392 snd_soc_component_update_bits(component, DA7218_CALIB_CTRL,
393 DA7218_CALIB_OFFSET_EN_MASK, 0); 393 DA7218_CALIB_OFFSET_EN_MASK, 0);
394 snd_soc_update_bits(codec, DA7218_ALC_CTRL1, 394 snd_soc_component_update_bits(component, DA7218_ALC_CTRL1,
395 DA7218_ALC_SYNC_MODE_MASK, 0); 395 DA7218_ALC_SYNC_MODE_MASK, 0);
396 396
397 } else { 397 } else {
398 /* Enable DC offset cancellation */ 398 /* Enable DC offset cancellation */
399 snd_soc_update_bits(codec, DA7218_CALIB_CTRL, 399 snd_soc_component_update_bits(component, DA7218_CALIB_CTRL,
400 DA7218_CALIB_OFFSET_EN_MASK, 400 DA7218_CALIB_OFFSET_EN_MASK,
401 DA7218_CALIB_OFFSET_EN_MASK); 401 DA7218_CALIB_OFFSET_EN_MASK);
402 402
403 /* Enable ALC hybrid mode */ 403 /* Enable ALC hybrid mode */
404 snd_soc_update_bits(codec, DA7218_ALC_CTRL1, 404 snd_soc_component_update_bits(component, DA7218_ALC_CTRL1,
405 DA7218_ALC_SYNC_MODE_MASK, 405 DA7218_ALC_SYNC_MODE_MASK,
406 DA7218_ALC_SYNC_MODE_CH1 | 406 DA7218_ALC_SYNC_MODE_CH1 |
407 DA7218_ALC_SYNC_MODE_CH2); 407 DA7218_ALC_SYNC_MODE_CH2);
408 } 408 }
409 409
410 /* Restore input HPF control registers to original states */ 410 /* Restore input HPF control registers to original states */
411 snd_soc_write(codec, DA7218_IN_1_HPF_FILTER_CTRL, in_1_hpf_ctrl); 411 snd_soc_component_write(component, DA7218_IN_1_HPF_FILTER_CTRL, in_1_hpf_ctrl);
412 snd_soc_write(codec, DA7218_IN_2_HPF_FILTER_CTRL, in_2_hpf_ctrl); 412 snd_soc_component_write(component, DA7218_IN_2_HPF_FILTER_CTRL, in_2_hpf_ctrl);
413 413
414 /* Restore input filter control registers to original states */ 414 /* Restore input filter control registers to original states */
415 snd_soc_write(codec, DA7218_IN_1L_FILTER_CTRL, in_1l_filt_ctrl); 415 snd_soc_component_write(component, DA7218_IN_1L_FILTER_CTRL, in_1l_filt_ctrl);
416 snd_soc_write(codec, DA7218_IN_1R_FILTER_CTRL, in_1r_filt_ctrl); 416 snd_soc_component_write(component, DA7218_IN_1R_FILTER_CTRL, in_1r_filt_ctrl);
417 snd_soc_write(codec, DA7218_IN_2L_FILTER_CTRL, in_2l_filt_ctrl); 417 snd_soc_component_write(component, DA7218_IN_2L_FILTER_CTRL, in_2l_filt_ctrl);
418 snd_soc_write(codec, DA7218_IN_2R_FILTER_CTRL, in_2r_filt_ctrl); 418 snd_soc_component_write(component, DA7218_IN_2R_FILTER_CTRL, in_2r_filt_ctrl);
419 419
420 /* Restore input mixer control registers to original state */ 420 /* Restore input mixer control registers to original state */
421 snd_soc_write(codec, DA7218_MIXIN_1_CTRL, mixin_1_ctrl); 421 snd_soc_component_write(component, DA7218_MIXIN_1_CTRL, mixin_1_ctrl);
422 snd_soc_write(codec, DA7218_MIXIN_2_CTRL, mixin_2_ctrl); 422 snd_soc_component_write(component, DA7218_MIXIN_2_CTRL, mixin_2_ctrl);
423 423
424 /* Restore MIC control registers to original states */ 424 /* Restore MIC control registers to original states */
425 snd_soc_write(codec, DA7218_MIC_1_CTRL, mic_1_ctrl); 425 snd_soc_component_write(component, DA7218_MIC_1_CTRL, mic_1_ctrl);
426 snd_soc_write(codec, DA7218_MIC_2_CTRL, mic_2_ctrl); 426 snd_soc_component_write(component, DA7218_MIC_2_CTRL, mic_2_ctrl);
427} 427}
428 428
429static int da7218_mixin_gain_put(struct snd_kcontrol *kcontrol, 429static int da7218_mixin_gain_put(struct snd_kcontrol *kcontrol,
430 struct snd_ctl_elem_value *ucontrol) 430 struct snd_ctl_elem_value *ucontrol)
431{ 431{
432 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 432 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
433 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 433 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
434 int ret; 434 int ret;
435 435
436 ret = snd_soc_put_volsw(kcontrol, ucontrol); 436 ret = snd_soc_put_volsw(kcontrol, ucontrol);
@@ -440,7 +440,7 @@ static int da7218_mixin_gain_put(struct snd_kcontrol *kcontrol,
440 * make sure calibrated offsets are updated. 440 * make sure calibrated offsets are updated.
441 */ 441 */
442 if ((ret == 1) && (da7218->alc_en)) 442 if ((ret == 1) && (da7218->alc_en))
443 da7218_alc_calib(codec); 443 da7218_alc_calib(component);
444 444
445 return ret; 445 return ret;
446} 446}
@@ -450,8 +450,8 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol,
450{ 450{
451 struct soc_mixer_control *mc = 451 struct soc_mixer_control *mc =
452 (struct soc_mixer_control *) kcontrol->private_value; 452 (struct soc_mixer_control *) kcontrol->private_value;
453 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 453 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
454 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 454 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
455 unsigned int lvalue = ucontrol->value.integer.value[0]; 455 unsigned int lvalue = ucontrol->value.integer.value[0];
456 unsigned int rvalue = ucontrol->value.integer.value[1]; 456 unsigned int rvalue = ucontrol->value.integer.value[1];
457 unsigned int lshift = mc->shift; 457 unsigned int lshift = mc->shift;
@@ -460,7 +460,7 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol,
460 460
461 /* Force ALC offset calibration if enabling ALC */ 461 /* Force ALC offset calibration if enabling ALC */
462 if ((lvalue || rvalue) && (!da7218->alc_en)) 462 if ((lvalue || rvalue) && (!da7218->alc_en))
463 da7218_alc_calib(codec); 463 da7218_alc_calib(component);
464 464
465 /* Update bits to detail which channels are enabled/disabled */ 465 /* Update bits to detail which channels are enabled/disabled */
466 da7218->alc_en &= ~mask; 466 da7218->alc_en &= ~mask;
@@ -473,8 +473,8 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol,
473static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol, 473static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol,
474 struct snd_ctl_elem_value *ucontrol) 474 struct snd_ctl_elem_value *ucontrol)
475{ 475{
476 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 476 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
477 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 477 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
478 struct soc_mixer_control *mixer_ctrl = 478 struct soc_mixer_control *mixer_ctrl =
479 (struct soc_mixer_control *) kcontrol->private_value; 479 (struct soc_mixer_control *) kcontrol->private_value;
480 unsigned int reg = mixer_ctrl->reg; 480 unsigned int reg = mixer_ctrl->reg;
@@ -497,8 +497,8 @@ static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol,
497static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol, 497static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol,
498 struct snd_ctl_elem_value *ucontrol) 498 struct snd_ctl_elem_value *ucontrol)
499{ 499{
500 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 500 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
501 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 501 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
502 struct soc_mixer_control *mixer_ctrl = 502 struct soc_mixer_control *mixer_ctrl =
503 (struct soc_mixer_control *) kcontrol->private_value; 503 (struct soc_mixer_control *) kcontrol->private_value;
504 unsigned int reg = mixer_ctrl->reg; 504 unsigned int reg = mixer_ctrl->reg;
@@ -517,8 +517,8 @@ static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol,
517static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol, 517static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol,
518 struct snd_ctl_elem_value *ucontrol) 518 struct snd_ctl_elem_value *ucontrol)
519{ 519{
520 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 520 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
521 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 521 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
522 struct soc_mixer_control *mixer_ctrl = 522 struct soc_mixer_control *mixer_ctrl =
523 (struct soc_mixer_control *) kcontrol->private_value; 523 (struct soc_mixer_control *) kcontrol->private_value;
524 unsigned int lvalue = ucontrol->value.integer.value[0]; 524 unsigned int lvalue = ucontrol->value.integer.value[0];
@@ -537,15 +537,15 @@ static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol,
537 * power the path (IN_FILTER widget events). This handling avoids 537 * power the path (IN_FILTER widget events). This handling avoids
538 * unwanted level detect events. 538 * unwanted level detect events.
539 */ 539 */
540 return snd_soc_write(codec, mixer_ctrl->reg, 540 return snd_soc_component_write(component, mixer_ctrl->reg,
541 (da7218->in_filt_en & da7218->mic_lvl_det_en)); 541 (da7218->in_filt_en & da7218->mic_lvl_det_en));
542} 542}
543 543
544static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol, 544static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_value *ucontrol) 545 struct snd_ctl_elem_value *ucontrol)
546{ 546{
547 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 547 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
548 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 548 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
549 struct soc_mixer_control *mixer_ctrl = 549 struct soc_mixer_control *mixer_ctrl =
550 (struct soc_mixer_control *) kcontrol->private_value; 550 (struct soc_mixer_control *) kcontrol->private_value;
551 unsigned int lshift = mixer_ctrl->shift; 551 unsigned int lshift = mixer_ctrl->shift;
@@ -564,8 +564,8 @@ static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol,
564static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol, 564static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol,
565 struct snd_ctl_elem_value *ucontrol) 565 struct snd_ctl_elem_value *ucontrol)
566{ 566{
567 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 567 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
568 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 568 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
569 struct soc_bytes_ext *bytes_ext = 569 struct soc_bytes_ext *bytes_ext =
570 (struct soc_bytes_ext *) kcontrol->private_value; 570 (struct soc_bytes_ext *) kcontrol->private_value;
571 571
@@ -589,8 +589,8 @@ static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol,
589static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol, 589static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol,
590 struct snd_ctl_elem_value *ucontrol) 590 struct snd_ctl_elem_value *ucontrol)
591{ 591{
592 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 592 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
593 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 593 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
594 struct soc_bytes_ext *bytes_ext = 594 struct soc_bytes_ext *bytes_ext =
595 (struct soc_bytes_ext *) kcontrol->private_value; 595 (struct soc_bytes_ext *) kcontrol->private_value;
596 u8 reg, out_filt1l; 596 u8 reg, out_filt1l;
@@ -617,8 +617,8 @@ static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol,
617 } 617 }
618 618
619 /* Make sure at least out filter1 enabled to allow programming */ 619 /* Make sure at least out filter1 enabled to allow programming */
620 out_filt1l = snd_soc_read(codec, DA7218_OUT_1L_FILTER_CTRL); 620 out_filt1l = snd_soc_component_read32(component, DA7218_OUT_1L_FILTER_CTRL);
621 snd_soc_write(codec, DA7218_OUT_1L_FILTER_CTRL, 621 snd_soc_component_write(component, DA7218_OUT_1L_FILTER_CTRL,
622 out_filt1l | DA7218_OUT_1L_FILTER_EN_MASK); 622 out_filt1l | DA7218_OUT_1L_FILTER_EN_MASK);
623 623
624 for (i = 0; i < bytes_ext->max; ++i) { 624 for (i = 0; i < bytes_ext->max; ++i) {
@@ -628,7 +628,7 @@ static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol,
628 } 628 }
629 629
630 /* Restore filter to previous setting */ 630 /* Restore filter to previous setting */
631 snd_soc_write(codec, DA7218_OUT_1L_FILTER_CTRL, out_filt1l); 631 snd_soc_component_write(component, DA7218_OUT_1L_FILTER_CTRL, out_filt1l);
632 632
633 return 0; 633 return 0;
634} 634}
@@ -1349,8 +1349,8 @@ static const struct snd_kcontrol_new da7218_st_out_filtr_mix_controls[] = {
1349static int da7218_in_filter_event(struct snd_soc_dapm_widget *w, 1349static int da7218_in_filter_event(struct snd_soc_dapm_widget *w,
1350 struct snd_kcontrol *kcontrol, int event) 1350 struct snd_kcontrol *kcontrol, int event)
1351{ 1351{
1352 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 1352 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1353 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 1353 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
1354 u8 mask; 1354 u8 mask;
1355 1355
1356 switch (w->reg) { 1356 switch (w->reg) {
@@ -1389,7 +1389,7 @@ static int da7218_in_filter_event(struct snd_soc_dapm_widget *w,
1389 } 1389 }
1390 1390
1391 /* Enable configured level detection paths */ 1391 /* Enable configured level detection paths */
1392 snd_soc_write(codec, DA7218_LVL_DET_CTRL, 1392 snd_soc_component_write(component, DA7218_LVL_DET_CTRL,
1393 (da7218->in_filt_en & da7218->mic_lvl_det_en)); 1393 (da7218->in_filt_en & da7218->mic_lvl_det_en));
1394 1394
1395 return 0; 1395 return 0;
@@ -1398,8 +1398,8 @@ static int da7218_in_filter_event(struct snd_soc_dapm_widget *w,
1398static int da7218_dai_event(struct snd_soc_dapm_widget *w, 1398static int da7218_dai_event(struct snd_soc_dapm_widget *w,
1399 struct snd_kcontrol *kcontrol, int event) 1399 struct snd_kcontrol *kcontrol, int event)
1400{ 1400{
1401 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 1401 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1402 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 1402 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
1403 u8 pll_ctrl, pll_status, refosc_cal; 1403 u8 pll_ctrl, pll_status, refosc_cal;
1404 int i; 1404 int i;
1405 bool success; 1405 bool success;
@@ -1408,14 +1408,14 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w,
1408 case SND_SOC_DAPM_POST_PMU: 1408 case SND_SOC_DAPM_POST_PMU:
1409 if (da7218->master) 1409 if (da7218->master)
1410 /* Enable DAI clks for master mode */ 1410 /* Enable DAI clks for master mode */
1411 snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, 1411 snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE,
1412 DA7218_DAI_CLK_EN_MASK, 1412 DA7218_DAI_CLK_EN_MASK,
1413 DA7218_DAI_CLK_EN_MASK); 1413 DA7218_DAI_CLK_EN_MASK);
1414 1414
1415 /* Tune reference oscillator */ 1415 /* Tune reference oscillator */
1416 snd_soc_write(codec, DA7218_PLL_REFOSC_CAL, 1416 snd_soc_component_write(component, DA7218_PLL_REFOSC_CAL,
1417 DA7218_PLL_REFOSC_CAL_START_MASK); 1417 DA7218_PLL_REFOSC_CAL_START_MASK);
1418 snd_soc_write(codec, DA7218_PLL_REFOSC_CAL, 1418 snd_soc_component_write(component, DA7218_PLL_REFOSC_CAL,
1419 DA7218_PLL_REFOSC_CAL_START_MASK | 1419 DA7218_PLL_REFOSC_CAL_START_MASK |
1420 DA7218_PLL_REFOSC_CAL_EN_MASK); 1420 DA7218_PLL_REFOSC_CAL_EN_MASK);
1421 1421
@@ -1423,7 +1423,7 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w,
1423 i = 0; 1423 i = 0;
1424 success = false; 1424 success = false;
1425 do { 1425 do {
1426 refosc_cal = snd_soc_read(codec, DA7218_PLL_REFOSC_CAL); 1426 refosc_cal = snd_soc_component_read32(component, DA7218_PLL_REFOSC_CAL);
1427 if (!(refosc_cal & DA7218_PLL_REFOSC_CAL_START_MASK)) { 1427 if (!(refosc_cal & DA7218_PLL_REFOSC_CAL_START_MASK)) {
1428 success = true; 1428 success = true;
1429 } else { 1429 } else {
@@ -1434,15 +1434,15 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w,
1434 } while ((i < DA7218_REF_OSC_CHECK_TRIES) && (!success)); 1434 } while ((i < DA7218_REF_OSC_CHECK_TRIES) && (!success));
1435 1435
1436 if (!success) 1436 if (!success)
1437 dev_warn(codec->dev, 1437 dev_warn(component->dev,
1438 "Reference oscillator failed calibration\n"); 1438 "Reference oscillator failed calibration\n");
1439 1439
1440 /* PC synchronised to DAI */ 1440 /* PC synchronised to DAI */
1441 snd_soc_write(codec, DA7218_PC_COUNT, 1441 snd_soc_component_write(component, DA7218_PC_COUNT,
1442 DA7218_PC_RESYNC_AUTO_MASK); 1442 DA7218_PC_RESYNC_AUTO_MASK);
1443 1443
1444 /* If SRM not enabled, we don't need to check status */ 1444 /* If SRM not enabled, we don't need to check status */
1445 pll_ctrl = snd_soc_read(codec, DA7218_PLL_CTRL); 1445 pll_ctrl = snd_soc_component_read32(component, DA7218_PLL_CTRL);
1446 if ((pll_ctrl & DA7218_PLL_MODE_MASK) != DA7218_PLL_MODE_SRM) 1446 if ((pll_ctrl & DA7218_PLL_MODE_MASK) != DA7218_PLL_MODE_SRM)
1447 return 0; 1447 return 0;
1448 1448
@@ -1450,7 +1450,7 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w,
1450 i = 0; 1450 i = 0;
1451 success = false; 1451 success = false;
1452 do { 1452 do {
1453 pll_status = snd_soc_read(codec, DA7218_PLL_STATUS); 1453 pll_status = snd_soc_component_read32(component, DA7218_PLL_STATUS);
1454 if (pll_status & DA7218_PLL_SRM_STATUS_SRM_LOCK) { 1454 if (pll_status & DA7218_PLL_SRM_STATUS_SRM_LOCK) {
1455 success = true; 1455 success = true;
1456 } else { 1456 } else {
@@ -1460,16 +1460,16 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w,
1460 } while ((i < DA7218_SRM_CHECK_TRIES) && (!success)); 1460 } while ((i < DA7218_SRM_CHECK_TRIES) && (!success));
1461 1461
1462 if (!success) 1462 if (!success)
1463 dev_warn(codec->dev, "SRM failed to lock\n"); 1463 dev_warn(component->dev, "SRM failed to lock\n");
1464 1464
1465 return 0; 1465 return 0;
1466 case SND_SOC_DAPM_POST_PMD: 1466 case SND_SOC_DAPM_POST_PMD:
1467 /* PC free-running */ 1467 /* PC free-running */
1468 snd_soc_write(codec, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); 1468 snd_soc_component_write(component, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK);
1469 1469
1470 if (da7218->master) 1470 if (da7218->master)
1471 /* Disable DAI clks for master mode */ 1471 /* Disable DAI clks for master mode */
1472 snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, 1472 snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE,
1473 DA7218_DAI_CLK_EN_MASK, 0); 1473 DA7218_DAI_CLK_EN_MASK, 0);
1474 1474
1475 return 0; 1475 return 0;
@@ -1481,8 +1481,8 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w,
1481static int da7218_cp_event(struct snd_soc_dapm_widget *w, 1481static int da7218_cp_event(struct snd_soc_dapm_widget *w,
1482 struct snd_kcontrol *kcontrol, int event) 1482 struct snd_kcontrol *kcontrol, int event)
1483{ 1483{
1484 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 1484 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1485 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 1485 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
1486 1486
1487 /* 1487 /*
1488 * If this is DA7217 and we're using single supply for differential 1488 * If this is DA7217 and we're using single supply for differential
@@ -1493,11 +1493,11 @@ static int da7218_cp_event(struct snd_soc_dapm_widget *w,
1493 1493
1494 switch (event) { 1494 switch (event) {
1495 case SND_SOC_DAPM_PRE_PMU: 1495 case SND_SOC_DAPM_PRE_PMU:
1496 snd_soc_update_bits(codec, DA7218_CP_CTRL, DA7218_CP_EN_MASK, 1496 snd_soc_component_update_bits(component, DA7218_CP_CTRL, DA7218_CP_EN_MASK,
1497 DA7218_CP_EN_MASK); 1497 DA7218_CP_EN_MASK);
1498 return 0; 1498 return 0;
1499 case SND_SOC_DAPM_PRE_PMD: 1499 case SND_SOC_DAPM_PRE_PMD:
1500 snd_soc_update_bits(codec, DA7218_CP_CTRL, DA7218_CP_EN_MASK, 1500 snd_soc_component_update_bits(component, DA7218_CP_CTRL, DA7218_CP_EN_MASK,
1501 0); 1501 0);
1502 return 0; 1502 return 0;
1503 default: 1503 default:
@@ -1508,17 +1508,17 @@ static int da7218_cp_event(struct snd_soc_dapm_widget *w,
1508static int da7218_hp_pga_event(struct snd_soc_dapm_widget *w, 1508static int da7218_hp_pga_event(struct snd_soc_dapm_widget *w,
1509 struct snd_kcontrol *kcontrol, int event) 1509 struct snd_kcontrol *kcontrol, int event)
1510{ 1510{
1511 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 1511 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1512 1512
1513 switch (event) { 1513 switch (event) {
1514 case SND_SOC_DAPM_POST_PMU: 1514 case SND_SOC_DAPM_POST_PMU:
1515 /* Enable headphone output */ 1515 /* Enable headphone output */
1516 snd_soc_update_bits(codec, w->reg, DA7218_HP_AMP_OE_MASK, 1516 snd_soc_component_update_bits(component, w->reg, DA7218_HP_AMP_OE_MASK,
1517 DA7218_HP_AMP_OE_MASK); 1517 DA7218_HP_AMP_OE_MASK);
1518 return 0; 1518 return 0;
1519 case SND_SOC_DAPM_PRE_PMD: 1519 case SND_SOC_DAPM_PRE_PMD:
1520 /* Headphone output high impedance */ 1520 /* Headphone output high impedance */
1521 snd_soc_update_bits(codec, w->reg, DA7218_HP_AMP_OE_MASK, 0); 1521 snd_soc_component_update_bits(component, w->reg, DA7218_HP_AMP_OE_MASK, 0);
1522 return 0; 1522 return 0;
1523 default: 1523 default:
1524 return -EINVAL; 1524 return -EINVAL;
@@ -1813,8 +1813,8 @@ static const struct snd_soc_dapm_route da7218_audio_map[] = {
1813static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai, 1813static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1814 int clk_id, unsigned int freq, int dir) 1814 int clk_id, unsigned int freq, int dir)
1815{ 1815{
1816 struct snd_soc_codec *codec = codec_dai->codec; 1816 struct snd_soc_component *component = codec_dai->component;
1817 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 1817 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
1818 int ret; 1818 int ret;
1819 1819
1820 if (da7218->mclk_rate == freq) 1820 if (da7218->mclk_rate == freq)
@@ -1828,12 +1828,12 @@ static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1828 1828
1829 switch (clk_id) { 1829 switch (clk_id) {
1830 case DA7218_CLKSRC_MCLK_SQR: 1830 case DA7218_CLKSRC_MCLK_SQR:
1831 snd_soc_update_bits(codec, DA7218_PLL_CTRL, 1831 snd_soc_component_update_bits(component, DA7218_PLL_CTRL,
1832 DA7218_PLL_MCLK_SQR_EN_MASK, 1832 DA7218_PLL_MCLK_SQR_EN_MASK,
1833 DA7218_PLL_MCLK_SQR_EN_MASK); 1833 DA7218_PLL_MCLK_SQR_EN_MASK);
1834 break; 1834 break;
1835 case DA7218_CLKSRC_MCLK: 1835 case DA7218_CLKSRC_MCLK:
1836 snd_soc_update_bits(codec, DA7218_PLL_CTRL, 1836 snd_soc_component_update_bits(component, DA7218_PLL_CTRL,
1837 DA7218_PLL_MCLK_SQR_EN_MASK, 0); 1837 DA7218_PLL_MCLK_SQR_EN_MASK, 0);
1838 break; 1838 break;
1839 default: 1839 default:
@@ -1859,8 +1859,8 @@ static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1859static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, 1859static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1860 int source, unsigned int fref, unsigned int fout) 1860 int source, unsigned int fref, unsigned int fout)
1861{ 1861{
1862 struct snd_soc_codec *codec = codec_dai->codec; 1862 struct snd_soc_component *component = codec_dai->component;
1863 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 1863 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
1864 1864
1865 u8 pll_ctrl, indiv_bits, indiv; 1865 u8 pll_ctrl, indiv_bits, indiv;
1866 u8 pll_frac_top, pll_frac_bot, pll_integer; 1866 u8 pll_frac_top, pll_frac_bot, pll_integer;
@@ -1869,7 +1869,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1869 1869
1870 /* Verify 2MHz - 54MHz MCLK provided, and set input divider */ 1870 /* Verify 2MHz - 54MHz MCLK provided, and set input divider */
1871 if (da7218->mclk_rate < 2000000) { 1871 if (da7218->mclk_rate < 2000000) {
1872 dev_err(codec->dev, "PLL input clock %d below valid range\n", 1872 dev_err(component->dev, "PLL input clock %d below valid range\n",
1873 da7218->mclk_rate); 1873 da7218->mclk_rate);
1874 return -EINVAL; 1874 return -EINVAL;
1875 } else if (da7218->mclk_rate <= 4500000) { 1875 } else if (da7218->mclk_rate <= 4500000) {
@@ -1888,7 +1888,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1888 indiv_bits = DA7218_PLL_INDIV_36_TO_54_MHZ; 1888 indiv_bits = DA7218_PLL_INDIV_36_TO_54_MHZ;
1889 indiv = DA7218_PLL_INDIV_36_TO_54_MHZ_VAL; 1889 indiv = DA7218_PLL_INDIV_36_TO_54_MHZ_VAL;
1890 } else { 1890 } else {
1891 dev_err(codec->dev, "PLL input clock %d above valid range\n", 1891 dev_err(component->dev, "PLL input clock %d above valid range\n",
1892 da7218->mclk_rate); 1892 da7218->mclk_rate);
1893 return -EINVAL; 1893 return -EINVAL;
1894 } 1894 }
@@ -1899,7 +1899,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1899 switch (source) { 1899 switch (source) {
1900 case DA7218_SYSCLK_MCLK: 1900 case DA7218_SYSCLK_MCLK:
1901 pll_ctrl |= DA7218_PLL_MODE_BYPASS; 1901 pll_ctrl |= DA7218_PLL_MODE_BYPASS;
1902 snd_soc_update_bits(codec, DA7218_PLL_CTRL, 1902 snd_soc_component_update_bits(component, DA7218_PLL_CTRL,
1903 DA7218_PLL_INDIV_MASK | 1903 DA7218_PLL_INDIV_MASK |
1904 DA7218_PLL_MODE_MASK, pll_ctrl); 1904 DA7218_PLL_MODE_MASK, pll_ctrl);
1905 return 0; 1905 return 0;
@@ -1910,7 +1910,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1910 pll_ctrl |= DA7218_PLL_MODE_SRM; 1910 pll_ctrl |= DA7218_PLL_MODE_SRM;
1911 break; 1911 break;
1912 default: 1912 default:
1913 dev_err(codec->dev, "Invalid PLL config\n"); 1913 dev_err(component->dev, "Invalid PLL config\n");
1914 return -EINVAL; 1914 return -EINVAL;
1915 } 1915 }
1916 1916
@@ -1922,10 +1922,10 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1922 pll_frac_bot = (frac_div) & DA7218_BYTE_MASK; 1922 pll_frac_bot = (frac_div) & DA7218_BYTE_MASK;
1923 1923
1924 /* Write PLL config & dividers */ 1924 /* Write PLL config & dividers */
1925 snd_soc_write(codec, DA7218_PLL_FRAC_TOP, pll_frac_top); 1925 snd_soc_component_write(component, DA7218_PLL_FRAC_TOP, pll_frac_top);
1926 snd_soc_write(codec, DA7218_PLL_FRAC_BOT, pll_frac_bot); 1926 snd_soc_component_write(component, DA7218_PLL_FRAC_BOT, pll_frac_bot);
1927 snd_soc_write(codec, DA7218_PLL_INTEGER, pll_integer); 1927 snd_soc_component_write(component, DA7218_PLL_INTEGER, pll_integer);
1928 snd_soc_update_bits(codec, DA7218_PLL_CTRL, 1928 snd_soc_component_update_bits(component, DA7218_PLL_CTRL,
1929 DA7218_PLL_MODE_MASK | DA7218_PLL_INDIV_MASK, 1929 DA7218_PLL_MODE_MASK | DA7218_PLL_INDIV_MASK,
1930 pll_ctrl); 1930 pll_ctrl);
1931 1931
@@ -1934,8 +1934,8 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1934 1934
1935static int da7218_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) 1935static int da7218_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
1936{ 1936{
1937 struct snd_soc_codec *codec = codec_dai->codec; 1937 struct snd_soc_component *component = codec_dai->component;
1938 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 1938 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
1939 u8 dai_clk_mode = 0, dai_ctrl = 0; 1939 u8 dai_clk_mode = 0, dai_ctrl = 0;
1940 1940
1941 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 1941 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -2012,8 +2012,8 @@ static int da7218_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
2012 /* By default 64 BCLKs per WCLK is supported */ 2012 /* By default 64 BCLKs per WCLK is supported */
2013 dai_clk_mode |= DA7218_DAI_BCLKS_PER_WCLK_64; 2013 dai_clk_mode |= DA7218_DAI_BCLKS_PER_WCLK_64;
2014 2014
2015 snd_soc_write(codec, DA7218_DAI_CLK_MODE, dai_clk_mode); 2015 snd_soc_component_write(component, DA7218_DAI_CLK_MODE, dai_clk_mode);
2016 snd_soc_update_bits(codec, DA7218_DAI_CTRL, DA7218_DAI_FORMAT_MASK, 2016 snd_soc_component_update_bits(component, DA7218_DAI_CTRL, DA7218_DAI_FORMAT_MASK,
2017 dai_ctrl); 2017 dai_ctrl);
2018 2018
2019 return 0; 2019 return 0;
@@ -2023,16 +2023,16 @@ static int da7218_set_dai_tdm_slot(struct snd_soc_dai *dai,
2023 unsigned int tx_mask, unsigned int rx_mask, 2023 unsigned int tx_mask, unsigned int rx_mask,
2024 int slots, int slot_width) 2024 int slots, int slot_width)
2025{ 2025{
2026 struct snd_soc_codec *codec = dai->codec; 2026 struct snd_soc_component *component = dai->component;
2027 u8 dai_bclks_per_wclk; 2027 u8 dai_bclks_per_wclk;
2028 u32 frame_size; 2028 u32 frame_size;
2029 2029
2030 /* No channels enabled so disable TDM, revert to 64-bit frames */ 2030 /* No channels enabled so disable TDM, revert to 64-bit frames */
2031 if (!tx_mask) { 2031 if (!tx_mask) {
2032 snd_soc_update_bits(codec, DA7218_DAI_TDM_CTRL, 2032 snd_soc_component_update_bits(component, DA7218_DAI_TDM_CTRL,
2033 DA7218_DAI_TDM_CH_EN_MASK | 2033 DA7218_DAI_TDM_CH_EN_MASK |
2034 DA7218_DAI_TDM_MODE_EN_MASK, 0); 2034 DA7218_DAI_TDM_MODE_EN_MASK, 0);
2035 snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, 2035 snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE,
2036 DA7218_DAI_BCLKS_PER_WCLK_MASK, 2036 DA7218_DAI_BCLKS_PER_WCLK_MASK,
2037 DA7218_DAI_BCLKS_PER_WCLK_64); 2037 DA7218_DAI_BCLKS_PER_WCLK_64);
2038 return 0; 2038 return 0;
@@ -2040,14 +2040,14 @@ static int da7218_set_dai_tdm_slot(struct snd_soc_dai *dai,
2040 2040
2041 /* Check we have valid slots */ 2041 /* Check we have valid slots */
2042 if (fls(tx_mask) > DA7218_DAI_TDM_MAX_SLOTS) { 2042 if (fls(tx_mask) > DA7218_DAI_TDM_MAX_SLOTS) {
2043 dev_err(codec->dev, "Invalid number of slots, max = %d\n", 2043 dev_err(component->dev, "Invalid number of slots, max = %d\n",
2044 DA7218_DAI_TDM_MAX_SLOTS); 2044 DA7218_DAI_TDM_MAX_SLOTS);
2045 return -EINVAL; 2045 return -EINVAL;
2046 } 2046 }
2047 2047
2048 /* Check we have a valid offset given (first 2 bytes of rx_mask) */ 2048 /* Check we have a valid offset given (first 2 bytes of rx_mask) */
2049 if (rx_mask >> DA7218_2BYTE_SHIFT) { 2049 if (rx_mask >> DA7218_2BYTE_SHIFT) {
2050 dev_err(codec->dev, "Invalid slot offset, max = %d\n", 2050 dev_err(component->dev, "Invalid slot offset, max = %d\n",
2051 DA7218_2BYTE_MASK); 2051 DA7218_2BYTE_MASK);
2052 return -EINVAL; 2052 return -EINVAL;
2053 } 2053 }
@@ -2068,18 +2068,18 @@ static int da7218_set_dai_tdm_slot(struct snd_soc_dai *dai,
2068 dai_bclks_per_wclk = DA7218_DAI_BCLKS_PER_WCLK_256; 2068 dai_bclks_per_wclk = DA7218_DAI_BCLKS_PER_WCLK_256;
2069 break; 2069 break;
2070 default: 2070 default:
2071 dev_err(codec->dev, "Invalid frame size\n"); 2071 dev_err(component->dev, "Invalid frame size\n");
2072 return -EINVAL; 2072 return -EINVAL;
2073 } 2073 }
2074 2074
2075 snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, 2075 snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE,
2076 DA7218_DAI_BCLKS_PER_WCLK_MASK, 2076 DA7218_DAI_BCLKS_PER_WCLK_MASK,
2077 dai_bclks_per_wclk); 2077 dai_bclks_per_wclk);
2078 snd_soc_write(codec, DA7218_DAI_OFFSET_LOWER, 2078 snd_soc_component_write(component, DA7218_DAI_OFFSET_LOWER,
2079 (rx_mask & DA7218_BYTE_MASK)); 2079 (rx_mask & DA7218_BYTE_MASK));
2080 snd_soc_write(codec, DA7218_DAI_OFFSET_UPPER, 2080 snd_soc_component_write(component, DA7218_DAI_OFFSET_UPPER,
2081 ((rx_mask >> DA7218_BYTE_SHIFT) & DA7218_BYTE_MASK)); 2081 ((rx_mask >> DA7218_BYTE_SHIFT) & DA7218_BYTE_MASK));
2082 snd_soc_update_bits(codec, DA7218_DAI_TDM_CTRL, 2082 snd_soc_component_update_bits(component, DA7218_DAI_TDM_CTRL,
2083 DA7218_DAI_TDM_CH_EN_MASK | 2083 DA7218_DAI_TDM_CH_EN_MASK |
2084 DA7218_DAI_TDM_MODE_EN_MASK, 2084 DA7218_DAI_TDM_MODE_EN_MASK,
2085 (tx_mask << DA7218_DAI_TDM_CH_EN_SHIFT) | 2085 (tx_mask << DA7218_DAI_TDM_CH_EN_SHIFT) |
@@ -2092,7 +2092,7 @@ static int da7218_hw_params(struct snd_pcm_substream *substream,
2092 struct snd_pcm_hw_params *params, 2092 struct snd_pcm_hw_params *params,
2093 struct snd_soc_dai *dai) 2093 struct snd_soc_dai *dai)
2094{ 2094{
2095 struct snd_soc_codec *codec = dai->codec; 2095 struct snd_soc_component *component = dai->component;
2096 u8 dai_ctrl = 0, fs; 2096 u8 dai_ctrl = 0, fs;
2097 unsigned int channels; 2097 unsigned int channels;
2098 2098
@@ -2115,7 +2115,7 @@ static int da7218_hw_params(struct snd_pcm_substream *substream,
2115 2115
2116 channels = params_channels(params); 2116 channels = params_channels(params);
2117 if ((channels < 1) || (channels > DA7218_DAI_CH_NUM_MAX)) { 2117 if ((channels < 1) || (channels > DA7218_DAI_CH_NUM_MAX)) {
2118 dev_err(codec->dev, 2118 dev_err(component->dev,
2119 "Invalid number of channels, only 1 to %d supported\n", 2119 "Invalid number of channels, only 1 to %d supported\n",
2120 DA7218_DAI_CH_NUM_MAX); 2120 DA7218_DAI_CH_NUM_MAX);
2121 return -EINVAL; 2121 return -EINVAL;
@@ -2160,11 +2160,11 @@ static int da7218_hw_params(struct snd_pcm_substream *substream,
2160 return -EINVAL; 2160 return -EINVAL;
2161 } 2161 }
2162 2162
2163 snd_soc_update_bits(codec, DA7218_DAI_CTRL, 2163 snd_soc_component_update_bits(component, DA7218_DAI_CTRL,
2164 DA7218_DAI_WORD_LENGTH_MASK | DA7218_DAI_CH_NUM_MASK, 2164 DA7218_DAI_WORD_LENGTH_MASK | DA7218_DAI_CH_NUM_MASK,
2165 dai_ctrl); 2165 dai_ctrl);
2166 /* SRs tied for ADCs and DACs. */ 2166 /* SRs tied for ADCs and DACs. */
2167 snd_soc_write(codec, DA7218_SR, 2167 snd_soc_component_write(component, DA7218_SR,
2168 (fs << DA7218_SR_DAC_SHIFT) | (fs << DA7218_SR_ADC_SHIFT)); 2168 (fs << DA7218_SR_DAC_SHIFT) | (fs << DA7218_SR_ADC_SHIFT));
2169 2169
2170 return 0; 2170 return 0;
@@ -2208,15 +2208,15 @@ static struct snd_soc_dai_driver da7218_dai = {
2208 * HP Detect 2208 * HP Detect
2209 */ 2209 */
2210 2210
2211int da7218_hpldet(struct snd_soc_codec *codec, struct snd_soc_jack *jack) 2211int da7218_hpldet(struct snd_soc_component *component, struct snd_soc_jack *jack)
2212{ 2212{
2213 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 2213 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
2214 2214
2215 if (da7218->dev_id == DA7217_DEV_ID) 2215 if (da7218->dev_id == DA7217_DEV_ID)
2216 return -EINVAL; 2216 return -EINVAL;
2217 2217
2218 da7218->jack = jack; 2218 da7218->jack = jack;
2219 snd_soc_update_bits(codec, DA7218_HPLDET_JACK, 2219 snd_soc_component_update_bits(component, DA7218_HPLDET_JACK,
2220 DA7218_HPLDET_JACK_EN_MASK, 2220 DA7218_HPLDET_JACK_EN_MASK,
2221 jack ? DA7218_HPLDET_JACK_EN_MASK : 0); 2221 jack ? DA7218_HPLDET_JACK_EN_MASK : 0);
2222 2222
@@ -2224,23 +2224,23 @@ int da7218_hpldet(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
2224} 2224}
2225EXPORT_SYMBOL_GPL(da7218_hpldet); 2225EXPORT_SYMBOL_GPL(da7218_hpldet);
2226 2226
2227static void da7218_micldet_irq(struct snd_soc_codec *codec) 2227static void da7218_micldet_irq(struct snd_soc_component *component)
2228{ 2228{
2229 char *envp[] = { 2229 char *envp[] = {
2230 "EVENT=MIC_LEVEL_DETECT", 2230 "EVENT=MIC_LEVEL_DETECT",
2231 NULL, 2231 NULL,
2232 }; 2232 };
2233 2233
2234 kobject_uevent_env(&codec->dev->kobj, KOBJ_CHANGE, envp); 2234 kobject_uevent_env(&component->dev->kobj, KOBJ_CHANGE, envp);
2235} 2235}
2236 2236
2237static void da7218_hpldet_irq(struct snd_soc_codec *codec) 2237static void da7218_hpldet_irq(struct snd_soc_component *component)
2238{ 2238{
2239 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 2239 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
2240 u8 jack_status; 2240 u8 jack_status;
2241 int report; 2241 int report;
2242 2242
2243 jack_status = snd_soc_read(codec, DA7218_EVENT_STATUS); 2243 jack_status = snd_soc_component_read32(component, DA7218_EVENT_STATUS);
2244 2244
2245 if (jack_status & DA7218_HPLDET_JACK_STS_MASK) 2245 if (jack_status & DA7218_HPLDET_JACK_STS_MASK)
2246 report = SND_JACK_HEADPHONE; 2246 report = SND_JACK_HEADPHONE;
@@ -2256,24 +2256,24 @@ static void da7218_hpldet_irq(struct snd_soc_codec *codec)
2256 2256
2257static irqreturn_t da7218_irq_thread(int irq, void *data) 2257static irqreturn_t da7218_irq_thread(int irq, void *data)
2258{ 2258{
2259 struct snd_soc_codec *codec = data; 2259 struct snd_soc_component *component = data;
2260 u8 status; 2260 u8 status;
2261 2261
2262 /* Read IRQ status reg */ 2262 /* Read IRQ status reg */
2263 status = snd_soc_read(codec, DA7218_EVENT); 2263 status = snd_soc_component_read32(component, DA7218_EVENT);
2264 if (!status) 2264 if (!status)
2265 return IRQ_NONE; 2265 return IRQ_NONE;
2266 2266
2267 /* Mic level detect */ 2267 /* Mic level detect */
2268 if (status & DA7218_LVL_DET_EVENT_MASK) 2268 if (status & DA7218_LVL_DET_EVENT_MASK)
2269 da7218_micldet_irq(codec); 2269 da7218_micldet_irq(component);
2270 2270
2271 /* HP detect */ 2271 /* HP detect */
2272 if (status & DA7218_HPLDET_JACK_EVENT_MASK) 2272 if (status & DA7218_HPLDET_JACK_EVENT_MASK)
2273 da7218_hpldet_irq(codec); 2273 da7218_hpldet_irq(component);
2274 2274
2275 /* Clear interrupts */ 2275 /* Clear interrupts */
2276 snd_soc_write(codec, DA7218_EVENT, status); 2276 snd_soc_component_write(component, DA7218_EVENT, status);
2277 2277
2278 return IRQ_HANDLED; 2278 return IRQ_HANDLED;
2279} 2279}
@@ -2300,7 +2300,7 @@ static inline int da7218_of_get_id(struct device *dev)
2300} 2300}
2301 2301
2302static enum da7218_micbias_voltage 2302static enum da7218_micbias_voltage
2303 da7218_of_micbias_lvl(struct snd_soc_codec *codec, u32 val) 2303 da7218_of_micbias_lvl(struct snd_soc_component *component, u32 val)
2304{ 2304{
2305 switch (val) { 2305 switch (val) {
2306 case 1200: 2306 case 1200:
@@ -2322,13 +2322,13 @@ static enum da7218_micbias_voltage
2322 case 3000: 2322 case 3000:
2323 return DA7218_MICBIAS_3_0V; 2323 return DA7218_MICBIAS_3_0V;
2324 default: 2324 default:
2325 dev_warn(codec->dev, "Invalid micbias level"); 2325 dev_warn(component->dev, "Invalid micbias level");
2326 return DA7218_MICBIAS_1_6V; 2326 return DA7218_MICBIAS_1_6V;
2327 } 2327 }
2328} 2328}
2329 2329
2330static enum da7218_mic_amp_in_sel 2330static enum da7218_mic_amp_in_sel
2331 da7218_of_mic_amp_in_sel(struct snd_soc_codec *codec, const char *str) 2331 da7218_of_mic_amp_in_sel(struct snd_soc_component *component, const char *str)
2332{ 2332{
2333 if (!strcmp(str, "diff")) { 2333 if (!strcmp(str, "diff")) {
2334 return DA7218_MIC_AMP_IN_SEL_DIFF; 2334 return DA7218_MIC_AMP_IN_SEL_DIFF;
@@ -2337,39 +2337,39 @@ static enum da7218_mic_amp_in_sel
2337 } else if (!strcmp(str, "se_n")) { 2337 } else if (!strcmp(str, "se_n")) {
2338 return DA7218_MIC_AMP_IN_SEL_SE_N; 2338 return DA7218_MIC_AMP_IN_SEL_SE_N;
2339 } else { 2339 } else {
2340 dev_warn(codec->dev, "Invalid mic input type selection"); 2340 dev_warn(component->dev, "Invalid mic input type selection");
2341 return DA7218_MIC_AMP_IN_SEL_DIFF; 2341 return DA7218_MIC_AMP_IN_SEL_DIFF;
2342 } 2342 }
2343} 2343}
2344 2344
2345static enum da7218_dmic_data_sel 2345static enum da7218_dmic_data_sel
2346 da7218_of_dmic_data_sel(struct snd_soc_codec *codec, const char *str) 2346 da7218_of_dmic_data_sel(struct snd_soc_component *component, const char *str)
2347{ 2347{
2348 if (!strcmp(str, "lrise_rfall")) { 2348 if (!strcmp(str, "lrise_rfall")) {
2349 return DA7218_DMIC_DATA_LRISE_RFALL; 2349 return DA7218_DMIC_DATA_LRISE_RFALL;
2350 } else if (!strcmp(str, "lfall_rrise")) { 2350 } else if (!strcmp(str, "lfall_rrise")) {
2351 return DA7218_DMIC_DATA_LFALL_RRISE; 2351 return DA7218_DMIC_DATA_LFALL_RRISE;
2352 } else { 2352 } else {
2353 dev_warn(codec->dev, "Invalid DMIC data type selection"); 2353 dev_warn(component->dev, "Invalid DMIC data type selection");
2354 return DA7218_DMIC_DATA_LRISE_RFALL; 2354 return DA7218_DMIC_DATA_LRISE_RFALL;
2355 } 2355 }
2356} 2356}
2357 2357
2358static enum da7218_dmic_samplephase 2358static enum da7218_dmic_samplephase
2359 da7218_of_dmic_samplephase(struct snd_soc_codec *codec, const char *str) 2359 da7218_of_dmic_samplephase(struct snd_soc_component *component, const char *str)
2360{ 2360{
2361 if (!strcmp(str, "on_clkedge")) { 2361 if (!strcmp(str, "on_clkedge")) {
2362 return DA7218_DMIC_SAMPLE_ON_CLKEDGE; 2362 return DA7218_DMIC_SAMPLE_ON_CLKEDGE;
2363 } else if (!strcmp(str, "between_clkedge")) { 2363 } else if (!strcmp(str, "between_clkedge")) {
2364 return DA7218_DMIC_SAMPLE_BETWEEN_CLKEDGE; 2364 return DA7218_DMIC_SAMPLE_BETWEEN_CLKEDGE;
2365 } else { 2365 } else {
2366 dev_warn(codec->dev, "Invalid DMIC sample phase"); 2366 dev_warn(component->dev, "Invalid DMIC sample phase");
2367 return DA7218_DMIC_SAMPLE_ON_CLKEDGE; 2367 return DA7218_DMIC_SAMPLE_ON_CLKEDGE;
2368 } 2368 }
2369} 2369}
2370 2370
2371static enum da7218_dmic_clk_rate 2371static enum da7218_dmic_clk_rate
2372 da7218_of_dmic_clkrate(struct snd_soc_codec *codec, u32 val) 2372 da7218_of_dmic_clkrate(struct snd_soc_component *component, u32 val)
2373{ 2373{
2374 switch (val) { 2374 switch (val) {
2375 case 1500000: 2375 case 1500000:
@@ -2377,13 +2377,13 @@ static enum da7218_dmic_clk_rate
2377 case 3000000: 2377 case 3000000:
2378 return DA7218_DMIC_CLK_3_0MHZ; 2378 return DA7218_DMIC_CLK_3_0MHZ;
2379 default: 2379 default:
2380 dev_warn(codec->dev, "Invalid DMIC clock rate"); 2380 dev_warn(component->dev, "Invalid DMIC clock rate");
2381 return DA7218_DMIC_CLK_3_0MHZ; 2381 return DA7218_DMIC_CLK_3_0MHZ;
2382 } 2382 }
2383} 2383}
2384 2384
2385static enum da7218_hpldet_jack_rate 2385static enum da7218_hpldet_jack_rate
2386 da7218_of_jack_rate(struct snd_soc_codec *codec, u32 val) 2386 da7218_of_jack_rate(struct snd_soc_component *component, u32 val)
2387{ 2387{
2388 switch (val) { 2388 switch (val) {
2389 case 5: 2389 case 5:
@@ -2403,13 +2403,13 @@ static enum da7218_hpldet_jack_rate
2403 case 640: 2403 case 640:
2404 return DA7218_HPLDET_JACK_RATE_640US; 2404 return DA7218_HPLDET_JACK_RATE_640US;
2405 default: 2405 default:
2406 dev_warn(codec->dev, "Invalid jack detect rate"); 2406 dev_warn(component->dev, "Invalid jack detect rate");
2407 return DA7218_HPLDET_JACK_RATE_40US; 2407 return DA7218_HPLDET_JACK_RATE_40US;
2408 } 2408 }
2409} 2409}
2410 2410
2411static enum da7218_hpldet_jack_debounce 2411static enum da7218_hpldet_jack_debounce
2412 da7218_of_jack_debounce(struct snd_soc_codec *codec, u32 val) 2412 da7218_of_jack_debounce(struct snd_soc_component *component, u32 val)
2413{ 2413{
2414 switch (val) { 2414 switch (val) {
2415 case 0: 2415 case 0:
@@ -2421,13 +2421,13 @@ static enum da7218_hpldet_jack_debounce
2421 case 4: 2421 case 4:
2422 return DA7218_HPLDET_JACK_DEBOUNCE_4; 2422 return DA7218_HPLDET_JACK_DEBOUNCE_4;
2423 default: 2423 default:
2424 dev_warn(codec->dev, "Invalid jack debounce"); 2424 dev_warn(component->dev, "Invalid jack debounce");
2425 return DA7218_HPLDET_JACK_DEBOUNCE_2; 2425 return DA7218_HPLDET_JACK_DEBOUNCE_2;
2426 } 2426 }
2427} 2427}
2428 2428
2429static enum da7218_hpldet_jack_thr 2429static enum da7218_hpldet_jack_thr
2430 da7218_of_jack_thr(struct snd_soc_codec *codec, u32 val) 2430 da7218_of_jack_thr(struct snd_soc_component *component, u32 val)
2431{ 2431{
2432 switch (val) { 2432 switch (val) {
2433 case 84: 2433 case 84:
@@ -2439,76 +2439,76 @@ static enum da7218_hpldet_jack_thr
2439 case 96: 2439 case 96:
2440 return DA7218_HPLDET_JACK_THR_96PCT; 2440 return DA7218_HPLDET_JACK_THR_96PCT;
2441 default: 2441 default:
2442 dev_warn(codec->dev, "Invalid jack threshold level"); 2442 dev_warn(component->dev, "Invalid jack threshold level");
2443 return DA7218_HPLDET_JACK_THR_84PCT; 2443 return DA7218_HPLDET_JACK_THR_84PCT;
2444 } 2444 }
2445} 2445}
2446 2446
2447static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) 2447static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_component *component)
2448{ 2448{
2449 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 2449 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
2450 struct device_node *np = codec->dev->of_node; 2450 struct device_node *np = component->dev->of_node;
2451 struct device_node *hpldet_np; 2451 struct device_node *hpldet_np;
2452 struct da7218_pdata *pdata; 2452 struct da7218_pdata *pdata;
2453 struct da7218_hpldet_pdata *hpldet_pdata; 2453 struct da7218_hpldet_pdata *hpldet_pdata;
2454 const char *of_str; 2454 const char *of_str;
2455 u32 of_val32; 2455 u32 of_val32;
2456 2456
2457 pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); 2457 pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL);
2458 if (!pdata) 2458 if (!pdata)
2459 return NULL; 2459 return NULL;
2460 2460
2461 if (of_property_read_u32(np, "dlg,micbias1-lvl-millivolt", &of_val32) >= 0) 2461 if (of_property_read_u32(np, "dlg,micbias1-lvl-millivolt", &of_val32) >= 0)
2462 pdata->micbias1_lvl = da7218_of_micbias_lvl(codec, of_val32); 2462 pdata->micbias1_lvl = da7218_of_micbias_lvl(component, of_val32);
2463 else 2463 else
2464 pdata->micbias1_lvl = DA7218_MICBIAS_1_6V; 2464 pdata->micbias1_lvl = DA7218_MICBIAS_1_6V;
2465 2465
2466 if (of_property_read_u32(np, "dlg,micbias2-lvl-millivolt", &of_val32) >= 0) 2466 if (of_property_read_u32(np, "dlg,micbias2-lvl-millivolt", &of_val32) >= 0)
2467 pdata->micbias2_lvl = da7218_of_micbias_lvl(codec, of_val32); 2467 pdata->micbias2_lvl = da7218_of_micbias_lvl(component, of_val32);
2468 else 2468 else
2469 pdata->micbias2_lvl = DA7218_MICBIAS_1_6V; 2469 pdata->micbias2_lvl = DA7218_MICBIAS_1_6V;
2470 2470
2471 if (!of_property_read_string(np, "dlg,mic1-amp-in-sel", &of_str)) 2471 if (!of_property_read_string(np, "dlg,mic1-amp-in-sel", &of_str))
2472 pdata->mic1_amp_in_sel = 2472 pdata->mic1_amp_in_sel =
2473 da7218_of_mic_amp_in_sel(codec, of_str); 2473 da7218_of_mic_amp_in_sel(component, of_str);
2474 else 2474 else
2475 pdata->mic1_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; 2475 pdata->mic1_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF;
2476 2476
2477 if (!of_property_read_string(np, "dlg,mic2-amp-in-sel", &of_str)) 2477 if (!of_property_read_string(np, "dlg,mic2-amp-in-sel", &of_str))
2478 pdata->mic2_amp_in_sel = 2478 pdata->mic2_amp_in_sel =
2479 da7218_of_mic_amp_in_sel(codec, of_str); 2479 da7218_of_mic_amp_in_sel(component, of_str);
2480 else 2480 else
2481 pdata->mic2_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; 2481 pdata->mic2_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF;
2482 2482
2483 if (!of_property_read_string(np, "dlg,dmic1-data-sel", &of_str)) 2483 if (!of_property_read_string(np, "dlg,dmic1-data-sel", &of_str))
2484 pdata->dmic1_data_sel = da7218_of_dmic_data_sel(codec, of_str); 2484 pdata->dmic1_data_sel = da7218_of_dmic_data_sel(component, of_str);
2485 else 2485 else
2486 pdata->dmic1_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; 2486 pdata->dmic1_data_sel = DA7218_DMIC_DATA_LRISE_RFALL;
2487 2487
2488 if (!of_property_read_string(np, "dlg,dmic1-samplephase", &of_str)) 2488 if (!of_property_read_string(np, "dlg,dmic1-samplephase", &of_str))
2489 pdata->dmic1_samplephase = 2489 pdata->dmic1_samplephase =
2490 da7218_of_dmic_samplephase(codec, of_str); 2490 da7218_of_dmic_samplephase(component, of_str);
2491 else 2491 else
2492 pdata->dmic1_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; 2492 pdata->dmic1_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE;
2493 2493
2494 if (of_property_read_u32(np, "dlg,dmic1-clkrate-hz", &of_val32) >= 0) 2494 if (of_property_read_u32(np, "dlg,dmic1-clkrate-hz", &of_val32) >= 0)
2495 pdata->dmic1_clk_rate = da7218_of_dmic_clkrate(codec, of_val32); 2495 pdata->dmic1_clk_rate = da7218_of_dmic_clkrate(component, of_val32);
2496 else 2496 else
2497 pdata->dmic1_clk_rate = DA7218_DMIC_CLK_3_0MHZ; 2497 pdata->dmic1_clk_rate = DA7218_DMIC_CLK_3_0MHZ;
2498 2498
2499 if (!of_property_read_string(np, "dlg,dmic2-data-sel", &of_str)) 2499 if (!of_property_read_string(np, "dlg,dmic2-data-sel", &of_str))
2500 pdata->dmic2_data_sel = da7218_of_dmic_data_sel(codec, of_str); 2500 pdata->dmic2_data_sel = da7218_of_dmic_data_sel(component, of_str);
2501 else 2501 else
2502 pdata->dmic2_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; 2502 pdata->dmic2_data_sel = DA7218_DMIC_DATA_LRISE_RFALL;
2503 2503
2504 if (!of_property_read_string(np, "dlg,dmic2-samplephase", &of_str)) 2504 if (!of_property_read_string(np, "dlg,dmic2-samplephase", &of_str))
2505 pdata->dmic2_samplephase = 2505 pdata->dmic2_samplephase =
2506 da7218_of_dmic_samplephase(codec, of_str); 2506 da7218_of_dmic_samplephase(component, of_str);
2507 else 2507 else
2508 pdata->dmic2_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; 2508 pdata->dmic2_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE;
2509 2509
2510 if (of_property_read_u32(np, "dlg,dmic2-clkrate-hz", &of_val32) >= 0) 2510 if (of_property_read_u32(np, "dlg,dmic2-clkrate-hz", &of_val32) >= 0)
2511 pdata->dmic2_clk_rate = da7218_of_dmic_clkrate(codec, of_val32); 2511 pdata->dmic2_clk_rate = da7218_of_dmic_clkrate(component, of_val32);
2512 else 2512 else
2513 pdata->dmic2_clk_rate = DA7218_DMIC_CLK_3_0MHZ; 2513 pdata->dmic2_clk_rate = DA7218_DMIC_CLK_3_0MHZ;
2514 2514
@@ -2522,7 +2522,7 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
2522 if (!hpldet_np) 2522 if (!hpldet_np)
2523 return pdata; 2523 return pdata;
2524 2524
2525 hpldet_pdata = devm_kzalloc(codec->dev, sizeof(*hpldet_pdata), 2525 hpldet_pdata = devm_kzalloc(component->dev, sizeof(*hpldet_pdata),
2526 GFP_KERNEL); 2526 GFP_KERNEL);
2527 if (!hpldet_pdata) { 2527 if (!hpldet_pdata) {
2528 of_node_put(hpldet_np); 2528 of_node_put(hpldet_np);
@@ -2533,14 +2533,14 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
2533 if (of_property_read_u32(hpldet_np, "dlg,jack-rate-us", 2533 if (of_property_read_u32(hpldet_np, "dlg,jack-rate-us",
2534 &of_val32) >= 0) 2534 &of_val32) >= 0)
2535 hpldet_pdata->jack_rate = 2535 hpldet_pdata->jack_rate =
2536 da7218_of_jack_rate(codec, of_val32); 2536 da7218_of_jack_rate(component, of_val32);
2537 else 2537 else
2538 hpldet_pdata->jack_rate = DA7218_HPLDET_JACK_RATE_40US; 2538 hpldet_pdata->jack_rate = DA7218_HPLDET_JACK_RATE_40US;
2539 2539
2540 if (of_property_read_u32(hpldet_np, "dlg,jack-debounce", 2540 if (of_property_read_u32(hpldet_np, "dlg,jack-debounce",
2541 &of_val32) >= 0) 2541 &of_val32) >= 0)
2542 hpldet_pdata->jack_debounce = 2542 hpldet_pdata->jack_debounce =
2543 da7218_of_jack_debounce(codec, of_val32); 2543 da7218_of_jack_debounce(component, of_val32);
2544 else 2544 else
2545 hpldet_pdata->jack_debounce = 2545 hpldet_pdata->jack_debounce =
2546 DA7218_HPLDET_JACK_DEBOUNCE_2; 2546 DA7218_HPLDET_JACK_DEBOUNCE_2;
@@ -2548,7 +2548,7 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
2548 if (of_property_read_u32(hpldet_np, "dlg,jack-threshold-pct", 2548 if (of_property_read_u32(hpldet_np, "dlg,jack-threshold-pct",
2549 &of_val32) >= 0) 2549 &of_val32) >= 0)
2550 hpldet_pdata->jack_thr = 2550 hpldet_pdata->jack_thr =
2551 da7218_of_jack_thr(codec, of_val32); 2551 da7218_of_jack_thr(component, of_val32);
2552 else 2552 else
2553 hpldet_pdata->jack_thr = DA7218_HPLDET_JACK_THR_84PCT; 2553 hpldet_pdata->jack_thr = DA7218_HPLDET_JACK_THR_84PCT;
2554 2554
@@ -2572,10 +2572,10 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
2572 * Codec driver functions 2572 * Codec driver functions
2573 */ 2573 */
2574 2574
2575static int da7218_set_bias_level(struct snd_soc_codec *codec, 2575static int da7218_set_bias_level(struct snd_soc_component *component,
2576 enum snd_soc_bias_level level) 2576 enum snd_soc_bias_level level)
2577{ 2577{
2578 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 2578 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
2579 int ret; 2579 int ret;
2580 2580
2581 switch (level) { 2581 switch (level) {
@@ -2583,11 +2583,11 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec,
2583 break; 2583 break;
2584 case SND_SOC_BIAS_PREPARE: 2584 case SND_SOC_BIAS_PREPARE:
2585 /* Enable MCLK for transition to ON state */ 2585 /* Enable MCLK for transition to ON state */
2586 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { 2586 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) {
2587 if (da7218->mclk) { 2587 if (da7218->mclk) {
2588 ret = clk_prepare_enable(da7218->mclk); 2588 ret = clk_prepare_enable(da7218->mclk);
2589 if (ret) { 2589 if (ret) {
2590 dev_err(codec->dev, "Failed to enable mclk\n"); 2590 dev_err(component->dev, "Failed to enable mclk\n");
2591 return ret; 2591 return ret;
2592 } 2592 }
2593 } 2593 }
@@ -2595,14 +2595,14 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec,
2595 2595
2596 break; 2596 break;
2597 case SND_SOC_BIAS_STANDBY: 2597 case SND_SOC_BIAS_STANDBY:
2598 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 2598 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
2599 /* Master bias */ 2599 /* Master bias */
2600 snd_soc_update_bits(codec, DA7218_REFERENCES, 2600 snd_soc_component_update_bits(component, DA7218_REFERENCES,
2601 DA7218_BIAS_EN_MASK, 2601 DA7218_BIAS_EN_MASK,
2602 DA7218_BIAS_EN_MASK); 2602 DA7218_BIAS_EN_MASK);
2603 2603
2604 /* Internal LDO */ 2604 /* Internal LDO */
2605 snd_soc_update_bits(codec, DA7218_LDO_CTRL, 2605 snd_soc_component_update_bits(component, DA7218_LDO_CTRL,
2606 DA7218_LDO_EN_MASK, 2606 DA7218_LDO_EN_MASK,
2607 DA7218_LDO_EN_MASK); 2607 DA7218_LDO_EN_MASK);
2608 } else { 2608 } else {
@@ -2615,11 +2615,11 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec,
2615 /* Only disable if jack detection disabled */ 2615 /* Only disable if jack detection disabled */
2616 if (!da7218->jack) { 2616 if (!da7218->jack) {
2617 /* Internal LDO */ 2617 /* Internal LDO */
2618 snd_soc_update_bits(codec, DA7218_LDO_CTRL, 2618 snd_soc_component_update_bits(component, DA7218_LDO_CTRL,
2619 DA7218_LDO_EN_MASK, 0); 2619 DA7218_LDO_EN_MASK, 0);
2620 2620
2621 /* Master bias */ 2621 /* Master bias */
2622 snd_soc_update_bits(codec, DA7218_REFERENCES, 2622 snd_soc_component_update_bits(component, DA7218_REFERENCES,
2623 DA7218_BIAS_EN_MASK, 0); 2623 DA7218_BIAS_EN_MASK, 0);
2624 } 2624 }
2625 break; 2625 break;
@@ -2634,9 +2634,9 @@ static const char *da7218_supply_names[DA7218_NUM_SUPPLIES] = {
2634 [DA7218_SUPPLY_VDDIO] = "VDDIO", 2634 [DA7218_SUPPLY_VDDIO] = "VDDIO",
2635}; 2635};
2636 2636
2637static int da7218_handle_supplies(struct snd_soc_codec *codec) 2637static int da7218_handle_supplies(struct snd_soc_component *component)
2638{ 2638{
2639 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 2639 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
2640 struct regulator *vddio; 2640 struct regulator *vddio;
2641 u8 io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_2_5V_3_6V; 2641 u8 io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_2_5V_3_6V;
2642 int i, ret; 2642 int i, ret;
@@ -2645,10 +2645,10 @@ static int da7218_handle_supplies(struct snd_soc_codec *codec)
2645 for (i = 0; i < DA7218_NUM_SUPPLIES; ++i) 2645 for (i = 0; i < DA7218_NUM_SUPPLIES; ++i)
2646 da7218->supplies[i].supply = da7218_supply_names[i]; 2646 da7218->supplies[i].supply = da7218_supply_names[i];
2647 2647
2648 ret = devm_regulator_bulk_get(codec->dev, DA7218_NUM_SUPPLIES, 2648 ret = devm_regulator_bulk_get(component->dev, DA7218_NUM_SUPPLIES,
2649 da7218->supplies); 2649 da7218->supplies);
2650 if (ret) { 2650 if (ret) {
2651 dev_err(codec->dev, "Failed to get supplies\n"); 2651 dev_err(component->dev, "Failed to get supplies\n");
2652 return ret; 2652 return ret;
2653 } 2653 }
2654 2654
@@ -2656,29 +2656,29 @@ static int da7218_handle_supplies(struct snd_soc_codec *codec)
2656 vddio = da7218->supplies[DA7218_SUPPLY_VDDIO].consumer; 2656 vddio = da7218->supplies[DA7218_SUPPLY_VDDIO].consumer;
2657 ret = regulator_get_voltage(vddio); 2657 ret = regulator_get_voltage(vddio);
2658 if (ret < 1500000) 2658 if (ret < 1500000)
2659 dev_warn(codec->dev, "Invalid VDDIO voltage\n"); 2659 dev_warn(component->dev, "Invalid VDDIO voltage\n");
2660 else if (ret < 2500000) 2660 else if (ret < 2500000)
2661 io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_1_5V_2_5V; 2661 io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_1_5V_2_5V;
2662 2662
2663 /* Enable main supplies */ 2663 /* Enable main supplies */
2664 ret = regulator_bulk_enable(DA7218_NUM_SUPPLIES, da7218->supplies); 2664 ret = regulator_bulk_enable(DA7218_NUM_SUPPLIES, da7218->supplies);
2665 if (ret) { 2665 if (ret) {
2666 dev_err(codec->dev, "Failed to enable supplies\n"); 2666 dev_err(component->dev, "Failed to enable supplies\n");
2667 return ret; 2667 return ret;
2668 } 2668 }
2669 2669
2670 /* Ensure device in active mode */ 2670 /* Ensure device in active mode */
2671 snd_soc_write(codec, DA7218_SYSTEM_ACTIVE, DA7218_SYSTEM_ACTIVE_MASK); 2671 snd_soc_component_write(component, DA7218_SYSTEM_ACTIVE, DA7218_SYSTEM_ACTIVE_MASK);
2672 2672
2673 /* Update IO voltage level range */ 2673 /* Update IO voltage level range */
2674 snd_soc_write(codec, DA7218_IO_CTRL, io_voltage_lvl); 2674 snd_soc_component_write(component, DA7218_IO_CTRL, io_voltage_lvl);
2675 2675
2676 return 0; 2676 return 0;
2677} 2677}
2678 2678
2679static void da7218_handle_pdata(struct snd_soc_codec *codec) 2679static void da7218_handle_pdata(struct snd_soc_component *component)
2680{ 2680{
2681 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 2681 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
2682 struct da7218_pdata *pdata = da7218->pdata; 2682 struct da7218_pdata *pdata = da7218->pdata;
2683 2683
2684 if (pdata) { 2684 if (pdata) {
@@ -2719,14 +2719,14 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec)
2719 break; 2719 break;
2720 } 2720 }
2721 2721
2722 snd_soc_write(codec, DA7218_MICBIAS_CTRL, micbias_lvl); 2722 snd_soc_component_write(component, DA7218_MICBIAS_CTRL, micbias_lvl);
2723 2723
2724 /* Mic */ 2724 /* Mic */
2725 switch (pdata->mic1_amp_in_sel) { 2725 switch (pdata->mic1_amp_in_sel) {
2726 case DA7218_MIC_AMP_IN_SEL_DIFF: 2726 case DA7218_MIC_AMP_IN_SEL_DIFF:
2727 case DA7218_MIC_AMP_IN_SEL_SE_P: 2727 case DA7218_MIC_AMP_IN_SEL_SE_P:
2728 case DA7218_MIC_AMP_IN_SEL_SE_N: 2728 case DA7218_MIC_AMP_IN_SEL_SE_N:
2729 snd_soc_write(codec, DA7218_MIC_1_SELECT, 2729 snd_soc_component_write(component, DA7218_MIC_1_SELECT,
2730 pdata->mic1_amp_in_sel); 2730 pdata->mic1_amp_in_sel);
2731 break; 2731 break;
2732 } 2732 }
@@ -2735,7 +2735,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec)
2735 case DA7218_MIC_AMP_IN_SEL_DIFF: 2735 case DA7218_MIC_AMP_IN_SEL_DIFF:
2736 case DA7218_MIC_AMP_IN_SEL_SE_P: 2736 case DA7218_MIC_AMP_IN_SEL_SE_P:
2737 case DA7218_MIC_AMP_IN_SEL_SE_N: 2737 case DA7218_MIC_AMP_IN_SEL_SE_N:
2738 snd_soc_write(codec, DA7218_MIC_2_SELECT, 2738 snd_soc_component_write(component, DA7218_MIC_2_SELECT,
2739 pdata->mic2_amp_in_sel); 2739 pdata->mic2_amp_in_sel);
2740 break; 2740 break;
2741 } 2741 }
@@ -2765,7 +2765,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec)
2765 break; 2765 break;
2766 } 2766 }
2767 2767
2768 snd_soc_update_bits(codec, DA7218_DMIC_1_CTRL, 2768 snd_soc_component_update_bits(component, DA7218_DMIC_1_CTRL,
2769 DA7218_DMIC_1_DATA_SEL_MASK | 2769 DA7218_DMIC_1_DATA_SEL_MASK |
2770 DA7218_DMIC_1_SAMPLEPHASE_MASK | 2770 DA7218_DMIC_1_SAMPLEPHASE_MASK |
2771 DA7218_DMIC_1_CLK_RATE_MASK, dmic_cfg); 2771 DA7218_DMIC_1_CLK_RATE_MASK, dmic_cfg);
@@ -2795,7 +2795,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec)
2795 break; 2795 break;
2796 } 2796 }
2797 2797
2798 snd_soc_update_bits(codec, DA7218_DMIC_2_CTRL, 2798 snd_soc_component_update_bits(component, DA7218_DMIC_2_CTRL,
2799 DA7218_DMIC_2_DATA_SEL_MASK | 2799 DA7218_DMIC_2_DATA_SEL_MASK |
2800 DA7218_DMIC_2_SAMPLEPHASE_MASK | 2800 DA7218_DMIC_2_SAMPLEPHASE_MASK |
2801 DA7218_DMIC_2_CLK_RATE_MASK, dmic_cfg); 2801 DA7218_DMIC_2_CLK_RATE_MASK, dmic_cfg);
@@ -2806,9 +2806,9 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec)
2806 pdata->hp_diff_single_supply; 2806 pdata->hp_diff_single_supply;
2807 2807
2808 if (da7218->hp_single_supply) { 2808 if (da7218->hp_single_supply) {
2809 snd_soc_write(codec, DA7218_HP_DIFF_UNLOCK, 2809 snd_soc_component_write(component, DA7218_HP_DIFF_UNLOCK,
2810 DA7218_HP_DIFF_UNLOCK_VAL); 2810 DA7218_HP_DIFF_UNLOCK_VAL);
2811 snd_soc_update_bits(codec, DA7218_HP_DIFF_CTRL, 2811 snd_soc_component_update_bits(component, DA7218_HP_DIFF_CTRL,
2812 DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK, 2812 DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK,
2813 DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK); 2813 DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK);
2814 } 2814 }
@@ -2857,7 +2857,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec)
2857 DA7218_HPLDET_JACK_THR_SHIFT); 2857 DA7218_HPLDET_JACK_THR_SHIFT);
2858 break; 2858 break;
2859 } 2859 }
2860 snd_soc_update_bits(codec, DA7218_HPLDET_JACK, 2860 snd_soc_component_update_bits(component, DA7218_HPLDET_JACK,
2861 DA7218_HPLDET_JACK_RATE_MASK | 2861 DA7218_HPLDET_JACK_RATE_MASK |
2862 DA7218_HPLDET_JACK_DEBOUNCE_MASK | 2862 DA7218_HPLDET_JACK_DEBOUNCE_MASK |
2863 DA7218_HPLDET_JACK_THR_MASK, 2863 DA7218_HPLDET_JACK_THR_MASK,
@@ -2873,31 +2873,31 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec)
2873 if (hpldet_pdata->discharge) 2873 if (hpldet_pdata->discharge)
2874 hpldet_cfg |= DA7218_HPLDET_DISCHARGE_EN_MASK; 2874 hpldet_cfg |= DA7218_HPLDET_DISCHARGE_EN_MASK;
2875 2875
2876 snd_soc_write(codec, DA7218_HPLDET_CTRL, hpldet_cfg); 2876 snd_soc_component_write(component, DA7218_HPLDET_CTRL, hpldet_cfg);
2877 } 2877 }
2878 } 2878 }
2879} 2879}
2880 2880
2881static int da7218_probe(struct snd_soc_codec *codec) 2881static int da7218_probe(struct snd_soc_component *component)
2882{ 2882{
2883 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 2883 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
2884 int ret; 2884 int ret;
2885 2885
2886 /* Regulator configuration */ 2886 /* Regulator configuration */
2887 ret = da7218_handle_supplies(codec); 2887 ret = da7218_handle_supplies(component);
2888 if (ret) 2888 if (ret)
2889 return ret; 2889 return ret;
2890 2890
2891 /* Handle DT/Platform data */ 2891 /* Handle DT/Platform data */
2892 if (codec->dev->of_node) 2892 if (component->dev->of_node)
2893 da7218->pdata = da7218_of_to_pdata(codec); 2893 da7218->pdata = da7218_of_to_pdata(component);
2894 else 2894 else
2895 da7218->pdata = dev_get_platdata(codec->dev); 2895 da7218->pdata = dev_get_platdata(component->dev);
2896 2896
2897 da7218_handle_pdata(codec); 2897 da7218_handle_pdata(component);
2898 2898
2899 /* Check if MCLK provided, if not the clock is NULL */ 2899 /* Check if MCLK provided, if not the clock is NULL */
2900 da7218->mclk = devm_clk_get(codec->dev, "mclk"); 2900 da7218->mclk = devm_clk_get(component->dev, "mclk");
2901 if (IS_ERR(da7218->mclk)) { 2901 if (IS_ERR(da7218->mclk)) {
2902 if (PTR_ERR(da7218->mclk) != -ENOENT) { 2902 if (PTR_ERR(da7218->mclk) != -ENOENT) {
2903 ret = PTR_ERR(da7218->mclk); 2903 ret = PTR_ERR(da7218->mclk);
@@ -2908,74 +2908,74 @@ static int da7218_probe(struct snd_soc_codec *codec)
2908 } 2908 }
2909 2909
2910 /* Default PC to free-running */ 2910 /* Default PC to free-running */
2911 snd_soc_write(codec, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); 2911 snd_soc_component_write(component, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK);
2912 2912
2913 /* 2913 /*
2914 * Default Output Filter mixers to off otherwise DAPM will power 2914 * Default Output Filter mixers to off otherwise DAPM will power
2915 * Mic to HP passthrough paths by default at startup. 2915 * Mic to HP passthrough paths by default at startup.
2916 */ 2916 */
2917 snd_soc_write(codec, DA7218_DROUTING_OUTFILT_1L, 0); 2917 snd_soc_component_write(component, DA7218_DROUTING_OUTFILT_1L, 0);
2918 snd_soc_write(codec, DA7218_DROUTING_OUTFILT_1R, 0); 2918 snd_soc_component_write(component, DA7218_DROUTING_OUTFILT_1R, 0);
2919 2919
2920 /* Default CP to normal load, power mode */ 2920 /* Default CP to normal load, power mode */
2921 snd_soc_update_bits(codec, DA7218_CP_CTRL, 2921 snd_soc_component_update_bits(component, DA7218_CP_CTRL,
2922 DA7218_CP_SMALL_SWITCH_FREQ_EN_MASK, 0); 2922 DA7218_CP_SMALL_SWITCH_FREQ_EN_MASK, 0);
2923 2923
2924 /* Default gain ramping */ 2924 /* Default gain ramping */
2925 snd_soc_update_bits(codec, DA7218_MIXIN_1_CTRL, 2925 snd_soc_component_update_bits(component, DA7218_MIXIN_1_CTRL,
2926 DA7218_MIXIN_1_AMP_RAMP_EN_MASK, 2926 DA7218_MIXIN_1_AMP_RAMP_EN_MASK,
2927 DA7218_MIXIN_1_AMP_RAMP_EN_MASK); 2927 DA7218_MIXIN_1_AMP_RAMP_EN_MASK);
2928 snd_soc_update_bits(codec, DA7218_MIXIN_2_CTRL, 2928 snd_soc_component_update_bits(component, DA7218_MIXIN_2_CTRL,
2929 DA7218_MIXIN_2_AMP_RAMP_EN_MASK, 2929 DA7218_MIXIN_2_AMP_RAMP_EN_MASK,
2930 DA7218_MIXIN_2_AMP_RAMP_EN_MASK); 2930 DA7218_MIXIN_2_AMP_RAMP_EN_MASK);
2931 snd_soc_update_bits(codec, DA7218_IN_1L_FILTER_CTRL, 2931 snd_soc_component_update_bits(component, DA7218_IN_1L_FILTER_CTRL,
2932 DA7218_IN_1L_RAMP_EN_MASK, 2932 DA7218_IN_1L_RAMP_EN_MASK,
2933 DA7218_IN_1L_RAMP_EN_MASK); 2933 DA7218_IN_1L_RAMP_EN_MASK);
2934 snd_soc_update_bits(codec, DA7218_IN_1R_FILTER_CTRL, 2934 snd_soc_component_update_bits(component, DA7218_IN_1R_FILTER_CTRL,
2935 DA7218_IN_1R_RAMP_EN_MASK, 2935 DA7218_IN_1R_RAMP_EN_MASK,
2936 DA7218_IN_1R_RAMP_EN_MASK); 2936 DA7218_IN_1R_RAMP_EN_MASK);
2937 snd_soc_update_bits(codec, DA7218_IN_2L_FILTER_CTRL, 2937 snd_soc_component_update_bits(component, DA7218_IN_2L_FILTER_CTRL,
2938 DA7218_IN_2L_RAMP_EN_MASK, 2938 DA7218_IN_2L_RAMP_EN_MASK,
2939 DA7218_IN_2L_RAMP_EN_MASK); 2939 DA7218_IN_2L_RAMP_EN_MASK);
2940 snd_soc_update_bits(codec, DA7218_IN_2R_FILTER_CTRL, 2940 snd_soc_component_update_bits(component, DA7218_IN_2R_FILTER_CTRL,
2941 DA7218_IN_2R_RAMP_EN_MASK, 2941 DA7218_IN_2R_RAMP_EN_MASK,
2942 DA7218_IN_2R_RAMP_EN_MASK); 2942 DA7218_IN_2R_RAMP_EN_MASK);
2943 snd_soc_update_bits(codec, DA7218_DGS_GAIN_CTRL, 2943 snd_soc_component_update_bits(component, DA7218_DGS_GAIN_CTRL,
2944 DA7218_DGS_RAMP_EN_MASK, DA7218_DGS_RAMP_EN_MASK); 2944 DA7218_DGS_RAMP_EN_MASK, DA7218_DGS_RAMP_EN_MASK);
2945 snd_soc_update_bits(codec, DA7218_OUT_1L_FILTER_CTRL, 2945 snd_soc_component_update_bits(component, DA7218_OUT_1L_FILTER_CTRL,
2946 DA7218_OUT_1L_RAMP_EN_MASK, 2946 DA7218_OUT_1L_RAMP_EN_MASK,
2947 DA7218_OUT_1L_RAMP_EN_MASK); 2947 DA7218_OUT_1L_RAMP_EN_MASK);
2948 snd_soc_update_bits(codec, DA7218_OUT_1R_FILTER_CTRL, 2948 snd_soc_component_update_bits(component, DA7218_OUT_1R_FILTER_CTRL,
2949 DA7218_OUT_1R_RAMP_EN_MASK, 2949 DA7218_OUT_1R_RAMP_EN_MASK,
2950 DA7218_OUT_1R_RAMP_EN_MASK); 2950 DA7218_OUT_1R_RAMP_EN_MASK);
2951 snd_soc_update_bits(codec, DA7218_HP_L_CTRL, 2951 snd_soc_component_update_bits(component, DA7218_HP_L_CTRL,
2952 DA7218_HP_L_AMP_RAMP_EN_MASK, 2952 DA7218_HP_L_AMP_RAMP_EN_MASK,
2953 DA7218_HP_L_AMP_RAMP_EN_MASK); 2953 DA7218_HP_L_AMP_RAMP_EN_MASK);
2954 snd_soc_update_bits(codec, DA7218_HP_R_CTRL, 2954 snd_soc_component_update_bits(component, DA7218_HP_R_CTRL,
2955 DA7218_HP_R_AMP_RAMP_EN_MASK, 2955 DA7218_HP_R_AMP_RAMP_EN_MASK,
2956 DA7218_HP_R_AMP_RAMP_EN_MASK); 2956 DA7218_HP_R_AMP_RAMP_EN_MASK);
2957 2957
2958 /* Default infinite tone gen, start/stop by Kcontrol */ 2958 /* Default infinite tone gen, start/stop by Kcontrol */
2959 snd_soc_write(codec, DA7218_TONE_GEN_CYCLES, DA7218_BEEP_CYCLES_MASK); 2959 snd_soc_component_write(component, DA7218_TONE_GEN_CYCLES, DA7218_BEEP_CYCLES_MASK);
2960 2960
2961 /* DA7217 specific config */ 2961 /* DA7217 specific config */
2962 if (da7218->dev_id == DA7217_DEV_ID) { 2962 if (da7218->dev_id == DA7217_DEV_ID) {
2963 snd_soc_update_bits(codec, DA7218_HP_DIFF_CTRL, 2963 snd_soc_component_update_bits(component, DA7218_HP_DIFF_CTRL,
2964 DA7218_HP_AMP_DIFF_MODE_EN_MASK, 2964 DA7218_HP_AMP_DIFF_MODE_EN_MASK,
2965 DA7218_HP_AMP_DIFF_MODE_EN_MASK); 2965 DA7218_HP_AMP_DIFF_MODE_EN_MASK);
2966 2966
2967 /* Only DA7218 supports HP detect, mask off for DA7217 */ 2967 /* Only DA7218 supports HP detect, mask off for DA7217 */
2968 snd_soc_write(codec, DA7218_EVENT_MASK, 2968 snd_soc_component_write(component, DA7218_EVENT_MASK,
2969 DA7218_HPLDET_JACK_EVENT_IRQ_MSK_MASK); 2969 DA7218_HPLDET_JACK_EVENT_IRQ_MSK_MASK);
2970 } 2970 }
2971 2971
2972 if (da7218->irq) { 2972 if (da7218->irq) {
2973 ret = devm_request_threaded_irq(codec->dev, da7218->irq, NULL, 2973 ret = devm_request_threaded_irq(component->dev, da7218->irq, NULL,
2974 da7218_irq_thread, 2974 da7218_irq_thread,
2975 IRQF_TRIGGER_LOW | IRQF_ONESHOT, 2975 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
2976 "da7218", codec); 2976 "da7218", component);
2977 if (ret != 0) { 2977 if (ret != 0) {
2978 dev_err(codec->dev, "Failed to request IRQ %d: %d\n", 2978 dev_err(component->dev, "Failed to request IRQ %d: %d\n",
2979 da7218->irq, ret); 2979 da7218->irq, ret);
2980 goto err_disable_reg; 2980 goto err_disable_reg;
2981 } 2981 }
@@ -2990,39 +2990,37 @@ err_disable_reg:
2990 return ret; 2990 return ret;
2991} 2991}
2992 2992
2993static int da7218_remove(struct snd_soc_codec *codec) 2993static void da7218_remove(struct snd_soc_component *component)
2994{ 2994{
2995 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 2995 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
2996 2996
2997 regulator_bulk_disable(DA7218_NUM_SUPPLIES, da7218->supplies); 2997 regulator_bulk_disable(DA7218_NUM_SUPPLIES, da7218->supplies);
2998
2999 return 0;
3000} 2998}
3001 2999
3002#ifdef CONFIG_PM 3000#ifdef CONFIG_PM
3003static int da7218_suspend(struct snd_soc_codec *codec) 3001static int da7218_suspend(struct snd_soc_component *component)
3004{ 3002{
3005 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 3003 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
3006 3004
3007 da7218_set_bias_level(codec, SND_SOC_BIAS_OFF); 3005 da7218_set_bias_level(component, SND_SOC_BIAS_OFF);
3008 3006
3009 /* Put device into standby mode if jack detection disabled */ 3007 /* Put device into standby mode if jack detection disabled */
3010 if (!da7218->jack) 3008 if (!da7218->jack)
3011 snd_soc_write(codec, DA7218_SYSTEM_ACTIVE, 0); 3009 snd_soc_component_write(component, DA7218_SYSTEM_ACTIVE, 0);
3012 3010
3013 return 0; 3011 return 0;
3014} 3012}
3015 3013
3016static int da7218_resume(struct snd_soc_codec *codec) 3014static int da7218_resume(struct snd_soc_component *component)
3017{ 3015{
3018 struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); 3016 struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component);
3019 3017
3020 /* Put device into active mode if previously moved to standby */ 3018 /* Put device into active mode if previously moved to standby */
3021 if (!da7218->jack) 3019 if (!da7218->jack)
3022 snd_soc_write(codec, DA7218_SYSTEM_ACTIVE, 3020 snd_soc_component_write(component, DA7218_SYSTEM_ACTIVE,
3023 DA7218_SYSTEM_ACTIVE_MASK); 3021 DA7218_SYSTEM_ACTIVE_MASK);
3024 3022
3025 da7218_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 3023 da7218_set_bias_level(component, SND_SOC_BIAS_STANDBY);
3026 3024
3027 return 0; 3025 return 0;
3028} 3026}
@@ -3031,21 +3029,22 @@ static int da7218_resume(struct snd_soc_codec *codec)
3031#define da7218_resume NULL 3029#define da7218_resume NULL
3032#endif 3030#endif
3033 3031
3034static const struct snd_soc_codec_driver soc_codec_dev_da7218 = { 3032static const struct snd_soc_component_driver soc_component_dev_da7218 = {
3035 .probe = da7218_probe, 3033 .probe = da7218_probe,
3036 .remove = da7218_remove, 3034 .remove = da7218_remove,
3037 .suspend = da7218_suspend, 3035 .suspend = da7218_suspend,
3038 .resume = da7218_resume, 3036 .resume = da7218_resume,
3039 .set_bias_level = da7218_set_bias_level, 3037 .set_bias_level = da7218_set_bias_level,
3040 3038 .controls = da7218_snd_controls,
3041 .component_driver = { 3039 .num_controls = ARRAY_SIZE(da7218_snd_controls),
3042 .controls = da7218_snd_controls, 3040 .dapm_widgets = da7218_dapm_widgets,
3043 .num_controls = ARRAY_SIZE(da7218_snd_controls), 3041 .num_dapm_widgets = ARRAY_SIZE(da7218_dapm_widgets),
3044 .dapm_widgets = da7218_dapm_widgets, 3042 .dapm_routes = da7218_audio_map,
3045 .num_dapm_widgets = ARRAY_SIZE(da7218_dapm_widgets), 3043 .num_dapm_routes = ARRAY_SIZE(da7218_audio_map),
3046 .dapm_routes = da7218_audio_map, 3044 .idle_bias_on = 1,
3047 .num_dapm_routes = ARRAY_SIZE(da7218_audio_map), 3045 .use_pmdown_time = 1,
3048 }, 3046 .endianness = 1,
3047 .non_legacy_dai_naming = 1,
3049}; 3048};
3050 3049
3051 3050
@@ -3295,21 +3294,15 @@ static int da7218_i2c_probe(struct i2c_client *i2c,
3295 return ret; 3294 return ret;
3296 } 3295 }
3297 3296
3298 ret = snd_soc_register_codec(&i2c->dev, 3297 ret = devm_snd_soc_register_component(&i2c->dev,
3299 &soc_codec_dev_da7218, &da7218_dai, 1); 3298 &soc_component_dev_da7218, &da7218_dai, 1);
3300 if (ret < 0) { 3299 if (ret < 0) {
3301 dev_err(&i2c->dev, "Failed to register da7218 codec: %d\n", 3300 dev_err(&i2c->dev, "Failed to register da7218 component: %d\n",
3302 ret); 3301 ret);
3303 } 3302 }
3304 return ret; 3303 return ret;
3305} 3304}
3306 3305
3307static int da7218_i2c_remove(struct i2c_client *client)
3308{
3309 snd_soc_unregister_codec(&client->dev);
3310 return 0;
3311}
3312
3313static const struct i2c_device_id da7218_i2c_id[] = { 3306static const struct i2c_device_id da7218_i2c_id[] = {
3314 { "da7217", DA7217_DEV_ID }, 3307 { "da7217", DA7217_DEV_ID },
3315 { "da7218", DA7218_DEV_ID }, 3308 { "da7218", DA7218_DEV_ID },
@@ -3323,7 +3316,6 @@ static struct i2c_driver da7218_i2c_driver = {
3323 .of_match_table = of_match_ptr(da7218_of_match), 3316 .of_match_table = of_match_ptr(da7218_of_match),
3324 }, 3317 },
3325 .probe = da7218_i2c_probe, 3318 .probe = da7218_i2c_probe,
3326 .remove = da7218_i2c_remove,
3327 .id_table = da7218_i2c_id, 3319 .id_table = da7218_i2c_id,
3328}; 3320};
3329 3321
diff --git a/sound/soc/codecs/da7218.h b/sound/soc/codecs/da7218.h
index 4f7ec21069a4..19e6cee2e42e 100644
--- a/sound/soc/codecs/da7218.h
+++ b/sound/soc/codecs/da7218.h
@@ -1410,6 +1410,6 @@ struct da7218_priv {
1410}; 1410};
1411 1411
1412/* HP detect control */ 1412/* HP detect control */
1413int da7218_hpldet(struct snd_soc_codec *codec, struct snd_soc_jack *jack); 1413int da7218_hpldet(struct snd_soc_component *component, struct snd_soc_jack *jack);
1414 1414
1415#endif /* _DA7218_H */ 1415#endif /* _DA7218_H */