From: Felix Fietkau Date: Sun, 11 Oct 2009 19:51:27 +0000 (+0000) Subject: atheros: merge gpio changes from r18036 to 8.09 X-Git-Tag: 8.09.2~20 X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=3d6d7246632c697ab809e6c36457606ab2744f06;p=openwrt%2Fsvn-archive%2Fopenwrt.git atheros: merge gpio changes from r18036 to 8.09 SVN-Revision: 18037 --- diff --git a/target/linux/atheros/files/arch/mips/atheros/ar5315/irq.c b/target/linux/atheros/files/arch/mips/atheros/ar5315/irq.c index 581b1a4a10..87ced6693b 100644 --- a/target/linux/atheros/files/arch/mips/atheros/ar5315/irq.c +++ b/target/linux/atheros/files/arch/mips/atheros/ar5315/irq.c @@ -33,6 +33,8 @@ static u32 gpiointmask = 0, gpiointval = 0; static inline void ar5315_gpio_irq(void) { u32 pend; + u32 gpio; + sysRegWrite(AR5315_ISR, sysRegRead(AR5315_IMR) | ~AR5315_ISR_GPIO); /* only do one gpio interrupt at a time */ @@ -40,7 +42,13 @@ static inline void ar5315_gpio_irq(void) if (!pend) return; - do_IRQ(AR531X_GPIO_IRQ_BASE + fls(pend) - 1); + gpio = fls(pend) - 1; + + /* check if GPIO line is input */ + if ((sysRegRead(AR5315_GPIO_CR) & (AR5315_GPIO_CR_M(gpio))) != AR5315_GPIO_CR_I(gpio)) + return; + + do_IRQ(AR531X_GPIO_IRQ_BASE + gpio); } @@ -116,8 +124,9 @@ static void ar5315_gpio_intr_enable(unsigned int irq) mask = 1 << gpio; gpiointmask |= mask; - /* reconfigure GPIO line as input */ - sysRegMask(AR5315_GPIO_CR, AR5315_GPIO_CR_M(gpio), AR5315_GPIO_CR_I(gpio)); + /* check if GPIO line is input */ + if ((sysRegRead(AR5315_GPIO_CR) & (AR5315_GPIO_CR_M(gpio))) != AR5315_GPIO_CR_I(gpio)) + return; /* Enable interrupt with edge detection */ sysRegMask(AR5315_GPIO_INT, AR5315_GPIO_INT_M | AR5315_GPIO_INT_LVL_M, gpio | AR5315_GPIO_INT_LVL(3)); @@ -138,6 +147,11 @@ static void ar5315_gpio_intr_disable(unsigned int irq) /* Turn on the specified AR531X_MISC_IRQ interrupt */ static unsigned int ar5315_gpio_intr_startup(unsigned int irq) { + u32 gpio = irq - AR531X_GPIO_IRQ_BASE; + + /* reconfigure GPIO line as input */ + sysRegMask(AR5315_GPIO_CR, AR5315_GPIO_CR_M(gpio), AR5315_GPIO_CR_I(gpio)); + ar5315_gpio_intr_enable(irq); return 0; }