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

ASoC: adau1701: 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 dd08102a
...@@ -298,10 +298,10 @@ static const struct sigmadsp_ops adau1701_sigmadsp_ops = { ...@@ -298,10 +298,10 @@ static const struct sigmadsp_ops adau1701_sigmadsp_ops = {
.safeload = adau1701_safeload, .safeload = adau1701_safeload,
}; };
static int adau1701_reset(struct snd_soc_codec *codec, unsigned int clkdiv, static int adau1701_reset(struct snd_soc_component *component, unsigned int clkdiv,
unsigned int rate) unsigned int rate)
{ {
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
int ret; int ret;
sigmadsp_reset(adau1701->sigmadsp); sigmadsp_reset(adau1701->sigmadsp);
...@@ -348,7 +348,7 @@ static int adau1701_reset(struct snd_soc_codec *codec, unsigned int clkdiv, ...@@ -348,7 +348,7 @@ static int adau1701_reset(struct snd_soc_codec *codec, unsigned int clkdiv,
if (clkdiv != ADAU1707_CLKDIV_UNSET) { if (clkdiv != ADAU1707_CLKDIV_UNSET) {
ret = sigmadsp_setup(adau1701->sigmadsp, rate); ret = sigmadsp_setup(adau1701->sigmadsp, rate);
if (ret) { if (ret) {
dev_warn(codec->dev, "Failed to load firmware\n"); dev_warn(component->dev, "Failed to load firmware\n");
return ret; return ret;
} }
} }
...@@ -362,10 +362,10 @@ static int adau1701_reset(struct snd_soc_codec *codec, unsigned int clkdiv, ...@@ -362,10 +362,10 @@ static int adau1701_reset(struct snd_soc_codec *codec, unsigned int clkdiv,
return 0; return 0;
} }
static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec, static int adau1701_set_capture_pcm_format(struct snd_soc_component *component,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
unsigned int mask = ADAU1701_SEROCTL_WORD_LEN_MASK; unsigned int mask = ADAU1701_SEROCTL_WORD_LEN_MASK;
unsigned int val; unsigned int val;
...@@ -403,10 +403,10 @@ static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec, ...@@ -403,10 +403,10 @@ static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec,
return 0; return 0;
} }
static int adau1701_set_playback_pcm_format(struct snd_soc_codec *codec, static int adau1701_set_playback_pcm_format(struct snd_soc_component *component,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
unsigned int val; unsigned int val;
if (adau1701->dai_fmt != SND_SOC_DAIFMT_RIGHT_J) if (adau1701->dai_fmt != SND_SOC_DAIFMT_RIGHT_J)
...@@ -435,8 +435,8 @@ static int adau1701_set_playback_pcm_format(struct snd_soc_codec *codec, ...@@ -435,8 +435,8 @@ static int adau1701_set_playback_pcm_format(struct snd_soc_codec *codec,
static int adau1701_hw_params(struct snd_pcm_substream *substream, static int adau1701_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
unsigned int clkdiv = adau1701->sysclk / params_rate(params); unsigned int clkdiv = adau1701->sysclk / params_rate(params);
unsigned int val; unsigned int val;
int ret; int ret;
...@@ -447,7 +447,7 @@ static int adau1701_hw_params(struct snd_pcm_substream *substream, ...@@ -447,7 +447,7 @@ static int adau1701_hw_params(struct snd_pcm_substream *substream,
* firmware upload. * firmware upload.
*/ */
if (clkdiv != adau1701->pll_clkdiv) { if (clkdiv != adau1701->pll_clkdiv) {
ret = adau1701_reset(codec, clkdiv, params_rate(params)); ret = adau1701_reset(component, clkdiv, params_rate(params));
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -470,16 +470,16 @@ static int adau1701_hw_params(struct snd_pcm_substream *substream, ...@@ -470,16 +470,16 @@ static int adau1701_hw_params(struct snd_pcm_substream *substream,
ADAU1701_DSPCTRL_SR_MASK, val); ADAU1701_DSPCTRL_SR_MASK, val);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
return adau1701_set_playback_pcm_format(codec, params); return adau1701_set_playback_pcm_format(component, params);
else else
return adau1701_set_capture_pcm_format(codec, params); return adau1701_set_capture_pcm_format(component, params);
} }
static int adau1701_set_dai_fmt(struct snd_soc_dai *codec_dai, static int adau1701_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;
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
unsigned int serictl = 0x00, seroctl = 0x00; unsigned int serictl = 0x00, seroctl = 0x00;
bool invert_lrclk; bool invert_lrclk;
...@@ -548,11 +548,11 @@ static int adau1701_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -548,11 +548,11 @@ static int adau1701_set_dai_fmt(struct snd_soc_dai *codec_dai,
return 0; return 0;
} }
static int adau1701_set_bias_level(struct snd_soc_codec *codec, static int adau1701_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
unsigned int mask = ADAU1701_AUXNPOW_VBPD | ADAU1701_AUXNPOW_VRPD; unsigned int mask = ADAU1701_AUXNPOW_VBPD | ADAU1701_AUXNPOW_VRPD;
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
...@@ -576,9 +576,9 @@ static int adau1701_set_bias_level(struct snd_soc_codec *codec, ...@@ -576,9 +576,9 @@ static int adau1701_set_bias_level(struct snd_soc_codec *codec,
static int adau1701_digital_mute(struct snd_soc_dai *dai, int mute) static int adau1701_digital_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
unsigned int mask = ADAU1701_DSPCTRL_DAM; unsigned int mask = ADAU1701_DSPCTRL_DAM;
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
unsigned int val; unsigned int val;
if (mute) if (mute)
...@@ -591,11 +591,11 @@ static int adau1701_digital_mute(struct snd_soc_dai *dai, int mute) ...@@ -591,11 +591,11 @@ static int adau1701_digital_mute(struct snd_soc_dai *dai, int mute)
return 0; return 0;
} }
static int adau1701_set_sysclk(struct snd_soc_codec *codec, int clk_id, static int adau1701_set_sysclk(struct snd_soc_component *component, int clk_id,
int source, unsigned int freq, int dir) int source, unsigned int freq, int dir)
{ {
unsigned int val; unsigned int val;
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
switch (clk_id) { switch (clk_id) {
case ADAU1701_CLK_SRC_OSC: case ADAU1701_CLK_SRC_OSC:
...@@ -618,7 +618,7 @@ static int adau1701_set_sysclk(struct snd_soc_codec *codec, int clk_id, ...@@ -618,7 +618,7 @@ static int adau1701_set_sysclk(struct snd_soc_codec *codec, int clk_id,
static int adau1701_startup(struct snd_pcm_substream *substream, static int adau1701_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(dai->codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(dai->component);
return sigmadsp_restrict_params(adau1701->sigmadsp, substream); return sigmadsp_restrict_params(adau1701->sigmadsp, substream);
} }
...@@ -664,20 +664,20 @@ static const struct of_device_id adau1701_dt_ids[] = { ...@@ -664,20 +664,20 @@ static const struct of_device_id adau1701_dt_ids[] = {
MODULE_DEVICE_TABLE(of, adau1701_dt_ids); MODULE_DEVICE_TABLE(of, adau1701_dt_ids);
#endif #endif
static int adau1701_probe(struct snd_soc_codec *codec) static int adau1701_probe(struct snd_soc_component *component)
{ {
int i, ret; int i, ret;
unsigned int val; unsigned int val;
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
ret = sigmadsp_attach(adau1701->sigmadsp, &codec->component); ret = sigmadsp_attach(adau1701->sigmadsp, component);
if (ret) if (ret)
return ret; return ret;
ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies),
adau1701->supplies); adau1701->supplies);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); dev_err(component->dev, "Failed to enable regulators: %d\n", ret);
return ret; return ret;
} }
...@@ -690,7 +690,7 @@ static int adau1701_probe(struct snd_soc_codec *codec) ...@@ -690,7 +690,7 @@ static int adau1701_probe(struct snd_soc_codec *codec)
adau1701->pll_clkdiv = ADAU1707_CLKDIV_UNSET; adau1701->pll_clkdiv = ADAU1707_CLKDIV_UNSET;
/* initalize with pre-configured pll mode settings */ /* initalize with pre-configured pll mode settings */
ret = adau1701_reset(codec, adau1701->pll_clkdiv, 0); ret = adau1701_reset(component, adau1701->pll_clkdiv, 0);
if (ret < 0) if (ret < 0)
goto exit_regulators_disable; goto exit_regulators_disable;
...@@ -715,22 +715,20 @@ static int adau1701_probe(struct snd_soc_codec *codec) ...@@ -715,22 +715,20 @@ static int adau1701_probe(struct snd_soc_codec *codec)
return ret; return ret;
} }
static int adau1701_remove(struct snd_soc_codec *codec) static void adau1701_remove(struct snd_soc_component *component)
{ {
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
if (gpio_is_valid(adau1701->gpio_nreset)) if (gpio_is_valid(adau1701->gpio_nreset))
gpio_set_value_cansleep(adau1701->gpio_nreset, 0); gpio_set_value_cansleep(adau1701->gpio_nreset, 0);
regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int adau1701_suspend(struct snd_soc_codec *codec) static int adau1701_suspend(struct snd_soc_component *component)
{ {
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies),
adau1701->supplies); adau1701->supplies);
...@@ -738,42 +736,41 @@ static int adau1701_suspend(struct snd_soc_codec *codec) ...@@ -738,42 +736,41 @@ static int adau1701_suspend(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int adau1701_resume(struct snd_soc_codec *codec) static int adau1701_resume(struct snd_soc_component *component)
{ {
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component);
int ret; int ret;
ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies),
adau1701->supplies); adau1701->supplies);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); dev_err(component->dev, "Failed to enable regulators: %d\n", ret);
return ret; return ret;
} }
return adau1701_reset(codec, adau1701->pll_clkdiv, 0); return adau1701_reset(component, adau1701->pll_clkdiv, 0);
} }
#else #else
#define adau1701_resume NULL #define adau1701_resume NULL
#define adau1701_suspend NULL #define adau1701_suspend NULL
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
static const struct snd_soc_codec_driver adau1701_codec_drv = { static const struct snd_soc_component_driver adau1701_component_drv = {
.probe = adau1701_probe, .probe = adau1701_probe,
.remove = adau1701_remove, .remove = adau1701_remove,
.resume = adau1701_resume, .resume = adau1701_resume,
.suspend = adau1701_suspend, .suspend = adau1701_suspend,
.set_bias_level = adau1701_set_bias_level, .set_bias_level = adau1701_set_bias_level,
.idle_bias_off = true, .controls = adau1701_controls,
.num_controls = ARRAY_SIZE(adau1701_controls),
.component_driver = { .dapm_widgets = adau1701_dapm_widgets,
.controls = adau1701_controls, .num_dapm_widgets = ARRAY_SIZE(adau1701_dapm_widgets),
.num_controls = ARRAY_SIZE(adau1701_controls), .dapm_routes = adau1701_dapm_routes,
.dapm_widgets = adau1701_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(adau1701_dapm_routes),
.num_dapm_widgets = ARRAY_SIZE(adau1701_dapm_widgets),
.dapm_routes = adau1701_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(adau1701_dapm_routes),
},
.set_sysclk = adau1701_set_sysclk, .set_sysclk = adau1701_set_sysclk,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config adau1701_regmap = { static const struct regmap_config adau1701_regmap = {
...@@ -889,7 +886,8 @@ static int adau1701_i2c_probe(struct i2c_client *client, ...@@ -889,7 +886,8 @@ static int adau1701_i2c_probe(struct i2c_client *client,
goto exit_regulators_disable; goto exit_regulators_disable;
} }
ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv, ret = devm_snd_soc_register_component(&client->dev,
&adau1701_component_drv,
&adau1701_dai, 1); &adau1701_dai, 1);
exit_regulators_disable: exit_regulators_disable:
...@@ -898,12 +896,6 @@ static int adau1701_i2c_probe(struct i2c_client *client, ...@@ -898,12 +896,6 @@ static int adau1701_i2c_probe(struct i2c_client *client,
return ret; return ret;
} }
static int adau1701_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id adau1701_i2c_id[] = { static const struct i2c_device_id adau1701_i2c_id[] = {
{ "adau1401", 0 }, { "adau1401", 0 },
{ "adau1401a", 0 }, { "adau1401a", 0 },
...@@ -919,7 +911,6 @@ static struct i2c_driver adau1701_i2c_driver = { ...@@ -919,7 +911,6 @@ static struct i2c_driver adau1701_i2c_driver = {
.of_match_table = of_match_ptr(adau1701_dt_ids), .of_match_table = of_match_ptr(adau1701_dt_ids),
}, },
.probe = adau1701_i2c_probe, .probe = adau1701_i2c_probe,
.remove = adau1701_i2c_remove,
.id_table = adau1701_i2c_id, .id_table = adau1701_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