Commit fd7c728d authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: alc5623: 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
...@@ -47,28 +47,28 @@ struct alc5623_priv { ...@@ -47,28 +47,28 @@ struct alc5623_priv {
unsigned int jack_det_ctrl; unsigned int jack_det_ctrl;
}; };
static inline int alc5623_reset(struct snd_soc_codec *codec) static inline int alc5623_reset(struct snd_soc_component *component)
{ {
return snd_soc_write(codec, ALC5623_RESET, 0); return snd_soc_component_write(component, ALC5623_RESET, 0);
} }
static int amp_mixer_event(struct snd_soc_dapm_widget *w, static int amp_mixer_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);
/* to power-on/off class-d amp generators/speaker */ /* to power-on/off class-d amp generators/speaker */
/* need to write to 'index-46h' register : */ /* need to write to 'index-46h' register : */
/* so write index num (here 0x46) to reg 0x6a */ /* so write index num (here 0x46) to reg 0x6a */
/* and then 0xffff/0 to reg 0x6c */ /* and then 0xffff/0 to reg 0x6c */
snd_soc_write(codec, ALC5623_HID_CTRL_INDEX, 0x46); snd_soc_component_write(component, ALC5623_HID_CTRL_INDEX, 0x46);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0xFFFF); snd_soc_component_write(component, ALC5623_HID_CTRL_DATA, 0xFFFF);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0); snd_soc_component_write(component, ALC5623_HID_CTRL_DATA, 0);
break; break;
} }
...@@ -526,7 +526,7 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, ...@@ -526,7 +526,7 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
int source, unsigned int freq_in, unsigned int freq_out) int source, unsigned int freq_in, unsigned int freq_out)
{ {
int i; int i;
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
int gbl_clk = 0, pll_div = 0; int gbl_clk = 0, pll_div = 0;
u16 reg; u16 reg;
...@@ -534,12 +534,12 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, ...@@ -534,12 +534,12 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
return -ENODEV; return -ENODEV;
/* Disable PLL power */ /* Disable PLL power */
snd_soc_update_bits(codec, ALC5623_PWR_MANAG_ADD2, snd_soc_component_update_bits(component, ALC5623_PWR_MANAG_ADD2,
ALC5623_PWR_ADD2_PLL, ALC5623_PWR_ADD2_PLL,
0); 0);
/* pll is not used in slave mode */ /* pll is not used in slave mode */
reg = snd_soc_read(codec, ALC5623_DAI_CONTROL); reg = snd_soc_component_read32(component, ALC5623_DAI_CONTROL);
if (reg & ALC5623_DAI_SDP_SLAVE_MODE) if (reg & ALC5623_DAI_SDP_SLAVE_MODE)
return 0; return 0;
...@@ -575,13 +575,13 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, ...@@ -575,13 +575,13 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
if (!pll_div) if (!pll_div)
return -EINVAL; return -EINVAL;
snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk); snd_soc_component_write(component, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
snd_soc_write(codec, ALC5623_PLL_CTRL, pll_div); snd_soc_component_write(component, ALC5623_PLL_CTRL, pll_div);
snd_soc_update_bits(codec, ALC5623_PWR_MANAG_ADD2, snd_soc_component_update_bits(component, ALC5623_PWR_MANAG_ADD2,
ALC5623_PWR_ADD2_PLL, ALC5623_PWR_ADD2_PLL,
ALC5623_PWR_ADD2_PLL); ALC5623_PWR_ADD2_PLL);
gbl_clk |= ALC5623_GBL_CLK_SYS_SOUR_SEL_PLL; gbl_clk |= ALC5623_GBL_CLK_SYS_SOUR_SEL_PLL;
snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk); snd_soc_component_write(component, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
return 0; return 0;
} }
...@@ -604,9 +604,9 @@ static const struct _coeff_div coeff_div[] = { ...@@ -604,9 +604,9 @@ static const struct _coeff_div coeff_div[] = {
{384*1, 0x0c6b}, {384*1, 0x0c6b},
}; };
static int get_coeff(struct snd_soc_codec *codec, int rate) static int get_coeff(struct snd_soc_component *component, int rate)
{ {
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
int i; int i;
for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
...@@ -622,8 +622,8 @@ static int get_coeff(struct snd_soc_codec *codec, int rate) ...@@ -622,8 +622,8 @@ static int get_coeff(struct snd_soc_codec *codec, int rate)
static int alc5623_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int alc5623_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 alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
switch (freq) { switch (freq) {
case 8192000: case 8192000:
...@@ -643,7 +643,7 @@ static int alc5623_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -643,7 +643,7 @@ static int alc5623_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int alc5623_set_dai_fmt(struct snd_soc_dai *codec_dai, static int alc5623_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 */
...@@ -695,18 +695,18 @@ static int alc5623_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -695,18 +695,18 @@ static int alc5623_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
return snd_soc_write(codec, ALC5623_DAI_CONTROL, iface); return snd_soc_component_write(component, ALC5623_DAI_CONTROL, iface);
} }
static int alc5623_pcm_hw_params(struct snd_pcm_substream *substream, static int alc5623_pcm_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 alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
int coeff, rate; int coeff, rate;
u16 iface; u16 iface;
iface = snd_soc_read(codec, ALC5623_DAI_CONTROL); iface = snd_soc_component_read32(component, ALC5623_DAI_CONTROL);
iface &= ~ALC5623_DAI_I2S_DL_MASK; iface &= ~ALC5623_DAI_I2S_DL_MASK;
/* bit size */ /* bit size */
...@@ -728,30 +728,30 @@ static int alc5623_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -728,30 +728,30 @@ static int alc5623_pcm_hw_params(struct snd_pcm_substream *substream,
} }
/* set iface & srate */ /* set iface & srate */
snd_soc_write(codec, ALC5623_DAI_CONTROL, iface); snd_soc_component_write(component, ALC5623_DAI_CONTROL, iface);
rate = params_rate(params); rate = params_rate(params);
coeff = get_coeff(codec, rate); coeff = get_coeff(component, rate);
if (coeff < 0) if (coeff < 0)
return -EINVAL; return -EINVAL;
coeff = coeff_div[coeff].regvalue; coeff = coeff_div[coeff].regvalue;
dev_dbg(codec->dev, "%s: sysclk=%d,rate=%d,coeff=0x%04x\n", dev_dbg(component->dev, "%s: sysclk=%d,rate=%d,coeff=0x%04x\n",
__func__, alc5623->sysclk, rate, coeff); __func__, alc5623->sysclk, rate, coeff);
snd_soc_write(codec, ALC5623_STEREO_AD_DA_CLK_CTRL, coeff); snd_soc_component_write(component, ALC5623_STEREO_AD_DA_CLK_CTRL, coeff);
return 0; return 0;
} }
static int alc5623_mute(struct snd_soc_dai *dai, int mute) static int alc5623_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u16 hp_mute = ALC5623_MISC_M_DAC_L_INPUT | ALC5623_MISC_M_DAC_R_INPUT; u16 hp_mute = ALC5623_MISC_M_DAC_L_INPUT | ALC5623_MISC_M_DAC_R_INPUT;
u16 mute_reg = snd_soc_read(codec, ALC5623_MISC_CTRL) & ~hp_mute; u16 mute_reg = snd_soc_component_read32(component, ALC5623_MISC_CTRL) & ~hp_mute;
if (mute) if (mute)
mute_reg |= hp_mute; mute_reg |= hp_mute;
return snd_soc_write(codec, ALC5623_MISC_CTRL, mute_reg); return snd_soc_component_write(component, ALC5623_MISC_CTRL, mute_reg);
} }
#define ALC5623_ADD2_POWER_EN (ALC5623_PWR_ADD2_VREF \ #define ALC5623_ADD2_POWER_EN (ALC5623_PWR_ADD2_VREF \
...@@ -769,60 +769,60 @@ static int alc5623_mute(struct snd_soc_dai *dai, int mute) ...@@ -769,60 +769,60 @@ static int alc5623_mute(struct snd_soc_dai *dai, int mute)
(ALC5623_PWR_ADD1_SHORT_CURR_DET_EN \ (ALC5623_PWR_ADD1_SHORT_CURR_DET_EN \
| ALC5623_PWR_ADD1_HP_OUT_AMP) | ALC5623_PWR_ADD1_HP_OUT_AMP)
static void enable_power_depop(struct snd_soc_codec *codec) static void enable_power_depop(struct snd_soc_component *component)
{ {
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
snd_soc_update_bits(codec, ALC5623_PWR_MANAG_ADD1, snd_soc_component_update_bits(component, ALC5623_PWR_MANAG_ADD1,
ALC5623_PWR_ADD1_SOFTGEN_EN, ALC5623_PWR_ADD1_SOFTGEN_EN,
ALC5623_PWR_ADD1_SOFTGEN_EN); ALC5623_PWR_ADD1_SOFTGEN_EN);
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD3, ALC5623_ADD3_POWER_EN); snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD3, ALC5623_ADD3_POWER_EN);
snd_soc_update_bits(codec, ALC5623_MISC_CTRL, snd_soc_component_update_bits(component, ALC5623_MISC_CTRL,
ALC5623_MISC_HP_DEPOP_MODE2_EN, ALC5623_MISC_HP_DEPOP_MODE2_EN,
ALC5623_MISC_HP_DEPOP_MODE2_EN); ALC5623_MISC_HP_DEPOP_MODE2_EN);
msleep(500); msleep(500);
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD2, ALC5623_ADD2_POWER_EN); snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD2, ALC5623_ADD2_POWER_EN);
/* avoid writing '1' into 5622 reserved bits */ /* avoid writing '1' into 5622 reserved bits */
if (alc5623->id == 0x22) if (alc5623->id == 0x22)
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD1, snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD1,
ALC5623_ADD1_POWER_EN_5622); ALC5623_ADD1_POWER_EN_5622);
else else
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD1, snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD1,
ALC5623_ADD1_POWER_EN); ALC5623_ADD1_POWER_EN);
/* disable HP Depop2 */ /* disable HP Depop2 */
snd_soc_update_bits(codec, ALC5623_MISC_CTRL, snd_soc_component_update_bits(component, ALC5623_MISC_CTRL,
ALC5623_MISC_HP_DEPOP_MODE2_EN, ALC5623_MISC_HP_DEPOP_MODE2_EN,
0); 0);
} }
static int alc5623_set_bias_level(struct snd_soc_codec *codec, static int alc5623_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
enable_power_depop(codec); enable_power_depop(component);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
/* everything off except vref/vmid, */ /* everything off except vref/vmid, */
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD2, snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD2,
ALC5623_PWR_ADD2_VREF); ALC5623_PWR_ADD2_VREF);
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD3, snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD3,
ALC5623_PWR_ADD3_MAIN_BIAS); ALC5623_PWR_ADD3_MAIN_BIAS);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* everything off, dac mute, inactive */ /* everything off, dac mute, inactive */
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD2, 0); snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD2, 0);
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD3, 0); snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD3, 0);
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD1, 0); snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD1, 0);
break; break;
} }
return 0; return 0;
...@@ -862,25 +862,25 @@ static struct snd_soc_dai_driver alc5623_dai = { ...@@ -862,25 +862,25 @@ static struct snd_soc_dai_driver alc5623_dai = {
.ops = &alc5623_dai_ops, .ops = &alc5623_dai_ops,
}; };
static int alc5623_suspend(struct snd_soc_codec *codec) static int alc5623_suspend(struct snd_soc_component *component)
{ {
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
regcache_cache_only(alc5623->regmap, true); regcache_cache_only(alc5623->regmap, true);
return 0; return 0;
} }
static int alc5623_resume(struct snd_soc_codec *codec) static int alc5623_resume(struct snd_soc_component *component)
{ {
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
int ret; int ret;
/* Sync reg_cache with the hardware */ /* Sync reg_cache with the hardware */
regcache_cache_only(alc5623->regmap, false); regcache_cache_only(alc5623->regmap, false);
ret = regcache_sync(alc5623->regmap); ret = regcache_sync(alc5623->regmap);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to sync register cache: %d\n", dev_err(component->dev, "Failed to sync register cache: %d\n",
ret); ret);
regcache_cache_only(alc5623->regmap, true); regcache_cache_only(alc5623->regmap, true);
return ret; return ret;
...@@ -889,41 +889,41 @@ static int alc5623_resume(struct snd_soc_codec *codec) ...@@ -889,41 +889,41 @@ static int alc5623_resume(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int alc5623_probe(struct snd_soc_codec *codec) static int alc5623_probe(struct snd_soc_component *component)
{ {
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
alc5623_reset(codec); alc5623_reset(component);
if (alc5623->add_ctrl) { if (alc5623->add_ctrl) {
snd_soc_write(codec, ALC5623_ADD_CTRL_REG, snd_soc_component_write(component, ALC5623_ADD_CTRL_REG,
alc5623->add_ctrl); alc5623->add_ctrl);
} }
if (alc5623->jack_det_ctrl) { if (alc5623->jack_det_ctrl) {
snd_soc_write(codec, ALC5623_JACK_DET_CTRL, snd_soc_component_write(component, ALC5623_JACK_DET_CTRL,
alc5623->jack_det_ctrl); alc5623->jack_det_ctrl);
} }
switch (alc5623->id) { switch (alc5623->id) {
case 0x21: case 0x21:
snd_soc_add_codec_controls(codec, alc5621_vol_snd_controls, snd_soc_add_component_controls(component, alc5621_vol_snd_controls,
ARRAY_SIZE(alc5621_vol_snd_controls)); ARRAY_SIZE(alc5621_vol_snd_controls));
break; break;
case 0x22: case 0x22:
snd_soc_add_codec_controls(codec, alc5622_vol_snd_controls, snd_soc_add_component_controls(component, alc5622_vol_snd_controls,
ARRAY_SIZE(alc5622_vol_snd_controls)); ARRAY_SIZE(alc5622_vol_snd_controls));
break; break;
case 0x23: case 0x23:
snd_soc_add_codec_controls(codec, alc5623_vol_snd_controls, snd_soc_add_component_controls(component, alc5623_vol_snd_controls,
ARRAY_SIZE(alc5623_vol_snd_controls)); ARRAY_SIZE(alc5623_vol_snd_controls));
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
snd_soc_add_codec_controls(codec, alc5623_snd_controls, snd_soc_add_component_controls(component, alc5623_snd_controls,
ARRAY_SIZE(alc5623_snd_controls)); ARRAY_SIZE(alc5623_snd_controls));
snd_soc_dapm_new_controls(dapm, alc5623_dapm_widgets, snd_soc_dapm_new_controls(dapm, alc5623_dapm_widgets,
...@@ -951,12 +951,16 @@ static int alc5623_probe(struct snd_soc_codec *codec) ...@@ -951,12 +951,16 @@ static int alc5623_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_device_alc5623 = { static const struct snd_soc_component_driver soc_component_device_alc5623 = {
.probe = alc5623_probe, .probe = alc5623_probe,
.suspend = alc5623_suspend, .suspend = alc5623_suspend,
.resume = alc5623_resume, .resume = alc5623_resume,
.set_bias_level = alc5623_set_bias_level, .set_bias_level = alc5623_set_bias_level,
.suspend_bias_off = true, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config alc5623_regmap = { static const struct regmap_config alc5623_regmap = {
...@@ -1052,20 +1056,14 @@ static int alc5623_i2c_probe(struct i2c_client *client, ...@@ -1052,20 +1056,14 @@ static int alc5623_i2c_probe(struct i2c_client *client,
i2c_set_clientdata(client, alc5623); i2c_set_clientdata(client, alc5623);
ret = snd_soc_register_codec(&client->dev, ret = devm_snd_soc_register_component(&client->dev,
&soc_codec_device_alc5623, &alc5623_dai, 1); &soc_component_device_alc5623, &alc5623_dai, 1);
if (ret != 0) if (ret != 0)
dev_err(&client->dev, "Failed to register codec: %d\n", ret); dev_err(&client->dev, "Failed to register codec: %d\n", ret);
return ret; return ret;
} }
static int alc5623_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id alc5623_i2c_table[] = { static const struct i2c_device_id alc5623_i2c_table[] = {
{"alc5621", 0x21}, {"alc5621", 0x21},
{"alc5622", 0x22}, {"alc5622", 0x22},
...@@ -1087,7 +1085,6 @@ static struct i2c_driver alc5623_i2c_driver = { ...@@ -1087,7 +1085,6 @@ static struct i2c_driver alc5623_i2c_driver = {
.of_match_table = of_match_ptr(alc5623_of_match), .of_match_table = of_match_ptr(alc5623_of_match),
}, },
.probe = alc5623_i2c_probe, .probe = alc5623_i2c_probe,
.remove = alc5623_i2c_remove,
.id_table = alc5623_i2c_table, .id_table = alc5623_i2c_table,
}; };
......
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