X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/8570a82f7c494d4da9063235227a72103dfa989a..ae57d8838ce086c44a95b54816191ed9e92545b2:/package/switch/src/switch-robo.c diff --git a/package/switch/src/switch-robo.c b/package/switch/src/switch-robo.c index 045dce1c4..7884bd8b6 100644 --- a/package/switch/src/switch-robo.c +++ b/package/switch/src/switch-robo.c @@ -21,7 +21,6 @@ * 02110-1301, USA. */ -#include #include #include #include @@ -41,6 +40,7 @@ #define ROBO_PHY_ADDR 0x1E /* robo switch phy address */ #define ROBO_PHY_ADDR_TG3 0x01 /* Tigon3 PHY address */ +#define ROBO_PHY_ADDR_BCM63XX 0x00 /* BCM63XX PHY address */ /* MII registers */ #define REG_MII_PAGE 0x10 /* MII Page register */ @@ -57,14 +57,18 @@ #define ROBO_DEVICE_ID_5395 0x95 #define ROBO_DEVICE_ID_5397 0x97 #define ROBO_DEVICE_ID_5398 0x98 +#define ROBO_DEVICE_ID_53115 0x3115 /* Private et.o ioctls */ #define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9) #define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10) -/* linux 2.4 does not have 'bool' */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#define bool int +/* 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. */ @@ -92,7 +96,11 @@ static int do_ioctl(int cmd, void *buf) robo.ifr.ifr_data = (caddr_t) buf; set_fs(KERNEL_DS); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + ret = robo.dev->netdev_ops->ndo_do_ioctl(robo.dev, &robo.ifr, cmd); +#else ret = robo.dev->do_ioctl(robo.dev, &robo.ifr, cmd); +#endif set_fs(old_fs); return ret; @@ -270,8 +278,9 @@ static int robo_switch_enable(void) robo_write16(ROBO_CTRL_PAGE, i, 0); } - /* WAN port LED */ - robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F); + /* WAN port LED, except for Netgear WGT634U */ + if (strcmp(getvar("nvram_type"), "cfe") != 0) + robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F); return 0; } @@ -283,6 +292,7 @@ static void robo_switch_reset(void) (robo.devid == ROBO_DEVICE_ID_5398)) { /* Trigger a software reset. */ robo_write16(ROBO_CTRL_PAGE, 0x79, 0x83); + mdelay(500); robo_write16(ROBO_CTRL_PAGE, 0x79, 0); } } @@ -318,13 +328,14 @@ static int robo_probe(char *devname) /* got phy address check for robo address */ struct mii_ioctl_data *mii = (struct mii_ioctl_data *) &robo.ifr.ifr_data; if ((mii->phy_id != ROBO_PHY_ADDR) && + (mii->phy_id != ROBO_PHY_ADDR_BCM63XX) && (mii->phy_id != ROBO_PHY_ADDR_TG3)) { printk("Invalid phy address (%d)\n", mii->phy_id); return 1; } robo.use_et = 0; /* The robo has a fixed PHY address that is different from the - * Tigon3 PHY address. */ + * Tigon3 and BCM63xx PHY address. */ robo.phy_addr = ROBO_PHY_ADDR; } @@ -332,7 +343,7 @@ static int robo_probe(char *devname) (mdio_read(robo.phy_addr, 0x3) << 16); if (phyid == 0xffffffff || phyid == 0x55210022) { - printk("No Robo switch in managed mode found\n"); + printk("No Robo switch in managed mode found, phy_id = 0x%08x\n", phyid); return 1; } @@ -352,7 +363,8 @@ static int robo_probe(char *devname) if (err) return err; - printk("found!\n"); + printk("found a 5%s%x!%s\n", robo.devid & 0xff00 ? "" : "3", robo.devid, + robo.is_5350 ? " It's a 5350." : ""); return 0; } @@ -430,6 +442,17 @@ static int handle_vlan_port_write(void *driver, char *buf, int nr) } /* write config now */ + + if (robo.devid != ROBO_DEVICE_ID_5325) { + __u8 regoff = ((robo.devid == ROBO_DEVICE_ID_5395) || + (robo.devid == ROBO_DEVICE_ID_53115)) ? 0x20 : 0; + + robo_write32(ROBO_ARLIO_PAGE, 0x63 + regoff, (c->untag << 9) | c->port); + robo_write16(ROBO_ARLIO_PAGE, 0x61 + regoff, nr); + robo_write16(ROBO_ARLIO_PAGE, 0x60 + regoff, 1 << 7); + return 0; + } + val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */; if (robo.is_5350) { robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, @@ -471,7 +494,12 @@ static int handle_enable_vlan_write(void *driver, char *buf, int nr) robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0, disable ? 0 : (1 << 7) /* 802.1Q VLAN */ | (3 << 5) /* mac check and hash */); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1, disable ? 0 : - (1 << 1) | (1 << 2) | (1 << 3) /* RSV multicast */); + (robo.devid == ROBO_DEVICE_ID_5325 ? (1 << 1) : + 0) | (1 << 2) | (1 << 3)); /* RSV multicast */ + + if (robo.devid != ROBO_DEVICE_ID_5325) + return 0; + robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL4, disable ? 0 : (1 << 6) /* drop invalid VID frames */); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL5, disable ? 0 : @@ -528,7 +556,8 @@ static int __init robo_init(void) device = strdup("ethX"); for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) { - notfound = robo_probe(device); + if (! switch_device_registered (device)) + notfound = robo_probe(device); } device[3]--; @@ -569,6 +598,10 @@ static int __init robo_init(void) .port_handlers = NULL, .vlan_handlers = vlan, }; + if (robo.devid != ROBO_DEVICE_ID_5325) { + driver.ports = 9; + driver.cpuport = 8; + } return switch_register_driver(&driver); }