aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2013-05-09 20:15:46 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-05-12 12:50:02 -0400
commitb871f1ad3c8a1ac2fb862f9261f14a67dc2c7b7d (patch)
tree13e2c366ab0336a85bb1aa6da8334f4f78c1c36f /sound/soc/codecs
parent24279dcee5456bb141a1ca007a3f0abe02bf91d0 (diff)
ASoC: sgtl5000: Read SGTL5000_CHIP_ID in i2c_probe()
The usual place for reading chip ID is inside i2c_probe, so move it there and also convert it to regmap. sgtl5000_enable_regulators() needs to read the chip revision, so keep the revision check there. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r--sound/soc/codecs/sgtl5000.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 327b4434b4ce..1ab356ab0f31 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -1275,7 +1275,7 @@ static int sgtl5000_replace_vddd_with_ldo(struct snd_soc_codec *codec)
1275 1275
1276static int sgtl5000_enable_regulators(struct snd_soc_codec *codec) 1276static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
1277{ 1277{
1278 u16 reg; 1278 int reg;
1279 int ret; 1279 int ret;
1280 int rev; 1280 int rev;
1281 int i; 1281 int i;
@@ -1303,23 +1303,17 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
1303 /* wait for all power rails bring up */ 1303 /* wait for all power rails bring up */
1304 udelay(10); 1304 udelay(10);
1305 1305
1306 /* read chip information */
1307 reg = snd_soc_read(codec, SGTL5000_CHIP_ID);
1308 if (((reg & SGTL5000_PARTID_MASK) >> SGTL5000_PARTID_SHIFT) !=
1309 SGTL5000_PARTID_PART_ID) {
1310 dev_err(codec->dev,
1311 "Device with ID register %x is not a sgtl5000\n", reg);
1312 ret = -ENODEV;
1313 goto err_regulator_disable;
1314 }
1315
1316 rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT;
1317 dev_info(codec->dev, "sgtl5000 revision 0x%x\n", rev);
1318
1319 /* 1306 /*
1320 * workaround for revision 0x11 and later, 1307 * workaround for revision 0x11 and later,
1321 * roll back to use internal LDO 1308 * roll back to use internal LDO
1322 */ 1309 */
1310
1311 ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, &reg);
1312 if (ret)
1313 goto err_regulator_disable;
1314
1315 rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT;
1316
1323 if (external_vddd && rev >= 0x11) { 1317 if (external_vddd && rev >= 0x11) {
1324 /* disable all regulator first */ 1318 /* disable all regulator first */
1325 regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), 1319 regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
@@ -1478,7 +1472,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1478 const struct i2c_device_id *id) 1472 const struct i2c_device_id *id)
1479{ 1473{
1480 struct sgtl5000_priv *sgtl5000; 1474 struct sgtl5000_priv *sgtl5000;
1481 int ret; 1475 int ret, reg, rev;
1482 1476
1483 sgtl5000 = devm_kzalloc(&client->dev, sizeof(struct sgtl5000_priv), 1477 sgtl5000 = devm_kzalloc(&client->dev, sizeof(struct sgtl5000_priv),
1484 GFP_KERNEL); 1478 GFP_KERNEL);
@@ -1492,6 +1486,21 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1492 return ret; 1486 return ret;
1493 } 1487 }
1494 1488
1489 /* read chip information */
1490 ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, &reg);
1491 if (ret)
1492 return ret;
1493
1494 if (((reg & SGTL5000_PARTID_MASK) >> SGTL5000_PARTID_SHIFT) !=
1495 SGTL5000_PARTID_PART_ID) {
1496 dev_err(&client->dev,
1497 "Device with ID register %x is not a sgtl5000\n", reg);
1498 return -ENODEV;
1499 }
1500
1501 rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT;
1502 dev_info(&client->dev, "sgtl5000 revision 0x%x\n", rev);
1503
1495 i2c_set_clientdata(client, sgtl5000); 1504 i2c_set_clientdata(client, sgtl5000);
1496 1505
1497 ret = snd_soc_register_codec(&client->dev, 1506 ret = snd_soc_register_codec(&client->dev,