aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorHebbar, Gururaja <gururaja.hebbar@ti.com>2012-08-27 09:26:44 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-08-27 13:25:58 -0400
commitc24fdc886fde9ce7bda8115b9c2b338818796c65 (patch)
tree96b462c67fbf11093cf35f88cbd421c181788197 /sound
parent2a9a9c876fd6486978a24cd8bc72bd1aeb228b7b (diff)
ASoC: tlv320aic3x: Add device tree bindings
Device tree support for tlv320aic3x CODEC driver. Signed-off-by: Hebbar, Gururaja <gururaja.hebbar@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/tlv320aic3x.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 01485bd51404..5708a973a776 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -40,6 +40,7 @@
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/gpio.h> 41#include <linux/gpio.h>
42#include <linux/regulator/consumer.h> 42#include <linux/regulator/consumer.h>
43#include <linux/of_gpio.h>
43#include <linux/slab.h> 44#include <linux/slab.h>
44#include <sound/core.h> 45#include <sound/core.h>
45#include <sound/pcm.h> 46#include <sound/pcm.h>
@@ -1457,6 +1458,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
1457{ 1458{
1458 struct aic3x_pdata *pdata = i2c->dev.platform_data; 1459 struct aic3x_pdata *pdata = i2c->dev.platform_data;
1459 struct aic3x_priv *aic3x; 1460 struct aic3x_priv *aic3x;
1461 struct aic3x_setup_data *ai3x_setup;
1462 struct device_node *np = i2c->dev.of_node;
1460 int ret; 1463 int ret;
1461 1464
1462 aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); 1465 aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL);
@@ -1471,6 +1474,25 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
1471 if (pdata) { 1474 if (pdata) {
1472 aic3x->gpio_reset = pdata->gpio_reset; 1475 aic3x->gpio_reset = pdata->gpio_reset;
1473 aic3x->setup = pdata->setup; 1476 aic3x->setup = pdata->setup;
1477 } else if (np) {
1478 ai3x_setup = devm_kzalloc(&i2c->dev, sizeof(*ai3x_setup),
1479 GFP_KERNEL);
1480 if (ai3x_setup == NULL) {
1481 dev_err(&i2c->dev, "failed to create private data\n");
1482 return -ENOMEM;
1483 }
1484
1485 ret = of_get_named_gpio(np, "gpio-reset", 0);
1486 if (ret >= 0)
1487 aic3x->gpio_reset = ret;
1488 else
1489 aic3x->gpio_reset = -1;
1490
1491 if (of_property_read_u32_array(np, "ai3x-gpio-func",
1492 ai3x_setup->gpio_func, 2) >= 0) {
1493 aic3x->setup = ai3x_setup;
1494 }
1495
1474 } else { 1496 } else {
1475 aic3x->gpio_reset = -1; 1497 aic3x->gpio_reset = -1;
1476 } 1498 }
@@ -1488,11 +1510,20 @@ static int aic3x_i2c_remove(struct i2c_client *client)
1488 return 0; 1510 return 0;
1489} 1511}
1490 1512
1513#if defined(CONFIG_OF)
1514static const struct of_device_id tlv320aic3x_of_match[] = {
1515 { .compatible = "ti,tlv320aic3x", },
1516 {},
1517};
1518MODULE_DEVICE_TABLE(of, tlv320aic3x_of_match);
1519#endif
1520
1491/* machine i2c codec control layer */ 1521/* machine i2c codec control layer */
1492static struct i2c_driver aic3x_i2c_driver = { 1522static struct i2c_driver aic3x_i2c_driver = {
1493 .driver = { 1523 .driver = {
1494 .name = "tlv320aic3x-codec", 1524 .name = "tlv320aic3x-codec",
1495 .owner = THIS_MODULE, 1525 .owner = THIS_MODULE,
1526 .of_match_table = of_match_ptr(tlv320aic3x_of_match),
1496 }, 1527 },
1497 .probe = aic3x_i2c_probe, 1528 .probe = aic3x_i2c_probe,
1498 .remove = aic3x_i2c_remove, 1529 .remove = aic3x_i2c_remove,