ASoC: Allow GPIO jack detection to be configured as a wake source
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 18 Feb 2011 00:35:55 +0000 (16:35 -0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 18 Feb 2011 17:14:14 +0000 (09:14 -0800)
Some systems wish to use jacks as wake sources. Provide a wake flag in the
GPIO configuration which causes the driver to enable the IRQ as a wake
source.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
include/sound/soc.h
sound/soc/soc-jack.c

index 4ccf1e4e0dd0d2ae829b9692ee89e5f510ce3be4..fb57c33482e54cd3868cdd819ef738388ad8f01b 100644 (file)
@@ -436,6 +436,7 @@ struct snd_soc_jack_zone {
  * @report:       value to report when jack detected
  * @invert:       report presence in low state
  * @debouce_time: debouce time in ms
+ * @wake:        enable as wake source
  */
 #ifdef CONFIG_GPIOLIB
 struct snd_soc_jack_gpio {
@@ -444,6 +445,8 @@ struct snd_soc_jack_gpio {
        int report;
        int invert;
        int debounce_time;
+       bool wake;
+
        struct snd_soc_jack *jack;
        struct delayed_work work;
 
index 4579ee090bbfdb061393ff2ef2bb497c722c7eb0..1382251ed2a2e03b0bad0f58cd66fb4203928684 100644 (file)
@@ -330,6 +330,14 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
                if (ret)
                        goto err;
 
+               if (gpios[i].wake) {
+                       ret = set_irq_wake(gpio_to_irq(gpios[i].gpio), 1);
+                       if (ret != 0)
+                               printk(KERN_ERR
+                                 "Failed to mark GPIO %d as wake source: %d\n",
+                                       gpios[i].gpio, ret);
+               }
+
 #ifdef CONFIG_GPIO_SYSFS
                /* Expose GPIO value over sysfs for diagnostic purposes */
                gpio_export(gpios[i].gpio, false);