aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2013-05-23 09:46:05 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-05-25 10:34:45 -0400
commit04561eacaa6ccd1988e468cdcbf4acc475ae2221 (patch)
tree5071311409468f1ecaf4dbfde985f2827755c7ee
parent47f5b692e04a8d7989ee14591a61be26e340a17b (diff)
ASoC: codecs: adau1701: add DT bindings
Apart from pure matching, the bindings also support setting the the reset gpio line. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--Documentation/devicetree/bindings/sound/adi,adau1701.txt23
-rw-r--r--sound/soc/codecs/adau1701.c35
2 files changed, 57 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/sound/adi,adau1701.txt b/Documentation/devicetree/bindings/sound/adi,adau1701.txt
new file mode 100644
index 000000000000..3afeda77b5b9
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/adi,adau1701.txt
@@ -0,0 +1,23 @@
1Analog Devices ADAU1701
2
3Required properties:
4
5 - compatible: Should contain "adi,adau1701"
6 - reg: The i2c address. Value depends on the state of ADDR0
7 and ADDR1, as wired in hardware.
8
9Optional properties:
10
11 - reset-gpio: A GPIO spec to define which pin is connected to the
12 chip's !RESET pin. If specified, the driver will
13 assert a hardware reset at probe time.
14
15Examples:
16
17 i2c_bus {
18 adau1701@34 {
19 compatible = "adi,adau1701";
20 reg = <0x34>;
21 reset-gpio = <&gpio 23 0>;
22 };
23 };
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
index 95e1677665e9..3fc176387351 100644
--- a/sound/soc/codecs/adau1701.c
+++ b/sound/soc/codecs/adau1701.c
@@ -13,6 +13,9 @@
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/of.h>
17#include <linux/of_gpio.h>
18#include <linux/of_device.h>
16#include <sound/core.h> 19#include <sound/core.h>
17#include <sound/pcm.h> 20#include <sound/pcm.h>
18#include <sound/pcm_params.h> 21#include <sound/pcm_params.h>
@@ -452,6 +455,14 @@ static struct snd_soc_dai_driver adau1701_dai = {
452 .symmetric_rates = 1, 455 .symmetric_rates = 1,
453}; 456};
454 457
458#ifdef CONFIG_OF
459static const struct of_device_id adau1701_dt_ids[] = {
460 { .compatible = "adi,adau1701", },
461 { }
462};
463MODULE_DEVICE_TABLE(of, adau1701_dt_ids);
464#endif
465
455static int adau1701_probe(struct snd_soc_codec *codec) 466static int adau1701_probe(struct snd_soc_codec *codec)
456{ 467{
457 int ret; 468 int ret;
@@ -494,12 +505,33 @@ static int adau1701_i2c_probe(struct i2c_client *client,
494 const struct i2c_device_id *id) 505 const struct i2c_device_id *id)
495{ 506{
496 struct adau1701 *adau1701; 507 struct adau1701 *adau1701;
508 struct device *dev = &client->dev;
509 int gpio_nreset = -EINVAL;
497 int ret; 510 int ret;
498 511
499 adau1701 = devm_kzalloc(&client->dev, sizeof(*adau1701), GFP_KERNEL); 512 adau1701 = devm_kzalloc(dev, sizeof(*adau1701), GFP_KERNEL);
500 if (!adau1701) 513 if (!adau1701)
501 return -ENOMEM; 514 return -ENOMEM;
502 515
516 if (dev->of_node) {
517 gpio_nreset = of_get_named_gpio(dev->of_node, "reset-gpio", 0);
518 if (gpio_nreset < 0 && gpio_nreset != -ENOENT)
519 return gpio_nreset;
520 }
521
522 if (gpio_is_valid(gpio_nreset)) {
523 ret = devm_gpio_request_one(dev, gpio_nreset, GPIOF_OUT_INIT_LOW,
524 "ADAU1701 Reset");
525 if (ret < 0)
526 return ret;
527
528 /* minimum reset time is 20ns */
529 udelay(1);
530 gpio_set_value(gpio_nreset, 1);
531 /* power-up time may be as long as 85ms */
532 mdelay(85);
533 }
534
503 i2c_set_clientdata(client, adau1701); 535 i2c_set_clientdata(client, adau1701);
504 ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv, 536 ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv,
505 &adau1701_dai, 1); 537 &adau1701_dai, 1);
@@ -522,6 +554,7 @@ static struct i2c_driver adau1701_i2c_driver = {
522 .driver = { 554 .driver = {
523 .name = "adau1701", 555 .name = "adau1701",
524 .owner = THIS_MODULE, 556 .owner = THIS_MODULE,
557 .of_match_table = of_match_ptr(adau1701_dt_ids),
525 }, 558 },
526 .probe = adau1701_i2c_probe, 559 .probe = adau1701_i2c_probe,
527 .remove = adau1701_i2c_remove, 560 .remove = adau1701_i2c_remove,