switch: update for brcm47xx target

* remove suport for 2.4 kernel
* add support for bcma bus

SVN-Revision: 27904
owl
Hauke Mehrtens 2011-08-04 20:07:58 +00:00
parent 695cef4f45
commit b220442c75
7 changed files with 82 additions and 101 deletions

View File

@ -33,10 +33,6 @@ define Build/Prepare
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
ifeq ($(BOARD),brcm47xx)
BUILDFLAGS := -DBROADCOM
endif
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
CROSS_COMPILE="$(TARGET_CROSS)" \

View File

@ -1,75 +1,55 @@
#ifndef __SWITCH_GPIO_H
#define __SWITCH_GPIO_H
#include <linux/interrupt.h>
#ifndef BCMDRIVER
#include <linux/ssb/ssb_embedded.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
#define ssb ssb_bcm47xx
#endif
extern struct ssb_bus ssb;
#include <linux/bcma/bcma_driver_chipcommon.h>
#include <bcm47xx.h>
static inline u32 gpio_in(void)
{
return ssb_gpio_in(&ssb, ~0);
switch (bcm47xx_bus_type) {
#ifdef CONFIG_BCM47XX_SSB
case BCM47XX_BUS_TYPE_SSB:
return ssb_gpio_in(&bcm47xx_bus.ssb, ~0);
#endif
#ifdef CONFIG_BCM47XX_BCMA
case BCM47XX_BUS_TYPE_BCMA:
return bcma_chipco_gpio_in(&bcm47xx_bus.bcma.bus.drv_cc, ~0);
#endif
}
return -EINVAL;
}
static inline u32 gpio_out(u32 mask, u32 value)
{
return ssb_gpio_out(&ssb, mask, value);
switch (bcm47xx_bus_type) {
#ifdef CONFIG_BCM47XX_SSB
case BCM47XX_BUS_TYPE_SSB:
return ssb_gpio_out(&bcm47xx_bus.ssb, mask, value);
#endif
#ifdef CONFIG_BCM47XX_BCMA
case BCM47XX_BUS_TYPE_BCMA:
return bcma_chipco_gpio_out(&bcm47xx_bus.bcma.bus.drv_cc, mask, value);
#endif
}
return -EINVAL;
}
static inline u32 gpio_outen(u32 mask, u32 value)
{
return ssb_gpio_outen(&ssb, mask, value);
}
static inline u32 gpio_control(u32 mask, u32 value)
{
return ssb_gpio_control(&ssb, mask, value);
}
static inline u32 gpio_intmask(u32 mask, u32 value)
{
return ssb_gpio_intmask(&ssb, mask, value);
}
static inline u32 gpio_intpolarity(u32 mask, u32 value)
{
return ssb_gpio_polarity(&ssb, 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>
switch (bcm47xx_bus_type) {
#ifdef CONFIG_BCM47XX_SSB
case BCM47XX_BUS_TYPE_SSB:
ssb_gpio_outen(&bcm47xx_bus.ssb, mask, value);
return 0;
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#define sbh bcm947xx_sbh
#define sbh_lock bcm947xx_sbh_lock
#ifdef CONFIG_BCM47XX_BCMA
case BCM47XX_BUS_TYPE_BCMA:
bcma_chipco_gpio_outen(&bcm47xx_bus.bcma.bus.drv_cc, mask, value);
return 0;
#endif
}
return -EINVAL;
}
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 */

View File

@ -8,7 +8,7 @@
#ifndef __GPIO_H
#define __GPIO_H
#ifdef BROADCOM
#ifdef CONFIG_BCM47XX
#include "gpio-bcm947xx.h"
#else
#warning "Unsupported configuration."

View File

@ -37,6 +37,10 @@
#include "switch-core.h"
#include "gpio.h"
#ifdef CONFIG_BCM47XX
#include <nvram.h>
#endif
#define DRIVER_NAME "adm6996"
#define DRIVER_VERSION "0.01"
@ -48,19 +52,11 @@ static int force = 0;
MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
MODULE_LICENSE("GPL");
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,52)
module_param(eecs, int, 0);
module_param(eesk, int, 0);
module_param(eedi, int, 0);
module_param(eerc, int, 0);
module_param(force, int, 0);
#else
MODULE_PARM(eecs, "i");
MODULE_PARM(eesk, "i");
MODULE_PARM(eedi, "i");
MODULE_PARM(eerc, "i");
MODULE_PARM(force, "i");
#endif
/* Minimum timing constants */
#define EECK_EDGE_TIME 3 /* 3us - max(adm 2.5us, 93c 1us) */
@ -74,8 +70,7 @@ MODULE_PARM(force, "i");
#define atoi(str) simple_strtoul(((str != NULL) ? str : ""), NULL, 0)
#ifdef BROADCOM
extern char *nvram_get(char *name);
#ifdef CONFIG_BCM47XX
/* Return gpio pin number assigned to the named pin */
/*
@ -88,15 +83,16 @@ extern char *nvram_get(char *name);
static unsigned int get_gpiopin(char *pin_name, unsigned int def_pin)
{
char name[] = "gpioXXXX";
char *val;
char val[10];
unsigned int pin;
/* Go thru all possibilities till a match in pin name */
for (pin = 0; pin < 16; pin ++) {
sprintf(name, "gpio%d", pin);
val = nvram_get(name);
if (val && !strcmp(val, pin_name))
return pin;
if (nvram_getenv(name, val, sizeof(val)) >= 0) {
if (!strcmp(val, pin_name))
return pin;
}
}
return def_pin;
}
@ -495,9 +491,16 @@ static int detect_adm(void)
{
int ret = 0;
#ifdef BROADCOM
int boardflags = atoi(nvram_get("boardflags"));
int boardnum = atoi(nvram_get("boardnum"));
#ifdef CONFIG_BCM47XX
char buf[20];
int boardflags = 0;
int boardnum = 0;
if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
boardflags = simple_strtoul(buf, NULL, 0);
if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
boardnum = simple_strtoul(buf, NULL, 0);
if ((boardnum == 44) && (boardflags == 0x0388)) { /* Trendware TEW-411BRP+ */
ret = 1;
@ -515,14 +518,19 @@ static int detect_adm(void)
eedi = get_gpiopin("adm_eedi", 4);
eerc = get_gpiopin("adm_rc", 0);
} else if ((strcmp(nvram_get("boardtype") ?: "", "bcm94710dev") == 0) &&
(strncmp(nvram_get("boardnum") ?: "", "42", 2) == 0)) {
/* WRT54G v1.1 hack */
eecs = 2;
eesk = 3;
eedi = 5;
} else if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0) {
if (strcmp(buf, "bcm94710dev") == 0) {
if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0) {
if (strncmp(buf, "42", 2) == 0) {
/* WRT54G v1.1 hack */
eecs = 2;
eesk = 3;
eedi = 5;
ret = 1;
ret = 1;
}
}
}
}
if (eecs)

View File

@ -394,7 +394,6 @@ switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf)
int switch_device_registered (char* device) {
struct list_head *pos;
switch_driver *new;
list_for_each(pos, &drivers.list) {
if (strcmp(list_entry(pos, switch_driver, list)->interface, device) == 0) {

View File

@ -9,10 +9,6 @@
#define SWITCH_MEDIA_100 2
#define SWITCH_MEDIA_FD 4
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
typedef int (*switch_handler)(void *driver, char *buf, int nr);
typedef struct {

View File

@ -34,6 +34,10 @@
#include "switch-core.h"
#include "etc53xx.h"
#ifdef CONFIG_BCM47XX
#include <nvram.h>
#endif
#define DRIVER_NAME "bcm53xx"
#define DRIVER_VERSION "0.02"
#define PFX "roboswitch: "
@ -63,14 +67,6 @@
#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
/* Only available on brcm47xx */
#ifdef BROADCOM
extern char *nvram_get(const char *name);
#define getvar(str) (nvram_get(str)?:"")
#else
#define getvar(str) ""
#endif
/* Data structure for a Roboswitch device. */
struct robo_switch {
char *device; /* The device name string (ethX) */
@ -258,6 +254,9 @@ static int robo_switch_enable(void)
{
unsigned int i, last_port;
u16 val;
#ifdef CONFIG_BCM47XX
char buf[20];
#endif
val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
if (!(val & (1 << 1))) {
@ -278,10 +277,13 @@ static int robo_switch_enable(void)
robo_write16(ROBO_CTRL_PAGE, i, 0);
}
#ifdef CONFIG_BCM47XX
/* WAN port LED, except for Netgear WGT634U */
if (strcmp(getvar("nvram_type"), "cfe") != 0)
robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
if (nvram_getenv("nvram_type", buf, sizeof(buf)) >= 0) {
if (strcmp(buf, "cfe") != 0)
robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
}
#endif
return 0;
}