diff options
author | Eric Miao <eric.miao@marvell.com> | 2009-04-21 02:39:07 -0400 |
---|---|---|
committer | Eric Miao <eric.miao@marvell.com> | 2009-04-26 23:45:16 -0400 |
commit | a8f6faebaf5b3f0f56b7c12a4f99d97c56938b37 (patch) | |
tree | c6368843d0f54638dd911f8230f7cee1e731f117 /arch | |
parent | 6ae85d6db4871d8dbcb5cc0e9056f97f1ca07061 (diff) |
[ARM] pxa: fix issue of muxed GPIO irq_chip functions touching non-muxed GPIOs
pxa_gpio_irq_type() and pxa_unmask_muxed_gpio() will touch non-muxed GPIOs
(0 and 1 on PXA2xx/PXA3xx) bits in GRERx and GFERx, which is incorrect.
Actually, only those bits should get updated if the corresponding bits are
set in c->irq_mask as well. Fix this by updating only those relevant bits.
Reported-and-tested-by: Daniel Ribeiro <drwyrm@gmail.com>
Signed-off-by: Eric Miao <eric.miao@marvell.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/plat-pxa/gpio.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/arch/arm/plat-pxa/gpio.c b/arch/arm/plat-pxa/gpio.c index af819bf21b63..abc79d44acaa 100644 --- a/arch/arm/plat-pxa/gpio.c +++ b/arch/arm/plat-pxa/gpio.c | |||
@@ -121,6 +121,8 @@ static int __init pxa_init_gpio_chip(int gpio_end) | |||
121 | return -ENOMEM; | 121 | return -ENOMEM; |
122 | } | 122 | } |
123 | 123 | ||
124 | memset(chips, 0, nbanks * sizeof(struct pxa_gpio_chip)); | ||
125 | |||
124 | for (i = 0, gpio = 0; i < nbanks; i++, gpio += 32) { | 126 | for (i = 0, gpio = 0; i < nbanks; i++, gpio += 32) { |
125 | struct gpio_chip *c = &chips[i].chip; | 127 | struct gpio_chip *c = &chips[i].chip; |
126 | 128 | ||
@@ -143,6 +145,21 @@ static int __init pxa_init_gpio_chip(int gpio_end) | |||
143 | return 0; | 145 | return 0; |
144 | } | 146 | } |
145 | 147 | ||
148 | /* Update only those GRERx and GFERx edge detection register bits if those | ||
149 | * bits are set in c->irq_mask | ||
150 | */ | ||
151 | static inline void update_edge_detect(struct pxa_gpio_chip *c) | ||
152 | { | ||
153 | uint32_t grer, gfer; | ||
154 | |||
155 | grer = __raw_readl(c->regbase + GRER_OFFSET) & ~c->irq_mask; | ||
156 | gfer = __raw_readl(c->regbase + GFER_OFFSET) & ~c->irq_mask; | ||
157 | grer |= c->irq_edge_rise & c->irq_mask; | ||
158 | gfer |= c->irq_edge_fall & c->irq_mask; | ||
159 | __raw_writel(grer, c->regbase + GRER_OFFSET); | ||
160 | __raw_writel(gfer, c->regbase + GFER_OFFSET); | ||
161 | } | ||
162 | |||
146 | static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) | 163 | static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) |
147 | { | 164 | { |
148 | struct pxa_gpio_chip *c; | 165 | struct pxa_gpio_chip *c; |
@@ -181,8 +198,7 @@ static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) | |||
181 | else | 198 | else |
182 | c->irq_edge_fall &= ~mask; | 199 | c->irq_edge_fall &= ~mask; |
183 | 200 | ||
184 | __raw_writel(c->irq_edge_rise & c->irq_mask, c->regbase + GRER_OFFSET); | 201 | update_edge_detect(c); |
185 | __raw_writel(c->irq_edge_fall & c->irq_mask, c->regbase + GFER_OFFSET); | ||
186 | 202 | ||
187 | pr_debug("%s: IRQ%d (GPIO%d) - edge%s%s\n", __func__, irq, gpio, | 203 | pr_debug("%s: IRQ%d (GPIO%d) - edge%s%s\n", __func__, irq, gpio, |
188 | ((type & IRQ_TYPE_EDGE_RISING) ? " rising" : ""), | 204 | ((type & IRQ_TYPE_EDGE_RISING) ? " rising" : ""), |
@@ -244,8 +260,7 @@ static void pxa_unmask_muxed_gpio(unsigned int irq) | |||
244 | struct pxa_gpio_chip *c = gpio_to_chip(gpio); | 260 | struct pxa_gpio_chip *c = gpio_to_chip(gpio); |
245 | 261 | ||
246 | c->irq_mask |= GPIO_bit(gpio); | 262 | c->irq_mask |= GPIO_bit(gpio); |
247 | __raw_writel(c->irq_edge_rise & c->irq_mask, c->regbase + GRER_OFFSET); | 263 | update_edge_detect(c); |
248 | __raw_writel(c->irq_edge_fall & c->irq_mask, c->regbase + GFER_OFFSET); | ||
249 | } | 264 | } |
250 | 265 | ||
251 | static struct irq_chip pxa_muxed_gpio_chip = { | 266 | static struct irq_chip pxa_muxed_gpio_chip = { |