add diag and switch support for brcm47xx-2.6
authorFelix Fietkau <nbd@openwrt.org>
Wed, 14 Mar 2007 01:19:24 +0000 (01:19 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 14 Mar 2007 01:19:24 +0000 (01:19 +0000)
SVN-Revision: 6562

package/broadcom-diag/Makefile
package/broadcom-diag/src/diag.c
package/broadcom-diag/src/diag.h
package/broadcom-diag/src/gpio.h
package/switch/Makefile
package/switch/src/gpio-bcm947xx.h [new file with mode: 0644]
package/switch/src/gpio.h
package/switch/src/switch-adm.c

index 73f66136c315b3c7bbc6de4bf460168f785f99d6..c414c3d1c92b22dc1bc9a2d717c149cc819698d1 100644 (file)
@@ -18,7 +18,7 @@ include $(INCLUDE_DIR)/package.mk
 
 define KernelPackage/diag
   SUBMENU:=Other modules
 
 define KernelPackage/diag
   SUBMENU:=Other modules
-  DEPENDS:=@LINUX_2_4_BRCM||LINUX_2_6_BRCM
+  DEPENDS:=@LINUX_2_4_BRCM||LINUX_2_6_BRCM||LINUX_2_6_BRCM47XX
   TITLE:=Driver for router LEDs and Buttons
   VERSION:=$(PKG_RELEASE)+$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)
   FILES:=$(PKG_BUILD_DIR)/diag.$(LINUX_KMOD_SUFFIX)
   TITLE:=Driver for router LEDs and Buttons
   VERSION:=$(PKG_RELEASE)+$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)
   FILES:=$(PKG_BUILD_DIR)/diag.$(LINUX_KMOD_SUFFIX)
@@ -29,12 +29,16 @@ define Build/Prepare
        $(CP) ./src/* $(PKG_BUILD_DIR)/
 endef
 
        $(CP) ./src/* $(PKG_BUILD_DIR)/
 endef
 
+ifeq ($(BOARD),brcm)
+       BUILDFLAGS=-DBCMDRIVER -I$(LINUX_DIR)/arch/mips/bcm947xx/include
+endif
+
 define Build/Compile
        $(MAKE) -C "$(LINUX_DIR)" \
                CROSS_COMPILE="$(TARGET_CROSS)" \
                ARCH="$(LINUX_KARCH)" \
                SUBDIRS="$(PKG_BUILD_DIR)" \
 define Build/Compile
        $(MAKE) -C "$(LINUX_DIR)" \
                CROSS_COMPILE="$(TARGET_CROSS)" \
                ARCH="$(LINUX_KARCH)" \
                SUBDIRS="$(PKG_BUILD_DIR)" \
-               EXTRA_CFLAGS="-DBCMDRIVER -I$(LINUX_DIR)/arch/mips/bcm947xx/include" \
+               EXTRA_CFLAGS="$(BUILDFLAGS)" \
                modules
 endef
        
                modules
 endef
        
index 5b9ff027f261e0cadbee804531df6dc9159f1167..a47d13993d9b99d4a4c3bafcc9b1a980827f495a 100644 (file)
@@ -539,8 +539,11 @@ static struct platform_t __init *platform_detect(void)
        boardnum = getvar("boardnum");
        boardtype = getvar("boardtype");
 
        boardnum = getvar("boardnum");
        boardtype = getvar("boardtype");
 
-       if (strncmp(getvar("model_no"), "WL700",5) == 0) {
-               return &platforms[WL700GE]; }
+       if (strcmp(getvar("nvram_type"), "cfe") == 0)
+               return &platforms[WGT634U];
+       
+       if (strncmp(getvar("model_no"), "WL700",5) == 0)
+               return &platforms[WL700GE];
 
        if (strncmp(getvar("pmon_ver"), "CFE", 3) == 0) {
                /* CFE based - newer hardware */
 
        if (strncmp(getvar("pmon_ver"), "CFE", 3) == 0) {
                /* CFE based - newer hardware */
index af30823aae1b2a0975eeea11cfd3cc06146975b2..dcc122ad2b5cfcf9629d5f46fbb0983917129ff3 100644 (file)
@@ -21,6 +21,7 @@
  * $Id:$
  */
 
  * $Id:$
  */
 
+#include <linux/irq.h>
 #define MODULE_NAME "diag"
 
 #define MAX_GPIO 8
 #define MODULE_NAME "diag"
 
 #define MAX_GPIO 8
index c6f34bdea2794bd3d633d475bf20fa1dd2df5a25..982caddae4e384616f472d0bd75013545141967d 100644 (file)
@@ -1,5 +1,77 @@
 #ifndef __DIAG_GPIO_H
 #define __DIAG_GPIO_H
 #ifndef __DIAG_GPIO_H
 #define __DIAG_GPIO_H
+#include <linux/interrupt.h>
+
+#ifndef BCMDRIVER
+#include <linux/ssb/ssb.h>
+#include <linux/ssb/ssb_driver_chipcommon.h>
+#include <linux/ssb/ssb_driver_extif.h>
+
+extern struct ssb_bus ssb;
+
+#define gpio_op(op, param...) \
+       do { \
+               if (ssb.chipco.dev) \
+                       return ssb_chipco_gpio_##op(&ssb.chipco, param); \
+               else if (ssb.extif.dev) \
+                       return ssb_extif_gpio_##op(&ssb.extif, param); \
+               else \
+                       return 0; \
+       } while (0);
+               
+
+static inline u32 gpio_in(void)
+{
+       gpio_op(in, ~0);
+}
+
+static inline u32 gpio_out(u32 mask, u32 value)
+{
+       gpio_op(out, mask, value);
+}
+
+static inline u32 gpio_outen(u32 mask, u32 value)
+{
+       gpio_op(outen, mask, value);
+}
+
+static inline u32 gpio_control(u32 mask, u32 value)
+{
+       if (ssb.chipco.dev)
+               return ssb_chipco_gpio_control(&ssb.chipco, mask, value);
+       else
+               return 0;
+}
+
+static inline u32 gpio_intmask(u32 mask, u32 value)
+{
+       gpio_op(intmask, mask, value);
+}
+
+static inline u32 gpio_intpolarity(u32 mask, u32 value)
+{
+       gpio_op(polarity, mask, value);
+}
+
+static void gpio_set_irqenable(int enabled, irqreturn_t (*handler)(int, void *, struct pt_regs *))
+{
+       int irq;
+
+       if (ssb.chipco.dev)
+               irq = ssb_mips_irq(ssb.chipco.dev) + 2;
+       else if (ssb.extif.dev)
+               irq = ssb_mips_irq(ssb.extif.dev) + 2;
+       else return;
+       
+       if (enabled)
+               request_irq(irq, handler, SA_SHIRQ | SA_SAMPLE_RANDOM, "gpio", handler);
+       else
+               free_irq(irq, handler);
+
+       gpio_intmask(1, (enabled ? 1 : 0));
+}
+
+#else
 
 #include <typedefs.h>
 #include <osl.h>
 
 #include <typedefs.h>
 #include <osl.h>
 #define sbh_lock bcm947xx_sbh_lock
 #endif
 
 #define sbh_lock bcm947xx_sbh_lock
 #endif
 
-#define EXTIF_ADDR 0x1f000000
-#define EXTIF_UART (EXTIF_ADDR + 0x00800000)
-
-#define GPIO_TYPE_NORMAL       (0x0 << 24)
-#define GPIO_TYPE_EXTIF        (0x1 << 24)
-#define GPIO_TYPE_MASK         (0xf << 24)
-
 extern void *sbh;
 extern spinlock_t sbh_lock;
 
 extern void *sbh;
 extern spinlock_t sbh_lock;
 
@@ -65,6 +130,15 @@ static void gpio_set_irqenable(int enabled, irqreturn_t (*handler)(int, void *,
        spin_unlock_irqrestore(sbh_lock, flags);
 }
 
        spin_unlock_irqrestore(sbh_lock, flags);
 }
 
+#endif /* BCMDRIVER */
+
+#define EXTIF_ADDR 0x1f000000
+#define EXTIF_UART (EXTIF_ADDR + 0x00800000)
+
+#define GPIO_TYPE_NORMAL       (0x0 << 24)
+#define GPIO_TYPE_EXTIF        (0x1 << 24)
+#define GPIO_TYPE_MASK         (0xf << 24)
+
 static inline void gpio_set_extif(int gpio, int value)
 {
        volatile u8 *addr = (volatile u8 *) KSEG1ADDR(EXTIF_UART) + (gpio & ~GPIO_TYPE_MASK);
 static inline void gpio_set_extif(int gpio, int value)
 {
        volatile u8 *addr = (volatile u8 *) KSEG1ADDR(EXTIF_UART) + (gpio & ~GPIO_TYPE_MASK);
@@ -74,5 +148,4 @@ static inline void gpio_set_extif(int gpio, int value)
                *addr;
 }
 
                *addr;
 }
 
-
-#endif
+#endif /* __DIAG_GPIO_H */
index 0ad6c3398d2f4acbb31bae5479c51d22591947ba..172d9911feae2a23903193e3fd4eb3bb03741052 100644 (file)
@@ -4,7 +4,7 @@
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
 #
-# $Id:$
+# $Id$
 
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
@@ -18,7 +18,7 @@ include $(INCLUDE_DIR)/package.mk
 
 define KernelPackage/switch
   SUBMENU:=Other modules
 
 define KernelPackage/switch
   SUBMENU:=Other modules
-  DEPENDS:=@LINUX_2_6_BRCM||LINUX_2_4_BRCM
+  DEPENDS:=@LINUX_2_6_BRCM||LINUX_2_4_BRCM||LINUX_2_6_BRCM47XX
   TITLE:=Switch drivers
   DESCRIPTION:=\
        This package contains switch drivers for ADM6996L and BCM53XX RoboSwitch.
   TITLE:=Switch drivers
   DESCRIPTION:=\
        This package contains switch drivers for ADM6996L and BCM53XX RoboSwitch.
@@ -35,12 +35,21 @@ define Build/Prepare
        $(CP) ./src/* $(PKG_BUILD_DIR)/
 endef
 
        $(CP) ./src/* $(PKG_BUILD_DIR)/
 endef
 
+ifeq ($(BOARD),brcm)
+BUILDFLAGS := -DBROADCOM -DBCMDRIVER
+else
+ifeq ($(BOARD),brcm47xx)
+BUILDFLAGS := -DBROADCOM
+endif
+endif
+
+
 define Build/Compile
        $(MAKE) -C "$(LINUX_DIR)" \
                CROSS_COMPILE="$(TARGET_CROSS)" \
                ARCH="$(LINUX_KARCH)" \
                SUBDIRS="$(PKG_BUILD_DIR)" \
 define Build/Compile
        $(MAKE) -C "$(LINUX_DIR)" \
                CROSS_COMPILE="$(TARGET_CROSS)" \
                ARCH="$(LINUX_KARCH)" \
                SUBDIRS="$(PKG_BUILD_DIR)" \
-               EXTRA_CFLAGS="-DBCMGPIO2" \
+               EXTRA_CFLAGS="$(BUILDFLAGS)" \
                modules
 endef
        
                modules
 endef
        
diff --git a/package/switch/src/gpio-bcm947xx.h b/package/switch/src/gpio-bcm947xx.h
new file mode 100644 (file)
index 0000000..384ea3e
--- /dev/null
@@ -0,0 +1,86 @@
+#ifndef __SWITCH_GPIO_H
+#define __SWITCH_GPIO_H
+#include <linux/interrupt.h>
+
+#ifndef BCMDRIVER
+#include <linux/ssb/ssb.h>
+#include <linux/ssb/ssb_driver_chipcommon.h>
+#include <linux/ssb/ssb_driver_extif.h>
+
+extern struct ssb_bus ssb;
+
+#define gpio_op(op, param...) \
+       do { \
+               if (ssb.chipco.dev) \
+                       return ssb_chipco_gpio_##op(&ssb.chipco, param); \
+               else if (ssb.extif.dev) \
+                       return ssb_extif_gpio_##op(&ssb.extif, param); \
+               else \
+                       return 0; \
+       } while (0);
+               
+
+static inline u32 gpio_in(void)
+{
+       gpio_op(in, ~0);
+}
+
+static inline u32 gpio_out(u32 mask, u32 value)
+{
+       gpio_op(out, mask, value);
+}
+
+static inline u32 gpio_outen(u32 mask, u32 value)
+{
+       gpio_op(outen, mask, value);
+}
+
+static inline u32 gpio_control(u32 mask, u32 value)
+{
+       if (ssb.chipco.dev)
+               return ssb_chipco_gpio_control(&ssb.chipco, mask, value);
+       else
+               return 0;
+}
+
+static inline u32 gpio_intmask(u32 mask, u32 value)
+{
+       gpio_op(intmask, mask, value);
+}
+
+static inline u32 gpio_intpolarity(u32 mask, u32 value)
+{
+       gpio_op(polarity, mask, value);
+}
+
+#else
+
+#include <typedefs.h>
+#include <osl.h>
+#include <bcmdevs.h>
+#include <sbutils.h>
+#include <sbconfig.h>
+#include <sbchipc.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#include <sbmips.h>
+#else
+#include <hndcpu.h>
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#define sbh bcm947xx_sbh
+#define sbh_lock bcm947xx_sbh_lock
+#endif
+
+extern void *sbh;
+extern spinlock_t sbh_lock;
+
+#define gpio_in()      sb_gpioin(sbh)
+#define gpio_out(mask, value)  sb_gpioout(sbh, mask, ((value) & (mask)), GPIO_DRV_PRIORITY)
+#define gpio_outen(mask, value)        sb_gpioouten(sbh, mask, value, GPIO_DRV_PRIORITY)
+#define gpio_control(mask, value)      sb_gpiocontrol(sbh, mask, value, GPIO_DRV_PRIORITY)
+#define gpio_intmask(mask, value)      sb_gpiointmask(sbh, mask, value, GPIO_DRV_PRIORITY)
+#define gpio_intpolarity(mask, value)  sb_gpiointpolarity(sbh, mask, value, GPIO_DRV_PRIORITY)
+
+#endif /* BCMDRIVER */
+#endif /* __SWITCH_GPIO_H */
index 800ae25a9fba552fd37975ae11a59e52b8e96b1c..f4fadfc6407536a30958d2af2865576b416b4658 100644 (file)
@@ -8,45 +8,10 @@
 #ifndef __GPIO_H
 #define __GPIO_H
 
 #ifndef __GPIO_H
 #define __GPIO_H
 
-#if defined(BCMGPIO2)
-
-#ifdef LINUX_2_4
-#define sbh bcm947xx_sbh
-extern void *bcm947xx_sbh;
-#else
-extern void *sbh;
-#endif
-
-extern __u32 sb_gpioin(void *sbh);
-extern __u32 sb_gpiointpolarity(void *sbh, __u32 mask, __u32 val, __u8 prio);
-extern __u32 sb_gpiointmask(void *sbh, __u32 mask, __u32 val, __u8 prio);
-extern __u32 sb_gpioouten(void *sbh, __u32 mask, __u32 val, __u8 prio);
-extern __u32 sb_gpioout(void *sbh, __u32 mask, __u32 val, __u8 prio);
-
-#define gpioin() sb_gpioin(sbh)
-#define gpiointpolarity(mask,val) sb_gpiointpolarity(sbh, mask, val, 0)
-#define gpiointmask(mask,val) sb_gpiointmask(sbh, mask, val, 0)
-#define gpioouten(mask,val) sb_gpioouten(sbh, mask, val, 0)
-#define gpioout(mask,val) sb_gpioout(sbh, mask, val, 0)
-
-#elif defined(BCMGPIO)
-
-#define sbh bcm947xx_sbh
-extern void *bcm947xx_sbh;
-extern __u32 sb_gpioin(void *sbh);
-extern __u32 sb_gpiointpolarity(void *sbh, __u32 mask, __u32 val);
-extern __u32 sb_gpiointmask(void *sbh, __u32 mask, __u32 val);
-extern __u32 sb_gpioouten(void *sbh, __u32 mask, __u32 val);
-extern __u32 sb_gpioout(void *sbh, __u32 mask, __u32 val);
-
-#define gpioin() sb_gpioin(sbh)
-#define gpiointpolarity(mask,val) sb_gpiointpolarity(sbh, mask, val)
-#define gpiointmask(mask,val) sb_gpiointmask(sbh, mask, val)
-#define gpioouten(mask,val) sb_gpioouten(sbh, mask, val)
-#define gpioout(mask,val) sb_gpioout(sbh, mask, val)
-
+#ifdef BROADCOM
+#include "gpio-bcm947xx.h"
 #else
 #else
-#error Unsupported/unknown GPIO configuration
+#error "Unsupported configuration."
 #endif
 
 #endif /* __GPIO_H */
 #endif
 
 #endif /* __GPIO_H */
index 85805f6b3a2eb25d31e0ee190b4eeeb235b94fa3..8d96316b7c1043eec19aa99e65957c928eb1d923 100644 (file)
@@ -109,7 +109,7 @@ static void adm_write(int cs, char *buf, unsigned int bits)
        int i, len = (bits + 7) / 8;
        __u8 mask;
 
        int i, len = (bits + 7) / 8;
        __u8 mask;
 
-       gpioout(eecs, (cs ? eecs : 0));
+       gpio_out(eecs, (cs ? eecs : 0));
        udelay(EECK_EDGE_TIME);
 
        /* Byte assemble from MSB to LSB */
        udelay(EECK_EDGE_TIME);
 
        /* Byte assemble from MSB to LSB */
@@ -117,25 +117,25 @@ static void adm_write(int cs, char *buf, unsigned int bits)
                /* Bit bang from MSB to LSB */
                for (mask = 0x80; mask && bits > 0; mask >>= 1, bits --) {
                        /* Clock low */
                /* Bit bang from MSB to LSB */
                for (mask = 0x80; mask && bits > 0; mask >>= 1, bits --) {
                        /* Clock low */
-                       gpioout(eesk, 0);
+                       gpio_out(eesk, 0);
                        udelay(EECK_EDGE_TIME);
 
                        /* Output on rising edge */
                        udelay(EECK_EDGE_TIME);
 
                        /* Output on rising edge */
-                       gpioout(eedi, ((mask & buf[i]) ? eedi : 0));
+                       gpio_out(eedi, ((mask & buf[i]) ? eedi : 0));
                        udelay(EEDI_SETUP_TIME);
 
                        /* Clock high */
                        udelay(EEDI_SETUP_TIME);
 
                        /* Clock high */
-                       gpioout(eesk, eesk);
+                       gpio_out(eesk, eesk);
                        udelay(EECK_EDGE_TIME);
                }
        }
 
        /* Clock low */
                        udelay(EECK_EDGE_TIME);
                }
        }
 
        /* Clock low */
-       gpioout(eesk, 0);
+       gpio_out(eesk, 0);
        udelay(EECK_EDGE_TIME);
 
        if (cs)
        udelay(EECK_EDGE_TIME);
 
        if (cs)
-               gpioout(eecs, 0);
+               gpio_out(eecs, 0);
 }
 
 
 }
 
 
@@ -144,7 +144,7 @@ static void adm_read(int cs, char *buf, unsigned int bits)
        int i, len = (bits + 7) / 8;
        __u8 mask;
 
        int i, len = (bits + 7) / 8;
        __u8 mask;
 
-       gpioout(eecs, (cs ? eecs : 0));
+       gpio_out(eecs, (cs ? eecs : 0));
        udelay(EECK_EDGE_TIME);
 
        /* Byte assemble from MSB to LSB */
        udelay(EECK_EDGE_TIME);
 
        /* Byte assemble from MSB to LSB */
@@ -156,16 +156,16 @@ static void adm_read(int cs, char *buf, unsigned int bits)
                        __u8 gp;
 
                        /* Clock low */
                        __u8 gp;
 
                        /* Clock low */
-                       gpioout(eesk, 0);
+                       gpio_out(eesk, 0);
                        udelay(EECK_EDGE_TIME);
 
                        /* Input on rising edge */
                        udelay(EECK_EDGE_TIME);
 
                        /* Input on rising edge */
-                       gp = gpioin();
+                       gp = gpio_in();
                        if (gp & eedi)
                                byte |= mask;
 
                        /* Clock high */
                        if (gp & eedi)
                                byte |= mask;
 
                        /* Clock high */
-                       gpioout(eesk, eesk);
+                       gpio_out(eesk, eesk);
                        udelay(EECK_EDGE_TIME);
                }
 
                        udelay(EECK_EDGE_TIME);
                }
 
@@ -173,11 +173,11 @@ static void adm_read(int cs, char *buf, unsigned int bits)
        }
 
        /* Clock low */
        }
 
        /* Clock low */
-       gpioout(eesk, 0);
+       gpio_out(eesk, 0);
        udelay(EECK_EDGE_TIME);
 
        if (cs)
        udelay(EECK_EDGE_TIME);
 
        if (cs)
-               gpioout(eecs, 0);
+               gpio_out(eecs, 0);
 }
 
 
 }
 
 
@@ -185,10 +185,10 @@ static void adm_read(int cs, char *buf, unsigned int bits)
 static void adm_enout(__u8 pins, __u8 val)
 {   
        /* Prepare GPIO output value */
 static void adm_enout(__u8 pins, __u8 val)
 {   
        /* Prepare GPIO output value */
-       gpioout(pins, val);
+       gpio_out(pins, val);
        
        /* Enable GPIO outputs */
        
        /* Enable GPIO outputs */
-       gpioouten(pins, pins);
+       gpio_outen(pins, pins);
        udelay(EECK_EDGE_TIME);
 }
 
        udelay(EECK_EDGE_TIME);
 }
 
@@ -197,7 +197,7 @@ static void adm_enout(__u8 pins, __u8 val)
 static void adm_disout(__u8 pins)
 {   
        /* Disable GPIO outputs */
 static void adm_disout(__u8 pins)
 {   
        /* Disable GPIO outputs */
-       gpioouten(pins, 0);
+       gpio_outen(pins, 0);
        udelay(EECK_EDGE_TIME);
 }
 
        udelay(EECK_EDGE_TIME);
 }
 
@@ -208,11 +208,11 @@ static void adm_adclk(int clocks)
        int i;
        for (i = 0; i < clocks; i++) {
                /* Clock high */
        int i;
        for (i = 0; i < clocks; i++) {
                /* Clock high */
-               gpioout(eesk, eesk);
+               gpio_out(eesk, eesk);
                udelay(EECK_EDGE_TIME);
 
                /* Clock low */
                udelay(EECK_EDGE_TIME);
 
                /* Clock low */
-               gpioout(eesk, 0);
+               gpio_out(eesk, 0);
                udelay(EECK_EDGE_TIME);
        }
 }
                udelay(EECK_EDGE_TIME);
        }
 }