Skip to content

Commit

Permalink
MIPS: RB532: Auto disable GPIO alternate function
Browse files Browse the repository at this point in the history
When a driver calls gpio_set_direction_{input,output}(), it obviously
doesn't want the alternate function for that pin to be active (as the
direction would not matter in that case). This patch ensures alternate
function is disabled when the direction is being changed.

Signed-off-by: Phil Sutter <n0-1@freewrt.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Phil Sutter authored and Ralf Baechle committed Jan 30, 2009
1 parent 4aa0f4d commit 33763d5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions arch/mips/rb532/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset)

gpch = container_of(chip, struct rb532_gpio_chip, chip);

if (rb532_get_bit(offset, gpch->regbase + GPIOFUNC))
return 1; /* alternate function, GPIOCFG is ignored */
/* disable alternate function in case it's set */
rb532_set_bit(0, offset, gpch->regbase + GPIOFUNC);

rb532_set_bit(0, offset, gpch->regbase + GPIOCFG);
return 0;
Expand All @@ -186,8 +186,8 @@ static int rb532_gpio_direction_output(struct gpio_chip *chip,

gpch = container_of(chip, struct rb532_gpio_chip, chip);

if (rb532_get_bit(offset, gpch->regbase + GPIOFUNC))
return 1; /* alternate function, GPIOCFG is ignored */
/* disable alternate function in case it's set */
rb532_set_bit(0, offset, gpch->regbase + GPIOFUNC);

/* set the initial output value */
rb532_set_bit(value, offset, gpch->regbase + GPIOD);
Expand Down

0 comments on commit 33763d5

Please sign in to comment.