From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by ozlabs.org (Postfix) with ESMTP id 0A30CB6F14 for ; Thu, 16 Sep 2010 06:13:06 +1000 (EST) From: Anatolij Gustschin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc/5121: pdm360ng: fix touch irq if 8xxx gpio driver is enabled Date: Wed, 15 Sep 2010 22:12:57 +0200 Message-Id: <1284581577-2217-1-git-send-email-agust@denx.de> Cc: Anatolij Gustschin List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 --- 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 #include #include +#include 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