aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 23:21:15 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:55:16 -0500
commit732ae454bdebdc2afa133150655277551a77ede4 (patch)
tree41a3c158f7b101ab30d7233b4fc7db913e79222d
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: msm8916-wcd-analog: 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/msm8916-wcd-analog.c207
1 files changed, 104 insertions, 103 deletions
diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
index 44062bb7bf2f..12ee83d52405 100644
--- a/sound/soc/codecs/msm8916-wcd-analog.c
+++ b/sound/soc/codecs/msm8916-wcd-analog.c
@@ -288,7 +288,7 @@ struct pm8916_wcd_analog_priv {
288 int mbhc_btn0_released; 288 int mbhc_btn0_released;
289 bool detect_accessory_type; 289 bool detect_accessory_type;
290 struct clk *mclk; 290 struct clk *mclk;
291 struct snd_soc_codec *codec; 291 struct snd_soc_component *component;
292 struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; 292 struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
293 struct snd_soc_jack *jack; 293 struct snd_soc_jack *jack;
294 bool hphl_jack_type_normally_open; 294 bool hphl_jack_type_normally_open;
@@ -338,18 +338,18 @@ static const struct snd_kcontrol_new pm8916_wcd_analog_snd_controls[] = {
338 SOC_SINGLE_TLV("ADC3 Volume", CDC_A_TX_3_EN, 3, 8, 0, analog_gain), 338 SOC_SINGLE_TLV("ADC3 Volume", CDC_A_TX_3_EN, 3, 8, 0, analog_gain),
339}; 339};
340 340
341static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec) 341static void pm8916_wcd_analog_micbias_enable(struct snd_soc_component *component)
342{ 342{
343 struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); 343 struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component);
344 344
345 snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, 345 snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL,
346 MICB_1_CTL_EXT_PRECHARG_EN_MASK | 346 MICB_1_CTL_EXT_PRECHARG_EN_MASK |
347 MICB_1_CTL_INT_PRECHARG_BYP_MASK, 347 MICB_1_CTL_INT_PRECHARG_BYP_MASK,
348 MICB_1_CTL_INT_PRECHARG_BYP_EXT_PRECHRG_SEL 348 MICB_1_CTL_INT_PRECHARG_BYP_EXT_PRECHRG_SEL
349 | MICB_1_CTL_EXT_PRECHARG_EN_ENABLE); 349 | MICB_1_CTL_EXT_PRECHARG_EN_ENABLE);
350 350
351 if (wcd->micbias_mv) { 351 if (wcd->micbias_mv) {
352 snd_soc_update_bits(codec, CDC_A_MICB_1_VAL, 352 snd_soc_component_update_bits(component, CDC_A_MICB_1_VAL,
353 MICB_1_VAL_MICB_OUT_VAL_MASK, 353 MICB_1_VAL_MICB_OUT_VAL_MASK,
354 MICB_VOLTAGE_REGVAL(wcd->micbias_mv)); 354 MICB_VOLTAGE_REGVAL(wcd->micbias_mv));
355 /* 355 /*
@@ -360,20 +360,20 @@ static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec)
360 msleep(50); 360 msleep(50);
361 } 361 }
362 362
363 snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, 363 snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL,
364 MICB_1_CTL_EXT_PRECHARG_EN_MASK | 364 MICB_1_CTL_EXT_PRECHARG_EN_MASK |
365 MICB_1_CTL_INT_PRECHARG_BYP_MASK, 0); 365 MICB_1_CTL_INT_PRECHARG_BYP_MASK, 0);
366 366
367} 367}
368 368
369static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_codec 369static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_component
370 *codec, int event, 370 *component, int event,
371 int reg, unsigned int cap_mode) 371 int reg, unsigned int cap_mode)
372{ 372{
373 switch (event) { 373 switch (event) {
374 case SND_SOC_DAPM_POST_PMU: 374 case SND_SOC_DAPM_POST_PMU:
375 pm8916_wcd_analog_micbias_enable(codec); 375 pm8916_wcd_analog_micbias_enable(component);
376 snd_soc_update_bits(codec, CDC_A_MICB_1_EN, 376 snd_soc_component_update_bits(component, CDC_A_MICB_1_EN,
377 MICB_1_EN_BYP_CAP_MASK, cap_mode); 377 MICB_1_EN_BYP_CAP_MASK, cap_mode);
378 break; 378 break;
379 } 379 }
@@ -381,25 +381,25 @@ static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_codec
381 return 0; 381 return 0;
382} 382}
383 383
384static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_codec 384static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_component
385 *codec, int event, 385 *component, int event,
386 int reg, u32 cap_mode) 386 int reg, u32 cap_mode)
387{ 387{
388 388
389 switch (event) { 389 switch (event) {
390 case SND_SOC_DAPM_PRE_PMU: 390 case SND_SOC_DAPM_PRE_PMU:
391 snd_soc_update_bits(codec, CDC_A_MICB_1_INT_RBIAS, 391 snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS,
392 MICB_1_INT_TX2_INT_RBIAS_EN_MASK, 392 MICB_1_INT_TX2_INT_RBIAS_EN_MASK,
393 MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); 393 MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE);
394 snd_soc_update_bits(codec, reg, MICB_1_EN_PULL_DOWN_EN_MASK, 0); 394 snd_soc_component_update_bits(component, reg, MICB_1_EN_PULL_DOWN_EN_MASK, 0);
395 snd_soc_update_bits(codec, CDC_A_MICB_1_EN, 395 snd_soc_component_update_bits(component, CDC_A_MICB_1_EN,
396 MICB_1_EN_OPA_STG2_TAIL_CURR_MASK, 396 MICB_1_EN_OPA_STG2_TAIL_CURR_MASK,
397 MICB_1_EN_OPA_STG2_TAIL_CURR_1_60UA); 397 MICB_1_EN_OPA_STG2_TAIL_CURR_1_60UA);
398 398
399 break; 399 break;
400 case SND_SOC_DAPM_POST_PMU: 400 case SND_SOC_DAPM_POST_PMU:
401 pm8916_wcd_analog_micbias_enable(codec); 401 pm8916_wcd_analog_micbias_enable(component);
402 snd_soc_update_bits(codec, CDC_A_MICB_1_EN, 402 snd_soc_component_update_bits(component, CDC_A_MICB_1_EN,
403 MICB_1_EN_BYP_CAP_MASK, cap_mode); 403 MICB_1_EN_BYP_CAP_MASK, cap_mode);
404 break; 404 break;
405 } 405 }
@@ -412,10 +412,10 @@ static int pm8916_wcd_analog_enable_micbias_ext1(struct
412 *w, struct snd_kcontrol 412 *w, struct snd_kcontrol
413 *kcontrol, int event) 413 *kcontrol, int event)
414{ 414{
415 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 415 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
416 struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); 416 struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component);
417 417
418 return pm8916_wcd_analog_enable_micbias_ext(codec, event, w->reg, 418 return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg,
419 wcd->micbias1_cap_mode); 419 wcd->micbias1_cap_mode);
420} 420}
421 421
@@ -424,10 +424,10 @@ static int pm8916_wcd_analog_enable_micbias_ext2(struct
424 *w, struct snd_kcontrol 424 *w, struct snd_kcontrol
425 *kcontrol, int event) 425 *kcontrol, int event)
426{ 426{
427 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 427 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
428 struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); 428 struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component);
429 429
430 return pm8916_wcd_analog_enable_micbias_ext(codec, event, w->reg, 430 return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg,
431 wcd->micbias2_cap_mode); 431 wcd->micbias2_cap_mode);
432 432
433} 433}
@@ -437,35 +437,35 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct
437 *w, struct snd_kcontrol 437 *w, struct snd_kcontrol
438 *kcontrol, int event) 438 *kcontrol, int event)
439{ 439{
440 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 440 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
441 struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); 441 struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component);
442 442
443 return pm8916_wcd_analog_enable_micbias_int(codec, event, w->reg, 443 return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg,
444 wcd->micbias1_cap_mode); 444 wcd->micbias1_cap_mode);
445} 445}
446 446
447static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, 447static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
448 bool micbias2_enabled) 448 bool micbias2_enabled)
449{ 449{
450 struct snd_soc_codec *codec = priv->codec; 450 struct snd_soc_component *component = priv->component;
451 u32 coarse, fine, reg_val, reg_addr; 451 u32 coarse, fine, reg_val, reg_addr;
452 int *vrefs, i; 452 int *vrefs, i;
453 453
454 if (!micbias2_enabled) { /* use internal 100uA Current source */ 454 if (!micbias2_enabled) { /* use internal 100uA Current source */
455 /* Enable internal 2.2k Internal Rbias Resistor */ 455 /* Enable internal 2.2k Internal Rbias Resistor */
456 snd_soc_update_bits(codec, CDC_A_MICB_1_INT_RBIAS, 456 snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS,
457 MICB_1_INT_TX2_INT_RBIAS_EN_MASK, 457 MICB_1_INT_TX2_INT_RBIAS_EN_MASK,
458 MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); 458 MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE);
459 /* Remove pull down on MIC BIAS2 */ 459 /* Remove pull down on MIC BIAS2 */
460 snd_soc_update_bits(codec, CDC_A_MICB_2_EN, 460 snd_soc_component_update_bits(component, CDC_A_MICB_2_EN,
461 CDC_A_MICB_2_PULL_DOWN_EN_MASK, 461 CDC_A_MICB_2_PULL_DOWN_EN_MASK,
462 0); 462 0);
463 /* enable 100uA internal current source */ 463 /* enable 100uA internal current source */
464 snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, 464 snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL,
465 CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK, 465 CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK,
466 CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_I_100UA); 466 CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_I_100UA);
467 } 467 }
468 snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, 468 snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL,
469 CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK, 469 CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK,
470 CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN); 470 CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN);
471 471
@@ -482,7 +482,7 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
482 fine = ((vrefs[i] % 100) / 12); 482 fine = ((vrefs[i] % 100) / 12);
483 reg_val = (coarse << CDC_A_MBHC_BTN_VREF_COARSE_SHIFT) | 483 reg_val = (coarse << CDC_A_MBHC_BTN_VREF_COARSE_SHIFT) |
484 (fine << CDC_A_MBHC_BTN_VREF_FINE_SHIFT); 484 (fine << CDC_A_MBHC_BTN_VREF_FINE_SHIFT);
485 snd_soc_update_bits(codec, reg_addr, 485 snd_soc_component_update_bits(component, reg_addr,
486 CDC_A_MBHC_BTN_VREF_MASK, 486 CDC_A_MBHC_BTN_VREF_MASK,
487 reg_val); 487 reg_val);
488 reg_addr++; 488 reg_addr++;
@@ -493,12 +493,12 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
493 493
494static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) 494static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
495{ 495{
496 struct snd_soc_codec *codec = wcd->codec; 496 struct snd_soc_component *component = wcd->component;
497 bool micbias_enabled = false; 497 bool micbias_enabled = false;
498 u32 plug_type = 0; 498 u32 plug_type = 0;
499 u32 int_en_mask; 499 u32 int_en_mask;
500 500
501 snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1, 501 snd_soc_component_write(component, CDC_A_MBHC_DET_CTL_1,
502 CDC_A_MBHC_DET_CTL_L_DET_EN | 502 CDC_A_MBHC_DET_CTL_L_DET_EN |
503 CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION | 503 CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
504 CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO | 504 CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
@@ -510,23 +510,23 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
510 if (wcd->gnd_jack_type_normally_open) 510 if (wcd->gnd_jack_type_normally_open)
511 plug_type |= CDC_A_GND_PLUG_TYPE_NO; 511 plug_type |= CDC_A_GND_PLUG_TYPE_NO;
512 512
513 snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2, 513 snd_soc_component_write(component, CDC_A_MBHC_DET_CTL_2,
514 CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 | 514 CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
515 CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD | 515 CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
516 plug_type | 516 plug_type |
517 CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN); 517 CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
518 518
519 519
520 snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER, 520 snd_soc_component_write(component, CDC_A_MBHC_DBNC_TIMER,
521 CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS | 521 CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
522 CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS); 522 CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
523 523
524 /* enable MBHC clock */ 524 /* enable MBHC clock */
525 snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL, 525 snd_soc_component_update_bits(component, CDC_D_CDC_DIG_CLK_CTL,
526 DIG_CLK_CTL_D_MBHC_CLK_EN_MASK, 526 DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
527 DIG_CLK_CTL_D_MBHC_CLK_EN); 527 DIG_CLK_CTL_D_MBHC_CLK_EN);
528 528
529 if (snd_soc_read(codec, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) 529 if (snd_soc_component_read32(component, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE)
530 micbias_enabled = true; 530 micbias_enabled = true;
531 531
532 pm8916_mbhc_configure_bias(wcd, micbias_enabled); 532 pm8916_mbhc_configure_bias(wcd, micbias_enabled);
@@ -535,8 +535,8 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
535 if (wcd->mbhc_btn_enabled) 535 if (wcd->mbhc_btn_enabled)
536 int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET; 536 int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
537 537
538 snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0); 538 snd_soc_component_update_bits(component, CDC_D_INT_EN_CLR, int_en_mask, 0);
539 snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask); 539 snd_soc_component_update_bits(component, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
540 wcd->mbhc_btn0_released = false; 540 wcd->mbhc_btn0_released = false;
541 wcd->detect_accessory_type = true; 541 wcd->detect_accessory_type = true;
542} 542}
@@ -546,8 +546,8 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct
546 *w, struct snd_kcontrol 546 *w, struct snd_kcontrol
547 *kcontrol, int event) 547 *kcontrol, int event)
548{ 548{
549 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 549 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
550 struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); 550 struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component);
551 551
552 switch (event) { 552 switch (event) {
553 case SND_SOC_DAPM_POST_PMU: 553 case SND_SOC_DAPM_POST_PMU:
@@ -558,7 +558,7 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct
558 break; 558 break;
559 } 559 }
560 560
561 return pm8916_wcd_analog_enable_micbias_int(codec, event, w->reg, 561 return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg,
562 wcd->micbias2_cap_mode); 562 wcd->micbias2_cap_mode);
563} 563}
564 564
@@ -566,7 +566,7 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w,
566 struct snd_kcontrol *kcontrol, 566 struct snd_kcontrol *kcontrol,
567 int event) 567 int event)
568{ 568{
569 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 569 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
570 u16 adc_reg = CDC_A_TX_1_2_TEST_CTL_2; 570 u16 adc_reg = CDC_A_TX_1_2_TEST_CTL_2;
571 u8 init_bit_shift; 571 u8 init_bit_shift;
572 572
@@ -578,7 +578,7 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w,
578 switch (event) { 578 switch (event) {
579 case SND_SOC_DAPM_PRE_PMU: 579 case SND_SOC_DAPM_PRE_PMU:
580 if (w->reg == CDC_A_TX_2_EN) 580 if (w->reg == CDC_A_TX_2_EN)
581 snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, 581 snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL,
582 MICB_1_CTL_CFILT_REF_SEL_MASK, 582 MICB_1_CTL_CFILT_REF_SEL_MASK,
583 MICB_1_CTL_CFILT_REF_SEL_HPF_REF); 583 MICB_1_CTL_CFILT_REF_SEL_HPF_REF);
584 /* 584 /*
@@ -587,17 +587,17 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w,
587 * happen when the input voltage is changing too much. 587 * happen when the input voltage is changing too much.
588 */ 588 */
589 usleep_range(10000, 10010); 589 usleep_range(10000, 10010);
590 snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 590 snd_soc_component_update_bits(component, adc_reg, 1 << init_bit_shift,
591 1 << init_bit_shift); 591 1 << init_bit_shift);
592 switch (w->reg) { 592 switch (w->reg) {
593 case CDC_A_TX_1_EN: 593 case CDC_A_TX_1_EN:
594 snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX1_CTL, 594 snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX1_CTL,
595 CONN_TX1_SERIAL_TX1_MUX, 595 CONN_TX1_SERIAL_TX1_MUX,
596 CONN_TX1_SERIAL_TX1_ADC_1); 596 CONN_TX1_SERIAL_TX1_ADC_1);
597 break; 597 break;
598 case CDC_A_TX_2_EN: 598 case CDC_A_TX_2_EN:
599 case CDC_A_TX_3_EN: 599 case CDC_A_TX_3_EN:
600 snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX2_CTL, 600 snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX2_CTL,
601 CONN_TX2_SERIAL_TX2_MUX, 601 CONN_TX2_SERIAL_TX2_MUX,
602 CONN_TX2_SERIAL_TX2_ADC_2); 602 CONN_TX2_SERIAL_TX2_ADC_2);
603 break; 603 break;
@@ -609,21 +609,21 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w,
609 * to reduce the tx pop 609 * to reduce the tx pop
610 */ 610 */
611 usleep_range(12000, 12010); 611 usleep_range(12000, 12010);
612 snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00); 612 snd_soc_component_update_bits(component, adc_reg, 1 << init_bit_shift, 0x00);
613 break; 613 break;
614 case SND_SOC_DAPM_POST_PMD: 614 case SND_SOC_DAPM_POST_PMD:
615 switch (w->reg) { 615 switch (w->reg) {
616 case CDC_A_TX_1_EN: 616 case CDC_A_TX_1_EN:
617 snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX1_CTL, 617 snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX1_CTL,
618 CONN_TX1_SERIAL_TX1_MUX, 618 CONN_TX1_SERIAL_TX1_MUX,
619 CONN_TX1_SERIAL_TX1_ZERO); 619 CONN_TX1_SERIAL_TX1_ZERO);
620 break; 620 break;
621 case CDC_A_TX_2_EN: 621 case CDC_A_TX_2_EN:
622 snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, 622 snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL,
623 MICB_1_CTL_CFILT_REF_SEL_MASK, 0); 623 MICB_1_CTL_CFILT_REF_SEL_MASK, 0);
624 /* fall through */ 624 /* fall through */
625 case CDC_A_TX_3_EN: 625 case CDC_A_TX_3_EN:
626 snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX2_CTL, 626 snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX2_CTL,
627 CONN_TX2_SERIAL_TX2_MUX, 627 CONN_TX2_SERIAL_TX2_MUX,
628 CONN_TX2_SERIAL_TX2_ZERO); 628 CONN_TX2_SERIAL_TX2_ZERO);
629 break; 629 break;
@@ -639,11 +639,11 @@ static int pm8916_wcd_analog_enable_spk_pa(struct snd_soc_dapm_widget *w,
639 struct snd_kcontrol *kcontrol, 639 struct snd_kcontrol *kcontrol,
640 int event) 640 int event)
641{ 641{
642 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 642 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
643 643
644 switch (event) { 644 switch (event) {
645 case SND_SOC_DAPM_PRE_PMU: 645 case SND_SOC_DAPM_PRE_PMU:
646 snd_soc_update_bits(codec, CDC_A_SPKR_PWRSTG_CTL, 646 snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
647 SPKR_PWRSTG_CTL_DAC_EN_MASK | 647 SPKR_PWRSTG_CTL_DAC_EN_MASK |
648 SPKR_PWRSTG_CTL_BBM_MASK | 648 SPKR_PWRSTG_CTL_BBM_MASK |
649 SPKR_PWRSTG_CTL_HBRDGE_EN_MASK | 649 SPKR_PWRSTG_CTL_HBRDGE_EN_MASK |
@@ -653,29 +653,29 @@ static int pm8916_wcd_analog_enable_spk_pa(struct snd_soc_dapm_widget *w,
653 SPKR_PWRSTG_CTL_HBRDGE_EN | 653 SPKR_PWRSTG_CTL_HBRDGE_EN |
654 SPKR_PWRSTG_CTL_CLAMP_EN); 654 SPKR_PWRSTG_CTL_CLAMP_EN);
655 655
656 snd_soc_update_bits(codec, CDC_A_RX_EAR_CTL, 656 snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
657 RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK, 657 RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK,
658 RX_EAR_CTL_SPK_VBAT_LDO_EN_ENABLE); 658 RX_EAR_CTL_SPK_VBAT_LDO_EN_ENABLE);
659 break; 659 break;
660 case SND_SOC_DAPM_POST_PMU: 660 case SND_SOC_DAPM_POST_PMU:
661 snd_soc_update_bits(codec, CDC_A_SPKR_DRV_CTL, 661 snd_soc_component_update_bits(component, CDC_A_SPKR_DRV_CTL,
662 SPKR_DRV_CTL_DEF_MASK, 662 SPKR_DRV_CTL_DEF_MASK,
663 SPKR_DRV_CTL_DEF_VAL); 663 SPKR_DRV_CTL_DEF_VAL);
664 snd_soc_update_bits(codec, w->reg, 664 snd_soc_component_update_bits(component, w->reg,
665 SPKR_DRV_CLASSD_PA_EN_MASK, 665 SPKR_DRV_CLASSD_PA_EN_MASK,
666 SPKR_DRV_CLASSD_PA_EN_ENABLE); 666 SPKR_DRV_CLASSD_PA_EN_ENABLE);
667 break; 667 break;
668 case SND_SOC_DAPM_POST_PMD: 668 case SND_SOC_DAPM_POST_PMD:
669 snd_soc_update_bits(codec, CDC_A_SPKR_PWRSTG_CTL, 669 snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
670 SPKR_PWRSTG_CTL_DAC_EN_MASK| 670 SPKR_PWRSTG_CTL_DAC_EN_MASK|
671 SPKR_PWRSTG_CTL_BBM_MASK | 671 SPKR_PWRSTG_CTL_BBM_MASK |
672 SPKR_PWRSTG_CTL_HBRDGE_EN_MASK | 672 SPKR_PWRSTG_CTL_HBRDGE_EN_MASK |
673 SPKR_PWRSTG_CTL_CLAMP_EN_MASK, 0); 673 SPKR_PWRSTG_CTL_CLAMP_EN_MASK, 0);
674 674
675 snd_soc_update_bits(codec, CDC_A_SPKR_DAC_CTL, 675 snd_soc_component_update_bits(component, CDC_A_SPKR_DAC_CTL,
676 SPKR_DAC_CTL_DAC_RESET_MASK, 676 SPKR_DAC_CTL_DAC_RESET_MASK,
677 SPKR_DAC_CTL_DAC_RESET_NORMAL); 677 SPKR_DAC_CTL_DAC_RESET_NORMAL);
678 snd_soc_update_bits(codec, CDC_A_RX_EAR_CTL, 678 snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
679 RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK, 0); 679 RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK, 0);
680 break; 680 break;
681 } 681 }
@@ -701,36 +701,36 @@ static const struct reg_default wcd_reg_defaults_2_0[] = {
701 {CDC_A_MASTER_BIAS_CTL, 0x30}, 701 {CDC_A_MASTER_BIAS_CTL, 0x30},
702}; 702};
703 703
704static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec) 704static int pm8916_wcd_analog_probe(struct snd_soc_component *component)
705{ 705{
706 struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(codec->dev); 706 struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev);
707 int err, reg; 707 int err, reg;
708 708
709 err = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); 709 err = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
710 if (err != 0) { 710 if (err != 0) {
711 dev_err(codec->dev, "failed to enable regulators (%d)\n", err); 711 dev_err(component->dev, "failed to enable regulators (%d)\n", err);
712 return err; 712 return err;
713 } 713 }
714 714
715 snd_soc_codec_init_regmap(codec, 715 snd_soc_component_init_regmap(component,
716 dev_get_regmap(codec->dev->parent, NULL)); 716 dev_get_regmap(component->dev->parent, NULL));
717 snd_soc_codec_set_drvdata(codec, priv); 717 snd_soc_component_set_drvdata(component, priv);
718 priv->pmic_rev = snd_soc_read(codec, CDC_D_REVISION1); 718 priv->pmic_rev = snd_soc_component_read32(component, CDC_D_REVISION1);
719 priv->codec_version = snd_soc_read(codec, CDC_D_PERPH_SUBTYPE); 719 priv->codec_version = snd_soc_component_read32(component, CDC_D_PERPH_SUBTYPE);
720 720
721 dev_info(codec->dev, "PMIC REV: %d\t CODEC Version: %d\n", 721 dev_info(component->dev, "PMIC REV: %d\t CODEC Version: %d\n",
722 priv->pmic_rev, priv->codec_version); 722 priv->pmic_rev, priv->codec_version);
723 723
724 snd_soc_write(codec, CDC_D_PERPH_RESET_CTL4, 0x01); 724 snd_soc_component_write(component, CDC_D_PERPH_RESET_CTL4, 0x01);
725 snd_soc_write(codec, CDC_A_PERPH_RESET_CTL4, 0x01); 725 snd_soc_component_write(component, CDC_A_PERPH_RESET_CTL4, 0x01);
726 726
727 for (reg = 0; reg < ARRAY_SIZE(wcd_reg_defaults_2_0); reg++) 727 for (reg = 0; reg < ARRAY_SIZE(wcd_reg_defaults_2_0); reg++)
728 snd_soc_write(codec, wcd_reg_defaults_2_0[reg].reg, 728 snd_soc_component_write(component, wcd_reg_defaults_2_0[reg].reg,
729 wcd_reg_defaults_2_0[reg].def); 729 wcd_reg_defaults_2_0[reg].def);
730 730
731 priv->codec = codec; 731 priv->component = component;
732 732
733 snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, 733 snd_soc_component_update_bits(component, CDC_D_CDC_RST_CTL,
734 RST_CTL_DIG_SW_RST_N_MASK, 734 RST_CTL_DIG_SW_RST_N_MASK,
735 RST_CTL_DIG_SW_RST_N_REMOVE_RESET); 735 RST_CTL_DIG_SW_RST_N_REMOVE_RESET);
736 736
@@ -739,14 +739,14 @@ static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec)
739 return 0; 739 return 0;
740} 740}
741 741
742static int pm8916_wcd_analog_remove(struct snd_soc_codec *codec) 742static void pm8916_wcd_analog_remove(struct snd_soc_component *component)
743{ 743{
744 struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(codec->dev); 744 struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev);
745 745
746 snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, 746 snd_soc_component_update_bits(component, CDC_D_CDC_RST_CTL,
747 RST_CTL_DIG_SW_RST_N_MASK, 0); 747 RST_CTL_DIG_SW_RST_N_MASK, 0);
748 748
749 return regulator_bulk_disable(ARRAY_SIZE(priv->supplies), 749 regulator_bulk_disable(ARRAY_SIZE(priv->supplies),
750 priv->supplies); 750 priv->supplies);
751} 751}
752 752
@@ -934,11 +934,11 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = {
934 SND_SOC_DAPM_SUPPLY("A_MCLK2", CDC_D_CDC_TOP_CLK_CTL, 3, 0, NULL, 0), 934 SND_SOC_DAPM_SUPPLY("A_MCLK2", CDC_D_CDC_TOP_CLK_CTL, 3, 0, NULL, 0),
935}; 935};
936 936
937static int pm8916_wcd_analog_set_jack(struct snd_soc_codec *codec, 937static int pm8916_wcd_analog_set_jack(struct snd_soc_component *component,
938 struct snd_soc_jack *jack, 938 struct snd_soc_jack *jack,
939 void *data) 939 void *data)
940{ 940{
941 struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); 941 struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component);
942 942
943 wcd->jack = jack; 943 wcd->jack = jack;
944 944
@@ -950,8 +950,8 @@ static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg)
950 struct pm8916_wcd_analog_priv *priv = arg; 950 struct pm8916_wcd_analog_priv *priv = arg;
951 951
952 if (priv->detect_accessory_type) { 952 if (priv->detect_accessory_type) {
953 struct snd_soc_codec *codec = priv->codec; 953 struct snd_soc_component *component = priv->component;
954 u32 val = snd_soc_read(codec, CDC_A_MBHC_RESULT_1); 954 u32 val = snd_soc_component_read32(component, CDC_A_MBHC_RESULT_1);
955 955
956 /* check if its BTN0 thats released */ 956 /* check if its BTN0 thats released */
957 if ((val != -1) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK)) 957 if ((val != -1) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK))
@@ -967,10 +967,10 @@ static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg)
967static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg) 967static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg)
968{ 968{
969 struct pm8916_wcd_analog_priv *priv = arg; 969 struct pm8916_wcd_analog_priv *priv = arg;
970 struct snd_soc_codec *codec = priv->codec; 970 struct snd_soc_component *component = priv->component;
971 u32 btn_result; 971 u32 btn_result;
972 972
973 btn_result = snd_soc_read(codec, CDC_A_MBHC_RESULT_1) & 973 btn_result = snd_soc_component_read32(component, CDC_A_MBHC_RESULT_1) &
974 CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK; 974 CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK;
975 975
976 switch (btn_result) { 976 switch (btn_result) {
@@ -993,7 +993,7 @@ static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg)
993 SND_JACK_BTN_0, btn_mask); 993 SND_JACK_BTN_0, btn_mask);
994 break; 994 break;
995 default: 995 default:
996 dev_err(codec->dev, 996 dev_err(component->dev,
997 "Unexpected button press result (%x)", btn_result); 997 "Unexpected button press result (%x)", btn_result);
998 break; 998 break;
999 } 999 }
@@ -1004,15 +1004,15 @@ static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg)
1004static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg) 1004static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg)
1005{ 1005{
1006 struct pm8916_wcd_analog_priv *priv = arg; 1006 struct pm8916_wcd_analog_priv *priv = arg;
1007 struct snd_soc_codec *codec = priv->codec; 1007 struct snd_soc_component *component = priv->component;
1008 bool ins = false; 1008 bool ins = false;
1009 1009
1010 if (snd_soc_read(codec, CDC_A_MBHC_DET_CTL_1) & 1010 if (snd_soc_component_read32(component, CDC_A_MBHC_DET_CTL_1) &
1011 CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK) 1011 CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK)
1012 ins = true; 1012 ins = true;
1013 1013
1014 /* Set the detection type appropriately */ 1014 /* Set the detection type appropriately */
1015 snd_soc_update_bits(codec, CDC_A_MBHC_DET_CTL_1, 1015 snd_soc_component_update_bits(component, CDC_A_MBHC_DET_CTL_1,
1016 CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK, 1016 CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK,
1017 (!ins << CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_SHIFT)); 1017 (!ins << CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_SHIFT));
1018 1018
@@ -1020,7 +1020,7 @@ static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg)
1020 if (ins) { /* hs insertion */ 1020 if (ins) { /* hs insertion */
1021 bool micbias_enabled = false; 1021 bool micbias_enabled = false;
1022 1022
1023 if (snd_soc_read(codec, CDC_A_MICB_2_EN) & 1023 if (snd_soc_component_read32(component, CDC_A_MICB_2_EN) &
1024 CDC_A_MICB_2_EN_ENABLE) 1024 CDC_A_MICB_2_EN_ENABLE)
1025 micbias_enabled = true; 1025 micbias_enabled = true;
1026 1026
@@ -1075,18 +1075,20 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = {
1075 }, 1075 },
1076}; 1076};
1077 1077
1078static const struct snd_soc_codec_driver pm8916_wcd_analog = { 1078static const struct snd_soc_component_driver pm8916_wcd_analog = {
1079 .probe = pm8916_wcd_analog_probe, 1079 .probe = pm8916_wcd_analog_probe,
1080 .remove = pm8916_wcd_analog_remove, 1080 .remove = pm8916_wcd_analog_remove,
1081 .set_jack = pm8916_wcd_analog_set_jack, 1081 .set_jack = pm8916_wcd_analog_set_jack,
1082 .component_driver = { 1082 .controls = pm8916_wcd_analog_snd_controls,
1083 .controls = pm8916_wcd_analog_snd_controls, 1083 .num_controls = ARRAY_SIZE(pm8916_wcd_analog_snd_controls),
1084 .num_controls = ARRAY_SIZE(pm8916_wcd_analog_snd_controls), 1084 .dapm_widgets = pm8916_wcd_analog_dapm_widgets,
1085 .dapm_widgets = pm8916_wcd_analog_dapm_widgets, 1085 .num_dapm_widgets = ARRAY_SIZE(pm8916_wcd_analog_dapm_widgets),
1086 .num_dapm_widgets = ARRAY_SIZE(pm8916_wcd_analog_dapm_widgets), 1086 .dapm_routes = pm8916_wcd_analog_audio_map,
1087 .dapm_routes = pm8916_wcd_analog_audio_map, 1087 .num_dapm_routes = ARRAY_SIZE(pm8916_wcd_analog_audio_map),
1088 .num_dapm_routes = ARRAY_SIZE(pm8916_wcd_analog_audio_map), 1088 .idle_bias_on = 1,
1089 }, 1089 .use_pmdown_time = 1,
1090 .endianness = 1,
1091 .non_legacy_dai_naming = 1,
1090}; 1092};
1091 1093
1092static int pm8916_wcd_analog_parse_dt(struct device *dev, 1094static int pm8916_wcd_analog_parse_dt(struct device *dev,
@@ -1223,7 +1225,7 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev)
1223 1225
1224 dev_set_drvdata(dev, priv); 1226 dev_set_drvdata(dev, priv);
1225 1227
1226 return snd_soc_register_codec(dev, &pm8916_wcd_analog, 1228 return devm_snd_soc_register_component(dev, &pm8916_wcd_analog,
1227 pm8916_wcd_analog_dai, 1229 pm8916_wcd_analog_dai,
1228 ARRAY_SIZE(pm8916_wcd_analog_dai)); 1230 ARRAY_SIZE(pm8916_wcd_analog_dai));
1229} 1231}
@@ -1232,7 +1234,6 @@ static int pm8916_wcd_analog_spmi_remove(struct platform_device *pdev)
1232{ 1234{
1233 struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(&pdev->dev); 1235 struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(&pdev->dev);
1234 1236
1235 snd_soc_unregister_codec(&pdev->dev);
1236 clk_disable_unprepare(priv->mclk); 1237 clk_disable_unprepare(priv->mclk);
1237 1238
1238 return 0; 1239 return 0;