Skip to content

Commit

Permalink
pinctrl: sunxi: Read register before writing to it in irq_set_type
Browse files Browse the repository at this point in the history
The current irq_set_type code doesn't read the current register value
before writing to it, leading to the older programmed values being
overwritten and everything but the latest value being reset.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
  • Loading branch information
Maxime Ripard authored and Linus Walleij committed Aug 7, 2013
1 parent c095ba7 commit 2aaaddf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/pinctrl/pinctrl-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ static int sunxi_pinctrl_irq_set_type(struct irq_data *d,
struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
u32 reg = sunxi_irq_cfg_reg(d->hwirq);
u8 index = sunxi_irq_cfg_offset(d->hwirq);
u32 regval;
u8 mode;

switch (type) {
Expand All @@ -548,7 +549,9 @@ static int sunxi_pinctrl_irq_set_type(struct irq_data *d,
return -EINVAL;
}

writel((mode & IRQ_CFG_IRQ_MASK) << index, pctl->membase + reg);
regval = readl(pctl->membase + reg);
regval &= ~IRQ_CFG_IRQ_MASK;
writel(regval | (mode << index), pctl->membase + reg);

return 0;
}
Expand Down

0 comments on commit 2aaaddf

Please sign in to comment.