aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/sgtl5000.c
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2011-07-18 11:53:03 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-07-19 11:19:22 -0400
commite94a4062c88e5245fef91ceac86788ae336f755b (patch)
tree257eb60c3a9621ebb50caa352a4c4e414513beca /sound/soc/codecs/sgtl5000.c
parent1c8371d61e3a8e65fe6ef4ac535d1cd6d8ec7650 (diff)
ASoC: sgtl5000: refactor registering internal ldo
The code for registering the internal ldo was present twice. Turn it into a function instead. Also, inform the user if LDO is used now. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Tested-by: Dong Aisheng <b29396@freescale.com> Tested-by: Shawn Guo <shawn.guo@freescale.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/sgtl5000.c')
-rw-r--r--sound/soc/codecs/sgtl5000.c69
1 files changed, 31 insertions, 38 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index ff29380c9ed3..17af336892a7 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -1218,6 +1218,34 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
1218 return 0; 1218 return 0;
1219} 1219}
1220 1220
1221static int sgtl5000_replace_vddd_with_ldo(struct snd_soc_codec *codec)
1222{
1223 struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
1224 int ret;
1225
1226 /* set internal ldo to 1.2v */
1227 ret = ldo_regulator_register(codec, &ldo_init_data, LDO_VOLTAGE);
1228 if (ret) {
1229 dev_err(codec->dev,
1230 "Failed to register vddd internal supplies: %d\n", ret);
1231 return ret;
1232 }
1233
1234 sgtl5000->supplies[VDDD].supply = LDO_CONSUMER_NAME;
1235
1236 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies),
1237 sgtl5000->supplies);
1238
1239 if (ret) {
1240 ldo_regulator_remove(codec);
1241 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
1242 return ret;
1243 }
1244
1245 dev_info(codec->dev, "Using internal LDO instead of VDDD\n");
1246 return 0;
1247}
1248
1221static int sgtl5000_enable_regulators(struct snd_soc_codec *codec) 1249static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
1222{ 1250{
1223 u16 reg; 1251 u16 reg;
@@ -1235,30 +1263,9 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
1235 if (!ret) 1263 if (!ret)
1236 external_vddd = 1; 1264 external_vddd = 1;
1237 else { 1265 else {
1238 /* set internal ldo to 1.2v */ 1266 ret = sgtl5000_replace_vddd_with_ldo(codec);
1239 int voltage = LDO_VOLTAGE; 1267 if (ret)
1240
1241 ret = ldo_regulator_register(codec, &ldo_init_data, voltage);
1242 if (ret) {
1243 dev_err(codec->dev,
1244 "Failed to register vddd internal supplies: %d\n",
1245 ret);
1246 return ret;
1247 }
1248
1249 sgtl5000->supplies[VDDD].supply = LDO_CONSUMER_NAME;
1250
1251 ret = regulator_bulk_get(codec->dev,
1252 ARRAY_SIZE(sgtl5000->supplies),
1253 sgtl5000->supplies);
1254
1255 if (ret) {
1256 ldo_regulator_remove(codec);
1257 dev_err(codec->dev,
1258 "Failed to request supplies: %d\n", ret);
1259
1260 return ret; 1268 return ret;
1261 }
1262 } 1269 }
1263 1270
1264 ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies), 1271 ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies),
@@ -1287,7 +1294,6 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
1287 * roll back to use internal LDO 1294 * roll back to use internal LDO
1288 */ 1295 */
1289 if (external_vddd && rev >= 0x11) { 1296 if (external_vddd && rev >= 0x11) {
1290 int voltage = LDO_VOLTAGE;
1291 /* disable all regulator first */ 1297 /* disable all regulator first */
1292 regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), 1298 regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
1293 sgtl5000->supplies); 1299 sgtl5000->supplies);
@@ -1295,23 +1301,10 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
1295 regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), 1301 regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies),
1296 sgtl5000->supplies); 1302 sgtl5000->supplies);
1297 1303
1298 ret = ldo_regulator_register(codec, &ldo_init_data, voltage); 1304 ret = sgtl5000_replace_vddd_with_ldo(codec);
1299 if (ret) 1305 if (ret)
1300 return ret; 1306 return ret;
1301 1307
1302 sgtl5000->supplies[VDDD].supply = LDO_CONSUMER_NAME;
1303
1304 ret = regulator_bulk_get(codec->dev,
1305 ARRAY_SIZE(sgtl5000->supplies),
1306 sgtl5000->supplies);
1307 if (ret) {
1308 ldo_regulator_remove(codec);
1309 dev_err(codec->dev,
1310 "Failed to request supplies: %d\n", ret);
1311
1312 return ret;
1313 }
1314
1315 ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies), 1308 ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies),
1316 sgtl5000->supplies); 1309 sgtl5000->supplies);
1317 if (ret) 1310 if (ret)