linux-mips
[Top] [All Lists]

[PATCH 5/5] MIPS: bcm63xx: fix GPIO set/get for BCM6345

To: ralf@linux-mips.org
Subject: [PATCH 5/5] MIPS: bcm63xx: fix GPIO set/get for BCM6345
From: Florian Fainelli <florian@openwrt.org>
Date: Wed, 21 Sep 2011 15:39:50 +0200
Cc: linux-mips@linux-mips.org, Florian Fainelli <ffainelli@freebox.fr>, Florian Fainelli <florian@openwrt.org>
In-reply-to: <1316612390-6367-1-git-send-email-florian@openwrt.org>
References: <1316612390-6367-1-git-send-email-florian@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
From: Florian Fainelli <ffainelli@freebox.fr>

On BCM6345, the register offsets for the set/get GPIO registers is wrong
in order not add more complexity, use the HI_* variants for BCM6345
which results in reading/writing from/to the right register offsets.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
 arch/mips/bcm63xx/gpio.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/mips/bcm63xx/gpio.c b/arch/mips/bcm63xx/gpio.c
index f560fe7..154353f 100644
--- a/arch/mips/bcm63xx/gpio.c
+++ b/arch/mips/bcm63xx/gpio.c
@@ -4,7 +4,7 @@
  * for more details.
  *
  * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
- * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
+ * Copyright (C) 2008-2011 Florian Fainelli <florian@openwrt.org>
  */
 
 #include <linux/kernel.h>
@@ -33,7 +33,10 @@ static void bcm63xx_gpio_set(struct gpio_chip *chip,
                BUG();
 
        if (gpio < 32) {
-               reg = GPIO_DATA_LO_REG;
+               if (!BCMCPU_IS_6345())
+                       reg = GPIO_DATA_LO_REG;
+               else
+                       reg = GPIO_DATA_HI_REG;
                mask = 1 << gpio;
                v = &gpio_out_low;
        } else {
@@ -60,7 +63,10 @@ static int bcm63xx_gpio_get(struct gpio_chip *chip, unsigned 
gpio)
                BUG();
 
        if (gpio < 32) {
-               reg = GPIO_DATA_LO_REG;
+               if (!BCMCPU_IS_6345())
+                       reg = GPIO_DATA_LO_REG;
+               else
+                       reg = GPIO_DATA_HI_REG;
                mask = 1 << gpio;
        } else {
                reg = GPIO_DATA_HI_REG;
@@ -125,7 +131,11 @@ static struct gpio_chip bcm63xx_gpio_chip = {
 
 int __init bcm63xx_gpio_init(void)
 {
-       gpio_out_low = bcm_gpio_readl(GPIO_DATA_LO_REG);
+       if (!BCMCPU_IS_6345())
+               gpio_out_low = bcm_gpio_readl(GPIO_DATA_LO_REG);
+       else
+               gpio_out_low = bcm_gpio_readl(GPIO_DATA_HI_REG);
+
        gpio_out_high = bcm_gpio_readl(GPIO_DATA_HI_REG);
        bcm63xx_gpio_chip.ngpio = bcm63xx_gpio_count();
        pr_info("registering %d GPIOs\n", bcm63xx_gpio_chip.ngpio);
-- 
1.7.4.1


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