diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-01-28 23:01:06 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-12 04:48:27 -0500 |
commit | d06f33aed85cf73703555879157bf33866f8af05 (patch) | |
tree | 9a72521db7cb9bd853e33e251aba2d9d2753c8f5 | |
parent | 7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff) |
ASoC: da7210: 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/da7210.c | 181 |
1 files changed, 84 insertions, 97 deletions
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 1af443ccbc51..07153be52c52 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c | |||
@@ -331,12 +331,12 @@ static SOC_ENUM_SINGLE_DECL(da7210_hp_mode_sel, | |||
331 | static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, | 331 | static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, |
332 | struct snd_ctl_elem_value *ucontrol) | 332 | struct snd_ctl_elem_value *ucontrol) |
333 | { | 333 | { |
334 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 334 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
335 | 335 | ||
336 | if (ucontrol->value.integer.value[0]) { | 336 | if (ucontrol->value.integer.value[0]) { |
337 | /* Check if noise suppression is enabled */ | 337 | /* Check if noise suppression is enabled */ |
338 | if (snd_soc_read(codec, DA7210_CONTROL) & DA7210_NOISE_SUP_EN) { | 338 | if (snd_soc_component_read32(component, DA7210_CONTROL) & DA7210_NOISE_SUP_EN) { |
339 | dev_dbg(codec->dev, | 339 | dev_dbg(component->dev, |
340 | "Disable noise suppression to enable ALC\n"); | 340 | "Disable noise suppression to enable ALC\n"); |
341 | return -EINVAL; | 341 | return -EINVAL; |
342 | } | 342 | } |
@@ -354,32 +354,32 @@ static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, | |||
354 | static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, | 354 | static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, |
355 | struct snd_ctl_elem_value *ucontrol) | 355 | struct snd_ctl_elem_value *ucontrol) |
356 | { | 356 | { |
357 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 357 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
358 | u8 val; | 358 | u8 val; |
359 | 359 | ||
360 | if (ucontrol->value.integer.value[0]) { | 360 | if (ucontrol->value.integer.value[0]) { |
361 | /* Check if ALC is enabled */ | 361 | /* Check if ALC is enabled */ |
362 | if (snd_soc_read(codec, DA7210_ADC) & DA7210_ADC_ALC_EN) | 362 | if (snd_soc_component_read32(component, DA7210_ADC) & DA7210_ADC_ALC_EN) |
363 | goto err; | 363 | goto err; |
364 | 364 | ||
365 | /* Check ZC for HP and AUX1 PGA */ | 365 | /* Check ZC for HP and AUX1 PGA */ |
366 | if ((snd_soc_read(codec, DA7210_ZERO_CROSS) & | 366 | if ((snd_soc_component_read32(component, DA7210_ZERO_CROSS) & |
367 | (DA7210_AUX1_L_ZC | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | | 367 | (DA7210_AUX1_L_ZC | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | |
368 | DA7210_HP_R_ZC)) != (DA7210_AUX1_L_ZC | | 368 | DA7210_HP_R_ZC)) != (DA7210_AUX1_L_ZC | |
369 | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | DA7210_HP_R_ZC)) | 369 | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | DA7210_HP_R_ZC)) |
370 | goto err; | 370 | goto err; |
371 | 371 | ||
372 | /* Check INPGA_L_VOL and INPGA_R_VOL */ | 372 | /* Check INPGA_L_VOL and INPGA_R_VOL */ |
373 | val = snd_soc_read(codec, DA7210_IN_GAIN); | 373 | val = snd_soc_component_read32(component, DA7210_IN_GAIN); |
374 | if (((val & DA7210_INPGA_L_VOL) < DA7210_INPGA_MIN_VOL_NS) || | 374 | if (((val & DA7210_INPGA_L_VOL) < DA7210_INPGA_MIN_VOL_NS) || |
375 | (((val & DA7210_INPGA_R_VOL) >> 4) < | 375 | (((val & DA7210_INPGA_R_VOL) >> 4) < |
376 | DA7210_INPGA_MIN_VOL_NS)) | 376 | DA7210_INPGA_MIN_VOL_NS)) |
377 | goto err; | 377 | goto err; |
378 | 378 | ||
379 | /* Check AUX1_L_VOL and AUX1_R_VOL */ | 379 | /* Check AUX1_L_VOL and AUX1_R_VOL */ |
380 | if (((snd_soc_read(codec, DA7210_AUX1_L) & DA7210_AUX1_L_VOL) < | 380 | if (((snd_soc_component_read32(component, DA7210_AUX1_L) & DA7210_AUX1_L_VOL) < |
381 | DA7210_AUX1_MIN_VOL_NS) || | 381 | DA7210_AUX1_MIN_VOL_NS) || |
382 | ((snd_soc_read(codec, DA7210_AUX1_R) & DA7210_AUX1_R_VOL) < | 382 | ((snd_soc_component_read32(component, DA7210_AUX1_R) & DA7210_AUX1_R_VOL) < |
383 | DA7210_AUX1_MIN_VOL_NS)) | 383 | DA7210_AUX1_MIN_VOL_NS)) |
384 | goto err; | 384 | goto err; |
385 | } | 385 | } |
@@ -760,19 +760,19 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
760 | struct snd_pcm_hw_params *params, | 760 | struct snd_pcm_hw_params *params, |
761 | struct snd_soc_dai *dai) | 761 | struct snd_soc_dai *dai) |
762 | { | 762 | { |
763 | struct snd_soc_codec *codec = dai->codec; | 763 | struct snd_soc_component *component = dai->component; |
764 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 764 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
765 | u32 dai_cfg1; | 765 | u32 dai_cfg1; |
766 | u32 fs, sysclk; | 766 | u32 fs, sysclk; |
767 | 767 | ||
768 | /* set DAI source to Left and Right ADC */ | 768 | /* set DAI source to Left and Right ADC */ |
769 | snd_soc_write(codec, DA7210_DAI_SRC_SEL, | 769 | snd_soc_component_write(component, DA7210_DAI_SRC_SEL, |
770 | DA7210_DAI_OUT_R_SRC | DA7210_DAI_OUT_L_SRC); | 770 | DA7210_DAI_OUT_R_SRC | DA7210_DAI_OUT_L_SRC); |
771 | 771 | ||
772 | /* Enable DAI */ | 772 | /* Enable DAI */ |
773 | snd_soc_write(codec, DA7210_DAI_CFG3, DA7210_DAI_OE | DA7210_DAI_EN); | 773 | snd_soc_component_write(component, DA7210_DAI_CFG3, DA7210_DAI_OE | DA7210_DAI_EN); |
774 | 774 | ||
775 | dai_cfg1 = 0xFC & snd_soc_read(codec, DA7210_DAI_CFG1); | 775 | dai_cfg1 = 0xFC & snd_soc_component_read32(component, DA7210_DAI_CFG1); |
776 | 776 | ||
777 | switch (params_width(params)) { | 777 | switch (params_width(params)) { |
778 | case 16: | 778 | case 16: |
@@ -791,7 +791,7 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
791 | return -EINVAL; | 791 | return -EINVAL; |
792 | } | 792 | } |
793 | 793 | ||
794 | snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1); | 794 | snd_soc_component_write(component, DA7210_DAI_CFG1, dai_cfg1); |
795 | 795 | ||
796 | switch (params_rate(params)) { | 796 | switch (params_rate(params)) { |
797 | case 8000: | 797 | case 8000: |
@@ -839,17 +839,17 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
839 | } | 839 | } |
840 | 840 | ||
841 | /* Disable active mode */ | 841 | /* Disable active mode */ |
842 | snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); | 842 | snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); |
843 | 843 | ||
844 | snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs); | 844 | snd_soc_component_update_bits(component, DA7210_PLL, DA7210_PLL_FS_MASK, fs); |
845 | 845 | ||
846 | if (da7210->mclk_rate && (da7210->mclk_rate != sysclk)) { | 846 | if (da7210->mclk_rate && (da7210->mclk_rate != sysclk)) { |
847 | /* PLL mode, disable PLL bypass */ | 847 | /* PLL mode, disable PLL bypass */ |
848 | snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, 0); | 848 | snd_soc_component_update_bits(component, DA7210_PLL_DIV3, DA7210_PLL_BYP, 0); |
849 | 849 | ||
850 | if (!da7210->master) { | 850 | if (!da7210->master) { |
851 | /* PLL slave mode, also enable SRM */ | 851 | /* PLL slave mode, also enable SRM */ |
852 | snd_soc_update_bits(codec, DA7210_PLL, | 852 | snd_soc_component_update_bits(component, DA7210_PLL, |
853 | (DA7210_MCLK_SRM_EN | | 853 | (DA7210_MCLK_SRM_EN | |
854 | DA7210_MCLK_DET_EN), | 854 | DA7210_MCLK_DET_EN), |
855 | (DA7210_MCLK_SRM_EN | | 855 | (DA7210_MCLK_SRM_EN | |
@@ -857,13 +857,13 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
857 | } | 857 | } |
858 | } else { | 858 | } else { |
859 | /* PLL bypass mode, enable PLL bypass and Auto Detection */ | 859 | /* PLL bypass mode, enable PLL bypass and Auto Detection */ |
860 | snd_soc_update_bits(codec, DA7210_PLL, DA7210_MCLK_DET_EN, | 860 | snd_soc_component_update_bits(component, DA7210_PLL, DA7210_MCLK_DET_EN, |
861 | DA7210_MCLK_DET_EN); | 861 | DA7210_MCLK_DET_EN); |
862 | snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, | 862 | snd_soc_component_update_bits(component, DA7210_PLL_DIV3, DA7210_PLL_BYP, |
863 | DA7210_PLL_BYP); | 863 | DA7210_PLL_BYP); |
864 | } | 864 | } |
865 | /* Enable active mode */ | 865 | /* Enable active mode */ |
866 | snd_soc_update_bits(codec, DA7210_STARTUP1, | 866 | snd_soc_component_update_bits(component, DA7210_STARTUP1, |
867 | DA7210_SC_MST_EN, DA7210_SC_MST_EN); | 867 | DA7210_SC_MST_EN, DA7210_SC_MST_EN); |
868 | 868 | ||
869 | return 0; | 869 | return 0; |
@@ -874,16 +874,16 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
874 | */ | 874 | */ |
875 | static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) | 875 | static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) |
876 | { | 876 | { |
877 | struct snd_soc_codec *codec = codec_dai->codec; | 877 | struct snd_soc_component *component = codec_dai->component; |
878 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 878 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
879 | u32 dai_cfg1; | 879 | u32 dai_cfg1; |
880 | u32 dai_cfg3; | 880 | u32 dai_cfg3; |
881 | 881 | ||
882 | dai_cfg1 = 0x7f & snd_soc_read(codec, DA7210_DAI_CFG1); | 882 | dai_cfg1 = 0x7f & snd_soc_component_read32(component, DA7210_DAI_CFG1); |
883 | dai_cfg3 = 0xfc & snd_soc_read(codec, DA7210_DAI_CFG3); | 883 | dai_cfg3 = 0xfc & snd_soc_component_read32(component, DA7210_DAI_CFG3); |
884 | 884 | ||
885 | if ((snd_soc_read(codec, DA7210_PLL) & DA7210_PLL_EN) && | 885 | if ((snd_soc_component_read32(component, DA7210_PLL) & DA7210_PLL_EN) && |
886 | (!(snd_soc_read(codec, DA7210_PLL_DIV3) & DA7210_PLL_BYP))) | 886 | (!(snd_soc_component_read32(component, DA7210_PLL_DIV3) & DA7210_PLL_BYP))) |
887 | return -EINVAL; | 887 | return -EINVAL; |
888 | 888 | ||
889 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 889 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
@@ -923,21 +923,21 @@ static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) | |||
923 | */ | 923 | */ |
924 | dai_cfg1 |= DA7210_DAI_FLEN_64BIT; | 924 | dai_cfg1 |= DA7210_DAI_FLEN_64BIT; |
925 | 925 | ||
926 | snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1); | 926 | snd_soc_component_write(component, DA7210_DAI_CFG1, dai_cfg1); |
927 | snd_soc_write(codec, DA7210_DAI_CFG3, dai_cfg3); | 927 | snd_soc_component_write(component, DA7210_DAI_CFG3, dai_cfg3); |
928 | 928 | ||
929 | return 0; | 929 | return 0; |
930 | } | 930 | } |
931 | 931 | ||
932 | static int da7210_mute(struct snd_soc_dai *dai, int mute) | 932 | static int da7210_mute(struct snd_soc_dai *dai, int mute) |
933 | { | 933 | { |
934 | struct snd_soc_codec *codec = dai->codec; | 934 | struct snd_soc_component *component = dai->component; |
935 | u8 mute_reg = snd_soc_read(codec, DA7210_DAC_HPF) & 0xFB; | 935 | u8 mute_reg = snd_soc_component_read32(component, DA7210_DAC_HPF) & 0xFB; |
936 | 936 | ||
937 | if (mute) | 937 | if (mute) |
938 | snd_soc_write(codec, DA7210_DAC_HPF, mute_reg | 0x4); | 938 | snd_soc_component_write(component, DA7210_DAC_HPF, mute_reg | 0x4); |
939 | else | 939 | else |
940 | snd_soc_write(codec, DA7210_DAC_HPF, mute_reg); | 940 | snd_soc_component_write(component, DA7210_DAC_HPF, mute_reg); |
941 | return 0; | 941 | return 0; |
942 | } | 942 | } |
943 | 943 | ||
@@ -947,8 +947,8 @@ static int da7210_mute(struct snd_soc_dai *dai, int mute) | |||
947 | static int da7210_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 947 | static int da7210_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
948 | int clk_id, unsigned int freq, int dir) | 948 | int clk_id, unsigned int freq, int dir) |
949 | { | 949 | { |
950 | struct snd_soc_codec *codec = codec_dai->codec; | 950 | struct snd_soc_component *component = codec_dai->component; |
951 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 951 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
952 | 952 | ||
953 | switch (clk_id) { | 953 | switch (clk_id) { |
954 | case DA7210_CLKSRC_MCLK: | 954 | case DA7210_CLKSRC_MCLK: |
@@ -988,8 +988,8 @@ static int da7210_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
988 | static int da7210_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | 988 | static int da7210_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, |
989 | int source, unsigned int fref, unsigned int fout) | 989 | int source, unsigned int fref, unsigned int fout) |
990 | { | 990 | { |
991 | struct snd_soc_codec *codec = codec_dai->codec; | 991 | struct snd_soc_component *component = codec_dai->component; |
992 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 992 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
993 | 993 | ||
994 | u8 pll_div1, pll_div2, pll_div3, cnt; | 994 | u8 pll_div1, pll_div2, pll_div3, cnt; |
995 | 995 | ||
@@ -1014,18 +1014,18 @@ static int da7210_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1014 | goto err; | 1014 | goto err; |
1015 | 1015 | ||
1016 | /* Disable active mode */ | 1016 | /* Disable active mode */ |
1017 | snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); | 1017 | snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); |
1018 | /* Write PLL dividers */ | 1018 | /* Write PLL dividers */ |
1019 | snd_soc_write(codec, DA7210_PLL_DIV1, pll_div1); | 1019 | snd_soc_component_write(component, DA7210_PLL_DIV1, pll_div1); |
1020 | snd_soc_write(codec, DA7210_PLL_DIV2, pll_div2); | 1020 | snd_soc_component_write(component, DA7210_PLL_DIV2, pll_div2); |
1021 | snd_soc_update_bits(codec, DA7210_PLL_DIV3, | 1021 | snd_soc_component_update_bits(component, DA7210_PLL_DIV3, |
1022 | DA7210_PLL_DIV_L_MASK, pll_div3); | 1022 | DA7210_PLL_DIV_L_MASK, pll_div3); |
1023 | 1023 | ||
1024 | /* Enable PLL */ | 1024 | /* Enable PLL */ |
1025 | snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_EN, DA7210_PLL_EN); | 1025 | snd_soc_component_update_bits(component, DA7210_PLL, DA7210_PLL_EN, DA7210_PLL_EN); |
1026 | 1026 | ||
1027 | /* Enable active mode */ | 1027 | /* Enable active mode */ |
1028 | snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, | 1028 | snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, |
1029 | DA7210_SC_MST_EN); | 1029 | DA7210_SC_MST_EN); |
1030 | return 0; | 1030 | return 0; |
1031 | err: | 1031 | err: |
@@ -1064,53 +1064,53 @@ static struct snd_soc_dai_driver da7210_dai = { | |||
1064 | .symmetric_rates = 1, | 1064 | .symmetric_rates = 1, |
1065 | }; | 1065 | }; |
1066 | 1066 | ||
1067 | static int da7210_probe(struct snd_soc_codec *codec) | 1067 | static int da7210_probe(struct snd_soc_component *component) |
1068 | { | 1068 | { |
1069 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 1069 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
1070 | 1070 | ||
1071 | dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); | 1071 | dev_info(component->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); |
1072 | 1072 | ||
1073 | da7210->mclk_rate = 0; /* This will be set from set_sysclk() */ | 1073 | da7210->mclk_rate = 0; /* This will be set from set_sysclk() */ |
1074 | da7210->master = 0; /* This will be set from set_fmt() */ | 1074 | da7210->master = 0; /* This will be set from set_fmt() */ |
1075 | 1075 | ||
1076 | /* Enable internal regulator & bias current */ | 1076 | /* Enable internal regulator & bias current */ |
1077 | snd_soc_write(codec, DA7210_CONTROL, DA7210_REG_EN | DA7210_BIAS_EN); | 1077 | snd_soc_component_write(component, DA7210_CONTROL, DA7210_REG_EN | DA7210_BIAS_EN); |
1078 | 1078 | ||
1079 | /* | 1079 | /* |
1080 | * ADC settings | 1080 | * ADC settings |
1081 | */ | 1081 | */ |
1082 | 1082 | ||
1083 | /* Enable Left & Right MIC PGA and Mic Bias */ | 1083 | /* Enable Left & Right MIC PGA and Mic Bias */ |
1084 | snd_soc_write(codec, DA7210_MIC_L, DA7210_MIC_L_EN | DA7210_MICBIAS_EN); | 1084 | snd_soc_component_write(component, DA7210_MIC_L, DA7210_MIC_L_EN | DA7210_MICBIAS_EN); |
1085 | snd_soc_write(codec, DA7210_MIC_R, DA7210_MIC_R_EN); | 1085 | snd_soc_component_write(component, DA7210_MIC_R, DA7210_MIC_R_EN); |
1086 | 1086 | ||
1087 | /* Enable Left and Right input PGA */ | 1087 | /* Enable Left and Right input PGA */ |
1088 | snd_soc_write(codec, DA7210_INMIX_L, DA7210_IN_L_EN); | 1088 | snd_soc_component_write(component, DA7210_INMIX_L, DA7210_IN_L_EN); |
1089 | snd_soc_write(codec, DA7210_INMIX_R, DA7210_IN_R_EN); | 1089 | snd_soc_component_write(component, DA7210_INMIX_R, DA7210_IN_R_EN); |
1090 | 1090 | ||
1091 | /* Enable Left and Right ADC */ | 1091 | /* Enable Left and Right ADC */ |
1092 | snd_soc_write(codec, DA7210_ADC, DA7210_ADC_L_EN | DA7210_ADC_R_EN); | 1092 | snd_soc_component_write(component, DA7210_ADC, DA7210_ADC_L_EN | DA7210_ADC_R_EN); |
1093 | 1093 | ||
1094 | /* | 1094 | /* |
1095 | * DAC settings | 1095 | * DAC settings |
1096 | */ | 1096 | */ |
1097 | 1097 | ||
1098 | /* Enable Left and Right DAC */ | 1098 | /* Enable Left and Right DAC */ |
1099 | snd_soc_write(codec, DA7210_DAC_SEL, | 1099 | snd_soc_component_write(component, DA7210_DAC_SEL, |
1100 | DA7210_DAC_L_SRC_DAI_L | DA7210_DAC_L_EN | | 1100 | DA7210_DAC_L_SRC_DAI_L | DA7210_DAC_L_EN | |
1101 | DA7210_DAC_R_SRC_DAI_R | DA7210_DAC_R_EN); | 1101 | DA7210_DAC_R_SRC_DAI_R | DA7210_DAC_R_EN); |
1102 | 1102 | ||
1103 | /* Enable Left and Right out PGA */ | 1103 | /* Enable Left and Right out PGA */ |
1104 | snd_soc_write(codec, DA7210_OUTMIX_L, DA7210_OUT_L_EN); | 1104 | snd_soc_component_write(component, DA7210_OUTMIX_L, DA7210_OUT_L_EN); |
1105 | snd_soc_write(codec, DA7210_OUTMIX_R, DA7210_OUT_R_EN); | 1105 | snd_soc_component_write(component, DA7210_OUTMIX_R, DA7210_OUT_R_EN); |
1106 | 1106 | ||
1107 | /* Enable Left and Right HeadPhone PGA */ | 1107 | /* Enable Left and Right HeadPhone PGA */ |
1108 | snd_soc_write(codec, DA7210_HP_CFG, | 1108 | snd_soc_component_write(component, DA7210_HP_CFG, |
1109 | DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN | | 1109 | DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN | |
1110 | DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN); | 1110 | DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN); |
1111 | 1111 | ||
1112 | /* Enable ramp mode for DAC gain update */ | 1112 | /* Enable ramp mode for DAC gain update */ |
1113 | snd_soc_write(codec, DA7210_SOFTMUTE, DA7210_RAMP_EN); | 1113 | snd_soc_component_write(component, DA7210_SOFTMUTE, DA7210_RAMP_EN); |
1114 | 1114 | ||
1115 | /* | 1115 | /* |
1116 | * For DA7210 codec, there are two ways to enable/disable analog IOs | 1116 | * For DA7210 codec, there are two ways to enable/disable analog IOs |
@@ -1138,43 +1138,44 @@ static int da7210_probe(struct snd_soc_codec *codec) | |||
1138 | */ | 1138 | */ |
1139 | 1139 | ||
1140 | /* Enable Line out amplifiers */ | 1140 | /* Enable Line out amplifiers */ |
1141 | snd_soc_write(codec, DA7210_OUT1_L, DA7210_OUT1_L_EN); | 1141 | snd_soc_component_write(component, DA7210_OUT1_L, DA7210_OUT1_L_EN); |
1142 | snd_soc_write(codec, DA7210_OUT1_R, DA7210_OUT1_R_EN); | 1142 | snd_soc_component_write(component, DA7210_OUT1_R, DA7210_OUT1_R_EN); |
1143 | snd_soc_write(codec, DA7210_OUT2, DA7210_OUT2_EN | | 1143 | snd_soc_component_write(component, DA7210_OUT2, DA7210_OUT2_EN | |
1144 | DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R); | 1144 | DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R); |
1145 | 1145 | ||
1146 | /* Enable Aux1 */ | 1146 | /* Enable Aux1 */ |
1147 | snd_soc_write(codec, DA7210_AUX1_L, DA7210_AUX1_L_EN); | 1147 | snd_soc_component_write(component, DA7210_AUX1_L, DA7210_AUX1_L_EN); |
1148 | snd_soc_write(codec, DA7210_AUX1_R, DA7210_AUX1_R_EN); | 1148 | snd_soc_component_write(component, DA7210_AUX1_R, DA7210_AUX1_R_EN); |
1149 | /* Enable Aux2 */ | 1149 | /* Enable Aux2 */ |
1150 | snd_soc_write(codec, DA7210_AUX2, DA7210_AUX2_EN); | 1150 | snd_soc_component_write(component, DA7210_AUX2, DA7210_AUX2_EN); |
1151 | 1151 | ||
1152 | /* Set PLL Master clock range 10-20 MHz, enable PLL bypass */ | 1152 | /* Set PLL Master clock range 10-20 MHz, enable PLL bypass */ |
1153 | snd_soc_write(codec, DA7210_PLL_DIV3, DA7210_MCLK_RANGE_10_20_MHZ | | 1153 | snd_soc_component_write(component, DA7210_PLL_DIV3, DA7210_MCLK_RANGE_10_20_MHZ | |
1154 | DA7210_PLL_BYP); | 1154 | DA7210_PLL_BYP); |
1155 | 1155 | ||
1156 | /* Diable PLL and bypass it */ | 1156 | /* Diable PLL and bypass it */ |
1157 | snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000); | 1157 | snd_soc_component_write(component, DA7210_PLL, DA7210_PLL_FS_48000); |
1158 | 1158 | ||
1159 | /* Activate all enabled subsystem */ | 1159 | /* Activate all enabled subsystem */ |
1160 | snd_soc_write(codec, DA7210_STARTUP1, DA7210_SC_MST_EN); | 1160 | snd_soc_component_write(component, DA7210_STARTUP1, DA7210_SC_MST_EN); |
1161 | 1161 | ||
1162 | dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); | 1162 | dev_info(component->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); |
1163 | 1163 | ||
1164 | return 0; | 1164 | return 0; |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | static const struct snd_soc_codec_driver soc_codec_dev_da7210 = { | 1167 | static const struct snd_soc_component_driver soc_component_dev_da7210 = { |
1168 | .probe = da7210_probe, | 1168 | .probe = da7210_probe, |
1169 | 1169 | .controls = da7210_snd_controls, | |
1170 | .component_driver = { | 1170 | .num_controls = ARRAY_SIZE(da7210_snd_controls), |
1171 | .controls = da7210_snd_controls, | 1171 | .dapm_widgets = da7210_dapm_widgets, |
1172 | .num_controls = ARRAY_SIZE(da7210_snd_controls), | 1172 | .num_dapm_widgets = ARRAY_SIZE(da7210_dapm_widgets), |
1173 | .dapm_widgets = da7210_dapm_widgets, | 1173 | .dapm_routes = da7210_audio_map, |
1174 | .num_dapm_widgets = ARRAY_SIZE(da7210_dapm_widgets), | 1174 | .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), |
1175 | .dapm_routes = da7210_audio_map, | 1175 | .idle_bias_on = 1, |
1176 | .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), | 1176 | .use_pmdown_time = 1, |
1177 | }, | 1177 | .endianness = 1, |
1178 | .non_legacy_dai_naming = 1, | ||
1178 | }; | 1179 | }; |
1179 | 1180 | ||
1180 | #if IS_ENABLED(CONFIG_I2C) | 1181 | #if IS_ENABLED(CONFIG_I2C) |
@@ -1232,20 +1233,14 @@ static int da7210_i2c_probe(struct i2c_client *i2c, | |||
1232 | if (ret != 0) | 1233 | if (ret != 0) |
1233 | dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); | 1234 | dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); |
1234 | 1235 | ||
1235 | ret = snd_soc_register_codec(&i2c->dev, | 1236 | ret = snd_soc_register_component(&i2c->dev, |
1236 | &soc_codec_dev_da7210, &da7210_dai, 1); | 1237 | &soc_component_dev_da7210, &da7210_dai, 1); |
1237 | if (ret < 0) | 1238 | if (ret < 0) |
1238 | dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); | 1239 | dev_err(&i2c->dev, "Failed to register component: %d\n", ret); |
1239 | 1240 | ||
1240 | return ret; | 1241 | return ret; |
1241 | } | 1242 | } |
1242 | 1243 | ||
1243 | static int da7210_i2c_remove(struct i2c_client *client) | ||
1244 | { | ||
1245 | snd_soc_unregister_codec(&client->dev); | ||
1246 | return 0; | ||
1247 | } | ||
1248 | |||
1249 | static const struct i2c_device_id da7210_i2c_id[] = { | 1244 | static const struct i2c_device_id da7210_i2c_id[] = { |
1250 | { "da7210", 0 }, | 1245 | { "da7210", 0 }, |
1251 | { } | 1246 | { } |
@@ -1258,7 +1253,6 @@ static struct i2c_driver da7210_i2c_driver = { | |||
1258 | .name = "da7210", | 1253 | .name = "da7210", |
1259 | }, | 1254 | }, |
1260 | .probe = da7210_i2c_probe, | 1255 | .probe = da7210_i2c_probe, |
1261 | .remove = da7210_i2c_remove, | ||
1262 | .id_table = da7210_i2c_id, | 1256 | .id_table = da7210_i2c_id, |
1263 | }; | 1257 | }; |
1264 | #endif | 1258 | #endif |
@@ -1325,24 +1319,17 @@ static int da7210_spi_probe(struct spi_device *spi) | |||
1325 | if (ret != 0) | 1319 | if (ret != 0) |
1326 | dev_warn(&spi->dev, "Failed to apply regmap patch: %d\n", ret); | 1320 | dev_warn(&spi->dev, "Failed to apply regmap patch: %d\n", ret); |
1327 | 1321 | ||
1328 | ret = snd_soc_register_codec(&spi->dev, | 1322 | ret = devm_snd_soc_register_component(&spi->dev, |
1329 | &soc_codec_dev_da7210, &da7210_dai, 1); | 1323 | &soc_component_dev_da7210, &da7210_dai, 1); |
1330 | 1324 | ||
1331 | return ret; | 1325 | return ret; |
1332 | } | 1326 | } |
1333 | 1327 | ||
1334 | static int da7210_spi_remove(struct spi_device *spi) | ||
1335 | { | ||
1336 | snd_soc_unregister_codec(&spi->dev); | ||
1337 | return 0; | ||
1338 | } | ||
1339 | |||
1340 | static struct spi_driver da7210_spi_driver = { | 1328 | static struct spi_driver da7210_spi_driver = { |
1341 | .driver = { | 1329 | .driver = { |
1342 | .name = "da7210", | 1330 | .name = "da7210", |
1343 | }, | 1331 | }, |
1344 | .probe = da7210_spi_probe, | 1332 | .probe = da7210_spi_probe, |
1345 | .remove = da7210_spi_remove | ||
1346 | }; | 1333 | }; |
1347 | #endif | 1334 | #endif |
1348 | 1335 | ||