linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/5121: pdm360ng: fix touch irq if 8xxx gpio driver is enabled
@ 2010-09-15 20:12 Anatolij Gustschin
  2010-09-16  2:38 ` Grant Likely
  2010-10-14 14:55 ` Anatolij Gustschin
  0 siblings, 2 replies; 6+ messages in thread
From: Anatolij Gustschin @ 2010-09-15 20:12 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Anatolij Gustschin

Enabling the MPC8xxx GPIO driver with MPC512x GPIO extension
breaks touch screen support on this board since the GPIO
interrupt will be mapped to 8xxx GPIO irq host resulting in
a not requestable interrupt in the touch screen driver. Fix
it by mapping the touch interrupt on 8xxx GPIO irq host.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 arch/powerpc/platforms/512x/pdm360ng.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/512x/pdm360ng.c b/arch/powerpc/platforms/512x/pdm360ng.c
index 0575e85..558eb9e 100644
--- a/arch/powerpc/platforms/512x/pdm360ng.c
+++ b/arch/powerpc/platforms/512x/pdm360ng.c
@@ -27,6 +27,7 @@
 #include <linux/spi/ads7846.h>
 #include <linux/spi/spi.h>
 #include <linux/notifier.h>
+#include <asm/gpio.h>
 
 static void *pdm360ng_gpio_base;
 
@@ -50,7 +51,7 @@ static struct ads7846_platform_data pdm360ng_ads7846_pdata = {
 	.irq_flags		= IRQF_TRIGGER_LOW,
 };
 
-static int __init pdm360ng_penirq_init(void)
+static int pdm360ng_penirq_init(void)
 {
 	struct device_node *np;
 
@@ -73,6 +74,9 @@ static int __init pdm360ng_penirq_init(void)
 	return 0;
 }
 
+#define GPIO_NR(x)	(ARCH_NR_GPIOS - 32 + (x))
+#define PENDOWN_GPIO	GPIO_NR(25)
+
 static int pdm360ng_touchscreen_notifier_call(struct notifier_block *nb,
 					unsigned long event, void *__dev)
 {
@@ -80,7 +84,24 @@ static int pdm360ng_touchscreen_notifier_call(struct notifier_block *nb,
 
 	if ((event == BUS_NOTIFY_ADD_DEVICE) &&
 	    of_device_is_compatible(dev->of_node, "ti,ads7846")) {
+		struct spi_device *spi = to_spi_device(dev);
+		int gpio = PENDOWN_GPIO;
+
 		dev->platform_data = &pdm360ng_ads7846_pdata;
+		if (pdm360ng_penirq_init())
+			return NOTIFY_DONE;
+
+		if (gpio_request_one(gpio, GPIOF_IN, "ads7845_pen_down") < 0) {
+			pr_err("Failed to request GPIO %d for "
+				"ads7845 pen down IRQ\n", gpio);
+			return NOTIFY_DONE;
+		}
+		spi->irq = gpio_to_irq(gpio);
+		if (spi->irq < 0) {
+			pr_err("Can't map GPIO IRQ\n");
+			gpio_free(gpio);
+			return NOTIFY_DONE;
+		}
 		return NOTIFY_OK;
 	}
 	return NOTIFY_DONE;
@@ -92,9 +113,6 @@ static struct notifier_block pdm360ng_touchscreen_nb = {
 
 static void __init pdm360ng_touchscreen_init(void)
 {
-	if (pdm360ng_penirq_init())
-		return;
-
 	bus_register_notifier(&spi_bus_type, &pdm360ng_touchscreen_nb);
 }
 #else
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-10-27 13:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-15 20:12 [PATCH] powerpc/5121: pdm360ng: fix touch irq if 8xxx gpio driver is enabled Anatolij Gustschin
2010-09-16  2:38 ` Grant Likely
2010-09-25 20:22   ` Anatolij Gustschin
2010-10-27 13:40     ` Grant Likely
2010-10-14 14:55 ` Anatolij Gustschin
2010-10-16  3:52   ` Grant Likely

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).