diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-01-28 22:00:04 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-12 04:40:05 -0500 |
commit | 10dc44c6462db0a4b60efa3add18684205088583 (patch) | |
tree | ce7c8133ca7515e4532eda62e3e22703dc8d07c4 | |
parent | 7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff) |
ASoC: wm8400: 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/wm8400.c | 211 |
1 files changed, 102 insertions, 109 deletions
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index a36adf881bca..c237365d1184 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c | |||
@@ -65,9 +65,9 @@ struct wm8400_priv { | |||
65 | int fll_in, fll_out; | 65 | int fll_in, fll_out; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | static void wm8400_codec_reset(struct snd_soc_codec *codec) | 68 | static void wm8400_component_reset(struct snd_soc_component *component) |
69 | { | 69 | { |
70 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | 70 | struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); |
71 | 71 | ||
72 | wm8400_reset_codec_reg_cache(wm8400->wm8400); | 72 | wm8400_reset_codec_reg_cache(wm8400->wm8400); |
73 | } | 73 | } |
@@ -91,7 +91,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0); | |||
91 | static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, | 91 | static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, |
92 | struct snd_ctl_elem_value *ucontrol) | 92 | struct snd_ctl_elem_value *ucontrol) |
93 | { | 93 | { |
94 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 94 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
95 | struct soc_mixer_control *mc = | 95 | struct soc_mixer_control *mc = |
96 | (struct soc_mixer_control *)kcontrol->private_value; | 96 | (struct soc_mixer_control *)kcontrol->private_value; |
97 | int reg = mc->reg; | 97 | int reg = mc->reg; |
@@ -103,8 +103,8 @@ static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, | |||
103 | return ret; | 103 | return ret; |
104 | 104 | ||
105 | /* now hit the volume update bits (always bit 8) */ | 105 | /* now hit the volume update bits (always bit 8) */ |
106 | val = snd_soc_read(codec, reg); | 106 | val = snd_soc_component_read32(component, reg); |
107 | return snd_soc_write(codec, reg, val | 0x0100); | 107 | return snd_soc_component_write(component, reg, val | 0x0100); |
108 | } | 108 | } |
109 | 109 | ||
110 | #define WM8400_OUTPGA_SINGLE_R_TLV(xname, reg, shift, max, invert, tlv_array) \ | 110 | #define WM8400_OUTPGA_SINGLE_R_TLV(xname, reg, shift, max, invert, tlv_array) \ |
@@ -324,7 +324,7 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, | |||
324 | static int outmixer_event (struct snd_soc_dapm_widget *w, | 324 | static int outmixer_event (struct snd_soc_dapm_widget *w, |
325 | struct snd_kcontrol * kcontrol, int event) | 325 | struct snd_kcontrol * kcontrol, int event) |
326 | { | 326 | { |
327 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 327 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
328 | struct soc_mixer_control *mc = | 328 | struct soc_mixer_control *mc = |
329 | (struct soc_mixer_control *)kcontrol->private_value; | 329 | (struct soc_mixer_control *)kcontrol->private_value; |
330 | u32 reg_shift = mc->shift; | 330 | u32 reg_shift = mc->shift; |
@@ -333,7 +333,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, | |||
333 | 333 | ||
334 | switch (reg_shift) { | 334 | switch (reg_shift) { |
335 | case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) : | 335 | case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) : |
336 | reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER1); | 336 | reg = snd_soc_component_read32(component, WM8400_OUTPUT_MIXER1); |
337 | if (reg & WM8400_LDLO) { | 337 | if (reg & WM8400_LDLO) { |
338 | printk(KERN_WARNING | 338 | printk(KERN_WARNING |
339 | "Cannot set as Output Mixer 1 LDLO Set\n"); | 339 | "Cannot set as Output Mixer 1 LDLO Set\n"); |
@@ -341,7 +341,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, | |||
341 | } | 341 | } |
342 | break; | 342 | break; |
343 | case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8): | 343 | case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8): |
344 | reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER2); | 344 | reg = snd_soc_component_read32(component, WM8400_OUTPUT_MIXER2); |
345 | if (reg & WM8400_RDRO) { | 345 | if (reg & WM8400_RDRO) { |
346 | printk(KERN_WARNING | 346 | printk(KERN_WARNING |
347 | "Cannot set as Output Mixer 2 RDRO Set\n"); | 347 | "Cannot set as Output Mixer 2 RDRO Set\n"); |
@@ -349,7 +349,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, | |||
349 | } | 349 | } |
350 | break; | 350 | break; |
351 | case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8): | 351 | case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8): |
352 | reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER); | 352 | reg = snd_soc_component_read32(component, WM8400_SPEAKER_MIXER); |
353 | if (reg & WM8400_LDSPK) { | 353 | if (reg & WM8400_LDSPK) { |
354 | printk(KERN_WARNING | 354 | printk(KERN_WARNING |
355 | "Cannot set as Speaker Mixer LDSPK Set\n"); | 355 | "Cannot set as Speaker Mixer LDSPK Set\n"); |
@@ -357,7 +357,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, | |||
357 | } | 357 | } |
358 | break; | 358 | break; |
359 | case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8): | 359 | case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8): |
360 | reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER); | 360 | reg = snd_soc_component_read32(component, WM8400_SPEAKER_MIXER); |
361 | if (reg & WM8400_RDSPK) { | 361 | if (reg & WM8400_RDSPK) { |
362 | printk(KERN_WARNING | 362 | printk(KERN_WARNING |
363 | "Cannot set as Speaker Mixer RDSPK Set\n"); | 363 | "Cannot set as Speaker Mixer RDSPK Set\n"); |
@@ -849,8 +849,8 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { | |||
849 | static int wm8400_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 849 | static int wm8400_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
850 | int clk_id, unsigned int freq, int dir) | 850 | int clk_id, unsigned int freq, int dir) |
851 | { | 851 | { |
852 | struct snd_soc_codec *codec = codec_dai->codec; | 852 | struct snd_soc_component *component = codec_dai->component; |
853 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | 853 | struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); |
854 | 854 | ||
855 | wm8400->sysclk = freq; | 855 | wm8400->sysclk = freq; |
856 | return 0; | 856 | return 0; |
@@ -938,8 +938,8 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
938 | int source, unsigned int freq_in, | 938 | int source, unsigned int freq_in, |
939 | unsigned int freq_out) | 939 | unsigned int freq_out) |
940 | { | 940 | { |
941 | struct snd_soc_codec *codec = codec_dai->codec; | 941 | struct snd_soc_component *component = codec_dai->component; |
942 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | 942 | struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); |
943 | struct fll_factors factors; | 943 | struct fll_factors factors; |
944 | int ret; | 944 | int ret; |
945 | u16 reg; | 945 | u16 reg; |
@@ -962,13 +962,13 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
962 | wm8400->fll_in = freq_in; | 962 | wm8400->fll_in = freq_in; |
963 | 963 | ||
964 | /* We *must* disable the FLL before any changes */ | 964 | /* We *must* disable the FLL before any changes */ |
965 | reg = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_2); | 965 | reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_2); |
966 | reg &= ~WM8400_FLL_ENA; | 966 | reg &= ~WM8400_FLL_ENA; |
967 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_2, reg); | 967 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_2, reg); |
968 | 968 | ||
969 | reg = snd_soc_read(codec, WM8400_FLL_CONTROL_1); | 969 | reg = snd_soc_component_read32(component, WM8400_FLL_CONTROL_1); |
970 | reg &= ~WM8400_FLL_OSC_ENA; | 970 | reg &= ~WM8400_FLL_OSC_ENA; |
971 | snd_soc_write(codec, WM8400_FLL_CONTROL_1, reg); | 971 | snd_soc_component_write(component, WM8400_FLL_CONTROL_1, reg); |
972 | 972 | ||
973 | if (!freq_out) | 973 | if (!freq_out) |
974 | return 0; | 974 | return 0; |
@@ -976,15 +976,15 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
976 | reg &= ~(WM8400_FLL_REF_FREQ | WM8400_FLL_FRATIO_MASK); | 976 | reg &= ~(WM8400_FLL_REF_FREQ | WM8400_FLL_FRATIO_MASK); |
977 | reg |= WM8400_FLL_FRAC | factors.fratio; | 977 | reg |= WM8400_FLL_FRAC | factors.fratio; |
978 | reg |= factors.freq_ref << WM8400_FLL_REF_FREQ_SHIFT; | 978 | reg |= factors.freq_ref << WM8400_FLL_REF_FREQ_SHIFT; |
979 | snd_soc_write(codec, WM8400_FLL_CONTROL_1, reg); | 979 | snd_soc_component_write(component, WM8400_FLL_CONTROL_1, reg); |
980 | 980 | ||
981 | snd_soc_write(codec, WM8400_FLL_CONTROL_2, factors.k); | 981 | snd_soc_component_write(component, WM8400_FLL_CONTROL_2, factors.k); |
982 | snd_soc_write(codec, WM8400_FLL_CONTROL_3, factors.n); | 982 | snd_soc_component_write(component, WM8400_FLL_CONTROL_3, factors.n); |
983 | 983 | ||
984 | reg = snd_soc_read(codec, WM8400_FLL_CONTROL_4); | 984 | reg = snd_soc_component_read32(component, WM8400_FLL_CONTROL_4); |
985 | reg &= ~WM8400_FLL_OUTDIV_MASK; | 985 | reg &= ~WM8400_FLL_OUTDIV_MASK; |
986 | reg |= factors.outdiv; | 986 | reg |= factors.outdiv; |
987 | snd_soc_write(codec, WM8400_FLL_CONTROL_4, reg); | 987 | snd_soc_component_write(component, WM8400_FLL_CONTROL_4, reg); |
988 | 988 | ||
989 | return 0; | 989 | return 0; |
990 | } | 990 | } |
@@ -995,11 +995,11 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
995 | static int wm8400_set_dai_fmt(struct snd_soc_dai *codec_dai, | 995 | static int wm8400_set_dai_fmt(struct snd_soc_dai *codec_dai, |
996 | unsigned int fmt) | 996 | unsigned int fmt) |
997 | { | 997 | { |
998 | struct snd_soc_codec *codec = codec_dai->codec; | 998 | struct snd_soc_component *component = codec_dai->component; |
999 | u16 audio1, audio3; | 999 | u16 audio1, audio3; |
1000 | 1000 | ||
1001 | audio1 = snd_soc_read(codec, WM8400_AUDIO_INTERFACE_1); | 1001 | audio1 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_1); |
1002 | audio3 = snd_soc_read(codec, WM8400_AUDIO_INTERFACE_3); | 1002 | audio3 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_3); |
1003 | 1003 | ||
1004 | /* set master/slave audio interface */ | 1004 | /* set master/slave audio interface */ |
1005 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 1005 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
@@ -1040,37 +1040,37 @@ static int wm8400_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
1040 | return -EINVAL; | 1040 | return -EINVAL; |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | snd_soc_write(codec, WM8400_AUDIO_INTERFACE_1, audio1); | 1043 | snd_soc_component_write(component, WM8400_AUDIO_INTERFACE_1, audio1); |
1044 | snd_soc_write(codec, WM8400_AUDIO_INTERFACE_3, audio3); | 1044 | snd_soc_component_write(component, WM8400_AUDIO_INTERFACE_3, audio3); |
1045 | return 0; | 1045 | return 0; |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | static int wm8400_set_dai_clkdiv(struct snd_soc_dai *codec_dai, | 1048 | static int wm8400_set_dai_clkdiv(struct snd_soc_dai *codec_dai, |
1049 | int div_id, int div) | 1049 | int div_id, int div) |
1050 | { | 1050 | { |
1051 | struct snd_soc_codec *codec = codec_dai->codec; | 1051 | struct snd_soc_component *component = codec_dai->component; |
1052 | u16 reg; | 1052 | u16 reg; |
1053 | 1053 | ||
1054 | switch (div_id) { | 1054 | switch (div_id) { |
1055 | case WM8400_MCLK_DIV: | 1055 | case WM8400_MCLK_DIV: |
1056 | reg = snd_soc_read(codec, WM8400_CLOCKING_2) & | 1056 | reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) & |
1057 | ~WM8400_MCLK_DIV_MASK; | 1057 | ~WM8400_MCLK_DIV_MASK; |
1058 | snd_soc_write(codec, WM8400_CLOCKING_2, reg | div); | 1058 | snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div); |
1059 | break; | 1059 | break; |
1060 | case WM8400_DACCLK_DIV: | 1060 | case WM8400_DACCLK_DIV: |
1061 | reg = snd_soc_read(codec, WM8400_CLOCKING_2) & | 1061 | reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) & |
1062 | ~WM8400_DAC_CLKDIV_MASK; | 1062 | ~WM8400_DAC_CLKDIV_MASK; |
1063 | snd_soc_write(codec, WM8400_CLOCKING_2, reg | div); | 1063 | snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div); |
1064 | break; | 1064 | break; |
1065 | case WM8400_ADCCLK_DIV: | 1065 | case WM8400_ADCCLK_DIV: |
1066 | reg = snd_soc_read(codec, WM8400_CLOCKING_2) & | 1066 | reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) & |
1067 | ~WM8400_ADC_CLKDIV_MASK; | 1067 | ~WM8400_ADC_CLKDIV_MASK; |
1068 | snd_soc_write(codec, WM8400_CLOCKING_2, reg | div); | 1068 | snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div); |
1069 | break; | 1069 | break; |
1070 | case WM8400_BCLK_DIV: | 1070 | case WM8400_BCLK_DIV: |
1071 | reg = snd_soc_read(codec, WM8400_CLOCKING_1) & | 1071 | reg = snd_soc_component_read32(component, WM8400_CLOCKING_1) & |
1072 | ~WM8400_BCLK_DIV_MASK; | 1072 | ~WM8400_BCLK_DIV_MASK; |
1073 | snd_soc_write(codec, WM8400_CLOCKING_1, reg | div); | 1073 | snd_soc_component_write(component, WM8400_CLOCKING_1, reg | div); |
1074 | break; | 1074 | break; |
1075 | default: | 1075 | default: |
1076 | return -EINVAL; | 1076 | return -EINVAL; |
@@ -1086,8 +1086,8 @@ static int wm8400_hw_params(struct snd_pcm_substream *substream, | |||
1086 | struct snd_pcm_hw_params *params, | 1086 | struct snd_pcm_hw_params *params, |
1087 | struct snd_soc_dai *dai) | 1087 | struct snd_soc_dai *dai) |
1088 | { | 1088 | { |
1089 | struct snd_soc_codec *codec = dai->codec; | 1089 | struct snd_soc_component *component = dai->component; |
1090 | u16 audio1 = snd_soc_read(codec, WM8400_AUDIO_INTERFACE_1); | 1090 | u16 audio1 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_1); |
1091 | 1091 | ||
1092 | audio1 &= ~WM8400_AIF_WL_MASK; | 1092 | audio1 &= ~WM8400_AIF_WL_MASK; |
1093 | /* bit size */ | 1093 | /* bit size */ |
@@ -1105,28 +1105,28 @@ static int wm8400_hw_params(struct snd_pcm_substream *substream, | |||
1105 | break; | 1105 | break; |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | snd_soc_write(codec, WM8400_AUDIO_INTERFACE_1, audio1); | 1108 | snd_soc_component_write(component, WM8400_AUDIO_INTERFACE_1, audio1); |
1109 | return 0; | 1109 | return 0; |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | static int wm8400_mute(struct snd_soc_dai *dai, int mute) | 1112 | static int wm8400_mute(struct snd_soc_dai *dai, int mute) |
1113 | { | 1113 | { |
1114 | struct snd_soc_codec *codec = dai->codec; | 1114 | struct snd_soc_component *component = dai->component; |
1115 | u16 val = snd_soc_read(codec, WM8400_DAC_CTRL) & ~WM8400_DAC_MUTE; | 1115 | u16 val = snd_soc_component_read32(component, WM8400_DAC_CTRL) & ~WM8400_DAC_MUTE; |
1116 | 1116 | ||
1117 | if (mute) | 1117 | if (mute) |
1118 | snd_soc_write(codec, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); | 1118 | snd_soc_component_write(component, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); |
1119 | else | 1119 | else |
1120 | snd_soc_write(codec, WM8400_DAC_CTRL, val); | 1120 | snd_soc_component_write(component, WM8400_DAC_CTRL, val); |
1121 | 1121 | ||
1122 | return 0; | 1122 | return 0; |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | /* TODO: set bias for best performance at standby */ | 1125 | /* TODO: set bias for best performance at standby */ |
1126 | static int wm8400_set_bias_level(struct snd_soc_codec *codec, | 1126 | static int wm8400_set_bias_level(struct snd_soc_component *component, |
1127 | enum snd_soc_bias_level level) | 1127 | enum snd_soc_bias_level level) |
1128 | { | 1128 | { |
1129 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | 1129 | struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); |
1130 | u16 val; | 1130 | u16 val; |
1131 | int ret; | 1131 | int ret; |
1132 | 1132 | ||
@@ -1136,13 +1136,13 @@ static int wm8400_set_bias_level(struct snd_soc_codec *codec, | |||
1136 | 1136 | ||
1137 | case SND_SOC_BIAS_PREPARE: | 1137 | case SND_SOC_BIAS_PREPARE: |
1138 | /* VMID=2*50k */ | 1138 | /* VMID=2*50k */ |
1139 | val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1) & | 1139 | val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1) & |
1140 | ~WM8400_VMID_MODE_MASK; | 1140 | ~WM8400_VMID_MODE_MASK; |
1141 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val | 0x2); | 1141 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val | 0x2); |
1142 | break; | 1142 | break; |
1143 | 1143 | ||
1144 | case SND_SOC_BIAS_STANDBY: | 1144 | case SND_SOC_BIAS_STANDBY: |
1145 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { | 1145 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { |
1146 | ret = regulator_bulk_enable(ARRAY_SIZE(power), | 1146 | ret = regulator_bulk_enable(ARRAY_SIZE(power), |
1147 | &power[0]); | 1147 | &power[0]); |
1148 | if (ret != 0) { | 1148 | if (ret != 0) { |
@@ -1152,74 +1152,74 @@ static int wm8400_set_bias_level(struct snd_soc_codec *codec, | |||
1152 | return ret; | 1152 | return ret; |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, | 1155 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, |
1156 | WM8400_CODEC_ENA | WM8400_SYSCLK_ENA); | 1156 | WM8400_CODEC_ENA | WM8400_SYSCLK_ENA); |
1157 | 1157 | ||
1158 | /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ | 1158 | /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ |
1159 | snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | | 1159 | snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | |
1160 | WM8400_BUFDCOPEN | WM8400_POBCTRL); | 1160 | WM8400_BUFDCOPEN | WM8400_POBCTRL); |
1161 | 1161 | ||
1162 | msleep(50); | 1162 | msleep(50); |
1163 | 1163 | ||
1164 | /* Enable VREF & VMID at 2x50k */ | 1164 | /* Enable VREF & VMID at 2x50k */ |
1165 | val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); | 1165 | val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); |
1166 | val |= 0x2 | WM8400_VREF_ENA; | 1166 | val |= 0x2 | WM8400_VREF_ENA; |
1167 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); | 1167 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val); |
1168 | 1168 | ||
1169 | /* Enable BUFIOEN */ | 1169 | /* Enable BUFIOEN */ |
1170 | snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | | 1170 | snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | |
1171 | WM8400_BUFDCOPEN | WM8400_POBCTRL | | 1171 | WM8400_BUFDCOPEN | WM8400_POBCTRL | |
1172 | WM8400_BUFIOEN); | 1172 | WM8400_BUFIOEN); |
1173 | 1173 | ||
1174 | /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ | 1174 | /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ |
1175 | snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_BUFIOEN); | 1175 | snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_BUFIOEN); |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | /* VMID=2*300k */ | 1178 | /* VMID=2*300k */ |
1179 | val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1) & | 1179 | val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1) & |
1180 | ~WM8400_VMID_MODE_MASK; | 1180 | ~WM8400_VMID_MODE_MASK; |
1181 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val | 0x4); | 1181 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val | 0x4); |
1182 | break; | 1182 | break; |
1183 | 1183 | ||
1184 | case SND_SOC_BIAS_OFF: | 1184 | case SND_SOC_BIAS_OFF: |
1185 | /* Enable POBCTRL and SOFT_ST */ | 1185 | /* Enable POBCTRL and SOFT_ST */ |
1186 | snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | | 1186 | snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | |
1187 | WM8400_POBCTRL | WM8400_BUFIOEN); | 1187 | WM8400_POBCTRL | WM8400_BUFIOEN); |
1188 | 1188 | ||
1189 | /* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ | 1189 | /* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ |
1190 | snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | | 1190 | snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | |
1191 | WM8400_BUFDCOPEN | WM8400_POBCTRL | | 1191 | WM8400_BUFDCOPEN | WM8400_POBCTRL | |
1192 | WM8400_BUFIOEN); | 1192 | WM8400_BUFIOEN); |
1193 | 1193 | ||
1194 | /* mute DAC */ | 1194 | /* mute DAC */ |
1195 | val = snd_soc_read(codec, WM8400_DAC_CTRL); | 1195 | val = snd_soc_component_read32(component, WM8400_DAC_CTRL); |
1196 | snd_soc_write(codec, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); | 1196 | snd_soc_component_write(component, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); |
1197 | 1197 | ||
1198 | /* Enable any disabled outputs */ | 1198 | /* Enable any disabled outputs */ |
1199 | val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); | 1199 | val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); |
1200 | val |= WM8400_SPK_ENA | WM8400_OUT3_ENA | | 1200 | val |= WM8400_SPK_ENA | WM8400_OUT3_ENA | |
1201 | WM8400_OUT4_ENA | WM8400_LOUT_ENA | | 1201 | WM8400_OUT4_ENA | WM8400_LOUT_ENA | |
1202 | WM8400_ROUT_ENA; | 1202 | WM8400_ROUT_ENA; |
1203 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); | 1203 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val); |
1204 | 1204 | ||
1205 | /* Disable VMID */ | 1205 | /* Disable VMID */ |
1206 | val &= ~WM8400_VMID_MODE_MASK; | 1206 | val &= ~WM8400_VMID_MODE_MASK; |
1207 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); | 1207 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val); |
1208 | 1208 | ||
1209 | msleep(300); | 1209 | msleep(300); |
1210 | 1210 | ||
1211 | /* Enable all output discharge bits */ | 1211 | /* Enable all output discharge bits */ |
1212 | snd_soc_write(codec, WM8400_ANTIPOP1, WM8400_DIS_LLINE | | 1212 | snd_soc_component_write(component, WM8400_ANTIPOP1, WM8400_DIS_LLINE | |
1213 | WM8400_DIS_RLINE | WM8400_DIS_OUT3 | | 1213 | WM8400_DIS_RLINE | WM8400_DIS_OUT3 | |
1214 | WM8400_DIS_OUT4 | WM8400_DIS_LOUT | | 1214 | WM8400_DIS_OUT4 | WM8400_DIS_LOUT | |
1215 | WM8400_DIS_ROUT); | 1215 | WM8400_DIS_ROUT); |
1216 | 1216 | ||
1217 | /* Disable VREF */ | 1217 | /* Disable VREF */ |
1218 | val &= ~WM8400_VREF_ENA; | 1218 | val &= ~WM8400_VREF_ENA; |
1219 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); | 1219 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val); |
1220 | 1220 | ||
1221 | /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ | 1221 | /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ |
1222 | snd_soc_write(codec, WM8400_ANTIPOP2, 0x0); | 1222 | snd_soc_component_write(component, WM8400_ANTIPOP2, 0x0); |
1223 | 1223 | ||
1224 | ret = regulator_bulk_disable(ARRAY_SIZE(power), | 1224 | ret = regulator_bulk_disable(ARRAY_SIZE(power), |
1225 | &power[0]); | 1225 | &power[0]); |
@@ -1273,93 +1273,86 @@ static struct snd_soc_dai_driver wm8400_dai = { | |||
1273 | .ops = &wm8400_dai_ops, | 1273 | .ops = &wm8400_dai_ops, |
1274 | }; | 1274 | }; |
1275 | 1275 | ||
1276 | static int wm8400_codec_probe(struct snd_soc_codec *codec) | 1276 | static int wm8400_component_probe(struct snd_soc_component *component) |
1277 | { | 1277 | { |
1278 | struct wm8400 *wm8400 = dev_get_platdata(codec->dev); | 1278 | struct wm8400 *wm8400 = dev_get_platdata(component->dev); |
1279 | struct wm8400_priv *priv; | 1279 | struct wm8400_priv *priv; |
1280 | int ret; | 1280 | int ret; |
1281 | u16 reg; | 1281 | u16 reg; |
1282 | 1282 | ||
1283 | priv = devm_kzalloc(codec->dev, sizeof(struct wm8400_priv), | 1283 | priv = devm_kzalloc(component->dev, sizeof(struct wm8400_priv), |
1284 | GFP_KERNEL); | 1284 | GFP_KERNEL); |
1285 | if (priv == NULL) | 1285 | if (priv == NULL) |
1286 | return -ENOMEM; | 1286 | return -ENOMEM; |
1287 | 1287 | ||
1288 | snd_soc_codec_init_regmap(codec, wm8400->regmap); | 1288 | snd_soc_component_init_regmap(component, wm8400->regmap); |
1289 | snd_soc_codec_set_drvdata(codec, priv); | 1289 | snd_soc_component_set_drvdata(component, priv); |
1290 | priv->wm8400 = wm8400; | 1290 | priv->wm8400 = wm8400; |
1291 | 1291 | ||
1292 | ret = devm_regulator_bulk_get(wm8400->dev, | 1292 | ret = devm_regulator_bulk_get(wm8400->dev, |
1293 | ARRAY_SIZE(power), &power[0]); | 1293 | ARRAY_SIZE(power), &power[0]); |
1294 | if (ret != 0) { | 1294 | if (ret != 0) { |
1295 | dev_err(codec->dev, "Failed to get regulators: %d\n", ret); | 1295 | dev_err(component->dev, "Failed to get regulators: %d\n", ret); |
1296 | return ret; | 1296 | return ret; |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | wm8400_codec_reset(codec); | 1299 | wm8400_component_reset(component); |
1300 | 1300 | ||
1301 | reg = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); | 1301 | reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); |
1302 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, reg | WM8400_CODEC_ENA); | 1302 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, reg | WM8400_CODEC_ENA); |
1303 | 1303 | ||
1304 | /* Latch volume update bits */ | 1304 | /* Latch volume update bits */ |
1305 | reg = snd_soc_read(codec, WM8400_LEFT_LINE_INPUT_1_2_VOLUME); | 1305 | reg = snd_soc_component_read32(component, WM8400_LEFT_LINE_INPUT_1_2_VOLUME); |
1306 | snd_soc_write(codec, WM8400_LEFT_LINE_INPUT_1_2_VOLUME, | 1306 | snd_soc_component_write(component, WM8400_LEFT_LINE_INPUT_1_2_VOLUME, |
1307 | reg & WM8400_IPVU); | 1307 | reg & WM8400_IPVU); |
1308 | reg = snd_soc_read(codec, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME); | 1308 | reg = snd_soc_component_read32(component, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME); |
1309 | snd_soc_write(codec, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, | 1309 | snd_soc_component_write(component, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, |
1310 | reg & WM8400_IPVU); | 1310 | reg & WM8400_IPVU); |
1311 | 1311 | ||
1312 | snd_soc_write(codec, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); | 1312 | snd_soc_component_write(component, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); |
1313 | snd_soc_write(codec, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); | 1313 | snd_soc_component_write(component, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); |
1314 | 1314 | ||
1315 | return 0; | 1315 | return 0; |
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | static int wm8400_codec_remove(struct snd_soc_codec *codec) | 1318 | static void wm8400_component_remove(struct snd_soc_component *component) |
1319 | { | 1319 | { |
1320 | u16 reg; | 1320 | u16 reg; |
1321 | 1321 | ||
1322 | reg = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); | 1322 | reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); |
1323 | snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, | 1323 | snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, |
1324 | reg & (~WM8400_CODEC_ENA)); | 1324 | reg & (~WM8400_CODEC_ENA)); |
1325 | |||
1326 | return 0; | ||
1327 | } | 1325 | } |
1328 | 1326 | ||
1329 | static const struct snd_soc_codec_driver soc_codec_dev_wm8400 = { | 1327 | static const struct snd_soc_component_driver soc_component_dev_wm8400 = { |
1330 | .probe = wm8400_codec_probe, | 1328 | .probe = wm8400_component_probe, |
1331 | .remove = wm8400_codec_remove, | 1329 | .remove = wm8400_component_remove, |
1332 | .set_bias_level = wm8400_set_bias_level, | 1330 | .set_bias_level = wm8400_set_bias_level, |
1333 | .suspend_bias_off = true, | 1331 | .controls = wm8400_snd_controls, |
1334 | 1332 | .num_controls = ARRAY_SIZE(wm8400_snd_controls), | |
1335 | .component_driver = { | 1333 | .dapm_widgets = wm8400_dapm_widgets, |
1336 | .controls = wm8400_snd_controls, | 1334 | .num_dapm_widgets = ARRAY_SIZE(wm8400_dapm_widgets), |
1337 | .num_controls = ARRAY_SIZE(wm8400_snd_controls), | 1335 | .dapm_routes = wm8400_dapm_routes, |
1338 | .dapm_widgets = wm8400_dapm_widgets, | 1336 | .num_dapm_routes = ARRAY_SIZE(wm8400_dapm_routes), |
1339 | .num_dapm_widgets = ARRAY_SIZE(wm8400_dapm_widgets), | 1337 | .suspend_bias_off = 1, |
1340 | .dapm_routes = wm8400_dapm_routes, | 1338 | .idle_bias_on = 1, |
1341 | .num_dapm_routes = ARRAY_SIZE(wm8400_dapm_routes), | 1339 | .use_pmdown_time = 1, |
1342 | }, | 1340 | .endianness = 1, |
1341 | .non_legacy_dai_naming = 1, | ||
1343 | }; | 1342 | }; |
1344 | 1343 | ||
1345 | static int wm8400_probe(struct platform_device *pdev) | 1344 | static int wm8400_probe(struct platform_device *pdev) |
1346 | { | 1345 | { |
1347 | return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8400, | 1346 | return snd_soc_register_component(&pdev->dev, |
1347 | &soc_component_dev_wm8400, | ||
1348 | &wm8400_dai, 1); | 1348 | &wm8400_dai, 1); |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | static int wm8400_remove(struct platform_device *pdev) | ||
1352 | { | ||
1353 | snd_soc_unregister_codec(&pdev->dev); | ||
1354 | return 0; | ||
1355 | } | ||
1356 | |||
1357 | static struct platform_driver wm8400_codec_driver = { | 1351 | static struct platform_driver wm8400_codec_driver = { |
1358 | .driver = { | 1352 | .driver = { |
1359 | .name = "wm8400-codec", | 1353 | .name = "wm8400-codec", |
1360 | }, | 1354 | }, |
1361 | .probe = wm8400_probe, | 1355 | .probe = wm8400_probe, |
1362 | .remove = wm8400_remove, | ||
1363 | }; | 1356 | }; |
1364 | 1357 | ||
1365 | module_platform_driver(wm8400_codec_driver); | 1358 | module_platform_driver(wm8400_codec_driver); |