aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:07:43 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:42:16 -0500
commite3a68fd8a8d19454bbff08bc14b959645601a48d (patch)
tree7a3358a1e1ed76d06ea2100dfcbdc5aa15deb9be
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8983: 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/wm8983.c170
1 files changed, 79 insertions, 91 deletions
diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c
index bfdbe72ee687..9f35801aa85f 100644
--- a/sound/soc/codecs/wm8983.c
+++ b/sound/soc/codecs/wm8983.c
@@ -492,10 +492,10 @@ static const struct snd_soc_dapm_route wm8983_audio_map[] = {
492static int eqmode_get(struct snd_kcontrol *kcontrol, 492static int eqmode_get(struct snd_kcontrol *kcontrol,
493 struct snd_ctl_elem_value *ucontrol) 493 struct snd_ctl_elem_value *ucontrol)
494{ 494{
495 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 495 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
496 unsigned int reg; 496 unsigned int reg;
497 497
498 reg = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF); 498 reg = snd_soc_component_read32(component, WM8983_EQ1_LOW_SHELF);
499 if (reg & WM8983_EQ3DMODE) 499 if (reg & WM8983_EQ3DMODE)
500 ucontrol->value.enumerated.item[0] = 1; 500 ucontrol->value.enumerated.item[0] = 1;
501 else 501 else
@@ -507,7 +507,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol,
507static int eqmode_put(struct snd_kcontrol *kcontrol, 507static int eqmode_put(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_value *ucontrol) 508 struct snd_ctl_elem_value *ucontrol)
509{ 509{
510 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 510 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
511 unsigned int regpwr2, regpwr3; 511 unsigned int regpwr2, regpwr3;
512 unsigned int reg_eq; 512 unsigned int reg_eq;
513 513
@@ -515,7 +515,7 @@ static int eqmode_put(struct snd_kcontrol *kcontrol,
515 && ucontrol->value.enumerated.item[0] != 1) 515 && ucontrol->value.enumerated.item[0] != 1)
516 return -EINVAL; 516 return -EINVAL;
517 517
518 reg_eq = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF); 518 reg_eq = snd_soc_component_read32(component, WM8983_EQ1_LOW_SHELF);
519 switch ((reg_eq & WM8983_EQ3DMODE) >> WM8983_EQ3DMODE_SHIFT) { 519 switch ((reg_eq & WM8983_EQ3DMODE) >> WM8983_EQ3DMODE_SHIFT) {
520 case 0: 520 case 0:
521 if (!ucontrol->value.enumerated.item[0]) 521 if (!ucontrol->value.enumerated.item[0])
@@ -527,21 +527,21 @@ static int eqmode_put(struct snd_kcontrol *kcontrol,
527 break; 527 break;
528 } 528 }
529 529
530 regpwr2 = snd_soc_read(codec, WM8983_POWER_MANAGEMENT_2); 530 regpwr2 = snd_soc_component_read32(component, WM8983_POWER_MANAGEMENT_2);
531 regpwr3 = snd_soc_read(codec, WM8983_POWER_MANAGEMENT_3); 531 regpwr3 = snd_soc_component_read32(component, WM8983_POWER_MANAGEMENT_3);
532 /* disable the DACs and ADCs */ 532 /* disable the DACs and ADCs */
533 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_2, 533 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_2,
534 WM8983_ADCENR_MASK | WM8983_ADCENL_MASK, 0); 534 WM8983_ADCENR_MASK | WM8983_ADCENL_MASK, 0);
535 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_3, 535 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_3,
536 WM8983_DACENR_MASK | WM8983_DACENL_MASK, 0); 536 WM8983_DACENR_MASK | WM8983_DACENL_MASK, 0);
537 /* set the desired eqmode */ 537 /* set the desired eqmode */
538 snd_soc_update_bits(codec, WM8983_EQ1_LOW_SHELF, 538 snd_soc_component_update_bits(component, WM8983_EQ1_LOW_SHELF,
539 WM8983_EQ3DMODE_MASK, 539 WM8983_EQ3DMODE_MASK,
540 ucontrol->value.enumerated.item[0] 540 ucontrol->value.enumerated.item[0]
541 << WM8983_EQ3DMODE_SHIFT); 541 << WM8983_EQ3DMODE_SHIFT);
542 /* restore DAC/ADC configuration */ 542 /* restore DAC/ADC configuration */
543 snd_soc_write(codec, WM8983_POWER_MANAGEMENT_2, regpwr2); 543 snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_2, regpwr2);
544 snd_soc_write(codec, WM8983_POWER_MANAGEMENT_3, regpwr3); 544 snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_3, regpwr3);
545 return 0; 545 return 0;
546} 546}
547 547
@@ -562,16 +562,16 @@ static bool wm8983_writeable(struct device *dev, unsigned int reg)
562 562
563static int wm8983_dac_mute(struct snd_soc_dai *dai, int mute) 563static int wm8983_dac_mute(struct snd_soc_dai *dai, int mute)
564{ 564{
565 struct snd_soc_codec *codec = dai->codec; 565 struct snd_soc_component *component = dai->component;
566 566
567 return snd_soc_update_bits(codec, WM8983_DAC_CONTROL, 567 return snd_soc_component_update_bits(component, WM8983_DAC_CONTROL,
568 WM8983_SOFTMUTE_MASK, 568 WM8983_SOFTMUTE_MASK,
569 !!mute << WM8983_SOFTMUTE_SHIFT); 569 !!mute << WM8983_SOFTMUTE_SHIFT);
570} 570}
571 571
572static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 572static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
573{ 573{
574 struct snd_soc_codec *codec = dai->codec; 574 struct snd_soc_component *component = dai->component;
575 u16 format, master, bcp, lrp; 575 u16 format, master, bcp, lrp;
576 576
577 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 577 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -593,7 +593,7 @@ static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
593 return -EINVAL; 593 return -EINVAL;
594 } 594 }
595 595
596 snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, 596 snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE,
597 WM8983_FMT_MASK, format << WM8983_FMT_SHIFT); 597 WM8983_FMT_MASK, format << WM8983_FMT_SHIFT);
598 598
599 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 599 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -608,7 +608,7 @@ static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
608 return -EINVAL; 608 return -EINVAL;
609 } 609 }
610 610
611 snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, 611 snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL,
612 WM8983_MS_MASK, master << WM8983_MS_SHIFT); 612 WM8983_MS_MASK, master << WM8983_MS_SHIFT);
613 613
614 /* FIXME: We don't currently support DSP A/B modes */ 614 /* FIXME: We don't currently support DSP A/B modes */
@@ -639,9 +639,9 @@ static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
639 return -EINVAL; 639 return -EINVAL;
640 } 640 }
641 641
642 snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, 642 snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE,
643 WM8983_LRCP_MASK, lrp << WM8983_LRCP_SHIFT); 643 WM8983_LRCP_MASK, lrp << WM8983_LRCP_SHIFT);
644 snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, 644 snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE,
645 WM8983_BCP_MASK, bcp << WM8983_BCP_SHIFT); 645 WM8983_BCP_MASK, bcp << WM8983_BCP_SHIFT);
646 return 0; 646 return 0;
647} 647}
@@ -651,8 +651,8 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream,
651 struct snd_soc_dai *dai) 651 struct snd_soc_dai *dai)
652{ 652{
653 int i; 653 int i;
654 struct snd_soc_codec *codec = dai->codec; 654 struct snd_soc_component *component = dai->component;
655 struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec); 655 struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component);
656 u16 blen, srate_idx; 656 u16 blen, srate_idx;
657 u32 tmp; 657 u32 tmp;
658 int srate_best; 658 int srate_best;
@@ -660,7 +660,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream,
660 660
661 ret = snd_soc_params_to_bclk(params); 661 ret = snd_soc_params_to_bclk(params);
662 if (ret < 0) { 662 if (ret < 0) {
663 dev_err(codec->dev, "Failed to convert params to bclk: %d\n", ret); 663 dev_err(component->dev, "Failed to convert params to bclk: %d\n", ret);
664 return ret; 664 return ret;
665 } 665 }
666 666
@@ -685,7 +685,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream,
685 return -EINVAL; 685 return -EINVAL;
686 } 686 }
687 687
688 snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, 688 snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE,
689 WM8983_WL_MASK, blen << WM8983_WL_SHIFT); 689 WM8983_WL_MASK, blen << WM8983_WL_SHIFT);
690 690
691 /* 691 /*
@@ -702,7 +702,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream,
702 } 702 }
703 703
704 dev_dbg(dai->dev, "Selected SRATE = %d\n", srates[srate_idx]); 704 dev_dbg(dai->dev, "Selected SRATE = %d\n", srates[srate_idx]);
705 snd_soc_update_bits(codec, WM8983_ADDITIONAL_CONTROL, 705 snd_soc_component_update_bits(component, WM8983_ADDITIONAL_CONTROL,
706 WM8983_SR_MASK, srate_idx << WM8983_SR_SHIFT); 706 WM8983_SR_MASK, srate_idx << WM8983_SR_SHIFT);
707 707
708 dev_dbg(dai->dev, "Target BCLK = %uHz\n", wm8983->bclk); 708 dev_dbg(dai->dev, "Target BCLK = %uHz\n", wm8983->bclk);
@@ -721,7 +721,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream,
721 } 721 }
722 722
723 dev_dbg(dai->dev, "MCLK ratio = %dfs\n", fs_ratios[i].ratio); 723 dev_dbg(dai->dev, "MCLK ratio = %dfs\n", fs_ratios[i].ratio);
724 snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, 724 snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL,
725 WM8983_MCLKDIV_MASK, i << WM8983_MCLKDIV_SHIFT); 725 WM8983_MCLKDIV_MASK, i << WM8983_MCLKDIV_SHIFT);
726 726
727 /* select the appropriate bclk divider */ 727 /* select the appropriate bclk divider */
@@ -737,7 +737,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream,
737 } 737 }
738 738
739 dev_dbg(dai->dev, "BCLK div = %d\n", i); 739 dev_dbg(dai->dev, "BCLK div = %d\n", i);
740 snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, 740 snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL,
741 WM8983_BCLKDIV_MASK, i << WM8983_BCLKDIV_SHIFT); 741 WM8983_BCLKDIV_MASK, i << WM8983_BCLKDIV_SHIFT);
742 742
743 return 0; 743 return 0;
@@ -789,13 +789,13 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id,
789 unsigned int freq_out) 789 unsigned int freq_out)
790{ 790{
791 int ret; 791 int ret;
792 struct snd_soc_codec *codec; 792 struct snd_soc_component *component;
793 struct pll_div pll_div; 793 struct pll_div pll_div;
794 794
795 codec = dai->codec; 795 component = dai->component;
796 if (!freq_in || !freq_out) { 796 if (!freq_in || !freq_out) {
797 /* disable the PLL */ 797 /* disable the PLL */
798 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, 798 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1,
799 WM8983_PLLEN_MASK, 0); 799 WM8983_PLLEN_MASK, 0);
800 return 0; 800 return 0;
801 } else { 801 } else {
@@ -804,19 +804,19 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id,
804 return ret; 804 return ret;
805 805
806 /* disable the PLL before re-programming it */ 806 /* disable the PLL before re-programming it */
807 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, 807 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1,
808 WM8983_PLLEN_MASK, 0); 808 WM8983_PLLEN_MASK, 0);
809 809
810 /* set PLLN and PRESCALE */ 810 /* set PLLN and PRESCALE */
811 snd_soc_write(codec, WM8983_PLL_N, 811 snd_soc_component_write(component, WM8983_PLL_N,
812 (pll_div.div2 << WM8983_PLL_PRESCALE_SHIFT) 812 (pll_div.div2 << WM8983_PLL_PRESCALE_SHIFT)
813 | pll_div.n); 813 | pll_div.n);
814 /* set PLLK */ 814 /* set PLLK */
815 snd_soc_write(codec, WM8983_PLL_K_3, pll_div.k & 0x1ff); 815 snd_soc_component_write(component, WM8983_PLL_K_3, pll_div.k & 0x1ff);
816 snd_soc_write(codec, WM8983_PLL_K_2, (pll_div.k >> 9) & 0x1ff); 816 snd_soc_component_write(component, WM8983_PLL_K_2, (pll_div.k >> 9) & 0x1ff);
817 snd_soc_write(codec, WM8983_PLL_K_1, (pll_div.k >> 18)); 817 snd_soc_component_write(component, WM8983_PLL_K_1, (pll_div.k >> 18));
818 /* enable the PLL */ 818 /* enable the PLL */
819 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, 819 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1,
820 WM8983_PLLEN_MASK, WM8983_PLLEN); 820 WM8983_PLLEN_MASK, WM8983_PLLEN);
821 } 821 }
822 822
@@ -826,16 +826,16 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id,
826static int wm8983_set_sysclk(struct snd_soc_dai *dai, 826static int wm8983_set_sysclk(struct snd_soc_dai *dai,
827 int clk_id, unsigned int freq, int dir) 827 int clk_id, unsigned int freq, int dir)
828{ 828{
829 struct snd_soc_codec *codec = dai->codec; 829 struct snd_soc_component *component = dai->component;
830 struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec); 830 struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component);
831 831
832 switch (clk_id) { 832 switch (clk_id) {
833 case WM8983_CLKSRC_MCLK: 833 case WM8983_CLKSRC_MCLK:
834 snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, 834 snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL,
835 WM8983_CLKSEL_MASK, 0); 835 WM8983_CLKSEL_MASK, 0);
836 break; 836 break;
837 case WM8983_CLKSRC_PLL: 837 case WM8983_CLKSRC_PLL:
838 snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, 838 snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL,
839 WM8983_CLKSEL_MASK, WM8983_CLKSEL); 839 WM8983_CLKSEL_MASK, WM8983_CLKSEL);
840 break; 840 break;
841 default: 841 default:
@@ -847,100 +847,100 @@ static int wm8983_set_sysclk(struct snd_soc_dai *dai,
847 return 0; 847 return 0;
848} 848}
849 849
850static int wm8983_set_bias_level(struct snd_soc_codec *codec, 850static int wm8983_set_bias_level(struct snd_soc_component *component,
851 enum snd_soc_bias_level level) 851 enum snd_soc_bias_level level)
852{ 852{
853 struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec); 853 struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component);
854 int ret; 854 int ret;
855 855
856 switch (level) { 856 switch (level) {
857 case SND_SOC_BIAS_ON: 857 case SND_SOC_BIAS_ON:
858 case SND_SOC_BIAS_PREPARE: 858 case SND_SOC_BIAS_PREPARE:
859 /* VMID at 100k */ 859 /* VMID at 100k */
860 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, 860 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1,
861 WM8983_VMIDSEL_MASK, 861 WM8983_VMIDSEL_MASK,
862 1 << WM8983_VMIDSEL_SHIFT); 862 1 << WM8983_VMIDSEL_SHIFT);
863 break; 863 break;
864 case SND_SOC_BIAS_STANDBY: 864 case SND_SOC_BIAS_STANDBY:
865 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 865 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
866 ret = regcache_sync(wm8983->regmap); 866 ret = regcache_sync(wm8983->regmap);
867 if (ret < 0) { 867 if (ret < 0) {
868 dev_err(codec->dev, "Failed to sync cache: %d\n", ret); 868 dev_err(component->dev, "Failed to sync cache: %d\n", ret);
869 return ret; 869 return ret;
870 } 870 }
871 /* enable anti-pop features */ 871 /* enable anti-pop features */
872 snd_soc_update_bits(codec, WM8983_OUT4_TO_ADC, 872 snd_soc_component_update_bits(component, WM8983_OUT4_TO_ADC,
873 WM8983_POBCTRL_MASK | WM8983_DELEN_MASK, 873 WM8983_POBCTRL_MASK | WM8983_DELEN_MASK,
874 WM8983_POBCTRL | WM8983_DELEN); 874 WM8983_POBCTRL | WM8983_DELEN);
875 /* enable thermal shutdown */ 875 /* enable thermal shutdown */
876 snd_soc_update_bits(codec, WM8983_OUTPUT_CTRL, 876 snd_soc_component_update_bits(component, WM8983_OUTPUT_CTRL,
877 WM8983_TSDEN_MASK, WM8983_TSDEN); 877 WM8983_TSDEN_MASK, WM8983_TSDEN);
878 /* enable BIASEN */ 878 /* enable BIASEN */
879 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, 879 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1,
880 WM8983_BIASEN_MASK, WM8983_BIASEN); 880 WM8983_BIASEN_MASK, WM8983_BIASEN);
881 /* VMID at 100k */ 881 /* VMID at 100k */
882 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, 882 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1,
883 WM8983_VMIDSEL_MASK, 883 WM8983_VMIDSEL_MASK,
884 1 << WM8983_VMIDSEL_SHIFT); 884 1 << WM8983_VMIDSEL_SHIFT);
885 msleep(250); 885 msleep(250);
886 /* disable anti-pop features */ 886 /* disable anti-pop features */
887 snd_soc_update_bits(codec, WM8983_OUT4_TO_ADC, 887 snd_soc_component_update_bits(component, WM8983_OUT4_TO_ADC,
888 WM8983_POBCTRL_MASK | 888 WM8983_POBCTRL_MASK |
889 WM8983_DELEN_MASK, 0); 889 WM8983_DELEN_MASK, 0);
890 } 890 }
891 891
892 /* VMID at 500k */ 892 /* VMID at 500k */
893 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, 893 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1,
894 WM8983_VMIDSEL_MASK, 894 WM8983_VMIDSEL_MASK,
895 2 << WM8983_VMIDSEL_SHIFT); 895 2 << WM8983_VMIDSEL_SHIFT);
896 break; 896 break;
897 case SND_SOC_BIAS_OFF: 897 case SND_SOC_BIAS_OFF:
898 /* disable thermal shutdown */ 898 /* disable thermal shutdown */
899 snd_soc_update_bits(codec, WM8983_OUTPUT_CTRL, 899 snd_soc_component_update_bits(component, WM8983_OUTPUT_CTRL,
900 WM8983_TSDEN_MASK, 0); 900 WM8983_TSDEN_MASK, 0);
901 /* disable VMIDSEL and BIASEN */ 901 /* disable VMIDSEL and BIASEN */
902 snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, 902 snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1,
903 WM8983_VMIDSEL_MASK | WM8983_BIASEN_MASK, 903 WM8983_VMIDSEL_MASK | WM8983_BIASEN_MASK,
904 0); 904 0);
905 /* wait for VMID to discharge */ 905 /* wait for VMID to discharge */
906 msleep(100); 906 msleep(100);
907 snd_soc_write(codec, WM8983_POWER_MANAGEMENT_1, 0); 907 snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_1, 0);
908 snd_soc_write(codec, WM8983_POWER_MANAGEMENT_2, 0); 908 snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_2, 0);
909 snd_soc_write(codec, WM8983_POWER_MANAGEMENT_3, 0); 909 snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_3, 0);
910 break; 910 break;
911 } 911 }
912 912
913 return 0; 913 return 0;
914} 914}
915 915
916static int wm8983_probe(struct snd_soc_codec *codec) 916static int wm8983_probe(struct snd_soc_component *component)
917{ 917{
918 int ret; 918 int ret;
919 int i; 919 int i;
920 920
921 ret = snd_soc_write(codec, WM8983_SOFTWARE_RESET, 0); 921 ret = snd_soc_component_write(component, WM8983_SOFTWARE_RESET, 0);
922 if (ret < 0) { 922 if (ret < 0) {
923 dev_err(codec->dev, "Failed to issue reset: %d\n", ret); 923 dev_err(component->dev, "Failed to issue reset: %d\n", ret);
924 return ret; 924 return ret;
925 } 925 }
926 926
927 /* set the vol/gain update bits */ 927 /* set the vol/gain update bits */
928 for (i = 0; i < ARRAY_SIZE(vol_update_regs); ++i) 928 for (i = 0; i < ARRAY_SIZE(vol_update_regs); ++i)
929 snd_soc_update_bits(codec, vol_update_regs[i], 929 snd_soc_component_update_bits(component, vol_update_regs[i],
930 0x100, 0x100); 930 0x100, 0x100);
931 931
932 /* mute all outputs and set PGAs to minimum gain */ 932 /* mute all outputs and set PGAs to minimum gain */
933 for (i = WM8983_LOUT1_HP_VOLUME_CTRL; 933 for (i = WM8983_LOUT1_HP_VOLUME_CTRL;
934 i <= WM8983_OUT4_MONO_MIX_CTRL; ++i) 934 i <= WM8983_OUT4_MONO_MIX_CTRL; ++i)
935 snd_soc_update_bits(codec, i, 0x40, 0x40); 935 snd_soc_component_update_bits(component, i, 0x40, 0x40);
936 936
937 /* enable soft mute */ 937 /* enable soft mute */
938 snd_soc_update_bits(codec, WM8983_DAC_CONTROL, 938 snd_soc_component_update_bits(component, WM8983_DAC_CONTROL,
939 WM8983_SOFTMUTE_MASK, 939 WM8983_SOFTMUTE_MASK,
940 WM8983_SOFTMUTE); 940 WM8983_SOFTMUTE);
941 941
942 /* enable BIASCUT */ 942 /* enable BIASCUT */
943 snd_soc_update_bits(codec, WM8983_BIAS_CTRL, 943 snd_soc_component_update_bits(component, WM8983_BIAS_CTRL,
944 WM8983_BIASCUT, WM8983_BIASCUT); 944 WM8983_BIASCUT, WM8983_BIASCUT);
945 return 0; 945 return 0;
946} 946}
@@ -976,18 +976,20 @@ static struct snd_soc_dai_driver wm8983_dai = {
976 .symmetric_rates = 1 976 .symmetric_rates = 1
977}; 977};
978 978
979static const struct snd_soc_codec_driver soc_codec_dev_wm8983 = { 979static const struct snd_soc_component_driver soc_component_dev_wm8983 = {
980 .probe = wm8983_probe, 980 .probe = wm8983_probe,
981 .set_bias_level = wm8983_set_bias_level, 981 .set_bias_level = wm8983_set_bias_level,
982 .suspend_bias_off = true, 982 .controls = wm8983_snd_controls,
983 .component_driver = { 983 .num_controls = ARRAY_SIZE(wm8983_snd_controls),
984 .controls = wm8983_snd_controls, 984 .dapm_widgets = wm8983_dapm_widgets,
985 .num_controls = ARRAY_SIZE(wm8983_snd_controls), 985 .num_dapm_widgets = ARRAY_SIZE(wm8983_dapm_widgets),
986 .dapm_widgets = wm8983_dapm_widgets, 986 .dapm_routes = wm8983_audio_map,
987 .num_dapm_widgets = ARRAY_SIZE(wm8983_dapm_widgets), 987 .num_dapm_routes = ARRAY_SIZE(wm8983_audio_map),
988 .dapm_routes = wm8983_audio_map, 988 .suspend_bias_off = 1,
989 .num_dapm_routes = ARRAY_SIZE(wm8983_audio_map), 989 .idle_bias_on = 1,
990 }, 990 .use_pmdown_time = 1,
991 .endianness = 1,
992 .non_legacy_dai_naming = 1,
991}; 993};
992 994
993static const struct regmap_config wm8983_regmap = { 995static const struct regmap_config wm8983_regmap = {
@@ -1021,23 +1023,16 @@ static int wm8983_spi_probe(struct spi_device *spi)
1021 1023
1022 spi_set_drvdata(spi, wm8983); 1024 spi_set_drvdata(spi, wm8983);
1023 1025
1024 ret = snd_soc_register_codec(&spi->dev, 1026 ret = devm_snd_soc_register_component(&spi->dev,
1025 &soc_codec_dev_wm8983, &wm8983_dai, 1); 1027 &soc_component_dev_wm8983, &wm8983_dai, 1);
1026 return ret; 1028 return ret;
1027} 1029}
1028 1030
1029static int wm8983_spi_remove(struct spi_device *spi)
1030{
1031 snd_soc_unregister_codec(&spi->dev);
1032 return 0;
1033}
1034
1035static struct spi_driver wm8983_spi_driver = { 1031static struct spi_driver wm8983_spi_driver = {
1036 .driver = { 1032 .driver = {
1037 .name = "wm8983", 1033 .name = "wm8983",
1038 }, 1034 },
1039 .probe = wm8983_spi_probe, 1035 .probe = wm8983_spi_probe,
1040 .remove = wm8983_spi_remove
1041}; 1036};
1042#endif 1037#endif
1043 1038
@@ -1061,18 +1056,12 @@ static int wm8983_i2c_probe(struct i2c_client *i2c,
1061 1056
1062 i2c_set_clientdata(i2c, wm8983); 1057 i2c_set_clientdata(i2c, wm8983);
1063 1058
1064 ret = snd_soc_register_codec(&i2c->dev, 1059 ret = devm_snd_soc_register_component(&i2c->dev,
1065 &soc_codec_dev_wm8983, &wm8983_dai, 1); 1060 &soc_component_dev_wm8983, &wm8983_dai, 1);
1066 1061
1067 return ret; 1062 return ret;
1068} 1063}
1069 1064
1070static int wm8983_i2c_remove(struct i2c_client *client)
1071{
1072 snd_soc_unregister_codec(&client->dev);
1073 return 0;
1074}
1075
1076static const struct i2c_device_id wm8983_i2c_id[] = { 1065static const struct i2c_device_id wm8983_i2c_id[] = {
1077 { "wm8983", 0 }, 1066 { "wm8983", 0 },
1078 { } 1067 { }
@@ -1084,7 +1073,6 @@ static struct i2c_driver wm8983_i2c_driver = {
1084 .name = "wm8983", 1073 .name = "wm8983",
1085 }, 1074 },
1086 .probe = wm8983_i2c_probe, 1075 .probe = wm8983_i2c_probe,
1087 .remove = wm8983_i2c_remove,
1088 .id_table = wm8983_i2c_id 1076 .id_table = wm8983_i2c_id
1089}; 1077};
1090#endif 1078#endif