aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-sunxi.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2013-07-25 06:41:16 -0400
committerLinus Walleij <linus.walleij@stericsson.com>2013-08-07 15:57:13 -0400
commitdf7b34f4c3d23f25b408d4c0d7f528092becce63 (patch)
tree9e622723aabd03e9f3292f436d4d1e3b538a9ff9 /drivers/pinctrl/pinctrl-sunxi.c
parent2aaaddff8df6cdb06b17c739e8e6be5c92665962 (diff)
pinctrl: sunxi: Fix gpio_set behaviour
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>
Diffstat (limited to 'drivers/pinctrl/pinctrl-sunxi.c')
-rw-r--r--drivers/pinctrl/pinctrl-sunxi.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
index 7b3a56c0bccd..8ed4b4a3d755 100644
--- a/drivers/pinctrl/pinctrl-sunxi.c
+++ b/drivers/pinctrl/pinctrl-sunxi.c
@@ -464,8 +464,14 @@ static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
464 struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev); 464 struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
465 u32 reg = sunxi_data_reg(offset); 465 u32 reg = sunxi_data_reg(offset);
466 u8 index = sunxi_data_offset(offset); 466 u8 index = sunxi_data_offset(offset);
467 u32 regval = readl(pctl->membase + reg);
467 468
468 writel((value & DATA_PINS_MASK) << index, pctl->membase + reg); 469 if (value)
470 regval |= BIT(index);
471 else
472 regval &= ~(BIT(index));
473
474 writel(regval, pctl->membase + reg);
469} 475}
470 476
471static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc, 477static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,