Commit 58a6597e authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: wm8971: 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
...@@ -89,7 +89,7 @@ static const struct reg_default wm8971_reg_defaults[] = { ...@@ -89,7 +89,7 @@ static const struct reg_default wm8971_reg_defaults[] = {
{ 42, 0x0079 }, { 42, 0x0079 },
}; };
#define wm8971_reset(c) snd_soc_write(c, WM8971_RESET, 0) #define wm8971_reset(c) snd_soc_component_write(c, WM8971_RESET, 0)
/* WM8971 Controls */ /* WM8971 Controls */
static const char *wm8971_bass[] = { "Linear Control", "Adaptive Boost" }; static const char *wm8971_bass[] = { "Linear Control", "Adaptive Boost" };
...@@ -433,8 +433,8 @@ static int get_coeff(int mclk, int rate) ...@@ -433,8 +433,8 @@ static int get_coeff(int mclk, int rate)
static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8971_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 wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
switch (freq) { switch (freq) {
case 11289600: case 11289600:
...@@ -451,7 +451,7 @@ static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -451,7 +451,7 @@ static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai, static int wm8971_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 iface = 0; u16 iface = 0;
/* set master/slave audio interface */ /* set master/slave audio interface */
...@@ -502,7 +502,7 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -502,7 +502,7 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, WM8971_IFACE, iface); snd_soc_component_write(component, WM8971_IFACE, iface);
return 0; return 0;
} }
...@@ -510,10 +510,10 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -510,10 +510,10 @@ static int wm8971_pcm_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 wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
u16 iface = snd_soc_read(codec, WM8971_IFACE) & 0x1f3; u16 iface = snd_soc_component_read32(component, WM8971_IFACE) & 0x1f3;
u16 srate = snd_soc_read(codec, WM8971_SRATE) & 0x1c0; u16 srate = snd_soc_component_read32(component, WM8971_SRATE) & 0x1c0;
int coeff = get_coeff(wm8971->sysclk, params_rate(params)); int coeff = get_coeff(wm8971->sysclk, params_rate(params));
/* bit size */ /* bit size */
...@@ -532,9 +532,9 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -532,9 +532,9 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
} }
/* set iface & srate */ /* set iface & srate */
snd_soc_write(codec, WM8971_IFACE, iface); snd_soc_component_write(component, WM8971_IFACE, iface);
if (coeff >= 0) if (coeff >= 0)
snd_soc_write(codec, WM8971_SRATE, srate | snd_soc_component_write(component, WM8971_SRATE, srate |
(coeff_div[coeff].sr << 1) | coeff_div[coeff].usb); (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);
return 0; return 0;
...@@ -542,13 +542,13 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -542,13 +542,13 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
static int wm8971_mute(struct snd_soc_dai *dai, int mute) static int wm8971_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u16 mute_reg = snd_soc_read(codec, WM8971_ADCDAC) & 0xfff7; u16 mute_reg = snd_soc_component_read32(component, WM8971_ADCDAC) & 0xfff7;
if (mute) if (mute)
snd_soc_write(codec, WM8971_ADCDAC, mute_reg | 0x8); snd_soc_component_write(component, WM8971_ADCDAC, mute_reg | 0x8);
else else
snd_soc_write(codec, WM8971_ADCDAC, mute_reg); snd_soc_component_write(component, WM8971_ADCDAC, mute_reg);
return 0; return 0;
} }
...@@ -561,37 +561,37 @@ static void wm8971_charge_work(struct work_struct *work) ...@@ -561,37 +561,37 @@ static void wm8971_charge_work(struct work_struct *work)
regmap_update_bits(wm8971->regmap, WM8971_PWR1, 0x0180, 0x0100); regmap_update_bits(wm8971->regmap, WM8971_PWR1, 0x0180, 0x0100);
} }
static int wm8971_set_bias_level(struct snd_soc_codec *codec, static int wm8971_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
u16 pwr_reg = snd_soc_read(codec, WM8971_PWR1) & 0xfe3e; u16 pwr_reg = snd_soc_component_read32(component, WM8971_PWR1) & 0xfe3e;
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
/* set vmid to 50k and unmute dac */ /* set vmid to 50k and unmute dac */
snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x00c1); snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x00c1);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* Wait until fully charged */ /* Wait until fully charged */
flush_delayed_work(&wm8971->charge_work); flush_delayed_work(&wm8971->charge_work);
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) {
snd_soc_cache_sync(codec); snd_soc_component_cache_sync(component);
/* charge output caps - set vmid to 5k for quick power up */ /* charge output caps - set vmid to 5k for quick power up */
snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x01c0); snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x01c0);
queue_delayed_work(system_power_efficient_wq, queue_delayed_work(system_power_efficient_wq,
&wm8971->charge_work, msecs_to_jiffies(1000)); &wm8971->charge_work, msecs_to_jiffies(1000));
} else { } else {
/* mute dac and set vmid to 500k, enable VREF */ /* mute dac and set vmid to 500k, enable VREF */
snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x0140); snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x0140);
} }
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
cancel_delayed_work_sync(&wm8971->charge_work); cancel_delayed_work_sync(&wm8971->charge_work);
snd_soc_write(codec, WM8971_PWR1, 0x0001); snd_soc_component_write(component, WM8971_PWR1, 0x0001);
break; break;
} }
return 0; return 0;
...@@ -628,40 +628,41 @@ static struct snd_soc_dai_driver wm8971_dai = { ...@@ -628,40 +628,41 @@ static struct snd_soc_dai_driver wm8971_dai = {
.ops = &wm8971_dai_ops, .ops = &wm8971_dai_ops,
}; };
static int wm8971_probe(struct snd_soc_codec *codec) static int wm8971_probe(struct snd_soc_component *component)
{ {
struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
INIT_DELAYED_WORK(&wm8971->charge_work, wm8971_charge_work); INIT_DELAYED_WORK(&wm8971->charge_work, wm8971_charge_work);
wm8971_reset(codec); wm8971_reset(component);
/* set the update bits */ /* set the update bits */
snd_soc_update_bits(codec, WM8971_LDAC, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_LDAC, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_RDAC, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_RDAC, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_LOUT1V, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_LOUT1V, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_ROUT1V, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_ROUT1V, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_LOUT2V, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_LOUT2V, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_ROUT2V, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_ROUT2V, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_LINVOL, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_LINVOL, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_RINVOL, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_RINVOL, 0x0100, 0x0100);
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm8971 = { static const struct snd_soc_component_driver soc_component_dev_wm8971 = {
.probe = wm8971_probe, .probe = wm8971_probe,
.set_bias_level = wm8971_set_bias_level, .set_bias_level = wm8971_set_bias_level,
.suspend_bias_off = true,
.component_driver = {
.controls = wm8971_snd_controls, .controls = wm8971_snd_controls,
.num_controls = ARRAY_SIZE(wm8971_snd_controls), .num_controls = ARRAY_SIZE(wm8971_snd_controls),
.dapm_widgets = wm8971_dapm_widgets, .dapm_widgets = wm8971_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets),
.dapm_routes = wm8971_dapm_routes, .dapm_routes = wm8971_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes),
}, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config wm8971_regmap = { static const struct regmap_config wm8971_regmap = {
...@@ -691,18 +692,12 @@ static int wm8971_i2c_probe(struct i2c_client *i2c, ...@@ -691,18 +692,12 @@ static int wm8971_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8971); i2c_set_clientdata(i2c, wm8971);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8971, &wm8971_dai, 1); &soc_component_dev_wm8971, &wm8971_dai, 1);
return ret; return ret;
} }
static int wm8971_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id wm8971_i2c_id[] = { static const struct i2c_device_id wm8971_i2c_id[] = {
{ "wm8971", 0 }, { "wm8971", 0 },
{ } { }
...@@ -714,7 +709,6 @@ static struct i2c_driver wm8971_i2c_driver = { ...@@ -714,7 +709,6 @@ static struct i2c_driver wm8971_i2c_driver = {
.name = "wm8971", .name = "wm8971",
}, },
.probe = wm8971_i2c_probe, .probe = wm8971_i2c_probe,
.remove = wm8971_i2c_remove,
.id_table = wm8971_i2c_id, .id_table = wm8971_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