aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/rt286.c
diff options
context:
space:
mode:
authorBard Liao <bardliao@realtek.com>2014-07-07 04:48:38 -0400
committerMark Brown <broonie@linaro.org>2014-07-07 06:26:40 -0400
commit61a414c412886bdb98c8842c00b2f0a3d4436b12 (patch)
tree51f92b5af7563711735b88c5bcfc4aa4338e3088 /sound/soc/codecs/rt286.c
parent4b21768a95d68fe26a6a9f08ca93a7c59c13fcac (diff)
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>
Diffstat (limited to 'sound/soc/codecs/rt286.c')
-rw-r--r--sound/soc/codecs/rt286.c99
1 files changed, 49 insertions, 50 deletions
diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index 53eb7f37bb73..e6f33ab78954 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -950,59 +950,10 @@ static irqreturn_t rt286_irq(int irq, void *data)
950static int rt286_probe(struct snd_soc_codec *codec) 950static int rt286_probe(struct snd_soc_codec *codec)
951{ 951{
952 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); 952 struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec);
953 int i, ret;
954
955 snd_soc_write(codec, RT286_SET_AUDIO_POWER, AC_PWRST_D3);
956
957 for (i = 0; i < RT286_POWER_REG_LEN; i++)
958 snd_soc_write(codec,
959 RT286_SET_POWER(rt286_support_power_controls[i]),
960 AC_PWRST_D1);
961
962 if (!rt286->pdata.cbj_en) {
963 snd_soc_write(codec, RT286_CBJ_CTRL2, 0x0000);
964 snd_soc_write(codec, RT286_MIC1_DET_CTRL, 0x0816);
965 snd_soc_write(codec, RT286_MISC_CTRL1, 0x0000);
966 snd_soc_update_bits(codec,
967 RT286_CBJ_CTRL1, 0xf000, 0xb000);
968 } else {
969 snd_soc_update_bits(codec,
970 RT286_CBJ_CTRL1, 0xf000, 0x5000);
971 }
972
973 mdelay(10);
974
975 if (!rt286->pdata.gpio2_en)
976 snd_soc_write(codec, RT286_SET_DMIC2_DEFAULT, 0x4000);
977 else
978 snd_soc_write(codec, RT286_SET_DMIC2_DEFAULT, 0);
979
980 mdelay(10);
981
982 /*Power down LDO2*/
983 snd_soc_update_bits(codec, RT286_POWER_CTRL2, 0x8, 0x0);
984 953
985 codec->dapm.bias_level = SND_SOC_BIAS_OFF; 954 codec->dapm.bias_level = SND_SOC_BIAS_OFF;
986 rt286->codec = codec; 955 rt286->codec = codec;
987 956
988 if (rt286->i2c->irq) {
989 snd_soc_update_bits(codec,
990 RT286_IRQ_CTRL, 0x2, 0x2);
991
992 INIT_DELAYED_WORK(&rt286->jack_detect_work,
993 rt286_jack_detect_work);
994 schedule_delayed_work(&rt286->jack_detect_work,
995 msecs_to_jiffies(1250));
996
997 ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq,
998 IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt286", rt286);
999 if (ret != 0) {
1000 dev_err(codec->dev,
1001 "Failed to reguest IRQ: %d\n", ret);
1002 return ret;
1003 }
1004 }
1005
1006 return 0; 957 return 0;
1007} 958}
1008 959
@@ -1141,7 +1092,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
1141{ 1092{
1142 struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev); 1093 struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev);
1143 struct rt286_priv *rt286; 1094 struct rt286_priv *rt286;
1144 int ret; 1095 int i, ret;
1145 1096
1146 rt286 = devm_kzalloc(&i2c->dev, sizeof(*rt286), 1097 rt286 = devm_kzalloc(&i2c->dev, sizeof(*rt286),
1147 GFP_KERNEL); 1098 GFP_KERNEL);
@@ -1171,6 +1122,54 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
1171 if (pdata) 1122 if (pdata)
1172 rt286->pdata = *pdata; 1123 rt286->pdata = *pdata;
1173 1124
1125 regmap_write(rt286->regmap, RT286_SET_AUDIO_POWER, AC_PWRST_D3);
1126
1127 for (i = 0; i < RT286_POWER_REG_LEN; i++)
1128 regmap_write(rt286->regmap,
1129 RT286_SET_POWER(rt286_support_power_controls[i]),
1130 AC_PWRST_D1);
1131
1132 if (!rt286->pdata.cbj_en) {
1133 regmap_write(rt286->regmap, RT286_CBJ_CTRL2, 0x0000);
1134 regmap_write(rt286->regmap, RT286_MIC1_DET_CTRL, 0x0816);
1135 regmap_write(rt286->regmap, RT286_MISC_CTRL1, 0x0000);
1136 regmap_update_bits(rt286->regmap,
1137 RT286_CBJ_CTRL1, 0xf000, 0xb000);
1138 } else {
1139 regmap_update_bits(rt286->regmap,
1140 RT286_CBJ_CTRL1, 0xf000, 0x5000);
1141 }
1142
1143 mdelay(10);
1144
1145 if (!rt286->pdata.gpio2_en)
1146 regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0x4000);
1147 else
1148 regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0);
1149
1150 mdelay(10);
1151
1152 /*Power down LDO2*/
1153 regmap_update_bits(rt286->regmap, RT286_POWER_CTRL2, 0x8, 0x0);
1154
1155 if (rt286->i2c->irq) {
1156 regmap_update_bits(rt286->regmap,
1157 RT286_IRQ_CTRL, 0x2, 0x2);
1158
1159 INIT_DELAYED_WORK(&rt286->jack_detect_work,
1160 rt286_jack_detect_work);
1161 schedule_delayed_work(&rt286->jack_detect_work,
1162 msecs_to_jiffies(1250));
1163
1164 ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq,
1165 IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt286", rt286);
1166 if (ret != 0) {
1167 dev_err(&i2c->dev,
1168 "Failed to reguest IRQ: %d\n", ret);
1169 return ret;
1170 }
1171 }
1172
1174 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt286, 1173 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt286,
1175 rt286_dai, ARRAY_SIZE(rt286_dai)); 1174 rt286_dai, ARRAY_SIZE(rt286_dai));
1176 1175