Skip to content

Commit

Permalink
pinctrl: sunxi: Fix gpio_set behaviour
Browse files Browse the repository at this point in the history
The current gpio_set function is ignoring the previous value set in the
GPIO value register, which leads in erasing the values already set for
the other GPIOs in the same bank when setting the value of a given GPIO.

Add the usual read/mask/write pattern to fix this brown paper bag bug.

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 2aaaddf commit df7b34f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/pinctrl/pinctrl-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,14 @@ static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
u32 reg = sunxi_data_reg(offset);
u8 index = sunxi_data_offset(offset);
u32 regval = readl(pctl->membase + reg);

writel((value & DATA_PINS_MASK) << index, pctl->membase + reg);
if (value)
regval |= BIT(index);
else
regval &= ~(BIT(index));

writel(regval, pctl->membase + reg);
}

static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,
Expand Down

0 comments on commit df7b34f

Please sign in to comment.