diff options
| -rw-r--r-- | Documentation/devicetree/bindings/sound/tpa6130a2.txt | 27 | ||||
| -rw-r--r-- | sound/soc/codecs/tpa6130a2.c | 32 |
2 files changed, 50 insertions, 9 deletions
diff --git a/Documentation/devicetree/bindings/sound/tpa6130a2.txt b/Documentation/devicetree/bindings/sound/tpa6130a2.txt new file mode 100644 index 000000000000..6dfa740e4b2d --- /dev/null +++ b/Documentation/devicetree/bindings/sound/tpa6130a2.txt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | Texas Instruments - tpa6130a2 Codec module | ||
| 2 | |||
| 3 | The tpa6130a2 serial control bus communicates through I2C protocols | ||
| 4 | |||
| 5 | Required properties: | ||
| 6 | |||
| 7 | - compatible - "string" - One of: | ||
| 8 | "ti,tpa6130a2" - TPA6130A2 | ||
| 9 | "ti,tpa6140a2" - TPA6140A2 | ||
| 10 | |||
| 11 | |||
| 12 | - reg - <int> - I2C slave address | ||
| 13 | |||
| 14 | - Vdd-supply - <phandle> - power supply regulator | ||
| 15 | |||
| 16 | Optional properties: | ||
| 17 | |||
| 18 | - power-gpio - gpio pin to power the device | ||
| 19 | |||
| 20 | Example: | ||
| 21 | |||
| 22 | tpa6130a2: tpa6130a2@60 { | ||
| 23 | compatible = "ti,tpa6130a2"; | ||
| 24 | reg = <0x60>; | ||
| 25 | Vdd-supply = <&vmmc2>; | ||
| 26 | power-gpio = <&gpio4 2 GPIO_ACTIVE_HIGH>; | ||
| 27 | }; | ||
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, |
