mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-12-01 20:55:19 +02:00
sync kmod-switch with whiterussian
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@2981 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
8f0aa4a769
commit
693e5a62fc
@ -34,10 +34,10 @@
|
|||||||
#define DRIVER_NAME "adm6996"
|
#define DRIVER_NAME "adm6996"
|
||||||
#define DRIVER_VERSION "0.01"
|
#define DRIVER_VERSION "0.01"
|
||||||
|
|
||||||
static int eecs = 2;
|
static int eecs = 0;
|
||||||
static int eesk = 3;
|
static int eesk = 0;
|
||||||
static int eedi = 5;
|
static int eedi = 0;
|
||||||
static int eerc = 6;
|
static int eerc = 0;
|
||||||
static int force = 0;
|
static int force = 0;
|
||||||
|
|
||||||
MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
|
MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
|
||||||
@ -60,8 +60,34 @@ MODULE_PARM(force, "i");
|
|||||||
|
|
||||||
#define atoi(str) simple_strtoul(((str != NULL) ? str : ""), NULL, 0)
|
#define atoi(str) simple_strtoul(((str != NULL) ? str : ""), NULL, 0)
|
||||||
|
|
||||||
|
#if defined(BCMGPIO2) || defined(BCMGPIO)
|
||||||
extern char *nvram_get(char *name);
|
extern char *nvram_get(char *name);
|
||||||
|
|
||||||
|
/* Return gpio pin number assigned to the named pin */
|
||||||
|
/*
|
||||||
|
* Variable should be in format:
|
||||||
|
*
|
||||||
|
* gpio<N>=pin_name
|
||||||
|
*
|
||||||
|
* 'def_pin' is returned if there is no such variable found.
|
||||||
|
*/
|
||||||
|
static unsigned int getgpiopin(char *pin_name, unsigned int def_pin)
|
||||||
|
{
|
||||||
|
char name[] = "gpioXXXX";
|
||||||
|
char *val;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
return def_pin;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void adm_write(int cs, char *buf, unsigned int bits)
|
static void adm_write(int cs, char *buf, unsigned int bits)
|
||||||
{
|
{
|
||||||
@ -255,7 +281,16 @@ static int handle_vlan_port_read(void *driver, char *buf, int nr)
|
|||||||
for (i = 0; i <= 5; i++) {
|
for (i = 0; i <= 5; i++) {
|
||||||
if (ports & vlan_ports[i]) {
|
if (ports & vlan_ports[i]) {
|
||||||
c = adm_rreg(0, port_conf[i]);
|
c = adm_rreg(0, port_conf[i]);
|
||||||
len += sprintf(buf + len, (c & (1 << 4) ? "%dt\t" : (i == 5 ? "%du\t" : "%d\t")), i);
|
|
||||||
|
len += sprintf(buf + len, "%d", i);
|
||||||
|
if (c & (1 << 4)) {
|
||||||
|
buf[len++] = 't';
|
||||||
|
if (((c & (0xf << 10)) >> 10) == nr)
|
||||||
|
buf[len++] = '*';
|
||||||
|
} else if (i == 5)
|
||||||
|
buf[len++] = 'u';
|
||||||
|
|
||||||
|
buf[len++] = '\t';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len += sprintf(buf + len, "\n");
|
len += sprintf(buf + len, "\n");
|
||||||
@ -386,23 +421,24 @@ static int handle_reset(void *driver, char *buf, int nr)
|
|||||||
* reset logic therefore we must explicitly perform the
|
* reset logic therefore we must explicitly perform the
|
||||||
* sequence in software.
|
* sequence in software.
|
||||||
*/
|
*/
|
||||||
/* Keep RC high for at least 20ms */
|
if (eerc) {
|
||||||
adm_enout(eerc, eerc);
|
/* Keep RC high for at least 20ms */
|
||||||
for (i = 0; i < 20; i ++)
|
adm_enout(eerc, eerc);
|
||||||
udelay(1000);
|
for (i = 0; i < 20; i ++)
|
||||||
/* Keep RC low for at least 100ms */
|
udelay(1000);
|
||||||
adm_enout(eerc, 0);
|
/* Keep RC low for at least 100ms */
|
||||||
for (i = 0; i < 100; i++)
|
adm_enout(eerc, 0);
|
||||||
udelay(1000);
|
for (i = 0; i < 100; i++)
|
||||||
/* Set default configuration */
|
udelay(1000);
|
||||||
adm_enout((__u8)(eesk | eedi), eesk);
|
/* Set default configuration */
|
||||||
/* Keep RC high for at least 30ms */
|
adm_enout((__u8)(eesk | eedi), eesk);
|
||||||
adm_enout(eerc, eerc);
|
/* Keep RC high for at least 30ms */
|
||||||
for (i = 0; i < 30; i++)
|
adm_enout(eerc, eerc);
|
||||||
udelay(1000);
|
for (i = 0; i < 30; i++)
|
||||||
/* Leave RC high and disable GPIO outputs */
|
udelay(1000);
|
||||||
adm_disout((__u8)(eecs | eesk | eedi));
|
/* Leave RC high and disable GPIO outputs */
|
||||||
|
adm_disout((__u8)(eecs | eesk | eedi));
|
||||||
|
}
|
||||||
/* set up initial configuration for ports */
|
/* set up initial configuration for ports */
|
||||||
for (i = 0; i <= 5; i++) {
|
for (i = 0; i <= 5; i++) {
|
||||||
int cfg = 0x8000 | /* Auto MDIX */
|
int cfg = 0x8000 | /* Auto MDIX */
|
||||||
@ -446,10 +482,34 @@ static int detect_adm()
|
|||||||
#if defined(BCMGPIO2) || defined(BCMGPIO)
|
#if defined(BCMGPIO2) || defined(BCMGPIO)
|
||||||
int boardflags = atoi(nvram_get("boardflags"));
|
int boardflags = atoi(nvram_get("boardflags"));
|
||||||
|
|
||||||
if ((boardflags & 0x80) || force)
|
if ((boardflags & 0x80) || force) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
else
|
|
||||||
|
eecs = getgpiopin("adm_eecs", 2);
|
||||||
|
eesk = getgpiopin("adm_eesk", 3);
|
||||||
|
eedi = getgpiopin("adm_eedi", 4);
|
||||||
|
eerc = getgpiopin("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;
|
||||||
|
eerc = 6;
|
||||||
|
|
||||||
|
ret = 1;
|
||||||
|
} else
|
||||||
printk("BFL_ENETADM not set in boardflags. Use force=1 to ignore.\n");
|
printk("BFL_ENETADM not set in boardflags. Use force=1 to ignore.\n");
|
||||||
|
|
||||||
|
if (eecs)
|
||||||
|
eecs = (1 << eecs);
|
||||||
|
if (eesk)
|
||||||
|
eesk = (1 << eesk);
|
||||||
|
if (eedi)
|
||||||
|
eedi = (1 << eedi);
|
||||||
|
if (eerc)
|
||||||
|
eerc = (1 << eerc);
|
||||||
#else
|
#else
|
||||||
ret = 1;
|
ret = 1;
|
||||||
#endif
|
#endif
|
||||||
@ -487,10 +547,6 @@ static int __init adm_init()
|
|||||||
vlan_handlers: vlan,
|
vlan_handlers: vlan,
|
||||||
};
|
};
|
||||||
|
|
||||||
eecs = (1 << eecs);
|
|
||||||
eesk = (1 << eesk);
|
|
||||||
eedi = (1 << eedi);
|
|
||||||
|
|
||||||
if (!detect_adm())
|
if (!detect_adm())
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
@ -278,8 +278,15 @@ static int handle_vlan_port_read(void *driver, char *buf, int nr)
|
|||||||
if ((val32 & (1 << 20)) /* valid */) {
|
if ((val32 & (1 << 20)) /* valid */) {
|
||||||
for (j = 0; j < 6; j++) {
|
for (j = 0; j < 6; j++) {
|
||||||
if (val32 & (1 << j)) {
|
if (val32 & (1 << j)) {
|
||||||
len += sprintf(buf + len, "%d%s\t", j,
|
len += sprintf(buf + len, "%d", j);
|
||||||
(val32 & (1 << (j + 6))) ? (j == 5 ? "u" : "") : "t");
|
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';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len += sprintf(buf + len, "\n");
|
len += sprintf(buf + len, "\n");
|
||||||
@ -291,8 +298,15 @@ static int handle_vlan_port_read(void *driver, char *buf, int nr)
|
|||||||
if ((val16 & (1 << 14)) /* valid */) {
|
if ((val16 & (1 << 14)) /* valid */) {
|
||||||
for (j = 0; j < 6; j++) {
|
for (j = 0; j < 6; j++) {
|
||||||
if (val16 & (1 << j)) {
|
if (val16 & (1 << j)) {
|
||||||
len += sprintf(buf + len, "%d%s\t", j, (val16 & (1 << (j + 7))) ?
|
len += sprintf(buf + len, "%d", j);
|
||||||
(j == 5 ? "u" : "") : "t");
|
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';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len += sprintf(buf + len, "\n");
|
len += sprintf(buf + len, "\n");
|
||||||
@ -415,7 +429,7 @@ static int __init robo_init()
|
|||||||
if (notfound)
|
if (notfound)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
else {
|
else {
|
||||||
switch_config main[] = {
|
switch_config cfg[] = {
|
||||||
{"enable", handle_enable_read, handle_enable_write},
|
{"enable", handle_enable_read, handle_enable_write},
|
||||||
{"enable_vlan", handle_enable_vlan_read, handle_enable_vlan_write},
|
{"enable_vlan", handle_enable_vlan_read, handle_enable_vlan_write},
|
||||||
{"reset", NULL, handle_reset},
|
{"reset", NULL, handle_reset},
|
||||||
@ -432,7 +446,7 @@ static int __init robo_init()
|
|||||||
cpuport: 5,
|
cpuport: 5,
|
||||||
ports: 6,
|
ports: 6,
|
||||||
vlans: 16,
|
vlans: 16,
|
||||||
driver_handlers: main,
|
driver_handlers: cfg,
|
||||||
port_handlers: NULL,
|
port_handlers: NULL,
|
||||||
vlan_handlers: vlan,
|
vlan_handlers: vlan,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user