linux-mips
[Top] [All Lists]

[PATCH 3/8] bcm63xx: fix gpio set.

To: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH 3/8] bcm63xx: fix gpio set.
From: Maxime Bizon <mbizon@freebox.fr>
Date: Wed, 3 Jun 2009 16:02:22 +0200
Cc: Florian Fainelli <florian@openwrt.org>, Maxime Bizon <mbizon@freebox.fr>
In-reply-to: <1244037747-27144-1-git-send-email-mbizon@freebox.fr>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1244037747-27144-1-git-send-email-mbizon@freebox.fr>
Sender: linux-mips-bounce@linux-mips.org
Previously set gpio value can not be read back from register, we're
reading pin value instead. Keep cached value and always use it.

Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
---
 arch/mips/bcm63xx/gpio.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/mips/bcm63xx/gpio.c b/arch/mips/bcm63xx/gpio.c
index 97e3730..77636aa 100644
--- a/arch/mips/bcm63xx/gpio.c
+++ b/arch/mips/bcm63xx/gpio.c
@@ -18,12 +18,14 @@
 #include <bcm63xx_io.h>
 #include <bcm63xx_regs.h>
 
+static u32 gpio_out_low, gpio_out_high;
+
 static void bcm63xx_gpio_set(struct gpio_chip *chip,
                                unsigned gpio, int val)
 {
        u32 reg;
        u32 mask;
-       u32 tmp;
+       u32 *v;
        unsigned long flags;
 
        if (gpio >= chip->ngpio)
@@ -32,18 +34,19 @@ static void bcm63xx_gpio_set(struct gpio_chip *chip,
        if (gpio < 32) {
                reg = GPIO_DATA_LO_REG;
                mask = 1 << gpio;
+               v = &gpio_out_low;
        } else {
                reg = GPIO_DATA_HI_REG;
                mask = 1 << (gpio - 32);
+               v = &gpio_out_high;
        }
 
        local_irq_save(flags);
-       tmp = bcm_gpio_readl(reg);
        if (val)
-               tmp |= mask;
+               *v |= mask;
        else
-               tmp &= ~mask;
-       bcm_gpio_writel(tmp, reg);
+               *v &= ~mask;
+       bcm_gpio_writel(*v, reg);
        local_irq_restore(flags);
 }
 
-- 
1.6.0.4


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