summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:06:06 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:41:50 -0500
commitcbc23b742464357c25eef77f63ed86d24a12ff27 (patch)
treedbbff01193f1f659731f654ea57960a4f7e0c713
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8985: 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/wm8985.c201
1 files changed, 94 insertions, 107 deletions
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c
index 05344f974ff3..18b342ca4f8e 100644
--- a/sound/soc/codecs/wm8985.c
+++ b/sound/soc/codecs/wm8985.c
@@ -564,10 +564,10 @@ static const struct snd_soc_dapm_route wm8985_aux_dapm_routes[] = {
564 { "Left Boost Mixer", "AUXL Volume", "AUXL" }, 564 { "Left Boost Mixer", "AUXL Volume", "AUXL" },
565}; 565};
566 566
567static int wm8985_add_widgets(struct snd_soc_codec *codec) 567static int wm8985_add_widgets(struct snd_soc_component *component)
568{ 568{
569 struct wm8985_priv *wm8985 = snd_soc_codec_get_drvdata(codec); 569 struct wm8985_priv *wm8985 = snd_soc_component_get_drvdata(component);
570 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); 570 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
571 571
572 switch (wm8985->dev_type) { 572 switch (wm8985->dev_type) {
573 case WM8758: 573 case WM8758:
@@ -576,7 +576,7 @@ static int wm8985_add_widgets(struct snd_soc_codec *codec)
576 break; 576 break;
577 577
578 case WM8985: 578 case WM8985:
579 snd_soc_add_codec_controls(codec, wm8985_specific_snd_controls, 579 snd_soc_add_component_controls(component, wm8985_specific_snd_controls,
580 ARRAY_SIZE(wm8985_specific_snd_controls)); 580 ARRAY_SIZE(wm8985_specific_snd_controls));
581 581
582 snd_soc_dapm_new_controls(dapm, wm8985_dapm_widgets, 582 snd_soc_dapm_new_controls(dapm, wm8985_dapm_widgets,
@@ -592,10 +592,10 @@ static int wm8985_add_widgets(struct snd_soc_codec *codec)
592static int eqmode_get(struct snd_kcontrol *kcontrol, 592static int eqmode_get(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_value *ucontrol) 593 struct snd_ctl_elem_value *ucontrol)
594{ 594{
595 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 595 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
596 unsigned int reg; 596 unsigned int reg;
597 597
598 reg = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); 598 reg = snd_soc_component_read32(component, WM8985_EQ1_LOW_SHELF);
599 if (reg & WM8985_EQ3DMODE) 599 if (reg & WM8985_EQ3DMODE)
600 ucontrol->value.enumerated.item[0] = 1; 600 ucontrol->value.enumerated.item[0] = 1;
601 else 601 else
@@ -607,7 +607,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol,
607static int eqmode_put(struct snd_kcontrol *kcontrol, 607static int eqmode_put(struct snd_kcontrol *kcontrol,
608 struct snd_ctl_elem_value *ucontrol) 608 struct snd_ctl_elem_value *ucontrol)
609{ 609{
610 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 610 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
611 unsigned int regpwr2, regpwr3; 611 unsigned int regpwr2, regpwr3;
612 unsigned int reg_eq; 612 unsigned int reg_eq;
613 613
@@ -615,7 +615,7 @@ static int eqmode_put(struct snd_kcontrol *kcontrol,
615 && ucontrol->value.enumerated.item[0] != 1) 615 && ucontrol->value.enumerated.item[0] != 1)
616 return -EINVAL; 616 return -EINVAL;
617 617
618 reg_eq = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); 618 reg_eq = snd_soc_component_read32(component, WM8985_EQ1_LOW_SHELF);
619 switch ((reg_eq & WM8985_EQ3DMODE) >> WM8985_EQ3DMODE_SHIFT) { 619 switch ((reg_eq & WM8985_EQ3DMODE) >> WM8985_EQ3DMODE_SHIFT) {
620 case 0: 620 case 0:
621 if (!ucontrol->value.enumerated.item[0]) 621 if (!ucontrol->value.enumerated.item[0])
@@ -627,46 +627,46 @@ static int eqmode_put(struct snd_kcontrol *kcontrol,
627 break; 627 break;
628 } 628 }
629 629
630 regpwr2 = snd_soc_read(codec, WM8985_POWER_MANAGEMENT_2); 630 regpwr2 = snd_soc_component_read32(component, WM8985_POWER_MANAGEMENT_2);
631 regpwr3 = snd_soc_read(codec, WM8985_POWER_MANAGEMENT_3); 631 regpwr3 = snd_soc_component_read32(component, WM8985_POWER_MANAGEMENT_3);
632 /* disable the DACs and ADCs */ 632 /* disable the DACs and ADCs */
633 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_2, 633 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_2,
634 WM8985_ADCENR_MASK | WM8985_ADCENL_MASK, 0); 634 WM8985_ADCENR_MASK | WM8985_ADCENL_MASK, 0);
635 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_3, 635 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_3,
636 WM8985_DACENR_MASK | WM8985_DACENL_MASK, 0); 636 WM8985_DACENR_MASK | WM8985_DACENL_MASK, 0);
637 snd_soc_update_bits(codec, WM8985_ADDITIONAL_CONTROL, 637 snd_soc_component_update_bits(component, WM8985_ADDITIONAL_CONTROL,
638 WM8985_M128ENB_MASK, WM8985_M128ENB); 638 WM8985_M128ENB_MASK, WM8985_M128ENB);
639 /* set the desired eqmode */ 639 /* set the desired eqmode */
640 snd_soc_update_bits(codec, WM8985_EQ1_LOW_SHELF, 640 snd_soc_component_update_bits(component, WM8985_EQ1_LOW_SHELF,
641 WM8985_EQ3DMODE_MASK, 641 WM8985_EQ3DMODE_MASK,
642 ucontrol->value.enumerated.item[0] 642 ucontrol->value.enumerated.item[0]
643 << WM8985_EQ3DMODE_SHIFT); 643 << WM8985_EQ3DMODE_SHIFT);
644 /* restore DAC/ADC configuration */ 644 /* restore DAC/ADC configuration */
645 snd_soc_write(codec, WM8985_POWER_MANAGEMENT_2, regpwr2); 645 snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_2, regpwr2);
646 snd_soc_write(codec, WM8985_POWER_MANAGEMENT_3, regpwr3); 646 snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_3, regpwr3);
647 return 0; 647 return 0;
648} 648}
649 649
650static int wm8985_reset(struct snd_soc_codec *codec) 650static int wm8985_reset(struct snd_soc_component *component)
651{ 651{
652 return snd_soc_write(codec, WM8985_SOFTWARE_RESET, 0x0); 652 return snd_soc_component_write(component, WM8985_SOFTWARE_RESET, 0x0);
653} 653}
654 654
655static int wm8985_dac_mute(struct snd_soc_dai *dai, int mute) 655static int wm8985_dac_mute(struct snd_soc_dai *dai, int mute)
656{ 656{
657 struct snd_soc_codec *codec = dai->codec; 657 struct snd_soc_component *component = dai->component;
658 658
659 return snd_soc_update_bits(codec, WM8985_DAC_CONTROL, 659 return snd_soc_component_update_bits(component, WM8985_DAC_CONTROL,
660 WM8985_SOFTMUTE_MASK, 660 WM8985_SOFTMUTE_MASK,
661 !!mute << WM8985_SOFTMUTE_SHIFT); 661 !!mute << WM8985_SOFTMUTE_SHIFT);
662} 662}
663 663
664static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 664static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
665{ 665{
666 struct snd_soc_codec *codec; 666 struct snd_soc_component *component;
667 u16 format, master, bcp, lrp; 667 u16 format, master, bcp, lrp;
668 668
669 codec = dai->codec; 669 component = dai->component;
670 670
671 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 671 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
672 case SND_SOC_DAIFMT_I2S: 672 case SND_SOC_DAIFMT_I2S:
@@ -687,7 +687,7 @@ static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
687 return -EINVAL; 687 return -EINVAL;
688 } 688 }
689 689
690 snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, 690 snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE,
691 WM8985_FMT_MASK, format << WM8985_FMT_SHIFT); 691 WM8985_FMT_MASK, format << WM8985_FMT_SHIFT);
692 692
693 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 693 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -702,7 +702,7 @@ static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
702 return -EINVAL; 702 return -EINVAL;
703 } 703 }
704 704
705 snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, 705 snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL,
706 WM8985_MS_MASK, master << WM8985_MS_SHIFT); 706 WM8985_MS_MASK, master << WM8985_MS_SHIFT);
707 707
708 /* frame inversion is not valid for dsp modes */ 708 /* frame inversion is not valid for dsp modes */
@@ -739,9 +739,9 @@ static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
739 return -EINVAL; 739 return -EINVAL;
740 } 740 }
741 741
742 snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, 742 snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE,
743 WM8985_LRP_MASK, lrp << WM8985_LRP_SHIFT); 743 WM8985_LRP_MASK, lrp << WM8985_LRP_SHIFT);
744 snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, 744 snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE,
745 WM8985_BCP_MASK, bcp << WM8985_BCP_SHIFT); 745 WM8985_BCP_MASK, bcp << WM8985_BCP_SHIFT);
746 return 0; 746 return 0;
747} 747}
@@ -751,14 +751,14 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream,
751 struct snd_soc_dai *dai) 751 struct snd_soc_dai *dai)
752{ 752{
753 int i; 753 int i;
754 struct snd_soc_codec *codec; 754 struct snd_soc_component *component;
755 struct wm8985_priv *wm8985; 755 struct wm8985_priv *wm8985;
756 u16 blen, srate_idx; 756 u16 blen, srate_idx;
757 unsigned int tmp; 757 unsigned int tmp;
758 int srate_best; 758 int srate_best;
759 759
760 codec = dai->codec; 760 component = dai->component;
761 wm8985 = snd_soc_codec_get_drvdata(codec); 761 wm8985 = snd_soc_component_get_drvdata(component);
762 762
763 wm8985->bclk = snd_soc_params_to_bclk(params); 763 wm8985->bclk = snd_soc_params_to_bclk(params);
764 if ((int)wm8985->bclk < 0) 764 if ((int)wm8985->bclk < 0)
@@ -783,7 +783,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream,
783 return -EINVAL; 783 return -EINVAL;
784 } 784 }
785 785
786 snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, 786 snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE,
787 WM8985_WL_MASK, blen << WM8985_WL_SHIFT); 787 WM8985_WL_MASK, blen << WM8985_WL_SHIFT);
788 788
789 /* 789 /*
@@ -800,7 +800,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream,
800 } 800 }
801 801
802 dev_dbg(dai->dev, "Selected SRATE = %d\n", srates[srate_idx]); 802 dev_dbg(dai->dev, "Selected SRATE = %d\n", srates[srate_idx]);
803 snd_soc_update_bits(codec, WM8985_ADDITIONAL_CONTROL, 803 snd_soc_component_update_bits(component, WM8985_ADDITIONAL_CONTROL,
804 WM8985_SR_MASK, srate_idx << WM8985_SR_SHIFT); 804 WM8985_SR_MASK, srate_idx << WM8985_SR_SHIFT);
805 805
806 dev_dbg(dai->dev, "Target BCLK = %uHz\n", wm8985->bclk); 806 dev_dbg(dai->dev, "Target BCLK = %uHz\n", wm8985->bclk);
@@ -819,7 +819,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream,
819 } 819 }
820 820
821 dev_dbg(dai->dev, "MCLK ratio = %dfs\n", fs_ratios[i].ratio); 821 dev_dbg(dai->dev, "MCLK ratio = %dfs\n", fs_ratios[i].ratio);
822 snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, 822 snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL,
823 WM8985_MCLKDIV_MASK, i << WM8985_MCLKDIV_SHIFT); 823 WM8985_MCLKDIV_MASK, i << WM8985_MCLKDIV_SHIFT);
824 824
825 /* select the appropriate bclk divider */ 825 /* select the appropriate bclk divider */
@@ -835,7 +835,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream,
835 } 835 }
836 836
837 dev_dbg(dai->dev, "BCLK div = %d\n", i); 837 dev_dbg(dai->dev, "BCLK div = %d\n", i);
838 snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, 838 snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL,
839 WM8985_BCLKDIV_MASK, i << WM8985_BCLKDIV_SHIFT); 839 WM8985_BCLKDIV_MASK, i << WM8985_BCLKDIV_SHIFT);
840 return 0; 840 return 0;
841} 841}
@@ -887,13 +887,13 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id,
887 unsigned int freq_out) 887 unsigned int freq_out)
888{ 888{
889 int ret; 889 int ret;
890 struct snd_soc_codec *codec; 890 struct snd_soc_component *component;
891 struct pll_div pll_div; 891 struct pll_div pll_div;
892 892
893 codec = dai->codec; 893 component = dai->component;
894 if (!freq_in || !freq_out) { 894 if (!freq_in || !freq_out) {
895 /* disable the PLL */ 895 /* disable the PLL */
896 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, 896 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1,
897 WM8985_PLLEN_MASK, 0); 897 WM8985_PLLEN_MASK, 0);
898 } else { 898 } else {
899 ret = pll_factors(&pll_div, freq_out * 4 * 2, freq_in); 899 ret = pll_factors(&pll_div, freq_out * 4 * 2, freq_in);
@@ -901,18 +901,18 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id,
901 return ret; 901 return ret;
902 902
903 /* set PLLN and PRESCALE */ 903 /* set PLLN and PRESCALE */
904 snd_soc_write(codec, WM8985_PLL_N, 904 snd_soc_component_write(component, WM8985_PLL_N,
905 (pll_div.div2 << WM8985_PLL_PRESCALE_SHIFT) 905 (pll_div.div2 << WM8985_PLL_PRESCALE_SHIFT)
906 | pll_div.n); 906 | pll_div.n);
907 /* set PLLK */ 907 /* set PLLK */
908 snd_soc_write(codec, WM8985_PLL_K_3, pll_div.k & 0x1ff); 908 snd_soc_component_write(component, WM8985_PLL_K_3, pll_div.k & 0x1ff);
909 snd_soc_write(codec, WM8985_PLL_K_2, (pll_div.k >> 9) & 0x1ff); 909 snd_soc_component_write(component, WM8985_PLL_K_2, (pll_div.k >> 9) & 0x1ff);
910 snd_soc_write(codec, WM8985_PLL_K_1, (pll_div.k >> 18)); 910 snd_soc_component_write(component, WM8985_PLL_K_1, (pll_div.k >> 18));
911 /* set the source of the clock to be the PLL */ 911 /* set the source of the clock to be the PLL */
912 snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, 912 snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL,
913 WM8985_CLKSEL_MASK, WM8985_CLKSEL); 913 WM8985_CLKSEL_MASK, WM8985_CLKSEL);
914 /* enable the PLL */ 914 /* enable the PLL */
915 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, 915 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1,
916 WM8985_PLLEN_MASK, WM8985_PLLEN); 916 WM8985_PLLEN_MASK, WM8985_PLLEN);
917 } 917 }
918 return 0; 918 return 0;
@@ -921,21 +921,21 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id,
921static int wm8985_set_sysclk(struct snd_soc_dai *dai, 921static int wm8985_set_sysclk(struct snd_soc_dai *dai,
922 int clk_id, unsigned int freq, int dir) 922 int clk_id, unsigned int freq, int dir)
923{ 923{
924 struct snd_soc_codec *codec; 924 struct snd_soc_component *component;
925 struct wm8985_priv *wm8985; 925 struct wm8985_priv *wm8985;
926 926
927 codec = dai->codec; 927 component = dai->component;
928 wm8985 = snd_soc_codec_get_drvdata(codec); 928 wm8985 = snd_soc_component_get_drvdata(component);
929 929
930 switch (clk_id) { 930 switch (clk_id) {
931 case WM8985_CLKSRC_MCLK: 931 case WM8985_CLKSRC_MCLK:
932 snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, 932 snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL,
933 WM8985_CLKSEL_MASK, 0); 933 WM8985_CLKSEL_MASK, 0);
934 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, 934 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1,
935 WM8985_PLLEN_MASK, 0); 935 WM8985_PLLEN_MASK, 0);
936 break; 936 break;
937 case WM8985_CLKSRC_PLL: 937 case WM8985_CLKSRC_PLL:
938 snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, 938 snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL,
939 WM8985_CLKSEL_MASK, WM8985_CLKSEL); 939 WM8985_CLKSEL_MASK, WM8985_CLKSEL);
940 break; 940 break;
941 default: 941 default:
@@ -947,27 +947,27 @@ static int wm8985_set_sysclk(struct snd_soc_dai *dai,
947 return 0; 947 return 0;
948} 948}
949 949
950static int wm8985_set_bias_level(struct snd_soc_codec *codec, 950static int wm8985_set_bias_level(struct snd_soc_component *component,
951 enum snd_soc_bias_level level) 951 enum snd_soc_bias_level level)
952{ 952{
953 int ret; 953 int ret;
954 struct wm8985_priv *wm8985; 954 struct wm8985_priv *wm8985;
955 955
956 wm8985 = snd_soc_codec_get_drvdata(codec); 956 wm8985 = snd_soc_component_get_drvdata(component);
957 switch (level) { 957 switch (level) {
958 case SND_SOC_BIAS_ON: 958 case SND_SOC_BIAS_ON:
959 case SND_SOC_BIAS_PREPARE: 959 case SND_SOC_BIAS_PREPARE:
960 /* VMID at 75k */ 960 /* VMID at 75k */
961 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, 961 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1,
962 WM8985_VMIDSEL_MASK, 962 WM8985_VMIDSEL_MASK,
963 1 << WM8985_VMIDSEL_SHIFT); 963 1 << WM8985_VMIDSEL_SHIFT);
964 break; 964 break;
965 case SND_SOC_BIAS_STANDBY: 965 case SND_SOC_BIAS_STANDBY:
966 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 966 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
967 ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies), 967 ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies),
968 wm8985->supplies); 968 wm8985->supplies);
969 if (ret) { 969 if (ret) {
970 dev_err(codec->dev, 970 dev_err(component->dev,
971 "Failed to enable supplies: %d\n", 971 "Failed to enable supplies: %d\n",
972 ret); 972 ret);
973 return ret; 973 return ret;
@@ -976,45 +976,45 @@ static int wm8985_set_bias_level(struct snd_soc_codec *codec,
976 regcache_sync(wm8985->regmap); 976 regcache_sync(wm8985->regmap);
977 977
978 /* enable anti-pop features */ 978 /* enable anti-pop features */
979 snd_soc_update_bits(codec, WM8985_OUT4_TO_ADC, 979 snd_soc_component_update_bits(component, WM8985_OUT4_TO_ADC,
980 WM8985_POBCTRL_MASK, 980 WM8985_POBCTRL_MASK,
981 WM8985_POBCTRL); 981 WM8985_POBCTRL);
982 /* enable thermal shutdown */ 982 /* enable thermal shutdown */
983 snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, 983 snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0,
984 WM8985_TSDEN_MASK, WM8985_TSDEN); 984 WM8985_TSDEN_MASK, WM8985_TSDEN);
985 snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, 985 snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0,
986 WM8985_TSOPCTRL_MASK, 986 WM8985_TSOPCTRL_MASK,
987 WM8985_TSOPCTRL); 987 WM8985_TSOPCTRL);
988 /* enable BIASEN */ 988 /* enable BIASEN */
989 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, 989 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1,
990 WM8985_BIASEN_MASK, WM8985_BIASEN); 990 WM8985_BIASEN_MASK, WM8985_BIASEN);
991 /* VMID at 75k */ 991 /* VMID at 75k */
992 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, 992 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1,
993 WM8985_VMIDSEL_MASK, 993 WM8985_VMIDSEL_MASK,
994 1 << WM8985_VMIDSEL_SHIFT); 994 1 << WM8985_VMIDSEL_SHIFT);
995 msleep(500); 995 msleep(500);
996 /* disable anti-pop features */ 996 /* disable anti-pop features */
997 snd_soc_update_bits(codec, WM8985_OUT4_TO_ADC, 997 snd_soc_component_update_bits(component, WM8985_OUT4_TO_ADC,
998 WM8985_POBCTRL_MASK, 0); 998 WM8985_POBCTRL_MASK, 0);
999 } 999 }
1000 /* VMID at 300k */ 1000 /* VMID at 300k */
1001 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, 1001 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1,
1002 WM8985_VMIDSEL_MASK, 1002 WM8985_VMIDSEL_MASK,
1003 2 << WM8985_VMIDSEL_SHIFT); 1003 2 << WM8985_VMIDSEL_SHIFT);
1004 break; 1004 break;
1005 case SND_SOC_BIAS_OFF: 1005 case SND_SOC_BIAS_OFF:
1006 /* disable thermal shutdown */ 1006 /* disable thermal shutdown */
1007 snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, 1007 snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0,
1008 WM8985_TSOPCTRL_MASK, 0); 1008 WM8985_TSOPCTRL_MASK, 0);
1009 snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, 1009 snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0,
1010 WM8985_TSDEN_MASK, 0); 1010 WM8985_TSDEN_MASK, 0);
1011 /* disable VMIDSEL and BIASEN */ 1011 /* disable VMIDSEL and BIASEN */
1012 snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, 1012 snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1,
1013 WM8985_VMIDSEL_MASK | WM8985_BIASEN_MASK, 1013 WM8985_VMIDSEL_MASK | WM8985_BIASEN_MASK,
1014 0); 1014 0);
1015 snd_soc_write(codec, WM8985_POWER_MANAGEMENT_1, 0); 1015 snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_1, 0);
1016 snd_soc_write(codec, WM8985_POWER_MANAGEMENT_2, 0); 1016 snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_2, 0);
1017 snd_soc_write(codec, WM8985_POWER_MANAGEMENT_3, 0); 1017 snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_3, 0);
1018 1018
1019 regcache_mark_dirty(wm8985->regmap); 1019 regcache_mark_dirty(wm8985->regmap);
1020 1020
@@ -1026,46 +1026,46 @@ static int wm8985_set_bias_level(struct snd_soc_codec *codec,
1026 return 0; 1026 return 0;
1027} 1027}
1028 1028
1029static int wm8985_probe(struct snd_soc_codec *codec) 1029static int wm8985_probe(struct snd_soc_component *component)
1030{ 1030{
1031 size_t i; 1031 size_t i;
1032 struct wm8985_priv *wm8985; 1032 struct wm8985_priv *wm8985;
1033 int ret; 1033 int ret;
1034 1034
1035 wm8985 = snd_soc_codec_get_drvdata(codec); 1035 wm8985 = snd_soc_component_get_drvdata(component);
1036 1036
1037 for (i = 0; i < ARRAY_SIZE(wm8985->supplies); i++) 1037 for (i = 0; i < ARRAY_SIZE(wm8985->supplies); i++)
1038 wm8985->supplies[i].supply = wm8985_supply_names[i]; 1038 wm8985->supplies[i].supply = wm8985_supply_names[i];
1039 1039
1040 ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8985->supplies), 1040 ret = devm_regulator_bulk_get(component->dev, ARRAY_SIZE(wm8985->supplies),
1041 wm8985->supplies); 1041 wm8985->supplies);
1042 if (ret) { 1042 if (ret) {
1043 dev_err(codec->dev, "Failed to request supplies: %d\n", ret); 1043 dev_err(component->dev, "Failed to request supplies: %d\n", ret);
1044 return ret; 1044 return ret;
1045 } 1045 }
1046 1046
1047 ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies), 1047 ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies),
1048 wm8985->supplies); 1048 wm8985->supplies);
1049 if (ret) { 1049 if (ret) {
1050 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); 1050 dev_err(component->dev, "Failed to enable supplies: %d\n", ret);
1051 return ret; 1051 return ret;
1052 } 1052 }
1053 1053
1054 ret = wm8985_reset(codec); 1054 ret = wm8985_reset(component);
1055 if (ret < 0) { 1055 if (ret < 0) {
1056 dev_err(codec->dev, "Failed to issue reset: %d\n", ret); 1056 dev_err(component->dev, "Failed to issue reset: %d\n", ret);
1057 goto err_reg_enable; 1057 goto err_reg_enable;
1058 } 1058 }
1059 1059
1060 /* latch volume update bits */ 1060 /* latch volume update bits */
1061 for (i = 0; i < ARRAY_SIZE(volume_update_regs); ++i) 1061 for (i = 0; i < ARRAY_SIZE(volume_update_regs); ++i)
1062 snd_soc_update_bits(codec, volume_update_regs[i], 1062 snd_soc_component_update_bits(component, volume_update_regs[i],
1063 0x100, 0x100); 1063 0x100, 0x100);
1064 /* enable BIASCUT */ 1064 /* enable BIASCUT */
1065 snd_soc_update_bits(codec, WM8985_BIAS_CTRL, WM8985_BIASCUT, 1065 snd_soc_component_update_bits(component, WM8985_BIAS_CTRL, WM8985_BIASCUT,
1066 WM8985_BIASCUT); 1066 WM8985_BIASCUT);
1067 1067
1068 wm8985_add_widgets(codec); 1068 wm8985_add_widgets(component);
1069 1069
1070 return 0; 1070 return 0;
1071 1071
@@ -1105,19 +1105,20 @@ static struct snd_soc_dai_driver wm8985_dai = {
1105 .symmetric_rates = 1 1105 .symmetric_rates = 1
1106}; 1106};
1107 1107
1108static const struct snd_soc_codec_driver soc_codec_dev_wm8985 = { 1108static const struct snd_soc_component_driver soc_component_dev_wm8985 = {
1109 .probe = wm8985_probe, 1109 .probe = wm8985_probe,
1110 .set_bias_level = wm8985_set_bias_level, 1110 .set_bias_level = wm8985_set_bias_level,
1111 .suspend_bias_off = true, 1111 .controls = wm8985_common_snd_controls,
1112 1112 .num_controls = ARRAY_SIZE(wm8985_common_snd_controls),
1113 .component_driver = { 1113 .dapm_widgets = wm8985_common_dapm_widgets,
1114 .controls = wm8985_common_snd_controls, 1114 .num_dapm_widgets = ARRAY_SIZE(wm8985_common_dapm_widgets),
1115 .num_controls = ARRAY_SIZE(wm8985_common_snd_controls), 1115 .dapm_routes = wm8985_common_dapm_routes,
1116 .dapm_widgets = wm8985_common_dapm_widgets, 1116 .num_dapm_routes = ARRAY_SIZE(wm8985_common_dapm_routes),
1117 .num_dapm_widgets = ARRAY_SIZE(wm8985_common_dapm_widgets), 1117 .suspend_bias_off = 1,
1118 .dapm_routes = wm8985_common_dapm_routes, 1118 .idle_bias_on = 1,
1119 .num_dapm_routes = ARRAY_SIZE(wm8985_common_dapm_routes), 1119 .use_pmdown_time = 1,
1120 }, 1120 .endianness = 1,
1121 .non_legacy_dai_naming = 1,
1121}; 1122};
1122 1123
1123static const struct regmap_config wm8985_regmap = { 1124static const struct regmap_config wm8985_regmap = {
@@ -1154,23 +1155,16 @@ static int wm8985_spi_probe(struct spi_device *spi)
1154 return ret; 1155 return ret;
1155 } 1156 }
1156 1157
1157 ret = snd_soc_register_codec(&spi->dev, 1158 ret = devm_snd_soc_register_component(&spi->dev,
1158 &soc_codec_dev_wm8985, &wm8985_dai, 1); 1159 &soc_component_dev_wm8985, &wm8985_dai, 1);
1159 return ret; 1160 return ret;
1160} 1161}
1161 1162
1162static int wm8985_spi_remove(struct spi_device *spi)
1163{
1164 snd_soc_unregister_codec(&spi->dev);
1165 return 0;
1166}
1167
1168static struct spi_driver wm8985_spi_driver = { 1163static struct spi_driver wm8985_spi_driver = {
1169 .driver = { 1164 .driver = {
1170 .name = "wm8985", 1165 .name = "wm8985",
1171 }, 1166 },
1172 .probe = wm8985_spi_probe, 1167 .probe = wm8985_spi_probe,
1173 .remove = wm8985_spi_remove
1174}; 1168};
1175#endif 1169#endif
1176 1170
@@ -1197,17 +1191,11 @@ static int wm8985_i2c_probe(struct i2c_client *i2c,
1197 return ret; 1191 return ret;
1198 } 1192 }
1199 1193
1200 ret = snd_soc_register_codec(&i2c->dev, 1194 ret = devm_snd_soc_register_component(&i2c->dev,
1201 &soc_codec_dev_wm8985, &wm8985_dai, 1); 1195 &soc_component_dev_wm8985, &wm8985_dai, 1);
1202 return ret; 1196 return ret;
1203} 1197}
1204 1198
1205static int wm8985_i2c_remove(struct i2c_client *i2c)
1206{
1207 snd_soc_unregister_codec(&i2c->dev);
1208 return 0;
1209}
1210
1211static const struct i2c_device_id wm8985_i2c_id[] = { 1199static const struct i2c_device_id wm8985_i2c_id[] = {
1212 { "wm8985", WM8985 }, 1200 { "wm8985", WM8985 },
1213 { "wm8758", WM8758 }, 1201 { "wm8758", WM8758 },
@@ -1220,7 +1208,6 @@ static struct i2c_driver wm8985_i2c_driver = {
1220 .name = "wm8985", 1208 .name = "wm8985",
1221 }, 1209 },
1222 .probe = wm8985_i2c_probe, 1210 .probe = wm8985_i2c_probe,
1223 .remove = wm8985_i2c_remove,
1224 .id_table = wm8985_i2c_id 1211 .id_table = wm8985_i2c_id
1225}; 1212};
1226#endif 1213#endif