aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8962.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-10-01 20:46:37 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-10-02 17:23:57 -0400
commit8ca2aa9c59c39805c746b137c041576838f3de92 (patch)
treec30d7658b57106c84e8ef84223c4000b146b7c37 /sound/soc/codecs/wm8962.c
parent7711308ae68900a047782f5fe1bd46196ea8be0e (diff)
ASoC: Put WM8962 GPIO2/3 into GPIO mode when configuring platform data too
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>
Diffstat (limited to 'sound/soc/codecs/wm8962.c')
-rw-r--r--sound/soc/codecs/wm8962.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 3a1db4a76a6..6d30f3464ba 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)
1733} 1733}
1734#endif 1734#endif
1735 1735
1736static void wm8962_set_gpio_mode(struct snd_soc_codec *codec, int gpio)
1737{
1738 int mask = 0;
1739 int val = 0;
1740
1741 /* Some of the GPIOs are behind MFP configuration and need to
1742 * be put into GPIO mode. */
1743 switch (gpio) {
1744 case 2:
1745 mask = WM8962_CLKOUT2_SEL_MASK;
1746 val = 1 << WM8962_CLKOUT2_SEL_SHIFT;
1747 break;
1748 case 3:
1749 mask = WM8962_CLKOUT3_SEL_MASK;
1750 val = 1 << WM8962_CLKOUT3_SEL_SHIFT;
1751 break;
1752 default:
1753 break;
1754 }
1755
1756 if (mask)
1757 snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1,
1758 mask, val);
1759}
1760
1736#ifdef CONFIG_GPIOLIB 1761#ifdef CONFIG_GPIOLIB
1737static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip) 1762static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip)
1738{ 1763{
@@ -1743,8 +1768,6 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
1743{ 1768{
1744 struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); 1769 struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
1745 struct snd_soc_codec *codec = wm8962->codec; 1770 struct snd_soc_codec *codec = wm8962->codec;
1746 int mask = 0;
1747 int val;
1748 1771
1749 /* The WM8962 GPIOs aren't linearly numbered. For simplicity 1772 /* The WM8962 GPIOs aren't linearly numbered. For simplicity
1750 * we export linear numbers and error out if the unsupported 1773 * 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)
1752 */ 1775 */
1753 switch (offset + 1) { 1776 switch (offset + 1) {
1754 case 2: 1777 case 2:
1755 mask = WM8962_CLKOUT2_SEL_MASK;
1756 val = 1 << WM8962_CLKOUT2_SEL_SHIFT;
1757 break;
1758 case 3: 1778 case 3:
1759 mask = WM8962_CLKOUT3_SEL_MASK;
1760 val = 1 << WM8962_CLKOUT3_SEL_SHIFT;
1761 break;
1762 case 5: 1779 case 5:
1763 case 6: 1780 case 6:
1764 break; 1781 break;
@@ -1766,10 +1783,7 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
1766 return -EINVAL; 1783 return -EINVAL;
1767 } 1784 }
1768 1785
1769 /* Some of the GPIOs are behind MFP configuration */ 1786 wm8962_set_gpio_mode(codec, offset + 1);
1770 if (mask)
1771 snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1,
1772 mask, val);
1773 1787
1774 return 0; 1788 return 0;
1775} 1789}
@@ -1943,9 +1957,11 @@ static int wm8962_probe(struct snd_soc_codec *codec)
1943 if (pdata) { 1957 if (pdata) {
1944 /* Apply static configuration for GPIOs */ 1958 /* Apply static configuration for GPIOs */
1945 for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++) 1959 for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++)
1946 if (pdata->gpio_init[i]) 1960 if (pdata->gpio_init[i]) {
1961 wm8962_set_gpio_mode(codec, i + 1);
1947 snd_soc_write(codec, 0x200 + i, 1962 snd_soc_write(codec, 0x200 + i,
1948 pdata->gpio_init[i] & 0xffff); 1963 pdata->gpio_init[i] & 0xffff);
1964 }
1949 1965
1950 /* Put the speakers into mono mode? */ 1966 /* Put the speakers into mono mode? */
1951 if (pdata->spk_mono) 1967 if (pdata->spk_mono)