summaryrefslogtreecommitdiff
path: root/package/switch/src/switch-adm.c
diff options
context:
space:
mode:
authorhauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73>2011-08-04 20:07:58 +0000
committerhauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73>2011-08-04 20:07:58 +0000
commit7d9def4e2ef344626e4b5d2944345dd2779ac22b (patch)
tree149034bd9a56037f259ba3abcdb652847e1a0a09 /package/switch/src/switch-adm.c
parentf6abe30f2c9b4d39eef89dfe13e5b136a0993dab (diff)
switch: update for brcm47xx target
* remove suport for 2.4 kernel * add support for bcma bus git-svn-id: svn://svn.openwrt.org/openwrt/trunk@27904 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/switch/src/switch-adm.c')
-rw-r--r--package/switch/src/switch-adm.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/package/switch/src/switch-adm.c b/package/switch/src/switch-adm.c
index fa59c3fb8d..2aff14207b 100644
--- a/package/switch/src/switch-adm.c
+++ b/package/switch/src/switch-adm.c
@@ -37,6 +37,10 @@
#include "switch-core.h"
#include "gpio.h"
+#ifdef CONFIG_BCM47XX
+#include <nvram.h>
+#endif
+
#define DRIVER_NAME "adm6996"
#define DRIVER_VERSION "0.01"
@@ -48,19 +52,11 @@ static int force = 0;
MODULE_AUTHOR("Felix Fietkau <openwrt@nbd.name>");
MODULE_LICENSE("GPL");
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,52)
module_param(eecs, int, 0);
module_param(eesk, int, 0);
module_param(eedi, int, 0);
module_param(eerc, int, 0);
module_param(force, int, 0);
-#else
-MODULE_PARM(eecs, "i");
-MODULE_PARM(eesk, "i");
-MODULE_PARM(eedi, "i");
-MODULE_PARM(eerc, "i");
-MODULE_PARM(force, "i");
-#endif
/* Minimum timing constants */
#define EECK_EDGE_TIME 3 /* 3us - max(adm 2.5us, 93c 1us) */
@@ -74,8 +70,7 @@ MODULE_PARM(force, "i");
#define atoi(str) simple_strtoul(((str != NULL) ? str : ""), NULL, 0)
-#ifdef BROADCOM
-extern char *nvram_get(char *name);
+#ifdef CONFIG_BCM47XX
/* Return gpio pin number assigned to the named pin */
/*
@@ -88,15 +83,16 @@ extern char *nvram_get(char *name);
static unsigned int get_gpiopin(char *pin_name, unsigned int def_pin)
{
char name[] = "gpioXXXX";
- char *val;
+ char val[10];
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;
+ if (nvram_getenv(name, val, sizeof(val)) >= 0) {
+ if (!strcmp(val, pin_name))
+ return pin;
+ }
}
return def_pin;
}
@@ -495,9 +491,16 @@ static int detect_adm(void)
{
int ret = 0;
-#ifdef BROADCOM
- int boardflags = atoi(nvram_get("boardflags"));
- int boardnum = atoi(nvram_get("boardnum"));
+#ifdef CONFIG_BCM47XX
+ char buf[20];
+ int boardflags = 0;
+ int boardnum = 0;
+
+ if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
+ boardflags = simple_strtoul(buf, NULL, 0);
+
+ if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
+ boardnum = simple_strtoul(buf, NULL, 0);
if ((boardnum == 44) && (boardflags == 0x0388)) { /* Trendware TEW-411BRP+ */
ret = 1;
@@ -515,14 +518,19 @@ static int detect_adm(void)
eedi = get_gpiopin("adm_eedi", 4);
eerc = get_gpiopin("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;
-
- ret = 1;
+ } else if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0) {
+ if (strcmp(buf, "bcm94710dev") == 0) {
+ if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0) {
+ if (strncmp(buf, "42", 2) == 0) {
+ /* WRT54G v1.1 hack */
+ eecs = 2;
+ eesk = 3;
+ eedi = 5;
+
+ ret = 1;
+ }
+ }
+ }
}
if (eecs)