Commit 502cb3a2 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: wm8770: 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 = 1	->	.idle_bias_on = 0
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7928b2cb
...@@ -84,7 +84,7 @@ struct wm8770_priv { ...@@ -84,7 +84,7 @@ struct wm8770_priv {
struct regmap *regmap; struct regmap *regmap;
struct regulator_bulk_data supplies[WM8770_NUM_SUPPLIES]; struct regulator_bulk_data supplies[WM8770_NUM_SUPPLIES];
struct notifier_block disable_nb[WM8770_NUM_SUPPLIES]; struct notifier_block disable_nb[WM8770_NUM_SUPPLIES];
struct snd_soc_codec *codec; struct snd_soc_component *component;
int sysclk; int sysclk;
}; };
...@@ -308,14 +308,14 @@ static const struct snd_soc_dapm_route wm8770_intercon[] = { ...@@ -308,14 +308,14 @@ static const struct snd_soc_dapm_route wm8770_intercon[] = {
static int vout12supply_event(struct snd_soc_dapm_widget *w, static int vout12supply_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
snd_soc_update_bits(codec, WM8770_OUTMUX1, 0x180, 0); snd_soc_component_update_bits(component, WM8770_OUTMUX1, 0x180, 0);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, WM8770_OUTMUX1, 0x180, 0x180); snd_soc_component_update_bits(component, WM8770_OUTMUX1, 0x180, 0x180);
break; break;
} }
...@@ -325,31 +325,31 @@ static int vout12supply_event(struct snd_soc_dapm_widget *w, ...@@ -325,31 +325,31 @@ static int vout12supply_event(struct snd_soc_dapm_widget *w,
static int vout34supply_event(struct snd_soc_dapm_widget *w, static int vout34supply_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
snd_soc_update_bits(codec, WM8770_OUTMUX2, 0x180, 0); snd_soc_component_update_bits(component, WM8770_OUTMUX2, 0x180, 0);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, WM8770_OUTMUX2, 0x180, 0x180); snd_soc_component_update_bits(component, WM8770_OUTMUX2, 0x180, 0x180);
break; break;
} }
return 0; return 0;
} }
static int wm8770_reset(struct snd_soc_codec *codec) static int wm8770_reset(struct snd_soc_component *component)
{ {
return snd_soc_write(codec, WM8770_RESET, 0); return snd_soc_component_write(component, WM8770_RESET, 0);
} }
static int wm8770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int wm8770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec; struct snd_soc_component *component;
int iface, master; int iface, master;
codec = dai->codec; component = dai->component;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
...@@ -392,8 +392,8 @@ static int wm8770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -392,8 +392,8 @@ static int wm8770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, WM8770_IFACECTRL, 0xf, iface); snd_soc_component_update_bits(component, WM8770_IFACECTRL, 0xf, iface);
snd_soc_update_bits(codec, WM8770_MSTRCTRL, 0x100, master); snd_soc_component_update_bits(component, WM8770_MSTRCTRL, 0x100, master);
return 0; return 0;
} }
...@@ -411,15 +411,15 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, ...@@ -411,15 +411,15 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct wm8770_priv *wm8770; struct wm8770_priv *wm8770;
int i; int i;
int iface; int iface;
int shift; int shift;
int ratio; int ratio;
codec = dai->codec; component = dai->component;
wm8770 = snd_soc_codec_get_drvdata(codec); wm8770 = snd_soc_component_get_drvdata(component);
iface = 0; iface = 0;
switch (params_width(params)) { switch (params_width(params)) {
...@@ -450,7 +450,7 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, ...@@ -450,7 +450,7 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream,
} }
/* Only need to set MCLK/LRCLK ratio if we're master */ /* Only need to set MCLK/LRCLK ratio if we're master */
if (snd_soc_read(codec, WM8770_MSTRCTRL) & 0x100) { if (snd_soc_component_read32(component, WM8770_MSTRCTRL) & 0x100) {
for (; i < ARRAY_SIZE(mclk_ratios); ++i) { for (; i < ARRAY_SIZE(mclk_ratios); ++i) {
ratio = wm8770->sysclk / params_rate(params); ratio = wm8770->sysclk / params_rate(params);
if (ratio == mclk_ratios[i]) if (ratio == mclk_ratios[i])
...@@ -458,51 +458,51 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, ...@@ -458,51 +458,51 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream,
} }
if (i == ARRAY_SIZE(mclk_ratios)) { if (i == ARRAY_SIZE(mclk_ratios)) {
dev_err(codec->dev, dev_err(component->dev,
"Unable to configure MCLK ratio %d/%d\n", "Unable to configure MCLK ratio %d/%d\n",
wm8770->sysclk, params_rate(params)); wm8770->sysclk, params_rate(params));
return -EINVAL; return -EINVAL;
} }
dev_dbg(codec->dev, "MCLK is %dfs\n", mclk_ratios[i]); dev_dbg(component->dev, "MCLK is %dfs\n", mclk_ratios[i]);
snd_soc_update_bits(codec, WM8770_MSTRCTRL, 0x7 << shift, snd_soc_component_update_bits(component, WM8770_MSTRCTRL, 0x7 << shift,
i << shift); i << shift);
} }
snd_soc_update_bits(codec, WM8770_IFACECTRL, 0x30, iface); snd_soc_component_update_bits(component, WM8770_IFACECTRL, 0x30, iface);
return 0; return 0;
} }
static int wm8770_mute(struct snd_soc_dai *dai, int mute) static int wm8770_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec; struct snd_soc_component *component;
codec = dai->codec; component = dai->component;
return snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, return snd_soc_component_update_bits(component, WM8770_DACMUTE, 0x10,
!!mute << 4); !!mute << 4);
} }
static int wm8770_set_sysclk(struct snd_soc_dai *dai, static int wm8770_set_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct wm8770_priv *wm8770; struct wm8770_priv *wm8770;
codec = dai->codec; component = dai->component;
wm8770 = snd_soc_codec_get_drvdata(codec); wm8770 = snd_soc_component_get_drvdata(component);
wm8770->sysclk = freq; wm8770->sysclk = freq;
return 0; return 0;
} }
static int wm8770_set_bias_level(struct snd_soc_codec *codec, static int wm8770_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
int ret; int ret;
struct wm8770_priv *wm8770; struct wm8770_priv *wm8770;
wm8770 = snd_soc_codec_get_drvdata(codec); wm8770 = snd_soc_component_get_drvdata(component);
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
...@@ -510,11 +510,11 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec, ...@@ -510,11 +510,11 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies),
wm8770->supplies); wm8770->supplies);
if (ret) { if (ret) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to enable supplies: %d\n", "Failed to enable supplies: %d\n",
ret); ret);
return ret; return ret;
...@@ -523,12 +523,12 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec, ...@@ -523,12 +523,12 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec,
regcache_sync(wm8770->regmap); regcache_sync(wm8770->regmap);
/* global powerup */ /* global powerup */
snd_soc_write(codec, WM8770_PWDNCTRL, 0); snd_soc_component_write(component, WM8770_PWDNCTRL, 0);
} }
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* global powerdown */ /* global powerdown */
snd_soc_write(codec, WM8770_PWDNCTRL, 1); snd_soc_component_write(component, WM8770_PWDNCTRL, 1);
regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies),
wm8770->supplies); wm8770->supplies);
break; break;
...@@ -567,60 +567,59 @@ static struct snd_soc_dai_driver wm8770_dai = { ...@@ -567,60 +567,59 @@ static struct snd_soc_dai_driver wm8770_dai = {
.symmetric_rates = 1 .symmetric_rates = 1
}; };
static int wm8770_probe(struct snd_soc_codec *codec) static int wm8770_probe(struct snd_soc_component *component)
{ {
struct wm8770_priv *wm8770; struct wm8770_priv *wm8770;
int ret; int ret;
wm8770 = snd_soc_codec_get_drvdata(codec); wm8770 = snd_soc_component_get_drvdata(component);
wm8770->codec = codec; wm8770->component = component;
ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies),
wm8770->supplies); wm8770->supplies);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); dev_err(component->dev, "Failed to enable supplies: %d\n", ret);
return ret; return ret;
} }
ret = wm8770_reset(codec); ret = wm8770_reset(component);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to issue reset: %d\n", ret); dev_err(component->dev, "Failed to issue reset: %d\n", ret);
goto err_reg_enable; goto err_reg_enable;
} }
/* latch the volume update bits */ /* latch the volume update bits */
snd_soc_update_bits(codec, WM8770_MSDIGVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_MSDIGVOL, 0x100, 0x100);
snd_soc_update_bits(codec, WM8770_MSALGVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_MSALGVOL, 0x100, 0x100);
snd_soc_update_bits(codec, WM8770_VOUT1RVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_VOUT1RVOL, 0x100, 0x100);
snd_soc_update_bits(codec, WM8770_VOUT2RVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_VOUT2RVOL, 0x100, 0x100);
snd_soc_update_bits(codec, WM8770_VOUT3RVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_VOUT3RVOL, 0x100, 0x100);
snd_soc_update_bits(codec, WM8770_VOUT4RVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_VOUT4RVOL, 0x100, 0x100);
snd_soc_update_bits(codec, WM8770_DAC1RVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_DAC1RVOL, 0x100, 0x100);
snd_soc_update_bits(codec, WM8770_DAC2RVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_DAC2RVOL, 0x100, 0x100);
snd_soc_update_bits(codec, WM8770_DAC3RVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_DAC3RVOL, 0x100, 0x100);
snd_soc_update_bits(codec, WM8770_DAC4RVOL, 0x100, 0x100); snd_soc_component_update_bits(component, WM8770_DAC4RVOL, 0x100, 0x100);
/* mute all DACs */ /* mute all DACs */
snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, 0x10); snd_soc_component_update_bits(component, WM8770_DACMUTE, 0x10, 0x10);
err_reg_enable: err_reg_enable:
regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies);
return ret; return ret;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm8770 = { static const struct snd_soc_component_driver soc_component_dev_wm8770 = {
.probe = wm8770_probe, .probe = wm8770_probe,
.set_bias_level = wm8770_set_bias_level, .set_bias_level = wm8770_set_bias_level,
.idle_bias_off = true,
.component_driver = {
.controls = wm8770_snd_controls, .controls = wm8770_snd_controls,
.num_controls = ARRAY_SIZE(wm8770_snd_controls), .num_controls = ARRAY_SIZE(wm8770_snd_controls),
.dapm_widgets = wm8770_dapm_widgets, .dapm_widgets = wm8770_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm8770_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(wm8770_dapm_widgets),
.dapm_routes = wm8770_intercon, .dapm_routes = wm8770_intercon,
.num_dapm_routes = ARRAY_SIZE(wm8770_intercon), .num_dapm_routes = ARRAY_SIZE(wm8770_intercon),
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct of_device_id wm8770_of_match[] = { static const struct of_device_id wm8770_of_match[] = {
...@@ -682,8 +681,8 @@ static int wm8770_spi_probe(struct spi_device *spi) ...@@ -682,8 +681,8 @@ static int wm8770_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8770); spi_set_drvdata(spi, wm8770);
ret = snd_soc_register_codec(&spi->dev, ret = devm_snd_soc_register_component(&spi->dev,
&soc_codec_dev_wm8770, &wm8770_dai, 1); &soc_component_dev_wm8770, &wm8770_dai, 1);
return ret; return ret;
} }
...@@ -697,8 +696,6 @@ static int wm8770_spi_remove(struct spi_device *spi) ...@@ -697,8 +696,6 @@ static int wm8770_spi_remove(struct spi_device *spi)
regulator_unregister_notifier(wm8770->supplies[i].consumer, regulator_unregister_notifier(wm8770->supplies[i].consumer,
&wm8770->disable_nb[i]); &wm8770->disable_nb[i]);
snd_soc_unregister_codec(&spi->dev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment