Commit 4bf8ae83 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: wm8523: 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: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7928b2cb
...@@ -125,14 +125,14 @@ static const struct { ...@@ -125,14 +125,14 @@ static const struct {
static int wm8523_startup(struct snd_pcm_substream *substream, static int wm8523_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
/* The set of sample rates that can be supported depends on the /* The set of sample rates that can be supported depends on the
* MCLK supplied to the CODEC - enforce this. * MCLK supplied to the CODEC - enforce this.
*/ */
if (!wm8523->sysclk) { if (!wm8523->sysclk) {
dev_err(codec->dev, dev_err(component->dev,
"No MCLK configured, call set_sysclk() on init\n"); "No MCLK configured, call set_sysclk() on init\n");
return -EINVAL; return -EINVAL;
} }
...@@ -148,11 +148,11 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, ...@@ -148,11 +148,11 @@ static int wm8523_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 = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
int i; int i;
u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1); u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1);
u16 aifctrl2 = snd_soc_read(codec, WM8523_AIF_CTRL2); u16 aifctrl2 = snd_soc_component_read32(component, WM8523_AIF_CTRL2);
/* Find a supported LRCLK ratio */ /* Find a supported LRCLK ratio */
for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) { for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
...@@ -163,7 +163,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, ...@@ -163,7 +163,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
/* Should never happen, should be handled by constraints */ /* Should never happen, should be handled by constraints */
if (i == ARRAY_SIZE(lrclk_ratios)) { if (i == ARRAY_SIZE(lrclk_ratios)) {
dev_err(codec->dev, "MCLK/fs ratio %d unsupported\n", dev_err(component->dev, "MCLK/fs ratio %d unsupported\n",
wm8523->sysclk / params_rate(params)); wm8523->sysclk / params_rate(params));
return -EINVAL; return -EINVAL;
} }
...@@ -178,7 +178,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, ...@@ -178,7 +178,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
break; break;
if (i == ARRAY_SIZE(bclk_ratios)) { if (i == ARRAY_SIZE(bclk_ratios)) {
dev_err(codec->dev, dev_err(component->dev,
"No matching BCLK/fs ratio for word length %d\n", "No matching BCLK/fs ratio for word length %d\n",
params_width(params)); params_width(params));
return -EINVAL; return -EINVAL;
...@@ -203,8 +203,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, ...@@ -203,8 +203,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
break; break;
} }
snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1); snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1);
snd_soc_write(codec, WM8523_AIF_CTRL2, aifctrl2); snd_soc_component_write(component, WM8523_AIF_CTRL2, aifctrl2);
return 0; return 0;
} }
...@@ -212,8 +212,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, ...@@ -212,8 +212,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
unsigned int val; unsigned int val;
int i; int i;
...@@ -239,13 +239,13 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -239,13 +239,13 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
case 96000: case 96000:
case 176400: case 176400:
case 192000: case 192000:
dev_dbg(codec->dev, "Supported sample rate: %dHz\n", dev_dbg(component->dev, "Supported sample rate: %dHz\n",
val); val);
wm8523->rate_constraint_list[i] = val; wm8523->rate_constraint_list[i] = val;
wm8523->rate_constraint.count++; wm8523->rate_constraint.count++;
break; break;
default: default:
dev_dbg(codec->dev, "Skipping sample rate: %dHz\n", dev_dbg(component->dev, "Skipping sample rate: %dHz\n",
val); val);
} }
} }
...@@ -261,8 +261,8 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -261,8 +261,8 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai, static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1); u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1);
aifctrl1 &= ~(WM8523_BCLK_INV_MASK | WM8523_LRCLK_INV_MASK | aifctrl1 &= ~(WM8523_BCLK_INV_MASK | WM8523_LRCLK_INV_MASK |
WM8523_FMT_MASK | WM8523_AIF_MSTR_MASK); WM8523_FMT_MASK | WM8523_AIF_MSTR_MASK);
...@@ -312,15 +312,15 @@ static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -312,15 +312,15 @@ static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1); snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1);
return 0; return 0;
} }
static int wm8523_set_bias_level(struct snd_soc_codec *codec, static int wm8523_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
int ret; int ret;
switch (level) { switch (level) {
...@@ -329,16 +329,16 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec, ...@@ -329,16 +329,16 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* Full power on */ /* Full power on */
snd_soc_update_bits(codec, WM8523_PSCTRL1, snd_soc_component_update_bits(component, WM8523_PSCTRL1,
WM8523_SYS_ENA_MASK, 3); WM8523_SYS_ENA_MASK, 3);
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(wm8523->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies),
wm8523->supplies); wm8523->supplies);
if (ret != 0) { if (ret != 0) {
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;
...@@ -348,21 +348,21 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec, ...@@ -348,21 +348,21 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
regcache_sync(wm8523->regmap); regcache_sync(wm8523->regmap);
/* Initial power up */ /* Initial power up */
snd_soc_update_bits(codec, WM8523_PSCTRL1, snd_soc_component_update_bits(component, WM8523_PSCTRL1,
WM8523_SYS_ENA_MASK, 1); WM8523_SYS_ENA_MASK, 1);
msleep(100); msleep(100);
} }
/* Power up to mute */ /* Power up to mute */
snd_soc_update_bits(codec, WM8523_PSCTRL1, snd_soc_component_update_bits(component, WM8523_PSCTRL1,
WM8523_SYS_ENA_MASK, 2); WM8523_SYS_ENA_MASK, 2);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* The chip runs through the power down sequence for us. */ /* The chip runs through the power down sequence for us. */
snd_soc_update_bits(codec, WM8523_PSCTRL1, snd_soc_component_update_bits(component, WM8523_PSCTRL1,
WM8523_SYS_ENA_MASK, 0); WM8523_SYS_ENA_MASK, 0);
msleep(100); msleep(100);
...@@ -397,35 +397,36 @@ static struct snd_soc_dai_driver wm8523_dai = { ...@@ -397,35 +397,36 @@ static struct snd_soc_dai_driver wm8523_dai = {
.ops = &wm8523_dai_ops, .ops = &wm8523_dai_ops,
}; };
static int wm8523_probe(struct snd_soc_codec *codec) static int wm8523_probe(struct snd_soc_component *component)
{ {
struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0];
wm8523->rate_constraint.count = wm8523->rate_constraint.count =
ARRAY_SIZE(wm8523->rate_constraint_list); ARRAY_SIZE(wm8523->rate_constraint_list);
/* Change some default settings - latch VU and enable ZC */ /* Change some default settings - latch VU and enable ZC */
snd_soc_update_bits(codec, WM8523_DAC_GAINR, snd_soc_component_update_bits(component, WM8523_DAC_GAINR,
WM8523_DACR_VU, WM8523_DACR_VU); WM8523_DACR_VU, WM8523_DACR_VU);
snd_soc_update_bits(codec, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC); snd_soc_component_update_bits(component, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC);
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm8523 = { static const struct snd_soc_component_driver soc_component_dev_wm8523 = {
.probe = wm8523_probe, .probe = wm8523_probe,
.set_bias_level = wm8523_set_bias_level, .set_bias_level = wm8523_set_bias_level,
.suspend_bias_off = true, .controls = wm8523_controls,
.num_controls = ARRAY_SIZE(wm8523_controls),
.component_driver = { .dapm_widgets = wm8523_dapm_widgets,
.controls = wm8523_controls, .num_dapm_widgets = ARRAY_SIZE(wm8523_dapm_widgets),
.num_controls = ARRAY_SIZE(wm8523_controls), .dapm_routes = wm8523_dapm_routes,
.dapm_widgets = wm8523_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(wm8523_dapm_routes),
.num_dapm_widgets = ARRAY_SIZE(wm8523_dapm_widgets), .suspend_bias_off = 1,
.dapm_routes = wm8523_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(wm8523_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct of_device_id wm8523_of_match[] = { static const struct of_device_id wm8523_of_match[] = {
...@@ -511,8 +512,8 @@ static int wm8523_i2c_probe(struct i2c_client *i2c, ...@@ -511,8 +512,8 @@ static int wm8523_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8523); i2c_set_clientdata(i2c, wm8523);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8523, &wm8523_dai, 1); &soc_component_dev_wm8523, &wm8523_dai, 1);
return ret; return ret;
...@@ -521,12 +522,6 @@ static int wm8523_i2c_probe(struct i2c_client *i2c, ...@@ -521,12 +522,6 @@ static int wm8523_i2c_probe(struct i2c_client *i2c,
return ret; return ret;
} }
static int wm8523_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id wm8523_i2c_id[] = { static const struct i2c_device_id wm8523_i2c_id[] = {
{ "wm8523", 0 }, { "wm8523", 0 },
{ } { }
...@@ -539,7 +534,6 @@ static struct i2c_driver wm8523_i2c_driver = { ...@@ -539,7 +534,6 @@ static struct i2c_driver wm8523_i2c_driver = {
.of_match_table = wm8523_of_match, .of_match_table = wm8523_of_match,
}, },
.probe = wm8523_i2c_probe, .probe = wm8523_i2c_probe,
.remove = wm8523_i2c_remove,
.id_table = wm8523_i2c_id, .id_table = wm8523_i2c_id,
}; };
......
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