aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorSebastian Reichel <sre@debian.org>2013-10-23 08:03:28 -0400
committerMark Brown <broonie@linaro.org>2013-10-23 11:46:39 -0400
commitf95a48834cb9c581eec952215666a323136f339f (patch)
tree7bd36ede35798b84e261244980bfbb246e34cce6 /sound/soc
parent31d141e3a666269a3b6fcccddb0351caf7454240 (diff)
ASoC: tpa6130a2: Add device tree support
Add device tree support to tpa6130a2 driver and document the bindings. Signed-off-by: Sebastian Reichel <sre@debian.org> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/tpa6130a2.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index c58bee8346ce..998555f2a8aa 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -30,6 +30,7 @@
30#include <sound/tpa6130a2-plat.h> 30#include <sound/tpa6130a2-plat.h>
31#include <sound/soc.h> 31#include <sound/soc.h>
32#include <sound/tlv.h> 32#include <sound/tlv.h>
33#include <linux/of_gpio.h>
33 34
34#include "tpa6130a2.h" 35#include "tpa6130a2.h"
35 36
@@ -364,30 +365,33 @@ static int tpa6130a2_probe(struct i2c_client *client,
364{ 365{
365 struct device *dev; 366 struct device *dev;
366 struct tpa6130a2_data *data; 367 struct tpa6130a2_data *data;
367 struct tpa6130a2_platform_data *pdata; 368 struct tpa6130a2_platform_data *pdata = client->dev.platform_data;
369 struct device_node *np = client->dev.of_node;
368 const char *regulator; 370 const char *regulator;
369 int ret; 371 int ret;
370 372
371 dev = &client->dev; 373 dev = &client->dev;
372 374
373 if (client->dev.platform_data == NULL) {
374 dev_err(dev, "Platform data not set\n");
375 dump_stack();
376 return -ENODEV;
377 }
378
379 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); 375 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
380 if (data == NULL) { 376 if (data == NULL) {
381 dev_err(dev, "Can not allocate memory\n"); 377 dev_err(dev, "Can not allocate memory\n");
382 return -ENOMEM; 378 return -ENOMEM;
383 } 379 }
384 380
381 if (pdata) {
382 data->power_gpio = pdata->power_gpio;
383 } else if (np) {
384 data->power_gpio = of_get_named_gpio(np, "power-gpio", 0);
385 } else {
386 dev_err(dev, "Platform data not set\n");
387 dump_stack();
388 return -ENODEV;
389 }
390
385 tpa6130a2_client = client; 391 tpa6130a2_client = client;
386 392
387 i2c_set_clientdata(tpa6130a2_client, data); 393 i2c_set_clientdata(tpa6130a2_client, data);
388 394
389 pdata = client->dev.platform_data;
390 data->power_gpio = pdata->power_gpio;
391 data->id = id->driver_data; 395 data->id = id->driver_data;
392 396
393 mutex_init(&data->mutex); 397 mutex_init(&data->mutex);
@@ -466,10 +470,20 @@ static const struct i2c_device_id tpa6130a2_id[] = {
466}; 470};
467MODULE_DEVICE_TABLE(i2c, tpa6130a2_id); 471MODULE_DEVICE_TABLE(i2c, tpa6130a2_id);
468 472
473#if IS_ENABLED(CONFIG_OF)
474static const struct of_device_id tpa6130a2_of_match[] = {
475 { .compatible = "ti,tpa6130a2", },
476 { .compatible = "ti,tpa6140a2" },
477 {},
478};
479MODULE_DEVICE_TABLE(of, tpa6130a2_of_match);
480#endif
481
469static struct i2c_driver tpa6130a2_i2c_driver = { 482static struct i2c_driver tpa6130a2_i2c_driver = {
470 .driver = { 483 .driver = {
471 .name = "tpa6130a2", 484 .name = "tpa6130a2",
472 .owner = THIS_MODULE, 485 .owner = THIS_MODULE,
486 .of_match_table = of_match_ptr(tpa6130a2_of_match),
473 }, 487 },
474 .probe = tpa6130a2_probe, 488 .probe = tpa6130a2_probe,
475 .remove = tpa6130a2_remove, 489 .remove = tpa6130a2_remove,