Fix the roboswitch code for the WRT350N

SVN-Revision: 10531
This commit is contained in:
Michael Büsch 2008-02-27 22:35:41 +00:00
parent 66340c40ff
commit a9cddc69ec
4 changed files with 275 additions and 98 deletions

View file

@ -139,18 +139,18 @@ static ssize_t switch_proc_write(struct file *file, const char *buf, size_t coun
static int handle_driver_name(void *driver, char *buf, int nr) static int handle_driver_name(void *driver, char *buf, int nr)
{ {
char *name = ((switch_driver *) driver)->name; const char *name = ((switch_driver *) driver)->name;
return sprintf(buf, "%s\n", name); return sprintf(buf, "%s\n", name);
} }
static int handle_driver_version(void *driver, char *buf, int nr) static int handle_driver_version(void *driver, char *buf, int nr)
{ {
char *version = ((switch_driver *) driver)->version; const char *version = ((switch_driver *) driver)->version;
strcpy(buf, version); strcpy(buf, version);
return sprintf(buf, "%s\n", version); return sprintf(buf, "%s\n", version);
} }
static void add_handler(switch_driver *driver, switch_config *handler, struct proc_dir_entry *parent, int nr) static void add_handler(switch_driver *driver, const switch_config *handler, struct proc_dir_entry *parent, int nr)
{ {
switch_priv *priv = (switch_priv *) driver->data; switch_priv *priv = (switch_priv *) driver->data;
struct proc_dir_entry *p; struct proc_dir_entry *p;
@ -175,7 +175,7 @@ static void add_handler(switch_driver *driver, switch_config *handler, struct pr
} }
} }
static inline void add_handlers(switch_driver *driver, switch_config *handlers, struct proc_dir_entry *parent, int nr) static inline void add_handlers(switch_driver *driver, const switch_config *handlers, struct proc_dir_entry *parent, int nr)
{ {
int i; int i;
@ -408,7 +408,7 @@ int switch_register_driver(switch_driver *driver)
memcpy(new, driver, sizeof(switch_driver)); memcpy(new, driver, sizeof(switch_driver));
new->name = strdup(driver->name); new->name = strdup(driver->name);
new->interface = strdup(driver->interface); new->interface = strdup(driver->interface);
if ((ret = do_register(new)) < 0) { if ((ret = do_register(new)) < 0) {
kfree(new->name); kfree(new->name);
kfree(new); kfree(new);

View file

@ -20,19 +20,19 @@
typedef int (*switch_handler)(void *driver, char *buf, int nr); typedef int (*switch_handler)(void *driver, char *buf, int nr);
typedef struct { typedef struct {
char *name; const char *name;
switch_handler read, write; switch_handler read, write;
} switch_config; } switch_config;
typedef struct { typedef struct {
struct list_head list; struct list_head list;
char *name; const char *name;
char *version; const char *version;
char *interface; const char *interface;
int cpuport; int cpuport;
int ports; int ports;
int vlans; int vlans;
switch_config *driver_handlers, *port_handlers, *vlan_handlers; const switch_config *driver_handlers, *port_handlers, *vlan_handlers;
void *data; void *data;
void *priv; void *priv;
} switch_driver; } switch_driver;
@ -48,7 +48,7 @@ extern switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf);
extern int switch_parse_media(char *buf); extern int switch_parse_media(char *buf);
extern int switch_print_media(char *buf, int media); extern int switch_print_media(char *buf, int media);
static inline char *strdup(char *str) static inline char *strdup(const char *str)
{ {
char *new = kmalloc(strlen(str) + 1, GFP_KERNEL); char *new = kmalloc(strlen(str) + 1, GFP_KERNEL);
strcpy(new, str); strcpy(new, str);

View file

@ -2,6 +2,7 @@
* Broadcom BCM5325E/536x switch configuration module * Broadcom BCM5325E/536x switch configuration module
* *
* Copyright (C) 2005 Felix Fietkau <nbd@nbd.name> * Copyright (C) 2005 Felix Fietkau <nbd@nbd.name>
* Copyright (C) 2008 Michael Buesch <mb@bu3sch.de>
* Based on 'robocfg' by Oleg I. Vdovikin * Based on 'robocfg' by Oleg I. Vdovikin
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -28,15 +29,18 @@
#include <linux/sockios.h> #include <linux/sockios.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/mii.h> #include <linux/mii.h>
#include <linux/delay.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "switch-core.h" #include "switch-core.h"
#include "etc53xx.h" #include "etc53xx.h"
#define DRIVER_NAME "bcm53xx" #define DRIVER_NAME "bcm53xx"
#define DRIVER_VERSION "0.01" #define DRIVER_VERSION "0.02"
#define PFX "roboswitch: "
#define ROBO_PHY_ADDR 0x1E /* robo switch phy address */ #define ROBO_PHY_ADDR 0x1E /* robo switch phy address */
#define ROBO_PHY_ADDR_TG3 0x01 /* Tigon3 PHY address */
/* MII registers */ /* MII registers */
#define REG_MII_PAGE 0x10 /* MII Page register */ #define REG_MII_PAGE 0x10 /* MII Page register */
@ -47,16 +51,33 @@
#define REG_MII_ADDR_WRITE 1 #define REG_MII_ADDR_WRITE 1
#define REG_MII_ADDR_READ 2 #define REG_MII_ADDR_READ 2
/* Robo device ID register (in ROBO_MGMT_PAGE) */
#define ROBO_DEVICE_ID 0x30
#define ROBO_DEVICE_ID_5325 0x25 /* Faked */
#define ROBO_DEVICE_ID_5395 0x95
#define ROBO_DEVICE_ID_5397 0x97
#define ROBO_DEVICE_ID_5398 0x98
/* Private et.o ioctls */ /* Private et.o ioctls */
#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9) #define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10) #define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
static char *device;
static int use_et = 0; /* Data structure for a Roboswitch device. */
static int is_5350 = 0; struct robo_switch {
static struct ifreq ifr; char *device; /* The device name string (ethX) */
static struct net_device *dev; u16 devid; /* ROBO_DEVICE_ID_53xx */
static unsigned char port[6] = { 0, 1, 2, 3, 4, 8 }; bool use_et;
bool is_5350;
u8 phy_addr; /* PHY address of the device */
struct ifreq ifr;
struct net_device *dev;
unsigned char port[6];
};
/* Currently we can only have one device in the system. */
static struct robo_switch robo;
static int do_ioctl(int cmd, void *buf) static int do_ioctl(int cmd, void *buf)
{ {
@ -64,10 +85,10 @@ static int do_ioctl(int cmd, void *buf)
int ret; int ret;
if (buf != NULL) if (buf != NULL)
ifr.ifr_data = (caddr_t) buf; robo.ifr.ifr_data = (caddr_t) buf;
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
ret = dev->do_ioctl(dev, &ifr, cmd); ret = robo.dev->do_ioctl(robo.dev, &robo.ifr, cmd);
set_fs(old_fs); set_fs(old_fs);
return ret; return ret;
@ -75,11 +96,11 @@ static int do_ioctl(int cmd, void *buf)
static u16 mdio_read(__u16 phy_id, __u8 reg) static u16 mdio_read(__u16 phy_id, __u8 reg)
{ {
if (use_et) { if (robo.use_et) {
int args[2] = { reg }; int args[2] = { reg };
if (phy_id != ROBO_PHY_ADDR) { if (phy_id != robo.phy_addr) {
printk( printk(KERN_ERR PFX
"Access to real 'phy' registers unavaliable.\n" "Access to real 'phy' registers unavaliable.\n"
"Upgrade kernel driver.\n"); "Upgrade kernel driver.\n");
@ -88,18 +109,20 @@ static u16 mdio_read(__u16 phy_id, __u8 reg)
if (do_ioctl(SIOCGETCPHYRD, &args) < 0) { if (do_ioctl(SIOCGETCPHYRD, &args) < 0) {
printk("[%s:%d] SIOCGETCPHYRD failed!\n", __FILE__, __LINE__); printk(KERN_ERR PFX
"[%s:%d] SIOCGETCPHYRD failed!\n", __FILE__, __LINE__);
return 0xffff; return 0xffff;
} }
return args[1]; return args[1];
} else { } else {
struct mii_ioctl_data *mii = (struct mii_ioctl_data *) &ifr.ifr_data; struct mii_ioctl_data *mii = (struct mii_ioctl_data *) &robo.ifr.ifr_data;
mii->phy_id = phy_id; mii->phy_id = phy_id;
mii->reg_num = reg; mii->reg_num = reg;
if (do_ioctl(SIOCGMIIREG, NULL) < 0) { if (do_ioctl(SIOCGMIIREG, NULL) < 0) {
printk("[%s:%d] SIOCGMIIREG failed!\n", __FILE__, __LINE__); printk(KERN_ERR PFX
"[%s:%d] SIOCGMIIREG failed!\n", __FILE__, __LINE__);
return 0xffff; return 0xffff;
} }
@ -110,11 +133,11 @@ static u16 mdio_read(__u16 phy_id, __u8 reg)
static void mdio_write(__u16 phy_id, __u8 reg, __u16 val) static void mdio_write(__u16 phy_id, __u8 reg, __u16 val)
{ {
if (use_et) { if (robo.use_et) {
int args[2] = { reg, val }; int args[2] = { reg, val };
if (phy_id != ROBO_PHY_ADDR) { if (phy_id != robo.phy_addr) {
printk( printk(KERN_ERR PFX
"Access to real 'phy' registers unavaliable.\n" "Access to real 'phy' registers unavaliable.\n"
"Upgrade kernel driver.\n"); "Upgrade kernel driver.\n");
@ -122,18 +145,20 @@ static void mdio_write(__u16 phy_id, __u8 reg, __u16 val)
} }
if (do_ioctl(SIOCSETCPHYWR, args) < 0) { if (do_ioctl(SIOCSETCPHYWR, args) < 0) {
printk("[%s:%d] SIOCGETCPHYWR failed!\n", __FILE__, __LINE__); printk(KERN_ERR PFX
"[%s:%d] SIOCGETCPHYWR failed!\n", __FILE__, __LINE__);
return; return;
} }
} else { } else {
struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&ifr.ifr_data; struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo.ifr.ifr_data;
mii->phy_id = phy_id; mii->phy_id = phy_id;
mii->reg_num = reg; mii->reg_num = reg;
mii->val_in = val; mii->val_in = val;
if (do_ioctl(SIOCSMIIREG, NULL) < 0) { if (do_ioctl(SIOCSMIIREG, NULL) < 0) {
printk("[%s:%d] SIOCSMIIREG failed!\n", __FILE__, __LINE__); printk(KERN_ERR PFX
"[%s:%d] SIOCSMIIREG failed!\n", __FILE__, __LINE__);
return; return;
} }
} }
@ -144,20 +169,20 @@ static int robo_reg(__u8 page, __u8 reg, __u8 op)
int i = 3; int i = 3;
/* set page number */ /* set page number */
mdio_write(ROBO_PHY_ADDR, REG_MII_PAGE, mdio_write(robo.phy_addr, REG_MII_PAGE,
(page << 8) | REG_MII_PAGE_ENABLE); (page << 8) | REG_MII_PAGE_ENABLE);
/* set register address */ /* set register address */
mdio_write(ROBO_PHY_ADDR, REG_MII_ADDR, mdio_write(robo.phy_addr, REG_MII_ADDR,
(reg << 8) | op); (reg << 8) | op);
/* check if operation completed */ /* check if operation completed */
while (i--) { while (i--) {
if ((mdio_read(ROBO_PHY_ADDR, REG_MII_ADDR) & 3) == 0) if ((mdio_read(robo.phy_addr, REG_MII_ADDR) & 3) == 0)
return 0; return 0;
} }
printk("[%s:%d] timeout in robo_reg!\n", __FILE__, __LINE__); printk(KERN_ERR PFX "[%s:%d] timeout in robo_reg!\n", __FILE__, __LINE__);
return 0; return 0;
} }
@ -170,7 +195,7 @@ static void robo_read(__u8 page, __u8 reg, __u16 *val, int count)
robo_reg(page, reg, REG_MII_ADDR_READ); robo_reg(page, reg, REG_MII_ADDR_READ);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
val[i] = mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0 + i); val[i] = mdio_read(robo.phy_addr, REG_MII_DATA0 + i);
} }
*/ */
@ -178,21 +203,21 @@ static __u16 robo_read16(__u8 page, __u8 reg)
{ {
robo_reg(page, reg, REG_MII_ADDR_READ); robo_reg(page, reg, REG_MII_ADDR_READ);
return mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0); return mdio_read(robo.phy_addr, REG_MII_DATA0);
} }
static __u32 robo_read32(__u8 page, __u8 reg) static __u32 robo_read32(__u8 page, __u8 reg)
{ {
robo_reg(page, reg, REG_MII_ADDR_READ); robo_reg(page, reg, REG_MII_ADDR_READ);
return mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0) + return mdio_read(robo.phy_addr, REG_MII_DATA0) +
(mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0 + 1) << 16); (mdio_read(robo.phy_addr, REG_MII_DATA0 + 1) << 16);
} }
static void robo_write16(__u8 page, __u8 reg, __u16 val16) static void robo_write16(__u8 page, __u8 reg, __u16 val16)
{ {
/* write data */ /* write data */
mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0, val16); mdio_write(robo.phy_addr, REG_MII_DATA0, val16);
robo_reg(page, reg, REG_MII_ADDR_WRITE); robo_reg(page, reg, REG_MII_ADDR_WRITE);
} }
@ -200,8 +225,8 @@ static void robo_write16(__u8 page, __u8 reg, __u16 val16)
static void robo_write32(__u8 page, __u8 reg, __u32 val32) static void robo_write32(__u8 page, __u8 reg, __u32 val32)
{ {
/* write data */ /* write data */
mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0, val32 & 65535); mdio_write(robo.phy_addr, REG_MII_DATA0, val32 & 65535);
mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0 + 1, val32 >> 16); mdio_write(robo.phy_addr, REG_MII_DATA0 + 1, val32 >> 16);
robo_reg(page, reg, REG_MII_ADDR_WRITE); robo_reg(page, reg, REG_MII_ADDR_WRITE);
} }
@ -217,42 +242,108 @@ static int robo_vlan5350(void)
return (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350) == val16); return (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350) == val16);
} }
static int robo_switch_enable(void)
{
unsigned int i, last_port;
u16 val;
val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
if (!(val & (1 << 1))) {
/* Unmanaged mode */
val &= ~(1 << 0);
/* With forwarding */
val |= (1 << 1);
robo_write16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE, val);
val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
if (!(val & (1 << 1))) {
printk("Failed to enable switch\n");
return -EBUSY;
}
last_port = (robo.devid == ROBO_DEVICE_ID_5398) ?
ROBO_PORT6_CTRL : ROBO_PORT3_CTRL;
for (i = ROBO_PORT0_CTRL; i < last_port + 1; i++)
robo_write16(ROBO_CTRL_PAGE, i, 0);
}
/* WAN port LED */
robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
return 0;
}
static void robo_switch_reset(void)
{
if ((robo.devid == ROBO_DEVICE_ID_5395) ||
(robo.devid == ROBO_DEVICE_ID_5397) ||
(robo.devid == ROBO_DEVICE_ID_5398)) {
/* Trigger a software reset. */
robo_write16(ROBO_CTRL_PAGE, 0x79, 0x83);
robo_write16(ROBO_CTRL_PAGE, 0x79, 0);
}
}
static int robo_probe(char *devname) static int robo_probe(char *devname)
{ {
__u32 phyid; __u32 phyid;
unsigned int i;
int err;
printk("Probing device %s: ", devname); printk(KERN_INFO PFX "Probing device %s: ", devname);
strcpy(ifr.ifr_name, devname); strcpy(robo.ifr.ifr_name, devname);
if ((dev = dev_get_by_name(devname)) == NULL) { if ((robo.dev = dev_get_by_name(devname)) == NULL) {
printk("No such device\n"); printk("No such device\n");
return 1; return 1;
} }
robo.device = devname;
for (i = 0; i < 5; i++)
robo.port[i] = i;
robo.port[5] = 8;
/* try access using MII ioctls - get phy address */ /* try access using MII ioctls - get phy address */
if (do_ioctl(SIOCGMIIPHY, NULL) < 0) { if (do_ioctl(SIOCGMIIPHY, NULL) < 0) {
use_et = 1; robo.use_et = 1;
robo.phy_addr = ROBO_PHY_ADDR;
} else { } else {
/* got phy address check for robo address */ /* got phy address check for robo address */
struct mii_ioctl_data *mii = (struct mii_ioctl_data *) &ifr.ifr_data; struct mii_ioctl_data *mii = (struct mii_ioctl_data *) &robo.ifr.ifr_data;
if (mii->phy_id != ROBO_PHY_ADDR) { if ((mii->phy_id != ROBO_PHY_ADDR) &&
(mii->phy_id != ROBO_PHY_ADDR_TG3)) {
printk("Invalid phy address (%d)\n", mii->phy_id); printk("Invalid phy address (%d)\n", mii->phy_id);
return 1; return 1;
} }
robo.use_et = 0;
/* The robo has a fixed PHY address that is different from the
* Tigon3 PHY address. */
robo.phy_addr = ROBO_PHY_ADDR;
} }
phyid = mdio_read(ROBO_PHY_ADDR, 0x2) | phyid = mdio_read(robo.phy_addr, 0x2) |
(mdio_read(ROBO_PHY_ADDR, 0x3) << 16); (mdio_read(robo.phy_addr, 0x3) << 16);
if (phyid == 0xffffffff || phyid == 0x55210022) { if (phyid == 0xffffffff || phyid == 0x55210022) {
printk("No Robo switch in managed mode found\n"); printk("No Robo switch in managed mode found\n");
return 1; return 1;
} }
is_5350 = robo_vlan5350(); /* Get the device ID */
for (i = 0; i < 10; i++) {
robo.devid = robo_read16(ROBO_MGMT_PAGE, ROBO_DEVICE_ID);
if (robo.devid)
break;
udelay(10);
}
if (!robo.devid)
robo.devid = ROBO_DEVICE_ID_5325; /* Fake it */
robo.is_5350 = robo_vlan5350();
robo_switch_reset();
err = robo_switch_enable();
if (err)
return err;
printk("found!\n"); printk("found!\n");
return 0; return 0;
} }
@ -266,7 +357,7 @@ static int handle_vlan_port_read(void *driver, char *buf, int nr)
val16 = (nr) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */; val16 = (nr) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */;
if (is_5350) { if (robo.is_5350) {
u32 val32; u32 val32;
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
/* actual read */ /* actual read */
@ -332,7 +423,7 @@ static int handle_vlan_port_write(void *driver, char *buf, int nr)
/* write config now */ /* write config now */
val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */; val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
if (is_5350) { if (robo.is_5350) {
robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350,
(1 << 20) /* valid */ | (c->untag << 6) | c->port); (1 << 20) /* valid */ | (c->untag << 6) | c->port);
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
@ -395,19 +486,21 @@ static int handle_reset(void *driver, char *buf, int nr)
set_switch(0); set_switch(0);
/* reset vlans */ /* reset vlans */
for (j = 0; j <= (is_5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); j++) { for (j = 0; j <= ((robo.is_5350) ? VLAN_ID_MAX5350 : VLAN_ID_MAX); j++) {
/* write config now */ /* write config now */
val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */; val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
if (is_5350) if (robo.is_5350)
robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 0); robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 0);
else else
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0);
robo_write16(ROBO_VLAN_PAGE, (is_5350 ? ROBO_VLAN_TABLE_ACCESS_5350 : ROBO_VLAN_TABLE_ACCESS), val16); robo_write16(ROBO_VLAN_PAGE, robo.is_5350 ? ROBO_VLAN_TABLE_ACCESS_5350 :
ROBO_VLAN_TABLE_ACCESS,
val16);
} }
/* reset ports to a known good state */ /* reset ports to a known good state */
for (j = 0; j < d->ports; j++) { for (j = 0; j < d->ports; j++) {
robo_write16(ROBO_CTRL_PAGE, port[j], 0x0000); robo_write16(ROBO_CTRL_PAGE, robo.port[j], 0x0000);
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), 0); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), 0);
} }
@ -423,6 +516,7 @@ static int handle_reset(void *driver, char *buf, int nr)
static int __init robo_init(void) static int __init robo_init(void)
{ {
int notfound = 1; int notfound = 1;
char *device;
device = strdup("ethX"); device = strdup("ethX");
for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) { for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) {
@ -434,26 +528,38 @@ static int __init robo_init(void)
kfree(device); kfree(device);
return -ENODEV; return -ENODEV;
} else { } else {
switch_config cfg[] = { static const switch_config cfg[] = {
{"enable", handle_enable_read, handle_enable_write}, {
{"enable_vlan", handle_enable_vlan_read, handle_enable_vlan_write}, .name = "enable",
{"reset", NULL, handle_reset}, .read = handle_enable_read,
{NULL, NULL, NULL} .write = handle_enable_write
}, {
.name = "enable_vlan",
.read = handle_enable_vlan_read,
.write = handle_enable_vlan_write
}, {
.name = "reset",
.read = NULL,
.write = handle_reset
}, { NULL, },
}; };
switch_config vlan[] = { static const switch_config vlan[] = {
{"ports", handle_vlan_port_read, handle_vlan_port_write}, {
{NULL, NULL, NULL} .name = "ports",
.read = handle_vlan_port_read,
.write = handle_vlan_port_write
}, { NULL, },
}; };
switch_driver driver = { switch_driver driver = {
name: DRIVER_NAME, .name = DRIVER_NAME,
version: DRIVER_VERSION, .version = DRIVER_VERSION,
interface: device, .interface = device,
cpuport: 5, .cpuport = 5,
ports: 6, .ports = 6,
vlans: 16, .vlans = 16,
driver_handlers: cfg, .driver_handlers = cfg,
port_handlers: NULL, .port_handlers = NULL,
vlan_handlers: vlan, .vlan_handlers = vlan,
}; };
return switch_register_driver(&driver); return switch_register_driver(&driver);
@ -463,7 +569,7 @@ static int __init robo_init(void)
static void __exit robo_exit(void) static void __exit robo_exit(void)
{ {
switch_unregister_driver(DRIVER_NAME); switch_unregister_driver(DRIVER_NAME);
kfree(device); kfree(robo.device);
} }

View file

@ -912,7 +912,7 @@ Index: linux-2.6.23.16/drivers/ssb/ssb_private.h
Index: linux-2.6.23.16/drivers/net/tg3.c Index: linux-2.6.23.16/drivers/net/tg3.c
=================================================================== ===================================================================
--- linux-2.6.23.16.orig/drivers/net/tg3.c 2008-02-22 19:40:57.000000000 +0100 --- linux-2.6.23.16.orig/drivers/net/tg3.c 2008-02-22 19:40:57.000000000 +0100
+++ linux-2.6.23.16/drivers/net/tg3.c 2008-02-23 20:02:58.000000000 +0100 +++ linux-2.6.23.16/drivers/net/tg3.c 2008-02-27 23:18:31.000000000 +0100
@@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/prefetch.h> #include <linux/prefetch.h>
@ -933,7 +933,60 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
tp->read32_mbox(tp, off); tp->read32_mbox(tp, off);
} }
@@ -1988,6 +1990,14 @@ static int tg3_setup_copper_phy(struct t @@ -623,7 +625,7 @@ static void tg3_switch_clocks(struct tg3
#define PHY_BUSY_LOOPS 5000
-static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
+static int __tg3_readphy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 *val)
{
u32 frame_val;
unsigned int loops;
@@ -637,7 +639,7 @@ static int tg3_readphy(struct tg3 *tp, i
*val = 0x0;
- frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
+ frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
MI_COM_PHY_ADDR_MASK);
frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
MI_COM_REG_ADDR_MASK);
@@ -672,7 +674,12 @@ static int tg3_readphy(struct tg3 *tp, i
return ret;
}
-static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
+static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
+{
+ return __tg3_readphy(tp, PHY_ADDR, reg, val);
+}
+
+static int __tg3_writephy(struct tg3 *tp, unsigned int phy_addr, int reg, u32 val)
{
u32 frame_val;
unsigned int loops;
@@ -688,7 +695,7 @@ static int tg3_writephy(struct tg3 *tp,
udelay(80);
}
- frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
+ frame_val = ((phy_addr << MI_COM_PHY_ADDR_SHIFT) &
MI_COM_PHY_ADDR_MASK);
frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
MI_COM_REG_ADDR_MASK);
@@ -721,6 +728,11 @@ static int tg3_writephy(struct tg3 *tp,
return ret;
}
+static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
+{
+ return __tg3_writephy(tp, PHY_ADDR, reg, val);
+}
+
static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable)
{
u32 phy;
@@ -1988,6 +2000,14 @@ static int tg3_setup_copper_phy(struct t
tp->link_config.active_duplex = current_duplex; tp->link_config.active_duplex = current_duplex;
} }
@ -948,7 +1001,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
if (current_link_up == 1 && if (current_link_up == 1 &&
(tp->link_config.active_duplex == DUPLEX_FULL) && (tp->link_config.active_duplex == DUPLEX_FULL) &&
(tp->link_config.autoneg == AUTONEG_ENABLE)) { (tp->link_config.autoneg == AUTONEG_ENABLE)) {
@@ -4813,6 +4823,11 @@ static int tg3_poll_fw(struct tg3 *tp) @@ -4813,6 +4833,11 @@ static int tg3_poll_fw(struct tg3 *tp)
int i; int i;
u32 val; u32 val;
@ -960,7 +1013,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
/* Wait up to 20ms for init done. */ /* Wait up to 20ms for init done. */
for (i = 0; i < 200; i++) { for (i = 0; i < 200; i++) {
@@ -5040,6 +5055,14 @@ static int tg3_chip_reset(struct tg3 *tp @@ -5040,6 +5065,14 @@ static int tg3_chip_reset(struct tg3 *tp
tw32(0x5000, 0x400); tw32(0x5000, 0x400);
} }
@ -975,7 +1028,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
tw32(GRC_MODE, tp->grc_mode); tw32(GRC_MODE, tp->grc_mode);
if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A0) { if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A0) {
@@ -5308,9 +5331,12 @@ static int tg3_halt_cpu(struct tg3 *tp, @@ -5308,9 +5341,12 @@ static int tg3_halt_cpu(struct tg3 *tp,
return -ENODEV; return -ENODEV;
} }
@ -991,7 +1044,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
return 0; return 0;
} }
@@ -5391,6 +5417,11 @@ static int tg3_load_5701_a0_firmware_fix @@ -5391,6 +5427,11 @@ static int tg3_load_5701_a0_firmware_fix
struct fw_info info; struct fw_info info;
int err, i; int err, i;
@ -1003,7 +1056,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
info.text_base = TG3_FW_TEXT_ADDR; info.text_base = TG3_FW_TEXT_ADDR;
info.text_len = TG3_FW_TEXT_LEN; info.text_len = TG3_FW_TEXT_LEN;
info.text_data = &tg3FwText[0]; info.text_data = &tg3FwText[0];
@@ -5949,6 +5980,11 @@ static int tg3_load_tso_firmware(struct @@ -5949,6 +5990,11 @@ static int tg3_load_tso_firmware(struct
unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size; unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
int err, i; int err, i;
@ -1015,7 +1068,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
return 0; return 0;
@@ -6850,6 +6886,11 @@ static void tg3_timer(unsigned long __op @@ -6850,6 +6896,11 @@ static void tg3_timer(unsigned long __op
spin_lock(&tp->lock); spin_lock(&tp->lock);
@ -1027,7 +1080,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) { if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) {
/* All of this garbage is because when using non-tagged /* All of this garbage is because when using non-tagged
* IRQ status the mailbox/status_block protocol the chip * IRQ status the mailbox/status_block protocol the chip
@@ -8432,6 +8473,11 @@ static int tg3_test_nvram(struct tg3 *tp @@ -8432,6 +8483,11 @@ static int tg3_test_nvram(struct tg3 *tp
u32 *buf, csum, magic; u32 *buf, csum, magic;
int i, j, err = 0, size; int i, j, err = 0, size;
@ -1039,7 +1092,25 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
if (tg3_nvram_read_swab(tp, 0, &magic) != 0) if (tg3_nvram_read_swab(tp, 0, &magic) != 0)
return -EIO; return -EIO;
@@ -9571,6 +9617,12 @@ static void __devinit tg3_get_5906_nvram @@ -9154,7 +9210,7 @@ static int tg3_ioctl(struct net_device *
return -EAGAIN;
spin_lock_bh(&tp->lock);
- err = tg3_readphy(tp, data->reg_num & 0x1f, &mii_regval);
+ err = __tg3_readphy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, &mii_regval);
spin_unlock_bh(&tp->lock);
data->val_out = mii_regval;
@@ -9173,7 +9229,7 @@ static int tg3_ioctl(struct net_device *
return -EAGAIN;
spin_lock_bh(&tp->lock);
- err = tg3_writephy(tp, data->reg_num & 0x1f, data->val_in);
+ err = __tg3_writephy(tp, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
spin_unlock_bh(&tp->lock);
return err;
@@ -9571,6 +9627,12 @@ static void __devinit tg3_get_5906_nvram
/* Chips other than 5700/5701 use the NVRAM for fetching info. */ /* Chips other than 5700/5701 use the NVRAM for fetching info. */
static void __devinit tg3_nvram_init(struct tg3 *tp) static void __devinit tg3_nvram_init(struct tg3 *tp)
{ {
@ -1052,7 +1123,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
tw32_f(GRC_EEPROM_ADDR, tw32_f(GRC_EEPROM_ADDR,
(EEPROM_ADDR_FSM_RESET | (EEPROM_ADDR_FSM_RESET |
(EEPROM_DEFAULT_CLOCK_PERIOD << (EEPROM_DEFAULT_CLOCK_PERIOD <<
@@ -9706,6 +9758,9 @@ static int tg3_nvram_read(struct tg3 *tp @@ -9706,6 +9768,9 @@ static int tg3_nvram_read(struct tg3 *tp
{ {
int ret; int ret;
@ -1062,7 +1133,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
if (!(tp->tg3_flags & TG3_FLAG_NVRAM)) if (!(tp->tg3_flags & TG3_FLAG_NVRAM))
return tg3_nvram_read_using_eeprom(tp, offset, val); return tg3_nvram_read_using_eeprom(tp, offset, val);
@@ -9938,6 +9993,9 @@ static int tg3_nvram_write_block(struct @@ -9938,6 +10003,9 @@ static int tg3_nvram_write_block(struct
{ {
int ret; int ret;
@ -1072,7 +1143,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl & tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
~GRC_LCLCTRL_GPIO_OUTPUT1); ~GRC_LCLCTRL_GPIO_OUTPUT1);
@@ -10804,7 +10862,6 @@ static int __devinit tg3_get_invariants( @@ -10804,7 +10872,6 @@ static int __devinit tg3_get_invariants(
tp->write32 = tg3_write_flush_reg32; tp->write32 = tg3_write_flush_reg32;
} }
@ -1080,7 +1151,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) || if ((tp->tg3_flags & TG3_FLAG_TXD_MBOX_HWBUG) ||
(tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) { (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)) {
tp->write32_tx_mbox = tg3_write32_tx_mbox; tp->write32_tx_mbox = tg3_write32_tx_mbox;
@@ -10840,6 +10897,11 @@ static int __devinit tg3_get_invariants( @@ -10840,6 +10907,11 @@ static int __devinit tg3_get_invariants(
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701))) GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)))
tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG; tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
@ -1092,7 +1163,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
/* Get eeprom hw config before calling tg3_set_power_state(). /* Get eeprom hw config before calling tg3_set_power_state().
* In particular, the TG3_FLG2_IS_NIC flag must be * In particular, the TG3_FLG2_IS_NIC flag must be
* determined before calling tg3_set_power_state() so that * determined before calling tg3_set_power_state() so that
@@ -11184,6 +11246,10 @@ static int __devinit tg3_get_device_addr @@ -11184,6 +11256,10 @@ static int __devinit tg3_get_device_addr
} }
if (!is_valid_ether_addr(&dev->dev_addr[0])) { if (!is_valid_ether_addr(&dev->dev_addr[0])) {
@ -1103,7 +1174,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
#ifdef CONFIG_SPARC64 #ifdef CONFIG_SPARC64
if (!tg3_get_default_macaddr_sparc(tp)) if (!tg3_get_default_macaddr_sparc(tp))
return 0; return 0;
@@ -11675,6 +11741,7 @@ static char * __devinit tg3_phy_string(s @@ -11675,6 +11751,7 @@ static char * __devinit tg3_phy_string(s
case PHY_ID_BCM5704: return "5704"; case PHY_ID_BCM5704: return "5704";
case PHY_ID_BCM5705: return "5705"; case PHY_ID_BCM5705: return "5705";
case PHY_ID_BCM5750: return "5750"; case PHY_ID_BCM5750: return "5750";
@ -1111,7 +1182,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
case PHY_ID_BCM5752: return "5752"; case PHY_ID_BCM5752: return "5752";
case PHY_ID_BCM5714: return "5714"; case PHY_ID_BCM5714: return "5714";
case PHY_ID_BCM5780: return "5780"; case PHY_ID_BCM5780: return "5780";
@@ -11859,6 +11926,13 @@ static int __devinit tg3_init_one(struct @@ -11859,6 +11936,13 @@ static int __devinit tg3_init_one(struct
tp->msg_enable = tg3_debug; tp->msg_enable = tg3_debug;
else else
tp->msg_enable = TG3_DEF_MSG_ENABLE; tp->msg_enable = TG3_DEF_MSG_ENABLE;
@ -1128,7 +1199,7 @@ Index: linux-2.6.23.16/drivers/net/tg3.c
Index: linux-2.6.23.16/drivers/net/tg3.h Index: linux-2.6.23.16/drivers/net/tg3.h
=================================================================== ===================================================================
--- linux-2.6.23.16.orig/drivers/net/tg3.h 2008-02-22 19:40:57.000000000 +0100 --- linux-2.6.23.16.orig/drivers/net/tg3.h 2008-02-22 19:40:57.000000000 +0100
+++ linux-2.6.23.16/drivers/net/tg3.h 2008-02-23 19:35:15.000000000 +0100 +++ linux-2.6.23.16/drivers/net/tg3.h 2008-02-23 20:56:08.000000000 +0100
@@ -2279,6 +2279,10 @@ struct tg3 { @@ -2279,6 +2279,10 @@ struct tg3 {
#define TG3_FLG2_PHY_JITTER_BUG 0x20000000 #define TG3_FLG2_PHY_JITTER_BUG 0x20000000
#define TG3_FLG2_NO_FWARE_REPORTED 0x40000000 #define TG3_FLG2_NO_FWARE_REPORTED 0x40000000