aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/bcm63xx/gpio.c41
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h1
2 files changed, 37 insertions, 5 deletions
diff --git a/arch/mips/bcm63xx/gpio.c b/arch/mips/bcm63xx/gpio.c
index f560fe7d38d..a6c2135dbf3 100644
--- a/arch/mips/bcm63xx/gpio.c
+++ b/arch/mips/bcm63xx/gpio.c
@@ -4,7 +4,7 @@
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> 6 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
7 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org> 7 * Copyright (C) 2008-2011 Florian Fainelli <florian@openwrt.org>
8 */ 8 */
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
@@ -18,6 +18,34 @@
18#include <bcm63xx_io.h> 18#include <bcm63xx_io.h>
19#include <bcm63xx_regs.h> 19#include <bcm63xx_regs.h>
20 20
21#ifndef BCMCPU_RUNTIME_DETECT
22#define gpio_out_low_reg GPIO_DATA_LO_REG
23#ifdef CONFIG_BCM63XX_CPU_6345
24#ifdef gpio_out_low_reg
25#undef gpio_out_low_reg
26#define gpio_out_low_reg GPIO_DATA_LO_REG_6345
27#endif /* gpio_out_low_reg */
28#endif /* CONFIG_BCM63XX_CPU_6345 */
29
30static inline void bcm63xx_gpio_out_low_reg_init(void)
31{
32}
33#else /* ! BCMCPU_RUNTIME_DETECT */
34static u32 gpio_out_low_reg;
35
36static void bcm63xx_gpio_out_low_reg_init(void)
37{
38 switch (bcm63xx_get_cpu_id()) {
39 case BCM6345_CPU_ID:
40 gpio_out_low_reg = GPIO_DATA_LO_REG_6345;
41 break;
42 default:
43 gpio_out_low_reg = GPIO_DATA_LO_REG;
44 break;
45 }
46}
47#endif /* ! BCMCPU_RUNTIME_DETECT */
48
21static DEFINE_SPINLOCK(bcm63xx_gpio_lock); 49static DEFINE_SPINLOCK(bcm63xx_gpio_lock);
22static u32 gpio_out_low, gpio_out_high; 50static u32 gpio_out_low, gpio_out_high;
23 51
@@ -33,7 +61,7 @@ static void bcm63xx_gpio_set(struct gpio_chip *chip,
33 BUG(); 61 BUG();
34 62
35 if (gpio < 32) { 63 if (gpio < 32) {
36 reg = GPIO_DATA_LO_REG; 64 reg = gpio_out_low_reg;
37 mask = 1 << gpio; 65 mask = 1 << gpio;
38 v = &gpio_out_low; 66 v = &gpio_out_low;
39 } else { 67 } else {
@@ -60,7 +88,7 @@ static int bcm63xx_gpio_get(struct gpio_chip *chip, unsigned gpio)
60 BUG(); 88 BUG();
61 89
62 if (gpio < 32) { 90 if (gpio < 32) {
63 reg = GPIO_DATA_LO_REG; 91 reg = gpio_out_low_reg;
64 mask = 1 << gpio; 92 mask = 1 << gpio;
65 } else { 93 } else {
66 reg = GPIO_DATA_HI_REG; 94 reg = GPIO_DATA_HI_REG;
@@ -125,8 +153,11 @@ static struct gpio_chip bcm63xx_gpio_chip = {
125 153
126int __init bcm63xx_gpio_init(void) 154int __init bcm63xx_gpio_init(void)
127{ 155{
128 gpio_out_low = bcm_gpio_readl(GPIO_DATA_LO_REG); 156 bcm63xx_gpio_out_low_reg_init();
129 gpio_out_high = bcm_gpio_readl(GPIO_DATA_HI_REG); 157
158 gpio_out_low = bcm_gpio_readl(gpio_out_low_reg);
159 if (!BCMCPU_IS_6345())
160 gpio_out_high = bcm_gpio_readl(GPIO_DATA_HI_REG);
130 bcm63xx_gpio_chip.ngpio = bcm63xx_gpio_count(); 161 bcm63xx_gpio_chip.ngpio = bcm63xx_gpio_count();
131 pr_info("registering %d GPIOs\n", bcm63xx_gpio_chip.ngpio); 162 pr_info("registering %d GPIOs\n", bcm63xx_gpio_chip.ngpio);
132 163
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
index 6c9940fb7b7..94d4faad29a 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
@@ -437,6 +437,7 @@
437#define GPIO_CTL_LO_REG 0x4 437#define GPIO_CTL_LO_REG 0x4
438#define GPIO_DATA_HI_REG 0x8 438#define GPIO_DATA_HI_REG 0x8
439#define GPIO_DATA_LO_REG 0xC 439#define GPIO_DATA_LO_REG 0xC
440#define GPIO_DATA_LO_REG_6345 0x8
440 441
441/* GPIO mux registers and constants */ 442/* GPIO mux registers and constants */
442#define GPIO_MODE_REG 0x18 443#define GPIO_MODE_REG 0x18