aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2012-09-27 19:36:44 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-28 09:12:09 -0400
commita31ebc349dade4e6a7a27e88669f20dbc6f8a3b8 (patch)
tree4c927a8f6e4a7be26f6776f332ba995801e2f17e
parenteb4d5fc1f0ce89e3d5b072c594a1e213a0e05881 (diff)
ALSA: ASoC: add DT bindings for CS4271
Apart from pure matching, the bindings also support setting the the reset gpio line. Signed-off-by: Daniel Mack <zonque@gmail.com> Cc: Alexander Sverdlin <subaparts@yandex.ru> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--Documentation/devicetree/bindings/sound/cs4271.txt36
-rw-r--r--sound/soc/codecs/cs4271.c24
2 files changed, 57 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/sound/cs4271.txt b/Documentation/devicetree/bindings/sound/cs4271.txt
new file mode 100644
index 000000000000..c81b5fd5a5bc
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/cs4271.txt
@@ -0,0 +1,36 @@
1Cirrus Logic CS4271 DT bindings
2
3This driver supports both the I2C and the SPI bus.
4
5Required properties:
6
7 - compatible: "cirrus,cs4271"
8
9For required properties on SPI, please consult
10Documentation/devicetree/bindings/spi/spi-bus.txt
11
12Required properties on I2C:
13
14 - reg: the i2c address
15
16
17Optional properties:
18
19 - reset-gpio: a GPIO spec to define which pin is connected to the chip's
20 !RESET pin
21
22Examples:
23
24 codec_i2c: cs4271@10 {
25 compatible = "cirrus,cs4271";
26 reg = <0x10>;
27 reset-gpio = <&gpio 23 0>;
28 };
29
30 codec_spi: cs4271@0 {
31 compatible = "cirrus,cs4271";
32 reg = <0x0>;
33 reset-gpio = <&gpio 23 0>;
34 spi-max-frequency = <6000000>;
35 };
36
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index 9eb01d7d58a3..f994af34f552 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -22,12 +22,14 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <sound/pcm.h>
26#include <sound/soc.h>
27#include <sound/tlv.h>
28#include <linux/gpio.h> 25#include <linux/gpio.h>
29#include <linux/i2c.h> 26#include <linux/i2c.h>
30#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/of_device.h>
29#include <linux/of_gpio.h>
30#include <sound/pcm.h>
31#include <sound/soc.h>
32#include <sound/tlv.h>
31#include <sound/cs4271.h> 33#include <sound/cs4271.h>
32 34
33#define CS4271_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ 35#define CS4271_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
@@ -458,6 +460,14 @@ static int cs4271_soc_resume(struct snd_soc_codec *codec)
458#define cs4271_soc_resume NULL 460#define cs4271_soc_resume NULL
459#endif /* CONFIG_PM */ 461#endif /* CONFIG_PM */
460 462
463#ifdef CONFIG_OF
464static const struct of_device_id cs4271_dt_ids[] = {
465 { .compatible = "cirrus,cs4271", },
466 { }
467};
468MODULE_DEVICE_TABLE(of, cs4271_dt_ids);
469#endif
470
461static int cs4271_probe(struct snd_soc_codec *codec) 471static int cs4271_probe(struct snd_soc_codec *codec)
462{ 472{
463 struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); 473 struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
@@ -465,6 +475,12 @@ static int cs4271_probe(struct snd_soc_codec *codec)
465 int ret; 475 int ret;
466 int gpio_nreset = -EINVAL; 476 int gpio_nreset = -EINVAL;
467 477
478#ifdef CONFIG_OF
479 if (of_match_device(cs4271_dt_ids, codec->dev))
480 gpio_nreset = of_get_named_gpio(codec->dev->of_node,
481 "reset-gpio", 0);
482#endif
483
468 if (cs4271plat && gpio_is_valid(cs4271plat->gpio_nreset)) 484 if (cs4271plat && gpio_is_valid(cs4271plat->gpio_nreset))
469 gpio_nreset = cs4271plat->gpio_nreset; 485 gpio_nreset = cs4271plat->gpio_nreset;
470 486
@@ -569,6 +585,7 @@ static struct spi_driver cs4271_spi_driver = {
569 .driver = { 585 .driver = {
570 .name = "cs4271", 586 .name = "cs4271",
571 .owner = THIS_MODULE, 587 .owner = THIS_MODULE,
588 .of_match_table = of_match_ptr(cs4271_dt_ids),
572 }, 589 },
573 .probe = cs4271_spi_probe, 590 .probe = cs4271_spi_probe,
574 .remove = __devexit_p(cs4271_spi_remove), 591 .remove = __devexit_p(cs4271_spi_remove),
@@ -608,6 +625,7 @@ static struct i2c_driver cs4271_i2c_driver = {
608 .driver = { 625 .driver = {
609 .name = "cs4271", 626 .name = "cs4271",
610 .owner = THIS_MODULE, 627 .owner = THIS_MODULE,
628 .of_match_table = of_match_ptr(cs4271_dt_ids),
611 }, 629 },
612 .id_table = cs4271_i2c_id, 630 .id_table = cs4271_i2c_id,
613 .probe = cs4271_i2c_probe, 631 .probe = cs4271_i2c_probe,