* [PATCH] ASoC: Put WM8962 GPIO2/3 into GPIO mode when configuring platform data too
@ 2010-10-02 0:51 Mark Brown
2010-10-02 11:20 ` Liam Girdwood
0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2010-10-02 0:51 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown
GPIO2 and GPIO3 on the WM8962 are MFPs and need to be put into GPIO mode
before the GPIO block can be used to control them. We're already doing
this when used via gpiolib, factor out the code for use when setting static
configurations via platform data as well.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/codecs/wm8962.c | 42 +++++++++++++++++++++++++++++-------------
1 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 3a1db4a..6d30f34 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -1733,6 +1733,31 @@ static void wm8962_free_beep(struct snd_soc_codec *codec)
}
#endif
+static void wm8962_set_gpio_mode(struct snd_soc_codec *codec, int gpio)
+{
+ int mask = 0;
+ int val = 0;
+
+ /* Some of the GPIOs are behind MFP configuration and need to
+ * be put into GPIO mode. */
+ switch (gpio) {
+ case 2:
+ mask = WM8962_CLKOUT2_SEL_MASK;
+ val = 1 << WM8962_CLKOUT2_SEL_SHIFT;
+ break;
+ case 3:
+ mask = WM8962_CLKOUT3_SEL_MASK;
+ val = 1 << WM8962_CLKOUT3_SEL_SHIFT;
+ break;
+ default:
+ break;
+ }
+
+ if (mask)
+ snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1,
+ mask, val);
+}
+
#ifdef CONFIG_GPIOLIB
static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip)
{
@@ -1743,8 +1768,6 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
{
struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
struct snd_soc_codec *codec = wm8962->codec;
- int mask = 0;
- int val;
/* The WM8962 GPIOs aren't linearly numbered. For simplicity
* we export linear numbers and error out if the unsupported
@@ -1752,13 +1775,7 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
*/
switch (offset + 1) {
case 2:
- mask = WM8962_CLKOUT2_SEL_MASK;
- val = 1 << WM8962_CLKOUT2_SEL_SHIFT;
- break;
case 3:
- mask = WM8962_CLKOUT3_SEL_MASK;
- val = 1 << WM8962_CLKOUT3_SEL_SHIFT;
- break;
case 5:
case 6:
break;
@@ -1766,10 +1783,7 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
return -EINVAL;
}
- /* Some of the GPIOs are behind MFP configuration */
- if (mask)
- snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1,
- mask, val);
+ wm8962_set_gpio_mode(codec, offset + 1);
return 0;
}
@@ -1943,9 +1957,11 @@ static int wm8962_probe(struct snd_soc_codec *codec)
if (pdata) {
/* Apply static configuration for GPIOs */
for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++)
- if (pdata->gpio_init[i])
+ if (pdata->gpio_init[i]) {
+ wm8962_set_gpio_mode(codec, i + 1);
snd_soc_write(codec, 0x200 + i,
pdata->gpio_init[i] & 0xffff);
+ }
/* Put the speakers into mono mode? */
if (pdata->spk_mono)
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: Put WM8962 GPIO2/3 into GPIO mode when configuring platform data too
2010-10-02 0:51 [PATCH] ASoC: Put WM8962 GPIO2/3 into GPIO mode when configuring platform data too Mark Brown
@ 2010-10-02 11:20 ` Liam Girdwood
0 siblings, 0 replies; 2+ messages in thread
From: Liam Girdwood @ 2010-10-02 11:20 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, patches
On Fri, 2010-10-01 at 17:51 -0700, Mark Brown wrote:
> GPIO2 and GPIO3 on the WM8962 are MFPs and need to be put into GPIO mode
> before the GPIO block can be used to control them. We're already doing
> this when used via gpiolib, factor out the code for use when setting static
> configurations via platform data as well.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-10-02 11:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-02 0:51 [PATCH] ASoC: Put WM8962 GPIO2/3 into GPIO mode when configuring platform data too Mark Brown
2010-10-02 11:20 ` Liam Girdwood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).