Skip to content

Commit

Permalink
pch_gpio: set value before enabling output direction
Browse files Browse the repository at this point in the history
This ensures that the output signal does not toggle if set to high.

Signed-off-by: Daniel Krueger <daniel.krueger@systec-electronic.com>
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Daniel Krueger authored and Linus Walleij committed Mar 27, 2014
1 parent fc86035 commit 2ddf6cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/gpio/gpio-pch.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,18 @@ static int pch_gpio_direction_output(struct gpio_chip *gpio, unsigned nr,
unsigned long flags;

spin_lock_irqsave(&chip->spinlock, flags);
pm = ioread32(&chip->reg->pm) & ((1 << gpio_pins[chip->ioh]) - 1);
pm |= (1 << nr);
iowrite32(pm, &chip->reg->pm);

reg_val = ioread32(&chip->reg->po);
if (val)
reg_val |= (1 << nr);
else
reg_val &= ~(1 << nr);
iowrite32(reg_val, &chip->reg->po);

pm = ioread32(&chip->reg->pm) & ((1 << gpio_pins[chip->ioh]) - 1);
pm |= (1 << nr);
iowrite32(pm, &chip->reg->pm);

spin_unlock_irqrestore(&chip->spinlock, flags);

return 0;
Expand Down

0 comments on commit 2ddf6cd

Please sign in to comment.