aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>2010-04-30 07:59:34 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-05-03 07:55:48 -0400
commit239fe55c7fe17d67403cb1e9222fcaea84248974 (patch)
tree6624833e6a92e2de5fe0ebed28e34ac6126886fa /sound/soc
parentef909d67299498010f07889bd0980c829ae78990 (diff)
ASoC: tlv320dac33: Revised module loading, and DAC33 ID read
Optimize the way how tlv320dac33 is powered uppon module and soc initialization. Also read the DAC33 ID registers, and update the reg_cache to reflect it. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/tlv320dac33.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index 329a97f6e0f8..9944721a055c 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -329,6 +329,15 @@ static void dac33_init_chip(struct snd_soc_codec *codec)
329 dac33_read_reg_cache(codec, DAC33_LINER_TO_RLO_VOL)); 329 dac33_read_reg_cache(codec, DAC33_LINER_TO_RLO_VOL));
330} 330}
331 331
332static inline void dac33_read_id(struct snd_soc_codec *codec)
333{
334 u8 reg;
335
336 dac33_read(codec, DAC33_DEVICE_ID_MSB, &reg);
337 dac33_read(codec, DAC33_DEVICE_ID_LSB, &reg);
338 dac33_read(codec, DAC33_DEVICE_REV_ID, &reg);
339}
340
332static inline void dac33_soft_power(struct snd_soc_codec *codec, int power) 341static inline void dac33_soft_power(struct snd_soc_codec *codec, int power)
333{ 342{
334 u8 reg; 343 u8 reg;
@@ -1285,9 +1294,6 @@ static int dac33_soc_probe(struct platform_device *pdev)
1285 socdev->card->codec = codec; 1294 socdev->card->codec = codec;
1286 dac33 = snd_soc_codec_get_drvdata(codec); 1295 dac33 = snd_soc_codec_get_drvdata(codec);
1287 1296
1288 /* Power up the codec */
1289 dac33_hard_power(codec, 1);
1290
1291 /* register pcms */ 1297 /* register pcms */
1292 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); 1298 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
1293 if (ret < 0) { 1299 if (ret < 0) {
@@ -1307,9 +1313,6 @@ static int dac33_soc_probe(struct platform_device *pdev)
1307 /* power on device */ 1313 /* power on device */
1308 dac33_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1314 dac33_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1309 1315
1310 /* Bias level configuration has enabled regulator an extra time */
1311 regulator_bulk_disable(ARRAY_SIZE(dac33->supplies), dac33->supplies);
1312
1313 return 0; 1316 return 0;
1314 1317
1315pcm_err: 1318pcm_err:
@@ -1459,8 +1462,6 @@ static int __devinit dac33_i2c_probe(struct i2c_client *client,
1459 goto error_gpio; 1462 goto error_gpio;
1460 } 1463 }
1461 gpio_direction_output(dac33->power_gpio, 0); 1464 gpio_direction_output(dac33->power_gpio, 0);
1462 } else {
1463 dac33->chip_power = 1;
1464 } 1465 }
1465 1466
1466 /* Check if the IRQ number is valid and request it */ 1467 /* Check if the IRQ number is valid and request it */
@@ -1498,12 +1499,14 @@ static int __devinit dac33_i2c_probe(struct i2c_client *client,
1498 goto err_get; 1499 goto err_get;
1499 } 1500 }
1500 1501
1501 ret = regulator_bulk_enable(ARRAY_SIZE(dac33->supplies), 1502 /* Read the tlv320dac33 ID registers */
1502 dac33->supplies); 1503 ret = dac33_hard_power(codec, 1);
1503 if (ret != 0) { 1504 if (ret != 0) {
1504 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); 1505 dev_err(codec->dev, "Failed to power up codec: %d\n", ret);
1505 goto err_enable; 1506 goto error_codec;
1506 } 1507 }
1508 dac33_read_id(codec);
1509 dac33_hard_power(codec, 0);
1507 1510
1508 ret = snd_soc_register_codec(codec); 1511 ret = snd_soc_register_codec(codec);
1509 if (ret != 0) { 1512 if (ret != 0) {
@@ -1518,14 +1521,9 @@ static int __devinit dac33_i2c_probe(struct i2c_client *client,
1518 goto error_codec; 1521 goto error_codec;
1519 } 1522 }
1520 1523
1521 /* Shut down the codec for now */
1522 dac33_hard_power(codec, 0);
1523
1524 return ret; 1524 return ret;
1525 1525
1526error_codec: 1526error_codec:
1527 regulator_bulk_disable(ARRAY_SIZE(dac33->supplies), dac33->supplies);
1528err_enable:
1529 regulator_bulk_free(ARRAY_SIZE(dac33->supplies), dac33->supplies); 1527 regulator_bulk_free(ARRAY_SIZE(dac33->supplies), dac33->supplies);
1530err_get: 1528err_get:
1531 if (dac33->irq >= 0) { 1529 if (dac33->irq >= 0) {
@@ -1549,14 +1547,15 @@ static int __devexit dac33_i2c_remove(struct i2c_client *client)
1549 struct tlv320dac33_priv *dac33; 1547 struct tlv320dac33_priv *dac33;
1550 1548
1551 dac33 = i2c_get_clientdata(client); 1549 dac33 = i2c_get_clientdata(client);
1552 dac33_hard_power(&dac33->codec, 0); 1550
1551 if (unlikely(dac33->chip_power))
1552 dac33_hard_power(&dac33->codec, 0);
1553 1553
1554 if (dac33->power_gpio >= 0) 1554 if (dac33->power_gpio >= 0)
1555 gpio_free(dac33->power_gpio); 1555 gpio_free(dac33->power_gpio);
1556 if (dac33->irq >= 0) 1556 if (dac33->irq >= 0)
1557 free_irq(dac33->irq, &dac33->codec); 1557 free_irq(dac33->irq, &dac33->codec);
1558 1558
1559 regulator_bulk_disable(ARRAY_SIZE(dac33->supplies), dac33->supplies);
1560 regulator_bulk_free(ARRAY_SIZE(dac33->supplies), dac33->supplies); 1559 regulator_bulk_free(ARRAY_SIZE(dac33->supplies), dac33->supplies);
1561 1560
1562 destroy_workqueue(dac33->dac33_wq); 1561 destroy_workqueue(dac33->dac33_wq);