diff options
author | Jarkko Nikula <jhnikula@gmail.com> | 2010-04-26 08:49:14 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-04-27 06:19:23 -0400 |
commit | 07779fdd1a236145b5f5dc6916c6b84d9712b305 (patch) | |
tree | a2f3c6a45022ddd55cdfdd8f4493da52ac2eec8f /sound | |
parent | db13802e51f29c40b404038485121a3973c0947d (diff) |
ASoC: tlv320aic3x: Add basic regulator support
This patch adds the TLV320AIC3x supplies and enables all of them for the
entire lifetime of the device.
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/tlv320aic3x.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 6b74ad808a09..584bc1e67f76 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
39 | #include <linux/pm.h> | 39 | #include <linux/pm.h> |
40 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
41 | #include <linux/regulator/consumer.h> | ||
41 | #include <linux/platform_device.h> | 42 | #include <linux/platform_device.h> |
42 | #include <sound/core.h> | 43 | #include <sound/core.h> |
43 | #include <sound/pcm.h> | 44 | #include <sound/pcm.h> |
@@ -49,9 +50,18 @@ | |||
49 | 50 | ||
50 | #include "tlv320aic3x.h" | 51 | #include "tlv320aic3x.h" |
51 | 52 | ||
53 | #define AIC3X_NUM_SUPPLIES 4 | ||
54 | static const char *aic3x_supply_names[AIC3X_NUM_SUPPLIES] = { | ||
55 | "IOVDD", /* I/O Voltage */ | ||
56 | "DVDD", /* Digital Core Voltage */ | ||
57 | "AVDD", /* Analog DAC Voltage */ | ||
58 | "DRVDD", /* ADC Analog and Output Driver Voltage */ | ||
59 | }; | ||
60 | |||
52 | /* codec private data */ | 61 | /* codec private data */ |
53 | struct aic3x_priv { | 62 | struct aic3x_priv { |
54 | struct snd_soc_codec codec; | 63 | struct snd_soc_codec codec; |
64 | struct regulator_bulk_data supplies[AIC3X_NUM_SUPPLIES]; | ||
55 | unsigned int sysclk; | 65 | unsigned int sysclk; |
56 | int master; | 66 | int master; |
57 | }; | 67 | }; |
@@ -1268,6 +1278,9 @@ static int aic3x_unregister(struct aic3x_priv *aic3x) | |||
1268 | snd_soc_unregister_dai(&aic3x_dai); | 1278 | snd_soc_unregister_dai(&aic3x_dai); |
1269 | snd_soc_unregister_codec(&aic3x->codec); | 1279 | snd_soc_unregister_codec(&aic3x->codec); |
1270 | 1280 | ||
1281 | regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
1282 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
1283 | |||
1271 | kfree(aic3x); | 1284 | kfree(aic3x); |
1272 | aic3x_codec = NULL; | 1285 | aic3x_codec = NULL; |
1273 | 1286 | ||
@@ -1289,6 +1302,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
1289 | { | 1302 | { |
1290 | struct snd_soc_codec *codec; | 1303 | struct snd_soc_codec *codec; |
1291 | struct aic3x_priv *aic3x; | 1304 | struct aic3x_priv *aic3x; |
1305 | int ret, i; | ||
1292 | 1306 | ||
1293 | aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL); | 1307 | aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL); |
1294 | if (aic3x == NULL) { | 1308 | if (aic3x == NULL) { |
@@ -1304,7 +1318,30 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
1304 | 1318 | ||
1305 | i2c_set_clientdata(i2c, aic3x); | 1319 | i2c_set_clientdata(i2c, aic3x); |
1306 | 1320 | ||
1321 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | ||
1322 | aic3x->supplies[i].supply = aic3x_supply_names[i]; | ||
1323 | |||
1324 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(aic3x->supplies), | ||
1325 | aic3x->supplies); | ||
1326 | if (ret != 0) { | ||
1327 | dev_err(codec->dev, "Failed to request supplies: %d\n", ret); | ||
1328 | goto err_get; | ||
1329 | } | ||
1330 | |||
1331 | ret = regulator_bulk_enable(ARRAY_SIZE(aic3x->supplies), | ||
1332 | aic3x->supplies); | ||
1333 | if (ret != 0) { | ||
1334 | dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); | ||
1335 | goto err_enable; | ||
1336 | } | ||
1337 | |||
1307 | return aic3x_register(codec); | 1338 | return aic3x_register(codec); |
1339 | |||
1340 | err_enable: | ||
1341 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
1342 | err_get: | ||
1343 | kfree(aic3x); | ||
1344 | return ret; | ||
1308 | } | 1345 | } |
1309 | 1346 | ||
1310 | static int aic3x_i2c_remove(struct i2c_client *client) | 1347 | static int aic3x_i2c_remove(struct i2c_client *client) |