]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
ASoC: Codec: jack det. pin from dts and add workq
authorSameer Pujar <spujar@nvidia.com>
Tue, 5 Jan 2016 09:22:35 +0000 (14:52 +0530)
committermobile promotions <svcmobile_promotions@nvidia.com>
Thu, 7 Jan 2016 16:32:50 +0000 (08:32 -0800)
Added support to parse the information from i2c device
tree node for using assigned GPIO for jack detection.
The irq is requested based on this.

Defined a local workqueue to handle the jack interrupt
and report to the ASoC jack framework.
(This is specific to k310 version of codec driver, k318
uses the workq provided workqueue framework, which is
not available for k310)

Bug 200148270

Change-Id: I266142b19fa7333cfee88d9f80521cab89ff2b43
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: http://git-master/r/929001
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
sound/soc/codecs/rt5659.c
sound/soc/codecs/rt5659.h

index 126c3c40b9d3a5208cd83304ec5c337066821a32..3e6c33db25d8dfded50b6195c693a31746736030 100644 (file)
@@ -29,6 +29,7 @@
 #include <sound/initval.h>
 #include <sound/tlv.h>
 #include <sound/rt5659.h>
+#include <linux/of_gpio.h>
 
 #include "rt5659.h"
 
@@ -1398,9 +1399,8 @@ static irqreturn_t rt5659_irq(int irq, void *data)
 {
        struct rt5659_priv *rt5659 = data;
 
-       /* FIXME: define a local workqueue and use it */
-       //queue_delayed_work(system_power_efficient_wq,
-                          //&rt5659->jack_detect_work, msecs_to_jiffies(250));
+       queue_delayed_work(rt5659->jack_workq, &rt5659->jack_detect_work,
+               msecs_to_jiffies(250));
 
        return IRQ_HANDLED;
 }
@@ -3728,7 +3728,6 @@ static int rt5659_probe(struct snd_soc_codec *codec)
        struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
 
        rt5659->codec = codec;
-
        return 0;
 }
 
@@ -3737,6 +3736,8 @@ static int rt5659_remove(struct snd_soc_codec *codec)
        struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec);
 
        regmap_write(rt5659->regmap, RT5659_RESET, 0);
+       if (rt5659->jack_workq)
+               destroy_workqueue(rt5659->jack_workq);
 
        return 0;
 }
@@ -4273,10 +4274,18 @@ static int rt5659_i2c_probe(struct i2c_client *i2c,
                break;
        }
 
+       rt5659->jack_workq = create_workqueue("rt5659_jack_workq");
+       if (rt5659->jack_workq == NULL) {
+               dev_err(&i2c->dev, "cannot create workqueue for jack detection\n");
+               return -ENOMEM;
+       }
+
        INIT_DELAYED_WORK(&rt5659->jack_detect_work, rt5659_jack_detect_work);
 
-       /* FIXME: pass this info from device tree */
-       rt5659->i2c->irq = 542;
+       rt5659->i2c->irq = gpio_to_irq(of_get_gpio
+               (rt5659->i2c->dev.of_node, 0));
+       dev_dbg(&i2c->dev, "irq = %d, assigned for jack interrupt handling\n",
+               rt5659->i2c->irq);
 
        if (rt5659->i2c->irq) {
                ret = request_threaded_irq(rt5659->i2c->irq, NULL, rt5659_irq,
index 8f07ee903eaadf29a769f71b9c219cf9ac5bb3b6..108fdf4270851649e1e02c29eda5fa71a0c7e688 100644 (file)
@@ -1796,6 +1796,7 @@ struct rt5659_priv {
        struct gpio_desc *gpiod_ldo1_en;
        struct gpio_desc *gpiod_reset;
        struct snd_soc_jack *hs_jack;
+       struct workqueue_struct *jack_workq;
        struct delayed_work jack_detect_work;
 
        int sysclk;