2005-12-25 14:18:55 +00:00
|
|
|
/*
|
|
|
|
* Broadcom BCM5325E/536x switch configuration module
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Felix Fietkau <nbd@nbd.name>
|
2008-02-27 22:35:41 +00:00
|
|
|
* Copyright (C) 2008 Michael Buesch <mb@bu3sch.de>
|
2005-12-25 14:18:55 +00:00
|
|
|
* Based on 'robocfg' by Oleg I. Vdovikin
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2013-02-13 16:01:50 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
2005-12-25 14:18:55 +00:00
|
|
|
* 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/if.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/sockios.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/mii.h>
|
2008-02-27 22:35:41 +00:00
|
|
|
#include <linux/delay.h>
|
2013-02-13 16:02:41 +00:00
|
|
|
#include <linux/gpio.h>
|
2005-12-25 14:18:55 +00:00
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
|
|
#include "switch-core.h"
|
|
|
|
#include "etc53xx.h"
|
|
|
|
|
2011-08-04 20:07:58 +00:00
|
|
|
#ifdef CONFIG_BCM47XX
|
2013-01-03 01:53:30 +00:00
|
|
|
#include <bcm47xx_nvram.h>
|
2011-08-04 20:07:58 +00:00
|
|
|
#endif
|
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
#define DRIVER_NAME "bcm53xx"
|
2008-02-27 22:35:41 +00:00
|
|
|
#define DRIVER_VERSION "0.02"
|
|
|
|
#define PFX "roboswitch: "
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2008-02-27 22:35:41 +00:00
|
|
|
#define ROBO_PHY_ADDR 0x1E /* robo switch phy address */
|
|
|
|
#define ROBO_PHY_ADDR_TG3 0x01 /* Tigon3 PHY address */
|
2009-03-09 21:57:11 +00:00
|
|
|
#define ROBO_PHY_ADDR_BCM63XX 0x00 /* BCM63XX PHY address */
|
2005-12-25 14:18:55 +00:00
|
|
|
|
|
|
|
/* MII registers */
|
|
|
|
#define REG_MII_PAGE 0x10 /* MII Page register */
|
|
|
|
#define REG_MII_ADDR 0x11 /* MII Address register */
|
|
|
|
#define REG_MII_DATA0 0x18 /* MII Data register 0 */
|
|
|
|
|
|
|
|
#define REG_MII_PAGE_ENABLE 1
|
|
|
|
#define REG_MII_ADDR_WRITE 1
|
|
|
|
#define REG_MII_ADDR_READ 2
|
|
|
|
|
2008-02-27 22:35:41 +00:00
|
|
|
/* 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
|
2009-10-29 21:26:36 +00:00
|
|
|
#define ROBO_DEVICE_ID_53115 0x3115
|
2008-02-27 22:35:41 +00:00
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
/* Private et.o ioctls */
|
|
|
|
#define SIOCGETCPHYRD (SIOCDEVPRIVATE + 9)
|
|
|
|
#define SIOCSETCPHYWR (SIOCDEVPRIVATE + 10)
|
|
|
|
|
2008-02-27 22:35:41 +00:00
|
|
|
/* Data structure for a Roboswitch device. */
|
|
|
|
struct robo_switch {
|
|
|
|
char *device; /* The device name string (ethX) */
|
|
|
|
u16 devid; /* ROBO_DEVICE_ID_53xx */
|
|
|
|
bool is_5350;
|
2013-01-03 01:58:01 +00:00
|
|
|
u8 gmii; /* gigabit mii */
|
2013-02-13 16:02:41 +00:00
|
|
|
int gpio_robo_reset;
|
|
|
|
int gpio_lanports_enable;
|
2008-02-27 22:35:41 +00:00
|
|
|
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;
|
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2012-08-05 13:10:43 +00:00
|
|
|
static int do_ioctl(int cmd)
|
2005-12-25 14:18:55 +00:00
|
|
|
{
|
|
|
|
mm_segment_t old_fs = get_fs();
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
set_fs(KERNEL_DS);
|
2009-09-26 11:48:48 +00:00
|
|
|
ret = robo.dev->netdev_ops->ndo_do_ioctl(robo.dev, &robo.ifr, cmd);
|
2005-12-25 14:18:55 +00:00
|
|
|
set_fs(old_fs);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u16 mdio_read(__u16 phy_id, __u8 reg)
|
|
|
|
{
|
2012-08-05 13:10:43 +00:00
|
|
|
struct mii_ioctl_data *mii = if_mii(&robo.ifr);
|
2012-09-19 10:57:38 +00:00
|
|
|
int err;
|
|
|
|
|
2012-08-05 13:10:43 +00:00
|
|
|
mii->phy_id = phy_id;
|
|
|
|
mii->reg_num = reg;
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2012-09-19 10:57:38 +00:00
|
|
|
err = do_ioctl(SIOCGMIIREG);
|
|
|
|
if (err < 0) {
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_ERR PFX "failed to read mdio reg %i with err %i.\n", reg, err);
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2012-08-05 13:10:43 +00:00
|
|
|
return 0xffff;
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
2012-08-05 13:10:43 +00:00
|
|
|
|
|
|
|
return mii->val_out;
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mdio_write(__u16 phy_id, __u8 reg, __u16 val)
|
|
|
|
{
|
2012-08-05 13:10:43 +00:00
|
|
|
struct mii_ioctl_data *mii = if_mii(&robo.ifr);
|
2012-09-19 10:57:38 +00:00
|
|
|
int err;
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2012-08-05 13:10:43 +00:00
|
|
|
mii->phy_id = phy_id;
|
|
|
|
mii->reg_num = reg;
|
|
|
|
mii->val_in = val;
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2012-09-19 10:57:38 +00:00
|
|
|
err = do_ioctl(SIOCSMIIREG);
|
|
|
|
if (err < 0) {
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_ERR PFX "failed to write mdio reg: %i with err %i.\n", reg, err);
|
2012-08-05 13:10:43 +00:00
|
|
|
return;
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int robo_reg(__u8 page, __u8 reg, __u8 op)
|
|
|
|
{
|
|
|
|
int i = 3;
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
/* set page number */
|
2012-08-05 13:10:43 +00:00
|
|
|
mdio_write(ROBO_PHY_ADDR, REG_MII_PAGE,
|
2005-12-25 14:18:55 +00:00
|
|
|
(page << 8) | REG_MII_PAGE_ENABLE);
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
/* set register address */
|
2012-08-05 13:10:43 +00:00
|
|
|
mdio_write(ROBO_PHY_ADDR, REG_MII_ADDR,
|
2005-12-25 14:18:55 +00:00
|
|
|
(reg << 8) | op);
|
|
|
|
|
|
|
|
/* check if operation completed */
|
|
|
|
while (i--) {
|
2012-08-05 13:10:43 +00:00
|
|
|
if ((mdio_read(ROBO_PHY_ADDR, REG_MII_ADDR) & 3) == 0)
|
2005-12-25 14:18:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_ERR PFX "timeout in robo_reg on page %i and reg %i with op %i.\n", page, reg, op);
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2013-01-03 01:58:01 +00:00
|
|
|
return 1;
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 02:05:27 +00:00
|
|
|
/*
|
2005-12-25 14:18:55 +00:00
|
|
|
static void robo_read(__u8 page, __u8 reg, __u16 *val, int count)
|
|
|
|
{
|
|
|
|
int i;
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
robo_reg(page, reg, REG_MII_ADDR_READ);
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
for (i = 0; i < count; i++)
|
2012-08-05 13:10:43 +00:00
|
|
|
val[i] = mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0 + i);
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
2006-06-19 02:05:27 +00:00
|
|
|
*/
|
2005-12-25 14:18:55 +00:00
|
|
|
|
|
|
|
static __u16 robo_read16(__u8 page, __u8 reg)
|
|
|
|
{
|
|
|
|
robo_reg(page, reg, REG_MII_ADDR_READ);
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2012-08-05 13:10:43 +00:00
|
|
|
return mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0);
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __u32 robo_read32(__u8 page, __u8 reg)
|
|
|
|
{
|
|
|
|
robo_reg(page, reg, REG_MII_ADDR_READ);
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2013-01-03 01:58:01 +00:00
|
|
|
return mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0) |
|
2012-08-05 13:10:43 +00:00
|
|
|
(mdio_read(ROBO_PHY_ADDR, REG_MII_DATA0 + 1) << 16);
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void robo_write16(__u8 page, __u8 reg, __u16 val16)
|
|
|
|
{
|
|
|
|
/* write data */
|
2012-08-05 13:10:43 +00:00
|
|
|
mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0, val16);
|
2005-12-25 14:18:55 +00:00
|
|
|
|
|
|
|
robo_reg(page, reg, REG_MII_ADDR_WRITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void robo_write32(__u8 page, __u8 reg, __u32 val32)
|
|
|
|
{
|
|
|
|
/* write data */
|
2013-01-03 01:58:01 +00:00
|
|
|
mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0, val32 & 0xFFFF);
|
2012-08-05 13:10:43 +00:00
|
|
|
mdio_write(ROBO_PHY_ADDR, REG_MII_DATA0 + 1, val32 >> 16);
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
robo_reg(page, reg, REG_MII_ADDR_WRITE);
|
|
|
|
}
|
|
|
|
|
2013-01-03 01:58:01 +00:00
|
|
|
/* checks that attached switch is 5325/5352/5354/5356/5357/53115 */
|
|
|
|
static int robo_vlan5350(__u32 phyid)
|
2005-12-25 14:18:55 +00:00
|
|
|
{
|
|
|
|
/* set vlan access id to 15 and read it back */
|
|
|
|
__u16 val16 = 15;
|
|
|
|
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
/* 5365 will refuse this as it does not have this reg */
|
2013-01-03 01:58:01 +00:00
|
|
|
if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350) != val16)
|
|
|
|
return 0;
|
|
|
|
/* gigabit ? */
|
|
|
|
if (mdio_read(0, ROBO_MII_STAT) & 0x0100)
|
|
|
|
robo.gmii = ((mdio_read(0, 0x0f) & 0xf000) != 0);
|
|
|
|
/* 53115 ? */
|
|
|
|
if (robo.gmii && robo_read32(ROBO_STAT_PAGE, ROBO_LSA_IM_PORT) != 0) {
|
|
|
|
robo_write16(ROBO_ARLIO_PAGE, ROBO_VTBL_INDX_5395, val16);
|
|
|
|
robo_write16(ROBO_ARLIO_PAGE, ROBO_VTBL_ACCESS_5395,
|
|
|
|
(1 << 7) /* start */ | 1 /* read */);
|
|
|
|
if (robo_read16(ROBO_ARLIO_PAGE, ROBO_VTBL_ACCESS_5395) == 1 &&
|
|
|
|
robo_read16(ROBO_ARLIO_PAGE, ROBO_VTBL_INDX_5395) == val16)
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
/* dirty trick for 5356/5357 */
|
|
|
|
if ((phyid & 0xfff0ffff ) == 0x5da00362 ||
|
|
|
|
(phyid & 0xfff0ffff ) == 0x5e000362)
|
|
|
|
return 3;
|
|
|
|
/* 5325/5352/5354*/
|
|
|
|
return 1;
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
|
2008-02-27 22:35:41 +00:00
|
|
|
static int robo_switch_enable(void)
|
|
|
|
{
|
|
|
|
unsigned int i, last_port;
|
|
|
|
u16 val;
|
2011-08-04 20:07:58 +00:00
|
|
|
#ifdef CONFIG_BCM47XX
|
|
|
|
char buf[20];
|
|
|
|
#endif
|
2008-02-27 22:35:41 +00:00
|
|
|
|
|
|
|
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))) {
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_ERR PFX "Failed to enable switch\n");
|
2008-02-27 22:35:41 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-08-04 20:07:58 +00:00
|
|
|
#ifdef CONFIG_BCM47XX
|
2009-04-20 10:27:46 +00:00
|
|
|
/* WAN port LED, except for Netgear WGT634U */
|
2013-01-03 01:53:30 +00:00
|
|
|
if (bcm47xx_nvram_getenv("nvram_type", buf, sizeof(buf)) >= 0) {
|
2011-08-04 20:07:58 +00:00
|
|
|
if (strcmp(buf, "cfe") != 0)
|
|
|
|
robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
|
|
|
|
}
|
|
|
|
#endif
|
2008-02-27 22:35:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2008-02-27 22:35:41 +00:00
|
|
|
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);
|
2009-10-29 21:26:36 +00:00
|
|
|
mdelay(500);
|
2008-02-27 22:35:41 +00:00
|
|
|
robo_write16(ROBO_CTRL_PAGE, 0x79, 0);
|
|
|
|
}
|
|
|
|
}
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2013-02-13 16:02:41 +00:00
|
|
|
#ifdef CONFIG_BCM47XX
|
|
|
|
static int get_gpio_pin(const char *name)
|
|
|
|
{
|
|
|
|
int i, err;
|
|
|
|
char nvram_var[10];
|
|
|
|
char buf[30];
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
|
|
|
|
if (err <= 0)
|
|
|
|
continue;
|
|
|
|
err = bcm47xx_nvram_getenv(nvram_var, buf, sizeof(buf));
|
|
|
|
if (err <= 0)
|
|
|
|
continue;
|
|
|
|
if (!strcmp(name, buf))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
static int robo_probe(char *devname)
|
|
|
|
{
|
|
|
|
__u32 phyid;
|
2008-02-27 22:35:41 +00:00
|
|
|
unsigned int i;
|
2013-02-13 16:02:20 +00:00
|
|
|
int err = -1;
|
2013-01-03 01:58:01 +00:00
|
|
|
struct mii_ioctl_data *mii;
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_INFO PFX "Probing device '%s'\n", devname);
|
2008-02-27 22:35:41 +00:00
|
|
|
strcpy(robo.ifr.ifr_name, devname);
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2008-05-14 15:03:05 +00:00
|
|
|
if ((robo.dev = dev_get_by_name(&init_net, devname)) == NULL) {
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_ERR PFX "No such device\n");
|
2013-02-13 16:02:20 +00:00
|
|
|
err = -ENODEV;
|
|
|
|
goto err_done;
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
2012-09-22 12:29:23 +00:00
|
|
|
if (!robo.dev->netdev_ops || !robo.dev->netdev_ops->ndo_do_ioctl) {
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_ERR PFX "ndo_do_ioctl not implemented in ethernet driver\n");
|
2013-02-13 16:02:20 +00:00
|
|
|
err = -ENXIO;
|
|
|
|
goto err_put;
|
2012-09-22 12:29:23 +00:00
|
|
|
}
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2008-02-27 22:35:41 +00:00
|
|
|
robo.device = devname;
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
robo.port[i] = i;
|
|
|
|
robo.port[5] = 8;
|
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
/* try access using MII ioctls - get phy address */
|
2013-01-03 01:57:19 +00:00
|
|
|
err = do_ioctl(SIOCGMIIPHY);
|
|
|
|
if (err < 0) {
|
|
|
|
printk(KERN_ERR PFX "error (%i) while accessing MII phy registers with ioctls\n", err);
|
2013-02-13 16:02:20 +00:00
|
|
|
goto err_put;
|
2012-08-05 13:10:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* got phy address check for robo address */
|
2013-01-03 01:58:01 +00:00
|
|
|
mii = if_mii(&robo.ifr);
|
2012-08-05 13:10:43 +00:00
|
|
|
if ((mii->phy_id != ROBO_PHY_ADDR) &&
|
|
|
|
(mii->phy_id != ROBO_PHY_ADDR_BCM63XX) &&
|
|
|
|
(mii->phy_id != ROBO_PHY_ADDR_TG3)) {
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_ERR PFX "Invalid phy address (%d)\n", mii->phy_id);
|
2013-02-13 16:02:20 +00:00
|
|
|
err = -ENODEV;
|
|
|
|
goto err_put;
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 16:02:41 +00:00
|
|
|
#ifdef CONFIG_BCM47XX
|
|
|
|
robo.gpio_lanports_enable = get_gpio_pin("lanports_enable");
|
|
|
|
if (robo.gpio_lanports_enable >= 0) {
|
|
|
|
err = gpio_request(robo.gpio_lanports_enable, "lanports_enable");
|
|
|
|
if (err) {
|
|
|
|
printk(KERN_ERR PFX "error (%i) requesting lanports_enable gpio (%i)\n",
|
|
|
|
err, robo.gpio_lanports_enable);
|
|
|
|
goto err_put;
|
|
|
|
}
|
|
|
|
gpio_direction_output(robo.gpio_lanports_enable, 1);
|
|
|
|
mdelay(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
robo.gpio_robo_reset = get_gpio_pin("robo_reset");
|
|
|
|
if (robo.gpio_robo_reset >= 0) {
|
|
|
|
err = gpio_request(robo.gpio_robo_reset, "robo_reset");
|
|
|
|
if (err) {
|
|
|
|
printk(KERN_ERR PFX "error (%i) requesting robo_reset gpio (%i)\n",
|
|
|
|
err, robo.gpio_robo_reset);
|
|
|
|
goto err_gpio_robo;
|
|
|
|
}
|
|
|
|
gpio_set_value(robo.gpio_robo_reset, 0);
|
|
|
|
gpio_direction_output(robo.gpio_robo_reset, 1);
|
|
|
|
gpio_set_value(robo.gpio_robo_reset, 0);
|
|
|
|
mdelay(50);
|
|
|
|
|
|
|
|
gpio_set_value(robo.gpio_robo_reset, 1);
|
|
|
|
mdelay(20);
|
|
|
|
} else {
|
|
|
|
// TODO: reset the internal robo switch
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-02-13 16:01:50 +00:00
|
|
|
phyid = mdio_read(ROBO_PHY_ADDR, 0x2) |
|
2012-08-05 13:10:43 +00:00
|
|
|
(mdio_read(ROBO_PHY_ADDR, 0x3) << 16);
|
2005-12-25 14:18:55 +00:00
|
|
|
|
|
|
|
if (phyid == 0xffffffff || phyid == 0x55210022) {
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_ERR PFX "No Robo switch in managed mode found, phy_id = 0x%08x\n", phyid);
|
2013-02-13 16:02:20 +00:00
|
|
|
err = -ENODEV;
|
2013-02-13 16:02:41 +00:00
|
|
|
goto err_gpio_lanports;
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
2008-02-27 22:35:41 +00:00
|
|
|
|
|
|
|
/* 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 */
|
2013-01-03 01:58:01 +00:00
|
|
|
robo.is_5350 = robo_vlan5350(phyid);
|
2008-02-27 22:35:41 +00:00
|
|
|
|
|
|
|
robo_switch_reset();
|
|
|
|
err = robo_switch_enable();
|
|
|
|
if (err)
|
2013-02-13 16:02:41 +00:00
|
|
|
goto err_gpio_lanports;
|
2008-02-27 22:35:41 +00:00
|
|
|
|
2013-01-03 01:57:19 +00:00
|
|
|
printk(KERN_INFO PFX "found a 5%s%x!%s at %s\n", robo.devid & 0xff00 ? "" : "3", robo.devid,
|
|
|
|
robo.is_5350 ? " It's a 5350." : "", devname);
|
2011-02-20 17:24:15 +00:00
|
|
|
|
2013-02-13 16:02:20 +00:00
|
|
|
return 0;
|
2013-02-13 16:02:41 +00:00
|
|
|
|
|
|
|
err_gpio_lanports:
|
|
|
|
if (robo.gpio_lanports_enable >= 0)
|
|
|
|
gpio_free(robo.gpio_lanports_enable);
|
|
|
|
err_gpio_robo:
|
|
|
|
if (robo.gpio_robo_reset >= 0)
|
|
|
|
gpio_free(robo.gpio_robo_reset);
|
2013-02-13 16:02:20 +00:00
|
|
|
err_put:
|
|
|
|
dev_put(robo.dev);
|
|
|
|
robo.dev = NULL;
|
|
|
|
err_done:
|
2011-02-20 17:24:15 +00:00
|
|
|
return err;
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-04 19:10:06 +00:00
|
|
|
static int handle_vlan_port_read(void *driver, char *buf, int nr)
|
2005-12-25 14:18:55 +00:00
|
|
|
{
|
|
|
|
__u16 val16;
|
|
|
|
int len = 0;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
val16 = (nr) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */;
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2008-02-27 22:35:41 +00:00
|
|
|
if (robo.is_5350) {
|
2005-12-25 14:18:55 +00:00
|
|
|
u32 val32;
|
|
|
|
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
|
|
|
|
/* actual read */
|
|
|
|
val32 = robo_read32(ROBO_VLAN_PAGE, ROBO_VLAN_READ);
|
|
|
|
if ((val32 & (1 << 20)) /* valid */) {
|
|
|
|
for (j = 0; j < 6; j++) {
|
|
|
|
if (val32 & (1 << j)) {
|
2006-01-14 17:49:21 +00:00
|
|
|
len += sprintf(buf + len, "%d", j);
|
|
|
|
if (val32 & (1 << (j + 6))) {
|
|
|
|
if (j == 5) buf[len++] = 'u';
|
|
|
|
} else {
|
|
|
|
buf[len++] = 't';
|
|
|
|
if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr)
|
|
|
|
buf[len++] = '*';
|
|
|
|
}
|
|
|
|
buf[len++] = '\t';
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
len += sprintf(buf + len, "\n");
|
|
|
|
}
|
2010-07-20 22:25:04 +00:00
|
|
|
} else {
|
2005-12-25 14:18:55 +00:00
|
|
|
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
|
|
|
|
/* actual read */
|
|
|
|
val16 = robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_READ);
|
|
|
|
if ((val16 & (1 << 14)) /* valid */) {
|
|
|
|
for (j = 0; j < 6; j++) {
|
|
|
|
if (val16 & (1 << j)) {
|
2006-01-14 17:49:21 +00:00
|
|
|
len += sprintf(buf + len, "%d", j);
|
|
|
|
if (val16 & (1 << (j + 7))) {
|
|
|
|
if (j == 5) buf[len++] = 'u';
|
|
|
|
} else {
|
|
|
|
buf[len++] = 't';
|
|
|
|
if (robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1)) == nr)
|
|
|
|
buf[len++] = '*';
|
|
|
|
}
|
|
|
|
buf[len++] = '\t';
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
len += sprintf(buf + len, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 22:44:35 +00:00
|
|
|
buf[len] = '\0';
|
|
|
|
|
2005-12-25 14:18:55 +00:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2006-01-04 19:10:06 +00:00
|
|
|
static int handle_vlan_port_write(void *driver, char *buf, int nr)
|
2005-12-25 14:18:55 +00:00
|
|
|
{
|
2006-01-04 19:10:06 +00:00
|
|
|
switch_driver *d = (switch_driver *) driver;
|
|
|
|
switch_vlan_config *c = switch_parse_vlan(d, buf);
|
2005-12-25 14:18:55 +00:00
|
|
|
int j;
|
|
|
|
__u16 val16;
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2006-01-04 19:10:06 +00:00
|
|
|
if (c == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
for (j = 0; j < d->ports; j++) {
|
|
|
|
if ((c->untag | c->pvid) & (1 << j))
|
2005-12-25 14:18:55 +00:00
|
|
|
/* change default vlan tag */
|
|
|
|
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), nr);
|
|
|
|
}
|
2006-01-04 19:10:06 +00:00
|
|
|
|
|
|
|
/* write config now */
|
2009-10-29 21:26:36 +00:00
|
|
|
|
|
|
|
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);
|
2012-01-28 13:52:37 +00:00
|
|
|
kfree(c);
|
2009-10-29 21:26:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-04 19:10:06 +00:00
|
|
|
val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
|
2008-02-27 22:35:41 +00:00
|
|
|
if (robo.is_5350) {
|
2006-01-04 19:10:06 +00:00
|
|
|
robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350,
|
|
|
|
(1 << 20) /* valid */ | (c->untag << 6) | c->port);
|
|
|
|
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
|
2005-12-25 14:18:55 +00:00
|
|
|
} else {
|
2006-01-04 19:10:06 +00:00
|
|
|
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE,
|
|
|
|
(1 << 14) /* valid */ | (c->untag << 7) | c->port);
|
|
|
|
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
2006-01-04 19:10:06 +00:00
|
|
|
|
2012-01-28 13:52:37 +00:00
|
|
|
kfree(c);
|
2005-12-25 14:18:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-11 22:57:52 +00:00
|
|
|
#define set_switch(state) \
|
|
|
|
robo_write16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE, (robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & ~2) | (state ? 2 : 0));
|
|
|
|
|
|
|
|
static int handle_enable_read(void *driver, char *buf, int nr)
|
|
|
|
{
|
|
|
|
return sprintf(buf, "%d\n", (((robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & 2) == 2) ? 1 : 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_enable_write(void *driver, char *buf, int nr)
|
|
|
|
{
|
|
|
|
set_switch(buf[0] == '1');
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-03 01:58:01 +00:00
|
|
|
static int handle_port_enable_read(void *driver, char *buf, int nr)
|
|
|
|
{
|
|
|
|
return sprintf(buf, "%d\n", ((robo_read16(ROBO_CTRL_PAGE, robo.port[nr]) & 3) == 3 ? 0 : 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_port_enable_write(void *driver, char *buf, int nr)
|
|
|
|
{
|
|
|
|
u16 val16;
|
|
|
|
|
|
|
|
if (buf[0] == '0')
|
|
|
|
val16 = 3; /* disabled */
|
|
|
|
else if (buf[0] == '1')
|
|
|
|
val16 = 0; /* enabled */
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
robo_write16(ROBO_CTRL_PAGE, robo.port[nr],
|
|
|
|
(robo_read16(ROBO_CTRL_PAGE, robo.port[nr]) & ~3) | val16);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_port_media_read(void *driver, char *buf, int nr)
|
|
|
|
{
|
|
|
|
u16 bmcr = mdio_read(robo.port[nr], MII_BMCR);
|
|
|
|
int media, len;
|
|
|
|
|
|
|
|
if (bmcr & BMCR_ANENABLE)
|
|
|
|
media = SWITCH_MEDIA_AUTO;
|
|
|
|
else {
|
|
|
|
if (bmcr & BMCR_SPEED1000)
|
|
|
|
media = SWITCH_MEDIA_1000;
|
|
|
|
else if (bmcr & BMCR_SPEED100)
|
|
|
|
media = SWITCH_MEDIA_100;
|
|
|
|
else
|
|
|
|
media = 0;
|
|
|
|
|
|
|
|
if (bmcr & BMCR_FULLDPLX)
|
|
|
|
media |= SWITCH_MEDIA_FD;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = switch_print_media(buf, media);
|
|
|
|
return len + sprintf(buf + len, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_port_media_write(void *driver, char *buf, int nr)
|
|
|
|
{
|
|
|
|
int media = switch_parse_media(buf);
|
|
|
|
u16 bmcr, bmcr_mask;
|
|
|
|
|
|
|
|
if (media & SWITCH_MEDIA_AUTO)
|
|
|
|
bmcr = BMCR_ANENABLE | BMCR_ANRESTART;
|
|
|
|
else {
|
|
|
|
if (media & SWITCH_MEDIA_1000) {
|
|
|
|
if (!robo.gmii)
|
|
|
|
return -EINVAL;
|
|
|
|
bmcr = BMCR_SPEED1000;
|
|
|
|
}
|
|
|
|
else if (media & SWITCH_MEDIA_100)
|
|
|
|
bmcr = BMCR_SPEED100;
|
|
|
|
else
|
|
|
|
bmcr = 0;
|
|
|
|
|
|
|
|
if (media & SWITCH_MEDIA_FD)
|
|
|
|
bmcr |= BMCR_FULLDPLX;
|
|
|
|
}
|
|
|
|
|
|
|
|
bmcr_mask = ~(BMCR_SPEED1000 | BMCR_SPEED100 | BMCR_FULLDPLX | BMCR_ANENABLE | BMCR_ANRESTART);
|
2013-02-13 16:01:50 +00:00
|
|
|
mdio_write(robo.port[nr], MII_BMCR,
|
2013-01-03 01:58:01 +00:00
|
|
|
(mdio_read(robo.port[nr], MII_BMCR) & bmcr_mask) | bmcr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-11 22:57:52 +00:00
|
|
|
static int handle_enable_vlan_read(void *driver, char *buf, int nr)
|
|
|
|
{
|
|
|
|
return sprintf(buf, "%d\n", (((robo_read16(ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0) & (1 << 7)) == (1 << 7)) ? 1 : 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_enable_vlan_write(void *driver, char *buf, int nr)
|
|
|
|
{
|
|
|
|
int disable = ((buf[0] != '1') ? 1 : 0);
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2006-01-11 22:57:52 +00:00
|
|
|
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 :
|
2009-11-03 20:35:37 +00:00
|
|
|
(robo.devid == ROBO_DEVICE_ID_5325 ? (1 << 1) :
|
|
|
|
0) | (1 << 2) | (1 << 3)); /* RSV multicast */
|
2009-10-29 21:26:36 +00:00
|
|
|
|
|
|
|
if (robo.devid != ROBO_DEVICE_ID_5325)
|
|
|
|
return 0;
|
|
|
|
|
2006-01-11 22:57:52 +00:00
|
|
|
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 :
|
|
|
|
(1 << 3) /* drop miss V table frames */);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_reset(void *driver, char *buf, int nr)
|
|
|
|
{
|
|
|
|
switch_driver *d = (switch_driver *) driver;
|
|
|
|
int j;
|
|
|
|
__u16 val16;
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2006-01-11 22:57:52 +00:00
|
|
|
/* disable switching */
|
|
|
|
set_switch(0);
|
|
|
|
|
|
|
|
/* reset vlans */
|
2008-02-27 22:35:41 +00:00
|
|
|
for (j = 0; j <= ((robo.is_5350) ? VLAN_ID_MAX5350 : VLAN_ID_MAX); j++) {
|
2006-01-11 22:57:52 +00:00
|
|
|
/* write config now */
|
|
|
|
val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
|
2008-02-27 22:35:41 +00:00
|
|
|
if (robo.is_5350)
|
2006-01-11 22:57:52 +00:00
|
|
|
robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 0);
|
|
|
|
else
|
|
|
|
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0);
|
2008-02-27 22:35:41 +00:00
|
|
|
robo_write16(ROBO_VLAN_PAGE, robo.is_5350 ? ROBO_VLAN_TABLE_ACCESS_5350 :
|
|
|
|
ROBO_VLAN_TABLE_ACCESS,
|
|
|
|
val16);
|
2006-01-11 22:57:52 +00:00
|
|
|
}
|
2006-01-26 04:02:48 +00:00
|
|
|
|
|
|
|
/* reset ports to a known good state */
|
|
|
|
for (j = 0; j < d->ports; j++) {
|
2008-02-27 22:35:41 +00:00
|
|
|
robo_write16(ROBO_CTRL_PAGE, robo.port[j], 0x0000);
|
2006-01-26 04:02:48 +00:00
|
|
|
robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), 0);
|
|
|
|
}
|
|
|
|
|
2006-01-11 22:57:52 +00:00
|
|
|
/* enable switching */
|
|
|
|
set_switch(1);
|
|
|
|
|
|
|
|
/* enable vlans */
|
|
|
|
handle_enable_vlan_write(driver, "1", 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-06-19 02:05:27 +00:00
|
|
|
static int __init robo_init(void)
|
2005-12-25 14:18:55 +00:00
|
|
|
{
|
|
|
|
int notfound = 1;
|
2008-02-27 22:35:41 +00:00
|
|
|
char *device;
|
2005-12-25 14:18:55 +00:00
|
|
|
|
2006-03-25 14:31:42 +00:00
|
|
|
device = strdup("ethX");
|
2005-12-25 14:18:55 +00:00
|
|
|
for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) {
|
2008-06-15 11:10:27 +00:00
|
|
|
if (! switch_device_registered (device))
|
|
|
|
notfound = robo_probe(device);
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
2006-01-04 19:10:06 +00:00
|
|
|
device[3]--;
|
2010-07-20 22:25:04 +00:00
|
|
|
|
2006-03-25 14:31:42 +00:00
|
|
|
if (notfound) {
|
|
|
|
kfree(device);
|
2005-12-25 14:18:55 +00:00
|
|
|
return -ENODEV;
|
2006-03-25 14:31:42 +00:00
|
|
|
} else {
|
2008-02-27 22:35:41 +00:00
|
|
|
static const switch_config cfg[] = {
|
|
|
|
{
|
|
|
|
.name = "enable",
|
|
|
|
.read = handle_enable_read,
|
|
|
|
.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, },
|
2006-01-11 22:57:52 +00:00
|
|
|
};
|
2013-01-03 01:58:01 +00:00
|
|
|
static const switch_config port[] = {
|
|
|
|
{
|
|
|
|
.name = "enable",
|
|
|
|
.read = handle_port_enable_read,
|
|
|
|
.write = handle_port_enable_write
|
|
|
|
}, {
|
|
|
|
.name = "media",
|
|
|
|
.read = handle_port_media_read,
|
|
|
|
.write = handle_port_media_write
|
|
|
|
}, { NULL, },
|
|
|
|
};
|
2008-02-27 22:35:41 +00:00
|
|
|
static const switch_config vlan[] = {
|
|
|
|
{
|
|
|
|
.name = "ports",
|
|
|
|
.read = handle_vlan_port_read,
|
|
|
|
.write = handle_vlan_port_write
|
|
|
|
}, { NULL, },
|
2005-12-25 14:18:55 +00:00
|
|
|
};
|
|
|
|
switch_driver driver = {
|
2008-02-27 22:35:41 +00:00
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.version = DRIVER_VERSION,
|
|
|
|
.interface = device,
|
|
|
|
.cpuport = 5,
|
|
|
|
.ports = 6,
|
|
|
|
.vlans = 16,
|
|
|
|
.driver_handlers = cfg,
|
2013-01-03 01:58:01 +00:00
|
|
|
.port_handlers = port,
|
2008-02-27 22:35:41 +00:00
|
|
|
.vlan_handlers = vlan,
|
2005-12-25 14:18:55 +00:00
|
|
|
};
|
2009-10-29 21:26:36 +00:00
|
|
|
if (robo.devid != ROBO_DEVICE_ID_5325) {
|
|
|
|
driver.ports = 9;
|
|
|
|
driver.cpuport = 8;
|
|
|
|
}
|
2005-12-25 14:18:55 +00:00
|
|
|
|
|
|
|
return switch_register_driver(&driver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-19 02:05:27 +00:00
|
|
|
static void __exit robo_exit(void)
|
2005-12-25 14:18:55 +00:00
|
|
|
{
|
|
|
|
switch_unregister_driver(DRIVER_NAME);
|
2011-02-20 17:24:15 +00:00
|
|
|
if (robo.dev)
|
|
|
|
dev_put(robo.dev);
|
2013-02-13 16:02:41 +00:00
|
|
|
if (robo.gpio_robo_reset >= 0)
|
|
|
|
gpio_free(robo.gpio_robo_reset);
|
|
|
|
if (robo.gpio_lanports_enable >= 0)
|
|
|
|
gpio_free(robo.gpio_lanports_enable);
|
2008-02-27 22:35:41 +00:00
|
|
|
kfree(robo.device);
|
2005-12-25 14:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_init(robo_init);
|
|
|
|
module_exit(robo_exit);
|