ASoC: rt5514: 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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2018-01-29 03:45:07 +00:00 committed by Mark Brown
parent 7928b2cbe5
commit 04e8262ac8
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
3 changed files with 61 additions and 69 deletions

View File

@ -474,9 +474,9 @@ static int __maybe_unused rt5514_suspend(struct device *dev)
static int __maybe_unused rt5514_resume(struct device *dev) static int __maybe_unused rt5514_resume(struct device *dev)
{ {
struct snd_soc_platform *platform = snd_soc_lookup_platform(dev); struct snd_soc_component *component = snd_soc_lookup_component(dev, DRV_NAME);
struct rt5514_dsp *rt5514_dsp = struct rt5514_dsp *rt5514_dsp =
snd_soc_platform_get_drvdata(platform); snd_soc_component_get_drvdata(component);
int irq = to_spi_device(dev)->irq; int irq = to_spi_device(dev)->irq;
u8 buf[8]; u8 buf[8];

View File

@ -327,14 +327,13 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
{ {
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
struct snd_soc_codec *codec = rt5514->codec;
const struct firmware *fw = NULL; const struct firmware *fw = NULL;
u8 buf[8]; u8 buf[8];
if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled) if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled)
return 0; return 0;
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
rt5514->dsp_enabled = ucontrol->value.integer.value[0]; rt5514->dsp_enabled = ucontrol->value.integer.value[0];
if (rt5514->dsp_enabled) { if (rt5514->dsp_enabled) {
@ -342,11 +341,11 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
!IS_ERR(rt5514->dsp_calib_clk)) { !IS_ERR(rt5514->dsp_calib_clk)) {
if (clk_set_rate(rt5514->dsp_calib_clk, if (clk_set_rate(rt5514->dsp_calib_clk,
rt5514->pdata.dsp_calib_clk_rate)) rt5514->pdata.dsp_calib_clk_rate))
dev_err(codec->dev, dev_err(component->dev,
"Can't set rate for mclk"); "Can't set rate for mclk");
if (clk_prepare_enable(rt5514->dsp_calib_clk)) if (clk_prepare_enable(rt5514->dsp_calib_clk))
dev_err(codec->dev, dev_err(component->dev,
"Can't enable dsp_calib_clk"); "Can't enable dsp_calib_clk");
rt5514_calibration(rt5514, true); rt5514_calibration(rt5514, true);
@ -357,7 +356,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
RT5514_DSP_MAPPING, RT5514_DSP_MAPPING,
(u8 *)&buf, sizeof(buf)); (u8 *)&buf, sizeof(buf));
#else #else
dev_err(codec->dev, "There is no SPI driver for" dev_err(component->dev, "There is no SPI driver for"
" loading the firmware\n"); " loading the firmware\n");
#endif #endif
rt5514->pll3_cal_value = buf[0] | buf[1] << 8 | rt5514->pll3_cal_value = buf[0] | buf[1] << 8 |
@ -369,26 +368,26 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
rt5514_enable_dsp_prepare(rt5514); rt5514_enable_dsp_prepare(rt5514);
request_firmware(&fw, RT5514_FIRMWARE1, codec->dev); request_firmware(&fw, RT5514_FIRMWARE1, component->dev);
if (fw) { if (fw) {
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) #if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
rt5514_spi_burst_write(0x4ff60000, fw->data, rt5514_spi_burst_write(0x4ff60000, fw->data,
((fw->size/8)+1)*8); ((fw->size/8)+1)*8);
#else #else
dev_err(codec->dev, "There is no SPI driver for" dev_err(component->dev, "There is no SPI driver for"
" loading the firmware\n"); " loading the firmware\n");
#endif #endif
release_firmware(fw); release_firmware(fw);
fw = NULL; fw = NULL;
} }
request_firmware(&fw, RT5514_FIRMWARE2, codec->dev); request_firmware(&fw, RT5514_FIRMWARE2, component->dev);
if (fw) { if (fw) {
#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) #if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
rt5514_spi_burst_write(0x4ffc0000, fw->data, rt5514_spi_burst_write(0x4ffc0000, fw->data,
((fw->size/8)+1)*8); ((fw->size/8)+1)*8);
#else #else
dev_err(codec->dev, "There is no SPI driver for" dev_err(component->dev, "There is no SPI driver for"
" loading the firmware\n"); " loading the firmware\n");
#endif #endif
release_firmware(fw); release_firmware(fw);
@ -492,7 +491,7 @@ static const struct snd_kcontrol_new rt5514_sto2_dmic_mux =
* Choose divider parameter that gives the highest possible DMIC frequency in * Choose divider parameter that gives the highest possible DMIC frequency in
* 1MHz - 3MHz range. * 1MHz - 3MHz range.
*/ */
static int rt5514_calc_dmic_clk(struct snd_soc_codec *codec, int rate) static int rt5514_calc_dmic_clk(struct snd_soc_component *component, int rate)
{ {
int div[] = {2, 3, 4, 8, 12, 16, 24, 32}; int div[] = {2, 3, 4, 8, 12, 16, 24, 32};
int i; int i;
@ -508,20 +507,20 @@ static int rt5514_calc_dmic_clk(struct snd_soc_codec *codec, int rate)
return i; return i;
} }
dev_warn(codec->dev, "Base clock rate %d is too high\n", rate); dev_warn(component->dev, "Base clock rate %d is too high\n", rate);
return -EINVAL; return -EINVAL;
} }
static int rt5514_set_dmic_clk(struct snd_soc_dapm_widget *w, static int rt5514_set_dmic_clk(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);
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
int idx; int idx;
idx = rt5514_calc_dmic_clk(codec, rt5514->sysclk); idx = rt5514_calc_dmic_clk(component, rt5514->sysclk);
if (idx < 0) if (idx < 0)
dev_err(codec->dev, "Failed to set DMIC clock\n"); dev_err(component->dev, "Failed to set DMIC clock\n");
else else
regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL1, regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL1,
RT5514_CLK_DMIC_OUT_SEL_MASK, RT5514_CLK_DMIC_OUT_SEL_MASK,
@ -536,8 +535,8 @@ static int rt5514_set_dmic_clk(struct snd_soc_dapm_widget *w,
static int rt5514_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int rt5514_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
if (rt5514->sysclk_src == RT5514_SCLK_S_PLL1) if (rt5514->sysclk_src == RT5514_SCLK_S_PLL1)
return 1; return 1;
@ -548,8 +547,8 @@ static int rt5514_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
static int rt5514_i2s_use_asrc(struct snd_soc_dapm_widget *source, static int rt5514_i2s_use_asrc(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
return (rt5514->sysclk > rt5514->lrck * 384); return (rt5514->sysclk > rt5514->lrck * 384);
} }
@ -751,21 +750,21 @@ static const struct snd_soc_dapm_route rt5514_dapm_routes[] = {
static int rt5514_hw_params(struct snd_pcm_substream *substream, static int rt5514_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 rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
int pre_div, bclk_ms, frame_size; int pre_div, bclk_ms, frame_size;
unsigned int val_len = 0; unsigned int val_len = 0;
rt5514->lrck = params_rate(params); rt5514->lrck = params_rate(params);
pre_div = rl6231_get_clk_info(rt5514->sysclk, rt5514->lrck); pre_div = rl6231_get_clk_info(rt5514->sysclk, rt5514->lrck);
if (pre_div < 0) { if (pre_div < 0) {
dev_err(codec->dev, "Unsupported clock setting\n"); dev_err(component->dev, "Unsupported clock setting\n");
return -EINVAL; return -EINVAL;
} }
frame_size = snd_soc_params_to_frame_size(params); frame_size = snd_soc_params_to_frame_size(params);
if (frame_size < 0) { if (frame_size < 0) {
dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); dev_err(component->dev, "Unsupported frame size: %d\n", frame_size);
return -EINVAL; return -EINVAL;
} }
@ -808,8 +807,8 @@ static int rt5514_hw_params(struct snd_pcm_substream *substream,
static int rt5514_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5514_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
unsigned int reg_val = 0; unsigned int reg_val = 0;
switch (fmt & SND_SOC_DAIFMT_INV_MASK) { switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@ -862,8 +861,8 @@ static int rt5514_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static int rt5514_set_dai_sysclk(struct snd_soc_dai *dai, static int rt5514_set_dai_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 = dai->codec; struct snd_soc_component *component = dai->component;
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
unsigned int reg_val = 0; unsigned int reg_val = 0;
if (freq == rt5514->sysclk && clk_id == rt5514->sysclk_src) if (freq == rt5514->sysclk && clk_id == rt5514->sysclk_src)
@ -879,7 +878,7 @@ static int rt5514_set_dai_sysclk(struct snd_soc_dai *dai,
break; break;
default: default:
dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); dev_err(component->dev, "Invalid clock id (%d)\n", clk_id);
return -EINVAL; return -EINVAL;
} }
@ -897,13 +896,13 @@ static int rt5514_set_dai_sysclk(struct snd_soc_dai *dai,
static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
unsigned int freq_in, unsigned int freq_out) unsigned int freq_in, unsigned int freq_out)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
struct rl6231_pll_code pll_code; struct rl6231_pll_code pll_code;
int ret; int ret;
if (!freq_in || !freq_out) { if (!freq_in || !freq_out) {
dev_dbg(codec->dev, "PLL disabled\n"); dev_dbg(component->dev, "PLL disabled\n");
rt5514->pll_in = 0; rt5514->pll_in = 0;
rt5514->pll_out = 0; rt5514->pll_out = 0;
@ -930,17 +929,17 @@ static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
break; break;
default: default:
dev_err(codec->dev, "Unknown PLL source %d\n", source); dev_err(component->dev, "Unknown PLL source %d\n", source);
return -EINVAL; return -EINVAL;
} }
ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); ret = rl6231_pll_calc(freq_in, freq_out, &pll_code);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); dev_err(component->dev, "Unsupport input clock %d\n", freq_in);
return ret; return ret;
} }
dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n",
pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code),
pll_code.n_code, pll_code.k_code); pll_code.n_code, pll_code.k_code);
@ -961,8 +960,8 @@ static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
static int rt5514_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int rt5514_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, int slot_width) unsigned int rx_mask, int slots, int slot_width)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
unsigned int val = 0, val2 = 0; unsigned int val = 0, val2 = 0;
if (rx_mask || tx_mask) if (rx_mask || tx_mask)
@ -1047,10 +1046,10 @@ static int rt5514_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
return 0; return 0;
} }
static int rt5514_set_bias_level(struct snd_soc_codec *codec, static int rt5514_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
int ret; int ret;
switch (level) { switch (level) {
@ -1058,7 +1057,7 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec,
if (IS_ERR(rt5514->mclk)) if (IS_ERR(rt5514->mclk))
break; break;
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) {
clk_disable_unprepare(rt5514->mclk); clk_disable_unprepare(rt5514->mclk);
} else { } else {
ret = clk_prepare_enable(rt5514->mclk); ret = clk_prepare_enable(rt5514->mclk);
@ -1068,7 +1067,7 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec,
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) {
/* /*
* If the DSP is enabled in start of recording, the DSP * If the DSP is enabled in start of recording, the DSP
* should be disabled, and sync back to normal recording * should be disabled, and sync back to normal recording
@ -1092,13 +1091,13 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
static int rt5514_probe(struct snd_soc_codec *codec) static int rt5514_probe(struct snd_soc_component *component)
{ {
struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
struct platform_device *pdev = container_of(codec->dev, struct platform_device *pdev = container_of(component->dev,
struct platform_device, dev); struct platform_device, dev);
rt5514->mclk = devm_clk_get(codec->dev, "mclk"); rt5514->mclk = devm_clk_get(component->dev, "mclk");
if (PTR_ERR(rt5514->mclk) == -EPROBE_DEFER) if (PTR_ERR(rt5514->mclk) == -EPROBE_DEFER)
return -EPROBE_DEFER; return -EPROBE_DEFER;
@ -1109,7 +1108,7 @@ static int rt5514_probe(struct snd_soc_codec *codec)
return -EPROBE_DEFER; return -EPROBE_DEFER;
} }
rt5514->codec = codec; rt5514->component = component;
rt5514->pll3_cal_value = 0x0078b000; rt5514->pll3_cal_value = 0x0078b000;
return 0; return 0;
@ -1162,18 +1161,18 @@ static struct snd_soc_dai_driver rt5514_dai[] = {
} }
}; };
static const struct snd_soc_codec_driver soc_codec_dev_rt5514 = { static const struct snd_soc_component_driver soc_component_dev_rt5514 = {
.probe = rt5514_probe, .probe = rt5514_probe,
.idle_bias_off = true, .set_bias_level = rt5514_set_bias_level,
.set_bias_level = rt5514_set_bias_level, .controls = rt5514_snd_controls,
.component_driver = { .num_controls = ARRAY_SIZE(rt5514_snd_controls),
.controls = rt5514_snd_controls, .dapm_widgets = rt5514_dapm_widgets,
.num_controls = ARRAY_SIZE(rt5514_snd_controls), .num_dapm_widgets = ARRAY_SIZE(rt5514_dapm_widgets),
.dapm_widgets = rt5514_dapm_widgets, .dapm_routes = rt5514_dapm_routes,
.num_dapm_widgets = ARRAY_SIZE(rt5514_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(rt5514_dapm_routes),
.dapm_routes = rt5514_dapm_routes, .use_pmdown_time = 1,
.num_dapm_routes = ARRAY_SIZE(rt5514_dapm_routes), .endianness = 1,
}, .non_legacy_dai_naming = 1,
}; };
static const struct regmap_config rt5514_i2c_regmap = { static const struct regmap_config rt5514_i2c_regmap = {
@ -1313,17 +1312,11 @@ static int rt5514_i2c_probe(struct i2c_client *i2c,
if (ret != 0) if (ret != 0)
dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5514, return devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_rt5514,
rt5514_dai, ARRAY_SIZE(rt5514_dai)); rt5514_dai, ARRAY_SIZE(rt5514_dai));
} }
static int rt5514_i2c_remove(struct i2c_client *i2c)
{
snd_soc_unregister_codec(&i2c->dev);
return 0;
}
static const struct dev_pm_ops rt5514_i2_pm_ops = { static const struct dev_pm_ops rt5514_i2_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(NULL, rt5514_i2c_resume) SET_SYSTEM_SLEEP_PM_OPS(NULL, rt5514_i2c_resume)
}; };
@ -1336,7 +1329,6 @@ static struct i2c_driver rt5514_i2c_driver = {
.pm = &rt5514_i2_pm_ops, .pm = &rt5514_i2_pm_ops,
}, },
.probe = rt5514_i2c_probe, .probe = rt5514_i2c_probe,
.remove = rt5514_i2c_remove,
.id_table = rt5514_i2c_id, .id_table = rt5514_i2c_id,
}; };
module_i2c_driver(rt5514_i2c_driver); module_i2c_driver(rt5514_i2c_driver);

View File

@ -272,7 +272,7 @@ enum {
struct rt5514_priv { struct rt5514_priv {
struct rt5514_platform_data pdata; struct rt5514_platform_data pdata;
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct regmap *i2c_regmap, *regmap; struct regmap *i2c_regmap, *regmap;
struct clk *mclk, *dsp_calib_clk; struct clk *mclk, *dsp_calib_clk;
int sysclk; int sysclk;