/*
- * Broadcom BCM5325E/536x switch configuration module
+ * ADMTEK Adm6996 switch configuration module
*
* Copyright (C) 2005 Felix Fietkau <nbd@nbd.name>
*
#include <linux/delay.h>
#include <asm/uaccess.h>
-#include "gpio.h"
#include "switch-core.h"
+#include "gpio.h"
#define DRIVER_NAME "adm6996"
/* Bits in VLAN port mapping */
static int vlan_ports[] = { 1 << 0, 1 << 2, 1 << 4, 1 << 6, 1 << 7, 1 << 8 };
-static int handle_vlan_port_read(char *buf, int nr)
+static int handle_vlan_port_read(void *driver, char *buf, int nr)
{
int ports, i, c, len = 0;
return len;
}
-static int handle_vlan_port_write(char *buf, int nr)
+static int handle_vlan_port_write(void *driver, char *buf, int nr)
{
- int i, c, ports;
- int map = switch_parse_vlan(buf);
+ int i, cfg, ports;
+ switch_driver *d = (switch_driver *) driver;
+ switch_vlan_config *c = switch_parse_vlan(d, buf);
- if (map == -1)
+ if (c == NULL)
return -1;
ports = adm_rreg(0, 0x13 + nr);
- for (i = 0; i <= 5; i++) {
- if (map & (1 << i)) {
+ for (i = 0; i < d->ports; i++) {
+ if (c->port & (1 << i)) {
ports |= vlan_ports[i];
- c = adm_rreg(0, port_conf[i]);
+ cfg = adm_rreg(0, port_conf[i]);
/* Tagging */
- if (map & (1 << (8 + i)))
- c |= (1 << 4);
+ if (c->untag & (1 << i))
+ cfg &= ~(1 << 4);
else
- c &= ~(1 << 4);
-
- c = (c & ~(0xf << 10)) | (nr << 10);
+ cfg |= (1 << 4);
+
+ if ((c->untag | c->pvid) & (1 << i)) {
+ cfg = (cfg & ~(0xf << 10)) | (nr << 10);
+ }
- adm_wreg(port_conf[i], (__u16) c);
+ adm_wreg(port_conf[i], (__u16) cfg);
} else {
ports &= ~(vlan_ports[i]);
}
return 0;
}
-static int handle_port_enable_read(char *buf, int nr)
+static int handle_port_enable_read(void *driver, char *buf, int nr)
{
return sprintf(buf, "%d\n", ((adm_rreg(0, port_conf[nr]) & (1 << 5)) ? 0 : 1));
}
-static int handle_port_enable_write(char *buf, int nr)
+static int handle_port_enable_write(void *driver, char *buf, int nr)
{
int reg = adm_rreg(0, port_conf[nr]);
return 0;
}
-static int handle_port_media_read(char *buf, int nr)
+static int handle_port_media_read(void *driver, char *buf, int nr)
{
int len;
int media = 0;
return len + sprintf(buf + len, "\n");
}
-static int handle_port_media_write(char *buf, int nr)
+static int handle_port_media_write(void *driver, char *buf, int nr)
{
int media = switch_parse_media(buf);
int reg = adm_rreg(0, port_conf[nr]);
return 0;
}
-static int handle_vlan_enable_read(char *buf, int nr)
+static int handle_vlan_enable_read(void *driver, char *buf, int nr)
{
return sprintf(buf, "%d\n", ((adm_rreg(0, 0x11) & (1 << 5)) ? 1 : 0));
}
-static int handle_vlan_enable_write(char *buf, int nr)
+static int handle_vlan_enable_write(void *driver, char *buf, int nr)
{
int reg = adm_rreg(0, 0x11);
return 0;
}
-static int handle_reset(char *buf, int nr)
+static int handle_reset(void *driver, char *buf, int nr)
{
int i;
return 0;
}
-static int handle_registers(char *buf, int nr)
+static int handle_registers(void *driver, char *buf, int nr)
{
int i, len = 0;
return len;
}
-static int handle_counters(char *buf, int nr)
+static int handle_counters(void *driver, char *buf, int nr)
{
int i, len = 0;
#else
ret = 1;
#endif
+ if (ret == 1) {
+ int i = adm_rreg(0, 0);
+ if ((i == 0) || (i == 0xffff)) {
+ printk("No ADM6996 chip detected.\n");
+ ret = 0;
+ }
+ }
return ret;
}
};
switch_driver driver = {
name: DRIVER_NAME,
+ interface: "eth0",
ports: 6,
+ cpuport: 5,
vlans: 16,
driver_handlers: cfg,
port_handlers: port,