linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dinh.Nguyen@freescale.com (Dinh.Nguyen at freescale.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv5 3/3] ARM: imx: Add wake functionality to GPIO
Date: Fri, 22 Oct 2010 11:56:15 -0500	[thread overview]
Message-ID: <1287766575-4092-3-git-send-email-Dinh.Nguyen@freescale.com> (raw)
In-Reply-To: <1287766575-4092-2-git-send-email-Dinh.Nguyen@freescale.com>

From: Dinh Nguyen <Dinh.Nguyen@freescale.com>

Add function definition for irq_chip.set_wake to enable GPIO to
wake-up the system.

This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.

This patch has been tested on a MX51 Babbage system that had suspend
code implemented. The set_wake implementation is necessary for a
GPIO to wake up a system from suspend.

Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
 arch/arm/plat-mxc/gpio.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
index 9d38da0..9c3e362 100644
--- a/arch/arm/plat-mxc/gpio.c
+++ b/arch/arm/plat-mxc/gpio.c
@@ -20,6 +20,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/gpio.h>
@@ -201,11 +202,42 @@ static void mx2_gpio_irq_handler(u32 irq, struct irq_desc *desc)
 	}
 }
 
+/*
+ * Set interrupt number "irq" in the GPIO as a wake-up source.
+ * While system is running, all registered GPIO interrupts need to have
+ * wake-up enabled. When system is suspended, only selected GPIO interrupts
+ * need to have wake-up enabled.
+ * @param  irq          interrupt source number
+ * @param  enable       enable as wake-up if equal to non-zero
+ * @return       This function returns 0 on success.
+ */
+static int gpio_set_wake_irq(u32 irq, u32 enable)
+{
+	u32 gpio = irq_to_gpio(irq);
+	u32 gpio_idx = gpio & 0x1F;
+	struct mxc_gpio_port *port = &mxc_gpio_ports[gpio / 32];
+
+	if (enable) {
+		if (port->irq_high && (gpio_idx >= 16))
+			enable_irq_wake(port->irq_high);
+		else
+			enable_irq_wake(port->irq);
+	} else {
+		if (port->irq_high && (gpio_idx >= 16))
+			disable_irq_wake(port->irq_high);
+		else
+			disable_irq_wake(port->irq);
+	}
+
+	return 0;
+}
+
 static struct irq_chip gpio_irq_chip = {
 	.ack = gpio_ack_irq,
 	.mask = gpio_mask_irq,
 	.unmask = gpio_unmask_irq,
 	.set_type = gpio_set_irq_type,
+	.set_wake = gpio_set_wake_irq,
 };
 
 static void _set_gpio_direction(struct gpio_chip *chip, unsigned offset,
-- 
1.6.0.4

  reply	other threads:[~2010-10-22 16:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22 16:56 [PATCHv5 1/3] ARM: mx5: Add gpio-keys to mx51 babbage board Dinh.Nguyen at freescale.com
2010-10-22 16:56 ` [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc Dinh.Nguyen at freescale.com
2010-10-22 16:56   ` Dinh.Nguyen at freescale.com [this message]
2010-10-22 18:28   ` Uwe Kleine-König
2010-10-22 18:58     ` Nguyen Dinh-R00091
2010-10-22 19:42       ` Uwe Kleine-König
2010-10-23  2:43         ` Nguyen Dinh-R00091
2010-10-24  8:37           ` Lothar Waßmann
2010-10-24 19:20             ` Uwe Kleine-König
2010-10-25  7:02               ` Lothar Waßmann
2010-10-25  7:21                 ` Uwe Kleine-König
2010-10-26  9:07                   ` [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie Lothar Wa�mann
2010-10-26  9:07                     ` Lothar Wa�mann
2010-10-26  9:23                     ` Uwe Kleine-König
2010-10-26 12:28                       ` Lothar Waßmann
2010-10-26 14:16                     ` Sascha Hauer
2010-11-22  8:39                     ` [PATCH] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2) Lothar Waßmann
2010-11-22  9:16                       ` Uwe Kleine-König
2010-11-24 10:59                       ` Sascha Hauer
2010-10-22 17:51 ` [PATCHv5 1/3] ARM: mx5: Add gpio-keys to mx51 babbage board Amit Kucheria

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287766575-4092-3-git-send-email-Dinh.Nguyen@freescale.com \
    --to=dinh.nguyen@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).