diff options
author | Mark Brown <broonie@linaro.org> | 2013-10-24 06:24:17 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-24 06:24:17 -0400 |
commit | 856de8158303c18365c71828b9ba84c19edda0cd (patch) | |
tree | a040d4227657c0761a3e456fda043ecb78fc3612 /sound/soc | |
parent | 3caa28274e783875757a36dd4239c3269933255b (diff) | |
parent | f95a48834cb9c581eec952215666a323136f339f (diff) |
Merge remote-tracking branch 'asoc/topic/tpa6130a2' into asoc-next
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/tpa6130a2.c | 32 |
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 | }; |
467 | MODULE_DEVICE_TABLE(i2c, tpa6130a2_id); | 471 | MODULE_DEVICE_TABLE(i2c, tpa6130a2_id); |
468 | 472 | ||
473 | #if IS_ENABLED(CONFIG_OF) | ||
474 | static const struct of_device_id tpa6130a2_of_match[] = { | ||
475 | { .compatible = "ti,tpa6130a2", }, | ||
476 | { .compatible = "ti,tpa6140a2" }, | ||
477 | {}, | ||
478 | }; | ||
479 | MODULE_DEVICE_TABLE(of, tpa6130a2_of_match); | ||
480 | #endif | ||
481 | |||
469 | static struct i2c_driver tpa6130a2_i2c_driver = { | 482 | static 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, |