Skip to content

Commit 94c7024

Browse files
markto-atlnzLinus Walleij
authored andcommitted
pinctrl: nsp: Set irq handler based on trig type
Rather than always using handle_simple_irq() as the gpio_irq_chip handler, set a more appropriate handler based on the IRQ trigger type requested. This is important for level triggered interrupts which need to be masked during handling. Also, fix the interrupt acknowledge so that it clears only one interrupt instead of all interrupts which are currently active. Finally there is no need to clear the interrupt during the interrupt handler, since the edge-triggered handler will do that for us. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz> Reviewed-by: Ray Jui <ray.jui@broadcom.com> Link: https://lore.kernel.org/r/20200703011830.15655-1-mark.tomlinson@alliedtelesis.co.nz Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 5f4962d commit 94c7024

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎drivers/pinctrl/bcm/pinctrl-nsp-gpio.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,9 @@ static irqreturn_t nsp_gpio_irq_handler(int irq, void *data)
154154
level &= readl(chip->base + NSP_GPIO_INT_MASK);
155155
int_bits = level | event;
156156

157-
for_each_set_bit(bit, &int_bits, gc->ngpio) {
158-
/*
159-
* Clear the interrupt before invoking the
160-
* handler, so we do not leave any window
161-
*/
162-
writel(BIT(bit), chip->base + NSP_GPIO_EVENT);
157+
for_each_set_bit(bit, &int_bits, gc->ngpio)
163158
generic_handle_irq(
164159
irq_linear_revmap(gc->irq.domain, bit));
165-
}
166160
}
167161

168162
return int_bits ? IRQ_HANDLED : IRQ_NONE;
@@ -178,7 +172,7 @@ static void nsp_gpio_irq_ack(struct irq_data *d)
178172

179173
trigger_type = irq_get_trigger_type(d->irq);
180174
if (trigger_type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
181-
nsp_set_bit(chip, REG, NSP_GPIO_EVENT, gpio, val);
175+
writel(val, chip->base + NSP_GPIO_EVENT);
182176
}
183177

184178
/*
@@ -262,6 +256,12 @@ static int nsp_gpio_irq_set_type(struct irq_data *d, unsigned int type)
262256

263257
nsp_set_bit(chip, REG, NSP_GPIO_EVENT_INT_POLARITY, gpio, falling);
264258
nsp_set_bit(chip, REG, NSP_GPIO_INT_POLARITY, gpio, level_low);
259+
260+
if (type & IRQ_TYPE_EDGE_BOTH)
261+
irq_set_handler_locked(d, handle_edge_irq);
262+
else
263+
irq_set_handler_locked(d, handle_level_irq);
264+
265265
raw_spin_unlock_irqrestore(&chip->lock, flags);
266266

267267
dev_dbg(chip->dev, "gpio:%u level_low:%s falling:%s\n", gpio,
@@ -691,7 +691,7 @@ static int nsp_gpio_probe(struct platform_device *pdev)
691691
girq->num_parents = 0;
692692
girq->parents = NULL;
693693
girq->default_type = IRQ_TYPE_NONE;
694-
girq->handler = handle_simple_irq;
694+
girq->handler = handle_bad_irq;
695695
}
696696

697697
ret = devm_gpiochip_add_data(dev, gc, chip);

0 commit comments

Comments
 (0)