linux-mips
[Top] [All Lists]

[PATCH] MIPS: rb532: auto disable GPIO alternate function

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH] MIPS: rb532: auto disable GPIO alternate function
From: Phil Sutter <n0-1@freewrt.org>
Date: Fri, 28 Nov 2008 20:46:09 +0100
Cc: linux-mips@linux-mips.org
In-reply-to: <20081128193322.D103C386DBBE@mail.ifyouseekate.net>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20081128193322.D103C386DBBE@mail.ifyouseekate.net>
Sender: linux-mips-bounce@linux-mips.org
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>
---
 arch/mips/rb532/gpio.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c
index e35cb75..f5b15a1 100644
--- a/arch/mips/rb532/gpio.c
+++ b/arch/mips/rb532/gpio.c
@@ -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;
@@ -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);
-- 
1.5.6.4


<Prev in Thread] Current Thread [Next in Thread>