mirror of https://gitee.com/openkylin/linux.git
ASoC: RT286: move initial settings to _i2c_probe
Move codec initial settings from asoc probe to i2c probe. Signed-off-by: Bard Liao <bardliao@realtek.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
4b21768a95
commit
61a414c412
|
@ -950,59 +950,10 @@ static irqreturn_t rt286_irq(int irq, void *data)
|
||||||
static int rt286_probe(struct snd_soc_codec *codec)
|
static int rt286_probe(struct snd_soc_codec *codec)
|
||||||
{
|
{
|
||||||
struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec);
|
struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec);
|
||||||
int i, ret;
|
|
||||||
|
|
||||||
snd_soc_write(codec, RT286_SET_AUDIO_POWER, AC_PWRST_D3);
|
|
||||||
|
|
||||||
for (i = 0; i < RT286_POWER_REG_LEN; i++)
|
|
||||||
snd_soc_write(codec,
|
|
||||||
RT286_SET_POWER(rt286_support_power_controls[i]),
|
|
||||||
AC_PWRST_D1);
|
|
||||||
|
|
||||||
if (!rt286->pdata.cbj_en) {
|
|
||||||
snd_soc_write(codec, RT286_CBJ_CTRL2, 0x0000);
|
|
||||||
snd_soc_write(codec, RT286_MIC1_DET_CTRL, 0x0816);
|
|
||||||
snd_soc_write(codec, RT286_MISC_CTRL1, 0x0000);
|
|
||||||
snd_soc_update_bits(codec,
|
|
||||||
RT286_CBJ_CTRL1, 0xf000, 0xb000);
|
|
||||||
} else {
|
|
||||||
snd_soc_update_bits(codec,
|
|
||||||
RT286_CBJ_CTRL1, 0xf000, 0x5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
if (!rt286->pdata.gpio2_en)
|
|
||||||
snd_soc_write(codec, RT286_SET_DMIC2_DEFAULT, 0x4000);
|
|
||||||
else
|
|
||||||
snd_soc_write(codec, RT286_SET_DMIC2_DEFAULT, 0);
|
|
||||||
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
/*Power down LDO2*/
|
|
||||||
snd_soc_update_bits(codec, RT286_POWER_CTRL2, 0x8, 0x0);
|
|
||||||
|
|
||||||
codec->dapm.bias_level = SND_SOC_BIAS_OFF;
|
codec->dapm.bias_level = SND_SOC_BIAS_OFF;
|
||||||
rt286->codec = codec;
|
rt286->codec = codec;
|
||||||
|
|
||||||
if (rt286->i2c->irq) {
|
|
||||||
snd_soc_update_bits(codec,
|
|
||||||
RT286_IRQ_CTRL, 0x2, 0x2);
|
|
||||||
|
|
||||||
INIT_DELAYED_WORK(&rt286->jack_detect_work,
|
|
||||||
rt286_jack_detect_work);
|
|
||||||
schedule_delayed_work(&rt286->jack_detect_work,
|
|
||||||
msecs_to_jiffies(1250));
|
|
||||||
|
|
||||||
ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq,
|
|
||||||
IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt286", rt286);
|
|
||||||
if (ret != 0) {
|
|
||||||
dev_err(codec->dev,
|
|
||||||
"Failed to reguest IRQ: %d\n", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1141,7 +1092,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
|
||||||
{
|
{
|
||||||
struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev);
|
struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev);
|
||||||
struct rt286_priv *rt286;
|
struct rt286_priv *rt286;
|
||||||
int ret;
|
int i, ret;
|
||||||
|
|
||||||
rt286 = devm_kzalloc(&i2c->dev, sizeof(*rt286),
|
rt286 = devm_kzalloc(&i2c->dev, sizeof(*rt286),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
@ -1171,6 +1122,54 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
|
||||||
if (pdata)
|
if (pdata)
|
||||||
rt286->pdata = *pdata;
|
rt286->pdata = *pdata;
|
||||||
|
|
||||||
|
regmap_write(rt286->regmap, RT286_SET_AUDIO_POWER, AC_PWRST_D3);
|
||||||
|
|
||||||
|
for (i = 0; i < RT286_POWER_REG_LEN; i++)
|
||||||
|
regmap_write(rt286->regmap,
|
||||||
|
RT286_SET_POWER(rt286_support_power_controls[i]),
|
||||||
|
AC_PWRST_D1);
|
||||||
|
|
||||||
|
if (!rt286->pdata.cbj_en) {
|
||||||
|
regmap_write(rt286->regmap, RT286_CBJ_CTRL2, 0x0000);
|
||||||
|
regmap_write(rt286->regmap, RT286_MIC1_DET_CTRL, 0x0816);
|
||||||
|
regmap_write(rt286->regmap, RT286_MISC_CTRL1, 0x0000);
|
||||||
|
regmap_update_bits(rt286->regmap,
|
||||||
|
RT286_CBJ_CTRL1, 0xf000, 0xb000);
|
||||||
|
} else {
|
||||||
|
regmap_update_bits(rt286->regmap,
|
||||||
|
RT286_CBJ_CTRL1, 0xf000, 0x5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
mdelay(10);
|
||||||
|
|
||||||
|
if (!rt286->pdata.gpio2_en)
|
||||||
|
regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0x4000);
|
||||||
|
else
|
||||||
|
regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0);
|
||||||
|
|
||||||
|
mdelay(10);
|
||||||
|
|
||||||
|
/*Power down LDO2*/
|
||||||
|
regmap_update_bits(rt286->regmap, RT286_POWER_CTRL2, 0x8, 0x0);
|
||||||
|
|
||||||
|
if (rt286->i2c->irq) {
|
||||||
|
regmap_update_bits(rt286->regmap,
|
||||||
|
RT286_IRQ_CTRL, 0x2, 0x2);
|
||||||
|
|
||||||
|
INIT_DELAYED_WORK(&rt286->jack_detect_work,
|
||||||
|
rt286_jack_detect_work);
|
||||||
|
schedule_delayed_work(&rt286->jack_detect_work,
|
||||||
|
msecs_to_jiffies(1250));
|
||||||
|
|
||||||
|
ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq,
|
||||||
|
IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt286", rt286);
|
||||||
|
if (ret != 0) {
|
||||||
|
dev_err(&i2c->dev,
|
||||||
|
"Failed to reguest IRQ: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt286,
|
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt286,
|
||||||
rt286_dai, ARRAY_SIZE(rt286_dai));
|
rt286_dai, ARRAY_SIZE(rt286_dai));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue