From patchwork Fri Dec 11 03:59:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cory Maccarrone X-Patchwork-Id: 66420 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBB40acK019761 for ; Fri, 11 Dec 2009 04:00:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753856AbZLKEA2 (ORCPT ); Thu, 10 Dec 2009 23:00:28 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753597AbZLKEA2 (ORCPT ); Thu, 10 Dec 2009 23:00:28 -0500 Received: from mail-pz0-f171.google.com ([209.85.222.171]:36516 "EHLO mail-pz0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752099AbZLKEA1 (ORCPT ); Thu, 10 Dec 2009 23:00:27 -0500 Received: by pzk1 with SMTP id 1so410623pzk.33 for ; Thu, 10 Dec 2009 20:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=giMySM86L9diz4zgic5DbP3Ce9CYqP/Iq5syFpyKRco=; b=Rd4v/x+6QwBoUXaoyFHx67x5Kg5r57YHa5QMG6F9IJGT7yO+gJvBzFJYu6EdwQdUob pKcrRHzmu1njofs69kmH14zBL/654jlr/gyAqg8Jrrh+79KwCl63P160D0A+BJQUj/gZ AmQo1kOSb2XOQSMJSRK8ZMIMlm0PgCox7HurM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=sDK25DDhuneyBmf1ZSk3sik70Y4apDt/NAHGLyhE/ir7LWo/uwUZigN2u8qVwJY98C WbUCxJhtrKdCAFn2szLH1LpL2edLYFvdkDgPM+Pjv5PduAIaOCohqWS70PRtYzSTAUho 9GezGrjaqCzD/9SIljL8Bj2ZgtD/DB9KxaSFc= Received: by 10.140.251.20 with SMTP id y20mr509317rvh.206.1260504033859; Thu, 10 Dec 2009 20:00:33 -0800 (PST) Received: from localhost (97-126-116-159.tukw.qwest.net [97.126.116.159]) by mx.google.com with ESMTPS id 23sm1405531pzk.12.2009.12.10.20.00.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 10 Dec 2009 20:00:33 -0800 (PST) From: Cory Maccarrone To: linux-omap@vger.kernel.org Cc: Cory Maccarrone Subject: [PATCH] [OMAP] gpio: Simultaneously requested rising and falling edge Date: Thu, 10 Dec 2009 19:59:54 -0800 Message-Id: <1260503994-27823-1-git-send-email-darkstar6262@gmail.com> X-Mailer: git-send-email 1.6.3.3 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c index 055160e..b594398 100644 --- a/arch/arm/plat-omap/gpio.c +++ b/arch/arm/plat-omap/gpio.c @@ -749,6 +749,53 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio, } #endif +/* + * This only applies to chips that can't do both rising and falling edge + * detection at once. For all other chips, this function is a noop. + */ +static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) +{ + void __iomem *reg = bank->base; + u32 l = 0; + + switch (bank->method) { +#ifdef CONFIG_ARCH_OMAP1 + case METHOD_MPUIO: + reg += OMAP_MPUIO_GPIO_INT_EDGE; + l = __raw_readl(reg); + if ((l >> gpio) & 1) + l &= ~(1 << gpio); + else + l |= 1 << gpio; + break; +#endif +#ifdef CONFIG_ARCH_OMAP15XX + case METHOD_GPIO_1510: + reg += OMAP1510_GPIO_INT_CONTROL; + l = __raw_readl(reg); + if ((l >> gpio) & 1) + l &= ~(1 << gpio); + else + l |= 1 << gpio; + break; +#endif +#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) + case METHOD_GPIO_7XX: + reg += OMAP7XX_GPIO_INT_CONTROL; + l = __raw_readl(reg); + if ((l >> gpio) & 1) { + l &= ~(1 << gpio); + } else { + l |= 1 << gpio; + } + break; +#endif + default: + return; + } + __raw_writel(l, reg); +} + static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger) { void __iomem *reg = bank->base; @@ -1284,9 +1331,22 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) gpio_irq = bank->virtual_irq_start; for (; isr != 0; isr >>= 1, gpio_irq++) { + struct irq_desc *desc = irq_to_desc(gpio_irq); if (!(isr & 1)) continue; + /* + * Some chips can't respond to both rising and falling at the + * same time. If this irq was requested with both flags, we + * need to flip the ICR data for the IRQ to respond to the + * IRQ for the opposite direction. + */ + if (desc->status & IRQ_TYPE_EDGE_FALLING && + desc->status & IRQ_TYPE_EDGE_RISING) + _toggle_gpio_edge_triggering( + get_irq_chip_data(gpio_irq), + get_gpio_index(irq_to_gpio(gpio_irq))); + generic_handle_irq(gpio_irq); } }