diff options
-rw-r--r-- | include/sound/tlv320aic3x.h | 17 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320aic3x.c | 25 |
2 files changed, 42 insertions, 0 deletions
diff --git a/include/sound/tlv320aic3x.h b/include/sound/tlv320aic3x.h new file mode 100644 index 000000000000..b1a5f34e5cfa --- /dev/null +++ b/include/sound/tlv320aic3x.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * Platform data for Texas Instruments TLV320AIC3x codec | ||
3 | * | ||
4 | * Author: Jarkko Nikula <jhnikula@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | #ifndef __TLV320AIC3x_H__ | ||
11 | #define __TLV320AIC3x_H__ | ||
12 | |||
13 | struct aic3x_pdata { | ||
14 | int gpio_reset; /* < 0 if not used */ | ||
15 | }; | ||
16 | |||
17 | #endif \ No newline at end of file | ||
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 584bc1e67f76..d57372be7a96 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/gpio.h> | ||
41 | #include <linux/regulator/consumer.h> | 42 | #include <linux/regulator/consumer.h> |
42 | #include <linux/platform_device.h> | 43 | #include <linux/platform_device.h> |
43 | #include <sound/core.h> | 44 | #include <sound/core.h> |
@@ -47,6 +48,7 @@ | |||
47 | #include <sound/soc-dapm.h> | 48 | #include <sound/soc-dapm.h> |
48 | #include <sound/initval.h> | 49 | #include <sound/initval.h> |
49 | #include <sound/tlv.h> | 50 | #include <sound/tlv.h> |
51 | #include <sound/tlv320aic3x.h> | ||
50 | 52 | ||
51 | #include "tlv320aic3x.h" | 53 | #include "tlv320aic3x.h" |
52 | 54 | ||
@@ -64,6 +66,7 @@ struct aic3x_priv { | |||
64 | struct regulator_bulk_data supplies[AIC3X_NUM_SUPPLIES]; | 66 | struct regulator_bulk_data supplies[AIC3X_NUM_SUPPLIES]; |
65 | unsigned int sysclk; | 67 | unsigned int sysclk; |
66 | int master; | 68 | int master; |
69 | int gpio_reset; | ||
67 | }; | 70 | }; |
68 | 71 | ||
69 | /* | 72 | /* |
@@ -1278,6 +1281,10 @@ static int aic3x_unregister(struct aic3x_priv *aic3x) | |||
1278 | snd_soc_unregister_dai(&aic3x_dai); | 1281 | snd_soc_unregister_dai(&aic3x_dai); |
1279 | snd_soc_unregister_codec(&aic3x->codec); | 1282 | snd_soc_unregister_codec(&aic3x->codec); |
1280 | 1283 | ||
1284 | if (aic3x->gpio_reset >= 0) { | ||
1285 | gpio_set_value(aic3x->gpio_reset, 0); | ||
1286 | gpio_free(aic3x->gpio_reset); | ||
1287 | } | ||
1281 | regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | 1288 | regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); |
1282 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | 1289 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); |
1283 | 1290 | ||
@@ -1302,6 +1309,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
1302 | { | 1309 | { |
1303 | struct snd_soc_codec *codec; | 1310 | struct snd_soc_codec *codec; |
1304 | struct aic3x_priv *aic3x; | 1311 | struct aic3x_priv *aic3x; |
1312 | struct aic3x_pdata *pdata = i2c->dev.platform_data; | ||
1305 | int ret, i; | 1313 | int ret, i; |
1306 | 1314 | ||
1307 | aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL); | 1315 | aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL); |
@@ -1318,6 +1326,15 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
1318 | 1326 | ||
1319 | i2c_set_clientdata(i2c, aic3x); | 1327 | i2c_set_clientdata(i2c, aic3x); |
1320 | 1328 | ||
1329 | aic3x->gpio_reset = -1; | ||
1330 | if (pdata && pdata->gpio_reset >= 0) { | ||
1331 | ret = gpio_request(pdata->gpio_reset, "tlv320aic3x reset"); | ||
1332 | if (ret != 0) | ||
1333 | goto err_gpio; | ||
1334 | aic3x->gpio_reset = pdata->gpio_reset; | ||
1335 | gpio_direction_output(aic3x->gpio_reset, 0); | ||
1336 | } | ||
1337 | |||
1321 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | 1338 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) |
1322 | aic3x->supplies[i].supply = aic3x_supply_names[i]; | 1339 | aic3x->supplies[i].supply = aic3x_supply_names[i]; |
1323 | 1340 | ||
@@ -1335,11 +1352,19 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
1335 | goto err_enable; | 1352 | goto err_enable; |
1336 | } | 1353 | } |
1337 | 1354 | ||
1355 | if (aic3x->gpio_reset >= 0) { | ||
1356 | udelay(1); | ||
1357 | gpio_set_value(aic3x->gpio_reset, 1); | ||
1358 | } | ||
1359 | |||
1338 | return aic3x_register(codec); | 1360 | return aic3x_register(codec); |
1339 | 1361 | ||
1340 | err_enable: | 1362 | err_enable: |
1341 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | 1363 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); |
1342 | err_get: | 1364 | err_get: |
1365 | if (aic3x->gpio_reset >= 0) | ||
1366 | gpio_free(aic3x->gpio_reset); | ||
1367 | err_gpio: | ||
1343 | kfree(aic3x); | 1368 | kfree(aic3x); |
1344 | return ret; | 1369 | return ret; |
1345 | } | 1370 | } |