aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:04:21 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:41:29 -0500
commit22d15fc51ea79e0554cfa1c9ca78af0a8d5cd20b (patch)
tree87cc1d9f81940eb604382dbe75bab112d3c61613
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8753: 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/wm8753.c289
1 files changed, 138 insertions, 151 deletions
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index 0271a5253bd3..1e2823e2a906 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -55,9 +55,9 @@ static int caps_charge = 2000;
55module_param(caps_charge, int, 0); 55module_param(caps_charge, int, 0);
56MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)"); 56MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)");
57 57
58static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec, 58static int wm8753_hifi_write_dai_fmt(struct snd_soc_component *component,
59 unsigned int fmt); 59 unsigned int fmt);
60static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec, 60static int wm8753_voice_write_dai_fmt(struct snd_soc_component *component,
61 unsigned int fmt); 61 unsigned int fmt);
62 62
63/* 63/*
@@ -150,7 +150,7 @@ struct wm8753_priv {
150 struct delayed_work charge_work; 150 struct delayed_work charge_work;
151}; 151};
152 152
153#define wm8753_reset(c) snd_soc_write(c, WM8753_RESET, 0) 153#define wm8753_reset(c) snd_soc_component_write(c, WM8753_RESET, 0)
154 154
155/* 155/*
156 * WM8753 Controls 156 * WM8753 Controls
@@ -229,8 +229,8 @@ SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase),
229static int wm8753_get_dai(struct snd_kcontrol *kcontrol, 229static int wm8753_get_dai(struct snd_kcontrol *kcontrol,
230 struct snd_ctl_elem_value *ucontrol) 230 struct snd_ctl_elem_value *ucontrol)
231{ 231{
232 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 232 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
233 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 233 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
234 234
235 ucontrol->value.enumerated.item[0] = wm8753->dai_func; 235 ucontrol->value.enumerated.item[0] = wm8753->dai_func;
236 return 0; 236 return 0;
@@ -239,17 +239,17 @@ static int wm8753_get_dai(struct snd_kcontrol *kcontrol,
239static int wm8753_set_dai(struct snd_kcontrol *kcontrol, 239static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
240 struct snd_ctl_elem_value *ucontrol) 240 struct snd_ctl_elem_value *ucontrol)
241{ 241{
242 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 242 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
243 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 243 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
244 u16 ioctl; 244 u16 ioctl;
245 245
246 if (wm8753->dai_func == ucontrol->value.enumerated.item[0]) 246 if (wm8753->dai_func == ucontrol->value.enumerated.item[0])
247 return 0; 247 return 0;
248 248
249 if (snd_soc_codec_is_active(codec)) 249 if (snd_soc_component_is_active(component))
250 return -EBUSY; 250 return -EBUSY;
251 251
252 ioctl = snd_soc_read(codec, WM8753_IOCTL); 252 ioctl = snd_soc_component_read32(component, WM8753_IOCTL);
253 253
254 wm8753->dai_func = ucontrol->value.enumerated.item[0]; 254 wm8753->dai_func = ucontrol->value.enumerated.item[0];
255 255
@@ -257,11 +257,11 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
257 return 1; 257 return 1;
258 258
259 ioctl = (ioctl & 0x1f3) | (wm8753->dai_func << 2); 259 ioctl = (ioctl & 0x1f3) | (wm8753->dai_func << 2);
260 snd_soc_write(codec, WM8753_IOCTL, ioctl); 260 snd_soc_component_write(component, WM8753_IOCTL, ioctl);
261 261
262 262
263 wm8753_hifi_write_dai_fmt(codec, wm8753->hifi_fmt); 263 wm8753_hifi_write_dai_fmt(component, wm8753->hifi_fmt);
264 wm8753_voice_write_dai_fmt(codec, wm8753->voice_fmt); 264 wm8753_voice_write_dai_fmt(component, wm8753->voice_fmt);
265 265
266 return 1; 266 return 1;
267} 267}
@@ -745,7 +745,7 @@ static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
745{ 745{
746 u16 reg, enable; 746 u16 reg, enable;
747 int offset; 747 int offset;
748 struct snd_soc_codec *codec = codec_dai->codec; 748 struct snd_soc_component *component = codec_dai->component;
749 749
750 if (pll_id < WM8753_PLL1 || pll_id > WM8753_PLL2) 750 if (pll_id < WM8753_PLL1 || pll_id > WM8753_PLL2)
751 return -ENODEV; 751 return -ENODEV;
@@ -753,17 +753,17 @@ static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
753 if (pll_id == WM8753_PLL1) { 753 if (pll_id == WM8753_PLL1) {
754 offset = 0; 754 offset = 0;
755 enable = 0x10; 755 enable = 0x10;
756 reg = snd_soc_read(codec, WM8753_CLOCK) & 0xffef; 756 reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xffef;
757 } else { 757 } else {
758 offset = 4; 758 offset = 4;
759 enable = 0x8; 759 enable = 0x8;
760 reg = snd_soc_read(codec, WM8753_CLOCK) & 0xfff7; 760 reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfff7;
761 } 761 }
762 762
763 if (!freq_in || !freq_out) { 763 if (!freq_in || !freq_out) {
764 /* disable PLL */ 764 /* disable PLL */
765 snd_soc_write(codec, WM8753_PLL1CTL1 + offset, 0x0026); 765 snd_soc_component_write(component, WM8753_PLL1CTL1 + offset, 0x0026);
766 snd_soc_write(codec, WM8753_CLOCK, reg); 766 snd_soc_component_write(component, WM8753_CLOCK, reg);
767 return 0; 767 return 0;
768 } else { 768 } else {
769 u16 value = 0; 769 u16 value = 0;
@@ -774,20 +774,20 @@ static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
774 /* set up N and K PLL divisor ratios */ 774 /* set up N and K PLL divisor ratios */
775 /* bits 8:5 = PLL_N, bits 3:0 = PLL_K[21:18] */ 775 /* bits 8:5 = PLL_N, bits 3:0 = PLL_K[21:18] */
776 value = (pll_div.n << 5) + ((pll_div.k & 0x3c0000) >> 18); 776 value = (pll_div.n << 5) + ((pll_div.k & 0x3c0000) >> 18);
777 snd_soc_write(codec, WM8753_PLL1CTL2 + offset, value); 777 snd_soc_component_write(component, WM8753_PLL1CTL2 + offset, value);
778 778
779 /* bits 8:0 = PLL_K[17:9] */ 779 /* bits 8:0 = PLL_K[17:9] */
780 value = (pll_div.k & 0x03fe00) >> 9; 780 value = (pll_div.k & 0x03fe00) >> 9;
781 snd_soc_write(codec, WM8753_PLL1CTL3 + offset, value); 781 snd_soc_component_write(component, WM8753_PLL1CTL3 + offset, value);
782 782
783 /* bits 8:0 = PLL_K[8:0] */ 783 /* bits 8:0 = PLL_K[8:0] */
784 value = pll_div.k & 0x0001ff; 784 value = pll_div.k & 0x0001ff;
785 snd_soc_write(codec, WM8753_PLL1CTL4 + offset, value); 785 snd_soc_component_write(component, WM8753_PLL1CTL4 + offset, value);
786 786
787 /* set PLL as input and enable */ 787 /* set PLL as input and enable */
788 snd_soc_write(codec, WM8753_PLL1CTL1 + offset, 0x0027 | 788 snd_soc_component_write(component, WM8753_PLL1CTL1 + offset, 0x0027 |
789 (pll_div.div2 << 3)); 789 (pll_div.div2 << 3));
790 snd_soc_write(codec, WM8753_CLOCK, reg | enable); 790 snd_soc_component_write(component, WM8753_CLOCK, reg | enable);
791 } 791 }
792 return 0; 792 return 0;
793} 793}
@@ -866,8 +866,8 @@ static int get_coeff(int mclk, int rate)
866static int wm8753_set_dai_sysclk(struct snd_soc_dai *codec_dai, 866static int wm8753_set_dai_sysclk(struct snd_soc_dai *codec_dai,
867 int clk_id, unsigned int freq, int dir) 867 int clk_id, unsigned int freq, int dir)
868{ 868{
869 struct snd_soc_codec *codec = codec_dai->codec; 869 struct snd_soc_component *component = codec_dai->component;
870 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 870 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
871 871
872 switch (freq) { 872 switch (freq) {
873 case 11289600: 873 case 11289600:
@@ -890,10 +890,10 @@ static int wm8753_set_dai_sysclk(struct snd_soc_dai *codec_dai,
890/* 890/*
891 * Set's ADC and Voice DAC format. 891 * Set's ADC and Voice DAC format.
892 */ 892 */
893static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec *codec, 893static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_component *component,
894 unsigned int fmt) 894 unsigned int fmt)
895{ 895{
896 u16 voice = snd_soc_read(codec, WM8753_PCM) & 0x01ec; 896 u16 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x01ec;
897 897
898 /* interface format */ 898 /* interface format */
899 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 899 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -915,7 +915,7 @@ static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec *codec,
915 return -EINVAL; 915 return -EINVAL;
916 } 916 }
917 917
918 snd_soc_write(codec, WM8753_PCM, voice); 918 snd_soc_component_write(component, WM8753_PCM, voice);
919 return 0; 919 return 0;
920} 920}
921 921
@@ -926,10 +926,10 @@ static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream,
926 struct snd_pcm_hw_params *params, 926 struct snd_pcm_hw_params *params,
927 struct snd_soc_dai *dai) 927 struct snd_soc_dai *dai)
928{ 928{
929 struct snd_soc_codec *codec = dai->codec; 929 struct snd_soc_component *component = dai->component;
930 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 930 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
931 u16 voice = snd_soc_read(codec, WM8753_PCM) & 0x01f3; 931 u16 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x01f3;
932 u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x017f; 932 u16 srate = snd_soc_component_read32(component, WM8753_SRATE1) & 0x017f;
933 933
934 /* bit size */ 934 /* bit size */
935 switch (params_width(params)) { 935 switch (params_width(params)) {
@@ -949,22 +949,22 @@ static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream,
949 /* sample rate */ 949 /* sample rate */
950 if (params_rate(params) * 384 == wm8753->pcmclk) 950 if (params_rate(params) * 384 == wm8753->pcmclk)
951 srate |= 0x80; 951 srate |= 0x80;
952 snd_soc_write(codec, WM8753_SRATE1, srate); 952 snd_soc_component_write(component, WM8753_SRATE1, srate);
953 953
954 snd_soc_write(codec, WM8753_PCM, voice); 954 snd_soc_component_write(component, WM8753_PCM, voice);
955 return 0; 955 return 0;
956} 956}
957 957
958/* 958/*
959 * Set's PCM dai fmt and BCLK. 959 * Set's PCM dai fmt and BCLK.
960 */ 960 */
961static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec *codec, 961static int wm8753_pcm_set_dai_fmt(struct snd_soc_component *component,
962 unsigned int fmt) 962 unsigned int fmt)
963{ 963{
964 u16 voice, ioctl; 964 u16 voice, ioctl;
965 965
966 voice = snd_soc_read(codec, WM8753_PCM) & 0x011f; 966 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x011f;
967 ioctl = snd_soc_read(codec, WM8753_IOCTL) & 0x015d; 967 ioctl = snd_soc_component_read32(component, WM8753_IOCTL) & 0x015d;
968 968
969 /* set master/slave audio interface */ 969 /* set master/slave audio interface */
970 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 970 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -1018,29 +1018,29 @@ static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec *codec,
1018 return -EINVAL; 1018 return -EINVAL;
1019 } 1019 }
1020 1020
1021 snd_soc_write(codec, WM8753_PCM, voice); 1021 snd_soc_component_write(component, WM8753_PCM, voice);
1022 snd_soc_write(codec, WM8753_IOCTL, ioctl); 1022 snd_soc_component_write(component, WM8753_IOCTL, ioctl);
1023 return 0; 1023 return 0;
1024} 1024}
1025 1025
1026static int wm8753_set_dai_clkdiv(struct snd_soc_dai *codec_dai, 1026static int wm8753_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
1027 int div_id, int div) 1027 int div_id, int div)
1028{ 1028{
1029 struct snd_soc_codec *codec = codec_dai->codec; 1029 struct snd_soc_component *component = codec_dai->component;
1030 u16 reg; 1030 u16 reg;
1031 1031
1032 switch (div_id) { 1032 switch (div_id) {
1033 case WM8753_PCMDIV: 1033 case WM8753_PCMDIV:
1034 reg = snd_soc_read(codec, WM8753_CLOCK) & 0x003f; 1034 reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0x003f;
1035 snd_soc_write(codec, WM8753_CLOCK, reg | div); 1035 snd_soc_component_write(component, WM8753_CLOCK, reg | div);
1036 break; 1036 break;
1037 case WM8753_BCLKDIV: 1037 case WM8753_BCLKDIV:
1038 reg = snd_soc_read(codec, WM8753_SRATE2) & 0x01c7; 1038 reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x01c7;
1039 snd_soc_write(codec, WM8753_SRATE2, reg | div); 1039 snd_soc_component_write(component, WM8753_SRATE2, reg | div);
1040 break; 1040 break;
1041 case WM8753_VXCLKDIV: 1041 case WM8753_VXCLKDIV:
1042 reg = snd_soc_read(codec, WM8753_SRATE2) & 0x003f; 1042 reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x003f;
1043 snd_soc_write(codec, WM8753_SRATE2, reg | div); 1043 snd_soc_component_write(component, WM8753_SRATE2, reg | div);
1044 break; 1044 break;
1045 default: 1045 default:
1046 return -EINVAL; 1046 return -EINVAL;
@@ -1051,10 +1051,10 @@ static int wm8753_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
1051/* 1051/*
1052 * Set's HiFi DAC format. 1052 * Set's HiFi DAC format.
1053 */ 1053 */
1054static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec *codec, 1054static int wm8753_hdac_set_dai_fmt(struct snd_soc_component *component,
1055 unsigned int fmt) 1055 unsigned int fmt)
1056{ 1056{
1057 u16 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x01e0; 1057 u16 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x01e0;
1058 1058
1059 /* interface format */ 1059 /* interface format */
1060 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 1060 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -1076,20 +1076,20 @@ static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec *codec,
1076 return -EINVAL; 1076 return -EINVAL;
1077 } 1077 }
1078 1078
1079 snd_soc_write(codec, WM8753_HIFI, hifi); 1079 snd_soc_component_write(component, WM8753_HIFI, hifi);
1080 return 0; 1080 return 0;
1081} 1081}
1082 1082
1083/* 1083/*
1084 * Set's I2S DAI format. 1084 * Set's I2S DAI format.
1085 */ 1085 */
1086static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec *codec, 1086static int wm8753_i2s_set_dai_fmt(struct snd_soc_component *component,
1087 unsigned int fmt) 1087 unsigned int fmt)
1088{ 1088{
1089 u16 ioctl, hifi; 1089 u16 ioctl, hifi;
1090 1090
1091 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x013f; 1091 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x013f;
1092 ioctl = snd_soc_read(codec, WM8753_IOCTL) & 0x00ae; 1092 ioctl = snd_soc_component_read32(component, WM8753_IOCTL) & 0x00ae;
1093 1093
1094 /* set master/slave audio interface */ 1094 /* set master/slave audio interface */
1095 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 1095 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -1143,8 +1143,8 @@ static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec *codec,
1143 return -EINVAL; 1143 return -EINVAL;
1144 } 1144 }
1145 1145
1146 snd_soc_write(codec, WM8753_HIFI, hifi); 1146 snd_soc_component_write(component, WM8753_HIFI, hifi);
1147 snd_soc_write(codec, WM8753_IOCTL, ioctl); 1147 snd_soc_component_write(component, WM8753_IOCTL, ioctl);
1148 return 0; 1148 return 0;
1149} 1149}
1150 1150
@@ -1155,10 +1155,10 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream,
1155 struct snd_pcm_hw_params *params, 1155 struct snd_pcm_hw_params *params,
1156 struct snd_soc_dai *dai) 1156 struct snd_soc_dai *dai)
1157{ 1157{
1158 struct snd_soc_codec *codec = dai->codec; 1158 struct snd_soc_component *component = dai->component;
1159 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 1159 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
1160 u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x01c0; 1160 u16 srate = snd_soc_component_read32(component, WM8753_SRATE1) & 0x01c0;
1161 u16 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x01f3; 1161 u16 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x01f3;
1162 int coeff; 1162 int coeff;
1163 1163
1164 /* is digital filter coefficient valid ? */ 1164 /* is digital filter coefficient valid ? */
@@ -1167,7 +1167,7 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream,
1167 printk(KERN_ERR "wm8753 invalid MCLK or rate\n"); 1167 printk(KERN_ERR "wm8753 invalid MCLK or rate\n");
1168 return coeff; 1168 return coeff;
1169 } 1169 }
1170 snd_soc_write(codec, WM8753_SRATE1, srate | (coeff_div[coeff].sr << 1) | 1170 snd_soc_component_write(component, WM8753_SRATE1, srate | (coeff_div[coeff].sr << 1) |
1171 coeff_div[coeff].usb); 1171 coeff_div[coeff].usb);
1172 1172
1173 /* bit size */ 1173 /* bit size */
@@ -1185,70 +1185,70 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream,
1185 break; 1185 break;
1186 } 1186 }
1187 1187
1188 snd_soc_write(codec, WM8753_HIFI, hifi); 1188 snd_soc_component_write(component, WM8753_HIFI, hifi);
1189 return 0; 1189 return 0;
1190} 1190}
1191 1191
1192static int wm8753_mode1v_set_dai_fmt(struct snd_soc_codec *codec, 1192static int wm8753_mode1v_set_dai_fmt(struct snd_soc_component *component,
1193 unsigned int fmt) 1193 unsigned int fmt)
1194{ 1194{
1195 u16 clock; 1195 u16 clock;
1196 1196
1197 /* set clk source as pcmclk */ 1197 /* set clk source as pcmclk */
1198 clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb; 1198 clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb;
1199 snd_soc_write(codec, WM8753_CLOCK, clock); 1199 snd_soc_component_write(component, WM8753_CLOCK, clock);
1200 1200
1201 return wm8753_vdac_adc_set_dai_fmt(codec, fmt); 1201 return wm8753_vdac_adc_set_dai_fmt(component, fmt);
1202} 1202}
1203 1203
1204static int wm8753_mode1h_set_dai_fmt(struct snd_soc_codec *codec, 1204static int wm8753_mode1h_set_dai_fmt(struct snd_soc_component *component,
1205 unsigned int fmt) 1205 unsigned int fmt)
1206{ 1206{
1207 return wm8753_hdac_set_dai_fmt(codec, fmt); 1207 return wm8753_hdac_set_dai_fmt(component, fmt);
1208} 1208}
1209 1209
1210static int wm8753_mode2_set_dai_fmt(struct snd_soc_codec *codec, 1210static int wm8753_mode2_set_dai_fmt(struct snd_soc_component *component,
1211 unsigned int fmt) 1211 unsigned int fmt)
1212{ 1212{
1213 u16 clock; 1213 u16 clock;
1214 1214
1215 /* set clk source as pcmclk */ 1215 /* set clk source as pcmclk */
1216 clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb; 1216 clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb;
1217 snd_soc_write(codec, WM8753_CLOCK, clock); 1217 snd_soc_component_write(component, WM8753_CLOCK, clock);
1218 1218
1219 return wm8753_vdac_adc_set_dai_fmt(codec, fmt); 1219 return wm8753_vdac_adc_set_dai_fmt(component, fmt);
1220} 1220}
1221 1221
1222static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_codec *codec, 1222static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_component *component,
1223 unsigned int fmt) 1223 unsigned int fmt)
1224{ 1224{
1225 u16 clock; 1225 u16 clock;
1226 1226
1227 /* set clk source as mclk */ 1227 /* set clk source as mclk */
1228 clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb; 1228 clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb;
1229 snd_soc_write(codec, WM8753_CLOCK, clock | 0x4); 1229 snd_soc_component_write(component, WM8753_CLOCK, clock | 0x4);
1230 1230
1231 if (wm8753_hdac_set_dai_fmt(codec, fmt) < 0) 1231 if (wm8753_hdac_set_dai_fmt(component, fmt) < 0)
1232 return -EINVAL; 1232 return -EINVAL;
1233 return wm8753_vdac_adc_set_dai_fmt(codec, fmt); 1233 return wm8753_vdac_adc_set_dai_fmt(component, fmt);
1234} 1234}
1235 1235
1236static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec, 1236static int wm8753_hifi_write_dai_fmt(struct snd_soc_component *component,
1237 unsigned int fmt) 1237 unsigned int fmt)
1238{ 1238{
1239 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 1239 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
1240 int ret = 0; 1240 int ret = 0;
1241 1241
1242 switch (wm8753->dai_func) { 1242 switch (wm8753->dai_func) {
1243 case 0: 1243 case 0:
1244 ret = wm8753_mode1h_set_dai_fmt(codec, fmt); 1244 ret = wm8753_mode1h_set_dai_fmt(component, fmt);
1245 break; 1245 break;
1246 case 1: 1246 case 1:
1247 ret = wm8753_mode2_set_dai_fmt(codec, fmt); 1247 ret = wm8753_mode2_set_dai_fmt(component, fmt);
1248 break; 1248 break;
1249 case 2: 1249 case 2:
1250 case 3: 1250 case 3:
1251 ret = wm8753_mode3_4_set_dai_fmt(codec, fmt); 1251 ret = wm8753_mode3_4_set_dai_fmt(component, fmt);
1252 break; 1252 break;
1253 default: 1253 default:
1254 break; 1254 break;
@@ -1256,33 +1256,33 @@ static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec,
1256 if (ret) 1256 if (ret)
1257 return ret; 1257 return ret;
1258 1258
1259 return wm8753_i2s_set_dai_fmt(codec, fmt); 1259 return wm8753_i2s_set_dai_fmt(component, fmt);
1260} 1260}
1261 1261
1262static int wm8753_hifi_set_dai_fmt(struct snd_soc_dai *codec_dai, 1262static int wm8753_hifi_set_dai_fmt(struct snd_soc_dai *codec_dai,
1263 unsigned int fmt) 1263 unsigned int fmt)
1264{ 1264{
1265 struct snd_soc_codec *codec = codec_dai->codec; 1265 struct snd_soc_component *component = codec_dai->component;
1266 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 1266 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
1267 1267
1268 wm8753->hifi_fmt = fmt; 1268 wm8753->hifi_fmt = fmt;
1269 1269
1270 return wm8753_hifi_write_dai_fmt(codec, fmt); 1270 return wm8753_hifi_write_dai_fmt(component, fmt);
1271}; 1271};
1272 1272
1273static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec, 1273static int wm8753_voice_write_dai_fmt(struct snd_soc_component *component,
1274 unsigned int fmt) 1274 unsigned int fmt)
1275{ 1275{
1276 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 1276 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
1277 int ret = 0; 1277 int ret = 0;
1278 1278
1279 if (wm8753->dai_func != 0) 1279 if (wm8753->dai_func != 0)
1280 return 0; 1280 return 0;
1281 1281
1282 ret = wm8753_mode1v_set_dai_fmt(codec, fmt); 1282 ret = wm8753_mode1v_set_dai_fmt(component, fmt);
1283 if (ret) 1283 if (ret)
1284 return ret; 1284 return ret;
1285 ret = wm8753_pcm_set_dai_fmt(codec, fmt); 1285 ret = wm8753_pcm_set_dai_fmt(component, fmt);
1286 if (ret) 1286 if (ret)
1287 return ret; 1287 return ret;
1288 1288
@@ -1292,30 +1292,30 @@ static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec,
1292static int wm8753_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, 1292static int wm8753_voice_set_dai_fmt(struct snd_soc_dai *codec_dai,
1293 unsigned int fmt) 1293 unsigned int fmt)
1294{ 1294{
1295 struct snd_soc_codec *codec = codec_dai->codec; 1295 struct snd_soc_component *component = codec_dai->component;
1296 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 1296 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
1297 1297
1298 wm8753->voice_fmt = fmt; 1298 wm8753->voice_fmt = fmt;
1299 1299
1300 return wm8753_voice_write_dai_fmt(codec, fmt); 1300 return wm8753_voice_write_dai_fmt(component, fmt);
1301}; 1301};
1302 1302
1303static int wm8753_mute(struct snd_soc_dai *dai, int mute) 1303static int wm8753_mute(struct snd_soc_dai *dai, int mute)
1304{ 1304{
1305 struct snd_soc_codec *codec = dai->codec; 1305 struct snd_soc_component *component = dai->component;
1306 u16 mute_reg = snd_soc_read(codec, WM8753_DAC) & 0xfff7; 1306 u16 mute_reg = snd_soc_component_read32(component, WM8753_DAC) & 0xfff7;
1307 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 1307 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
1308 1308
1309 /* the digital mute covers the HiFi and Voice DAC's on the WM8753. 1309 /* the digital mute covers the HiFi and Voice DAC's on the WM8753.
1310 * make sure we check if they are not both active when we mute */ 1310 * make sure we check if they are not both active when we mute */
1311 if (mute && wm8753->dai_func == 1) { 1311 if (mute && wm8753->dai_func == 1) {
1312 if (!snd_soc_codec_is_active(codec)) 1312 if (!snd_soc_component_is_active(component))
1313 snd_soc_write(codec, WM8753_DAC, mute_reg | 0x8); 1313 snd_soc_component_write(component, WM8753_DAC, mute_reg | 0x8);
1314 } else { 1314 } else {
1315 if (mute) 1315 if (mute)
1316 snd_soc_write(codec, WM8753_DAC, mute_reg | 0x8); 1316 snd_soc_component_write(component, WM8753_DAC, mute_reg | 0x8);
1317 else 1317 else
1318 snd_soc_write(codec, WM8753_DAC, mute_reg); 1318 snd_soc_component_write(component, WM8753_DAC, mute_reg);
1319 } 1319 }
1320 1320
1321 return 0; 1321 return 0;
@@ -1330,35 +1330,35 @@ static void wm8753_charge_work(struct work_struct *work)
1330 regmap_update_bits(wm8753->regmap, WM8753_PWR1, 0x0180, 0x0100); 1330 regmap_update_bits(wm8753->regmap, WM8753_PWR1, 0x0180, 0x0100);
1331} 1331}
1332 1332
1333static int wm8753_set_bias_level(struct snd_soc_codec *codec, 1333static int wm8753_set_bias_level(struct snd_soc_component *component,
1334 enum snd_soc_bias_level level) 1334 enum snd_soc_bias_level level)
1335{ 1335{
1336 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 1336 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
1337 u16 pwr_reg = snd_soc_read(codec, WM8753_PWR1) & 0xfe3e; 1337 u16 pwr_reg = snd_soc_component_read32(component, WM8753_PWR1) & 0xfe3e;
1338 1338
1339 switch (level) { 1339 switch (level) {
1340 case SND_SOC_BIAS_ON: 1340 case SND_SOC_BIAS_ON:
1341 /* set vmid to 50k and unmute dac */ 1341 /* set vmid to 50k and unmute dac */
1342 snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x00c0); 1342 snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x00c0);
1343 break; 1343 break;
1344 case SND_SOC_BIAS_PREPARE: 1344 case SND_SOC_BIAS_PREPARE:
1345 /* Wait until fully charged */ 1345 /* Wait until fully charged */
1346 flush_delayed_work(&wm8753->charge_work); 1346 flush_delayed_work(&wm8753->charge_work);
1347 break; 1347 break;
1348 case SND_SOC_BIAS_STANDBY: 1348 case SND_SOC_BIAS_STANDBY:
1349 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 1349 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
1350 /* set vmid to 5k for quick power up */ 1350 /* set vmid to 5k for quick power up */
1351 snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x01c1); 1351 snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x01c1);
1352 schedule_delayed_work(&wm8753->charge_work, 1352 schedule_delayed_work(&wm8753->charge_work,
1353 msecs_to_jiffies(caps_charge)); 1353 msecs_to_jiffies(caps_charge));
1354 } else { 1354 } else {
1355 /* mute dac and set vmid to 500k, enable VREF */ 1355 /* mute dac and set vmid to 500k, enable VREF */
1356 snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x0141); 1356 snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x0141);
1357 } 1357 }
1358 break; 1358 break;
1359 case SND_SOC_BIAS_OFF: 1359 case SND_SOC_BIAS_OFF:
1360 cancel_delayed_work_sync(&wm8753->charge_work); 1360 cancel_delayed_work_sync(&wm8753->charge_work);
1361 snd_soc_write(codec, WM8753_PWR1, 0x0001); 1361 snd_soc_component_write(component, WM8753_PWR1, 0x0001);
1362 break; 1362 break;
1363 } 1363 }
1364 return 0; 1364 return 0;
@@ -1440,59 +1440,60 @@ static struct snd_soc_dai_driver wm8753_dai[] = {
1440}, 1440},
1441}; 1441};
1442 1442
1443static int wm8753_resume(struct snd_soc_codec *codec) 1443static int wm8753_resume(struct snd_soc_component *component)
1444{ 1444{
1445 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 1445 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
1446 1446
1447 regcache_sync(wm8753->regmap); 1447 regcache_sync(wm8753->regmap);
1448 1448
1449 return 0; 1449 return 0;
1450} 1450}
1451 1451
1452static int wm8753_probe(struct snd_soc_codec *codec) 1452static int wm8753_probe(struct snd_soc_component *component)
1453{ 1453{
1454 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 1454 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
1455 int ret; 1455 int ret;
1456 1456
1457 INIT_DELAYED_WORK(&wm8753->charge_work, wm8753_charge_work); 1457 INIT_DELAYED_WORK(&wm8753->charge_work, wm8753_charge_work);
1458 1458
1459 ret = wm8753_reset(codec); 1459 ret = wm8753_reset(component);
1460 if (ret < 0) { 1460 if (ret < 0) {
1461 dev_err(codec->dev, "Failed to issue reset: %d\n", ret); 1461 dev_err(component->dev, "Failed to issue reset: %d\n", ret);
1462 return ret; 1462 return ret;
1463 } 1463 }
1464 1464
1465 wm8753->dai_func = 0; 1465 wm8753->dai_func = 0;
1466 1466
1467 /* set the update bits */ 1467 /* set the update bits */
1468 snd_soc_update_bits(codec, WM8753_LDAC, 0x0100, 0x0100); 1468 snd_soc_component_update_bits(component, WM8753_LDAC, 0x0100, 0x0100);
1469 snd_soc_update_bits(codec, WM8753_RDAC, 0x0100, 0x0100); 1469 snd_soc_component_update_bits(component, WM8753_RDAC, 0x0100, 0x0100);
1470 snd_soc_update_bits(codec, WM8753_LADC, 0x0100, 0x0100); 1470 snd_soc_component_update_bits(component, WM8753_LADC, 0x0100, 0x0100);
1471 snd_soc_update_bits(codec, WM8753_RADC, 0x0100, 0x0100); 1471 snd_soc_component_update_bits(component, WM8753_RADC, 0x0100, 0x0100);
1472 snd_soc_update_bits(codec, WM8753_LOUT1V, 0x0100, 0x0100); 1472 snd_soc_component_update_bits(component, WM8753_LOUT1V, 0x0100, 0x0100);
1473 snd_soc_update_bits(codec, WM8753_ROUT1V, 0x0100, 0x0100); 1473 snd_soc_component_update_bits(component, WM8753_ROUT1V, 0x0100, 0x0100);
1474 snd_soc_update_bits(codec, WM8753_LOUT2V, 0x0100, 0x0100); 1474 snd_soc_component_update_bits(component, WM8753_LOUT2V, 0x0100, 0x0100);
1475 snd_soc_update_bits(codec, WM8753_ROUT2V, 0x0100, 0x0100); 1475 snd_soc_component_update_bits(component, WM8753_ROUT2V, 0x0100, 0x0100);
1476 snd_soc_update_bits(codec, WM8753_LINVOL, 0x0100, 0x0100); 1476 snd_soc_component_update_bits(component, WM8753_LINVOL, 0x0100, 0x0100);
1477 snd_soc_update_bits(codec, WM8753_RINVOL, 0x0100, 0x0100); 1477 snd_soc_component_update_bits(component, WM8753_RINVOL, 0x0100, 0x0100);
1478 1478
1479 return 0; 1479 return 0;
1480} 1480}
1481 1481
1482static const struct snd_soc_codec_driver soc_codec_dev_wm8753 = { 1482static const struct snd_soc_component_driver soc_component_dev_wm8753 = {
1483 .probe = wm8753_probe, 1483 .probe = wm8753_probe,
1484 .resume = wm8753_resume, 1484 .resume = wm8753_resume,
1485 .set_bias_level = wm8753_set_bias_level, 1485 .set_bias_level = wm8753_set_bias_level,
1486 .suspend_bias_off = true, 1486 .controls = wm8753_snd_controls,
1487 1487 .num_controls = ARRAY_SIZE(wm8753_snd_controls),
1488 .component_driver = { 1488 .dapm_widgets = wm8753_dapm_widgets,
1489 .controls = wm8753_snd_controls, 1489 .num_dapm_widgets = ARRAY_SIZE(wm8753_dapm_widgets),
1490 .num_controls = ARRAY_SIZE(wm8753_snd_controls), 1490 .dapm_routes = wm8753_dapm_routes,
1491 .dapm_widgets = wm8753_dapm_widgets, 1491 .num_dapm_routes = ARRAY_SIZE(wm8753_dapm_routes),
1492 .num_dapm_widgets = ARRAY_SIZE(wm8753_dapm_widgets), 1492 .suspend_bias_off = 1,
1493 .dapm_routes = wm8753_dapm_routes, 1493 .idle_bias_on = 1,
1494 .num_dapm_routes = ARRAY_SIZE(wm8753_dapm_routes), 1494 .use_pmdown_time = 1,
1495 }, 1495 .endianness = 1,
1496 .non_legacy_dai_naming = 1,
1496}; 1497};
1497 1498
1498static const struct of_device_id wm8753_of_match[] = { 1499static const struct of_device_id wm8753_of_match[] = {
@@ -1534,7 +1535,7 @@ static int wm8753_spi_probe(struct spi_device *spi)
1534 return ret; 1535 return ret;
1535 } 1536 }
1536 1537
1537 ret = snd_soc_register_codec(&spi->dev, &soc_codec_dev_wm8753, 1538 ret = devm_snd_soc_register_component(&spi->dev, &soc_component_dev_wm8753,
1538 wm8753_dai, ARRAY_SIZE(wm8753_dai)); 1539 wm8753_dai, ARRAY_SIZE(wm8753_dai));
1539 if (ret != 0) 1540 if (ret != 0)
1540 dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret); 1541 dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret);
@@ -1542,19 +1543,12 @@ static int wm8753_spi_probe(struct spi_device *spi)
1542 return ret; 1543 return ret;
1543} 1544}
1544 1545
1545static int wm8753_spi_remove(struct spi_device *spi)
1546{
1547 snd_soc_unregister_codec(&spi->dev);
1548 return 0;
1549}
1550
1551static struct spi_driver wm8753_spi_driver = { 1546static struct spi_driver wm8753_spi_driver = {
1552 .driver = { 1547 .driver = {
1553 .name = "wm8753", 1548 .name = "wm8753",
1554 .of_match_table = wm8753_of_match, 1549 .of_match_table = wm8753_of_match,
1555 }, 1550 },
1556 .probe = wm8753_spi_probe, 1551 .probe = wm8753_spi_probe,
1557 .remove = wm8753_spi_remove,
1558}; 1552};
1559#endif /* CONFIG_SPI_MASTER */ 1553#endif /* CONFIG_SPI_MASTER */
1560 1554
@@ -1580,7 +1574,7 @@ static int wm8753_i2c_probe(struct i2c_client *i2c,
1580 return ret; 1574 return ret;
1581 } 1575 }
1582 1576
1583 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8753, 1577 ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm8753,
1584 wm8753_dai, ARRAY_SIZE(wm8753_dai)); 1578 wm8753_dai, ARRAY_SIZE(wm8753_dai));
1585 if (ret != 0) 1579 if (ret != 0)
1586 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); 1580 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
@@ -1588,12 +1582,6 @@ static int wm8753_i2c_probe(struct i2c_client *i2c,
1588 return ret; 1582 return ret;
1589} 1583}
1590 1584
1591static int wm8753_i2c_remove(struct i2c_client *client)
1592{
1593 snd_soc_unregister_codec(&client->dev);
1594 return 0;
1595}
1596
1597static const struct i2c_device_id wm8753_i2c_id[] = { 1585static const struct i2c_device_id wm8753_i2c_id[] = {
1598 { "wm8753", 0 }, 1586 { "wm8753", 0 },
1599 { } 1587 { }
@@ -1606,7 +1594,6 @@ static struct i2c_driver wm8753_i2c_driver = {
1606 .of_match_table = wm8753_of_match, 1594 .of_match_table = wm8753_of_match,
1607 }, 1595 },
1608 .probe = wm8753_i2c_probe, 1596 .probe = wm8753_i2c_probe,
1609 .remove = wm8753_i2c_remove,
1610 .id_table = wm8753_i2c_id, 1597 .id_table = wm8753_i2c_id,
1611}; 1598};
1612#endif 1599#endif