aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8903.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-08 22:06:11 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-11 20:59:59 -0400
commite373cbfb2f7d194e48d528794b3b99274d4c1a97 (patch)
treefef7fc32b104abf700aedca34797d3af83bd80e6 /sound/soc/codecs/wm8903.c
parent20c5fd399482ef5b87a41ab064b3255f1faaaee4 (diff)
ASoC: wm8903: Make interrupt handler use regmap directly
There's no urgent need for the interrupt handler to use the ASoC I/O functions and it'll support a further move in where we request the interrupt so call the regmap APIs directly. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Tested-by: Stephen Warren <swarren@wwwdotorg.org>
Diffstat (limited to 'sound/soc/codecs/wm8903.c')
-rw-r--r--sound/soc/codecs/wm8903.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index 64ca9042bad3..f5d47c8e5402 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -1636,17 +1636,27 @@ EXPORT_SYMBOL_GPL(wm8903_mic_detect);
1636 1636
1637static irqreturn_t wm8903_irq(int irq, void *data) 1637static irqreturn_t wm8903_irq(int irq, void *data)
1638{ 1638{
1639 struct snd_soc_codec *codec = data; 1639 struct wm8903_priv *wm8903 = data;
1640 struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); 1640 int mic_report, ret;
1641 int mic_report; 1641 unsigned int int_val, mask, int_pol;
1642 int int_pol; 1642
1643 int int_val = 0; 1643 ret = regmap_read(wm8903->regmap, WM8903_INTERRUPT_STATUS_1_MASK,
1644 int mask = ~snd_soc_read(codec, WM8903_INTERRUPT_STATUS_1_MASK); 1644 &mask);
1645 if (ret != 0) {
1646 dev_err(wm8903->dev, "Failed to read IRQ mask: %d\n", ret);
1647 return IRQ_NONE;
1648 }
1649
1650 ret = regmap_read(wm8903->regmap, WM8903_INTERRUPT_STATUS_1, &int_val);
1651 if (ret != 0) {
1652 dev_err(wm8903->dev, "Failed to read IRQ status: %d\n", ret);
1653 return IRQ_NONE;
1654 }
1645 1655
1646 int_val = snd_soc_read(codec, WM8903_INTERRUPT_STATUS_1) & mask; 1656 int_val &= ~mask;
1647 1657
1648 if (int_val & WM8903_WSEQ_BUSY_EINT) { 1658 if (int_val & WM8903_WSEQ_BUSY_EINT) {
1649 dev_warn(codec->dev, "Write sequencer done\n"); 1659 dev_warn(wm8903->dev, "Write sequencer done\n");
1650 } 1660 }
1651 1661
1652 /* 1662 /*
@@ -1657,22 +1667,28 @@ static irqreturn_t wm8903_irq(int irq, void *data)
1657 * the polarity register. 1667 * the polarity register.
1658 */ 1668 */
1659 mic_report = wm8903->mic_last_report; 1669 mic_report = wm8903->mic_last_report;
1660 int_pol = snd_soc_read(codec, WM8903_INTERRUPT_POLARITY_1); 1670 ret = regmap_read(wm8903->regmap, WM8903_INTERRUPT_POLARITY_1,
1671 &int_pol);
1672 if (ret != 0) {
1673 dev_err(wm8903->dev, "Failed to read interrupt polarity: %d\n",
1674 ret);
1675 return IRQ_HANDLED;
1676 }
1661 1677
1662#ifndef CONFIG_SND_SOC_WM8903_MODULE 1678#ifndef CONFIG_SND_SOC_WM8903_MODULE
1663 if (int_val & (WM8903_MICSHRT_EINT | WM8903_MICDET_EINT)) 1679 if (int_val & (WM8903_MICSHRT_EINT | WM8903_MICDET_EINT))
1664 trace_snd_soc_jack_irq(dev_name(codec->dev)); 1680 trace_snd_soc_jack_irq(dev_name(wm8903->dev));
1665#endif 1681#endif
1666 1682
1667 if (int_val & WM8903_MICSHRT_EINT) { 1683 if (int_val & WM8903_MICSHRT_EINT) {
1668 dev_dbg(codec->dev, "Microphone short (pol=%x)\n", int_pol); 1684 dev_dbg(wm8903->dev, "Microphone short (pol=%x)\n", int_pol);
1669 1685
1670 mic_report ^= wm8903->mic_short; 1686 mic_report ^= wm8903->mic_short;
1671 int_pol ^= WM8903_MICSHRT_INV; 1687 int_pol ^= WM8903_MICSHRT_INV;
1672 } 1688 }
1673 1689
1674 if (int_val & WM8903_MICDET_EINT) { 1690 if (int_val & WM8903_MICDET_EINT) {
1675 dev_dbg(codec->dev, "Microphone detect (pol=%x)\n", int_pol); 1691 dev_dbg(wm8903->dev, "Microphone detect (pol=%x)\n", int_pol);
1676 1692
1677 mic_report ^= wm8903->mic_det; 1693 mic_report ^= wm8903->mic_det;
1678 int_pol ^= WM8903_MICDET_INV; 1694 int_pol ^= WM8903_MICDET_INV;
@@ -1680,8 +1696,8 @@ static irqreturn_t wm8903_irq(int irq, void *data)
1680 msleep(wm8903->mic_delay); 1696 msleep(wm8903->mic_delay);
1681 } 1697 }
1682 1698
1683 snd_soc_update_bits(codec, WM8903_INTERRUPT_POLARITY_1, 1699 regmap_update_bits(wm8903->regmap, WM8903_INTERRUPT_POLARITY_1,
1684 WM8903_MICSHRT_INV | WM8903_MICDET_INV, int_pol); 1700 WM8903_MICSHRT_INV | WM8903_MICDET_INV, int_pol);
1685 1701
1686 snd_soc_jack_report(wm8903->mic_jack, mic_report, 1702 snd_soc_jack_report(wm8903->mic_jack, mic_report,
1687 wm8903->mic_short | wm8903->mic_det); 1703 wm8903->mic_short | wm8903->mic_det);
@@ -1907,7 +1923,7 @@ static int wm8903_probe(struct snd_soc_codec *codec)
1907 1923
1908 ret = request_threaded_irq(wm8903->irq, NULL, wm8903_irq, 1924 ret = request_threaded_irq(wm8903->irq, NULL, wm8903_irq,
1909 trigger | IRQF_ONESHOT, 1925 trigger | IRQF_ONESHOT,
1910 "wm8903", codec); 1926 "wm8903", wm8903);
1911 if (ret != 0) { 1927 if (ret != 0) {
1912 dev_err(codec->dev, "Failed to request IRQ: %d\n", 1928 dev_err(codec->dev, "Failed to request IRQ: %d\n",
1913 ret); 1929 ret);
@@ -1963,7 +1979,7 @@ static int wm8903_remove(struct snd_soc_codec *codec)
1963 1979
1964 wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); 1980 wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF);
1965 if (wm8903->irq) 1981 if (wm8903->irq)
1966 free_irq(wm8903->irq, codec); 1982 free_irq(wm8903->irq, wm8903);
1967 1983
1968 return 0; 1984 return 0;
1969} 1985}