aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2013-06-24 10:31:32 -0400
committerMark Brown <broonie@linaro.org>2013-06-25 05:32:21 -0400
commit97d0a868450d08fae0db3f53459852901c6e2f4f (patch)
tree29160aea6bd860b3812cc94ccafe76be442b844c
parent45405d58924f49a13b924ed6db6fe47981487b4a (diff)
ASoC: adau1701: add support for pin muxing
The ADAU1701 has 12 pins that can be configured depending on the system configuration. Allow settting the corresponding registers from DT. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/sound/adi,adau1701.txt6
-rw-r--r--sound/soc/codecs/adau1701.c32
2 files changed, 36 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/sound/adi,adau1701.txt b/Documentation/devicetree/bindings/sound/adi,adau1701.txt
index a9fbed1be40e..547a49b56a62 100644
--- a/Documentation/devicetree/bindings/sound/adi,adau1701.txt
+++ b/Documentation/devicetree/bindings/sound/adi,adau1701.txt
@@ -16,6 +16,10 @@ Optional properties:
16 The state of the pins are set according to the 16 The state of the pins are set according to the
17 configured clock divider on ASoC side before the 17 configured clock divider on ASoC side before the
18 firmware is loaded. 18 firmware is loaded.
19 - adi,pin-config: An array of 12 numerical values selecting one of the
20 pin configurations as described in the datasheet,
21 table 53. Note that the value of this property has
22 to be prefixed with '/bits/ 8'.
19 23
20Examples: 24Examples:
21 25
@@ -25,5 +29,7 @@ Examples:
25 reg = <0x34>; 29 reg = <0x34>;
26 reset-gpio = <&gpio 23 0>; 30 reset-gpio = <&gpio 23 0>;
27 adi,pll-mode-gpios = <&gpio 24 0 &gpio 25 0>; 31 adi,pll-mode-gpios = <&gpio 24 0 &gpio 25 0>;
32 adi,pin-config = /bits/ 8 <0x4 0x7 0x5 0x5 0x4 0x4
33 0x4 0x4 0x4 0x4 0x4 0x4>;
28 }; 34 };
29 }; 35 };
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
index 881bab4a65aa..0e250f118c0e 100644
--- a/sound/soc/codecs/adau1701.c
+++ b/sound/soc/codecs/adau1701.c
@@ -30,6 +30,9 @@
30#define ADAU1701_SERICTL 0x081f 30#define ADAU1701_SERICTL 0x081f
31 31
32#define ADAU1701_AUXNPOW 0x0822 32#define ADAU1701_AUXNPOW 0x0822
33#define ADAU1701_PINCONF_0 0x0820
34#define ADAU1701_PINCONF_1 0x0821
35#define ADAU1701_AUXNPOW 0x0822
33 36
34#define ADAU1701_OSCIPOW 0x0826 37#define ADAU1701_OSCIPOW 0x0826
35#define ADAU1701_DACSET 0x0827 38#define ADAU1701_DACSET 0x0827
@@ -99,6 +102,7 @@ struct adau1701 {
99 unsigned int pll_clkdiv; 102 unsigned int pll_clkdiv;
100 unsigned int sysclk; 103 unsigned int sysclk;
101 struct regmap *regmap; 104 struct regmap *regmap;
105 u8 pin_config[12];
102}; 106};
103 107
104static const struct snd_kcontrol_new adau1701_controls[] = { 108static const struct snd_kcontrol_new adau1701_controls[] = {
@@ -134,6 +138,9 @@ static unsigned int adau1701_register_size(struct device *dev,
134 unsigned int reg) 138 unsigned int reg)
135{ 139{
136 switch (reg) { 140 switch (reg) {
141 case ADAU1701_PINCONF_0:
142 case ADAU1701_PINCONF_1:
143 return 3;
137 case ADAU1701_DSPCTRL: 144 case ADAU1701_DSPCTRL:
138 case ADAU1701_SEROCTL: 145 case ADAU1701_SEROCTL:
139 case ADAU1701_AUXNPOW: 146 case ADAU1701_AUXNPOW:
@@ -164,7 +171,7 @@ static int adau1701_reg_write(void *context, unsigned int reg,
164 struct i2c_client *client = context; 171 struct i2c_client *client = context;
165 unsigned int i; 172 unsigned int i;
166 unsigned int size; 173 unsigned int size;
167 uint8_t buf[4]; 174 uint8_t buf[5];
168 int ret; 175 int ret;
169 176
170 size = adau1701_register_size(&client->dev, reg); 177 size = adau1701_register_size(&client->dev, reg);
@@ -584,7 +591,8 @@ MODULE_DEVICE_TABLE(of, adau1701_dt_ids);
584 591
585static int adau1701_probe(struct snd_soc_codec *codec) 592static int adau1701_probe(struct snd_soc_codec *codec)
586{ 593{
587 int ret; 594 int i, ret;
595 unsigned int val;
588 struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); 596 struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec);
589 597
590 codec->control_data = to_i2c_client(codec->dev); 598 codec->control_data = to_i2c_client(codec->dev);
@@ -602,6 +610,19 @@ static int adau1701_probe(struct snd_soc_codec *codec)
602 if (ret < 0) 610 if (ret < 0)
603 return ret; 611 return ret;
604 612
613 /* set up pin config */
614 val = 0;
615 for (i = 0; i < 6; i++)
616 val |= adau1701->pin_config[i] << (i * 4);
617
618 regmap_write(adau1701->regmap, ADAU1701_PINCONF_0, val);
619
620 val = 0;
621 for (i = 0; i < 6; i++)
622 val |= adau1701->pin_config[i + 6] << (i * 4);
623
624 regmap_write(adau1701->regmap, ADAU1701_PINCONF_1, val);
625
605 return 0; 626 return 0;
606} 627}
607 628
@@ -662,6 +683,13 @@ static int adau1701_i2c_probe(struct i2c_client *client,
662 "adi,pll-mode-gpios", 1); 683 "adi,pll-mode-gpios", 1);
663 if (gpio_pll_mode[1] < 0 && gpio_pll_mode[1] != -ENOENT) 684 if (gpio_pll_mode[1] < 0 && gpio_pll_mode[1] != -ENOENT)
664 return gpio_pll_mode[1]; 685 return gpio_pll_mode[1];
686
687 of_property_read_u32(dev->of_node, "adi,pll-clkdiv",
688 &adau1701->pll_clkdiv);
689
690 of_property_read_u8_array(dev->of_node, "adi,pin-config",
691 adau1701->pin_config,
692 ARRAY_SIZE(adau1701->pin_config));
665 } 693 }
666 694
667 if (gpio_is_valid(gpio_nreset)) { 695 if (gpio_is_valid(gpio_nreset)) {