summaryrefslogtreecommitdiff
path: root/target/linux/adm5120-2.6/files
diff options
context:
space:
mode:
authorflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-05-13 21:56:34 +0000
committerflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-05-13 21:56:34 +0000
commit1117278190aa5f4dca9b14f1e6959eacc842927c (patch)
treebf9d2b36093e5839eb2c636034aa25fe086fd4cf /target/linux/adm5120-2.6/files
parentf0663614b6add874f0e2443b745d05f96ba50355 (diff)
Fix routeboard board detection, add some new ZyXEL boards, thanks to Gabor Juhos
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7214 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/adm5120-2.6/files')
-rw-r--r--target/linux/adm5120-2.6/files/arch/mips/adm5120/adm5120_info.c154
-rw-r--r--target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/routerboot.h19
2 files changed, 131 insertions, 42 deletions
diff --git a/target/linux/adm5120-2.6/files/arch/mips/adm5120/adm5120_info.c b/target/linux/adm5120-2.6/files/arch/mips/adm5120/adm5120_info.c
index 67b3e42ee7..fde86c8f86 100644
--- a/target/linux/adm5120-2.6/files/arch/mips/adm5120/adm5120_info.c
+++ b/target/linux/adm5120-2.6/files/arch/mips/adm5120/adm5120_info.c
@@ -115,48 +115,83 @@ static struct adm5120_board __initdata adm5120_boards[] = {
.flash0_size = 4*1024*1024,
},
{
- .name = "RouterBOARD RB-111",
+ .name = "RouterBOARD 111",
.mach_type = MACH_ADM5120_RB_111,
.has_usb = 0,
.iface_num = 1,
.flash0_size = 128*1024,
},
{
- .name = "RouterBOARD RB-112",
+ .name = "RouterBOARD 112",
.mach_type = MACH_ADM5120_RB_112,
.has_usb = 0,
.iface_num = 1,
.flash0_size = 128*1024,
},
{
- .name = "RouterBOARD RB-133",
+ .name = "RouterBOARD 133",
.mach_type = MACH_ADM5120_RB_133,
.has_usb = 0,
.iface_num = 3,
.flash0_size = 128*1024,
},
{
- .name = "RouterBOARD RB-133C",
+ .name = "RouterBOARD 133C",
.mach_type = MACH_ADM5120_RB_133C,
.has_usb = 0,
.iface_num = 1,
.flash0_size = 128*1024,
},
{
- .name = "RouterBOARD RB-150",
+ .name = "RouterBOARD 150",
.mach_type = MACH_ADM5120_RB_150,
.has_usb = 0,
.iface_num = 5,
.flash0_size = 128*1024,
},
{
- .name = "RouterBOARD RB-153",
+ .name = "RouterBOARD 153",
.mach_type = MACH_ADM5120_RB_153,
.has_usb = 0,
.iface_num = 5,
.flash0_size = 128*1024,
},
{
+ .name = "ZyXEL ES-2108",
+ .mach_type = MACH_ADM5120_ES2108,
+ .has_usb = 0,
+ .iface_num = 0,
+ .flash0_size = 4*1024*1024,
+ },
+ {
+ .name = "ZyXEL ES-2108-F",
+ .mach_type = MACH_ADM5120_ES2108F,
+ .has_usb = 0,
+ .iface_num = 0,
+ .flash0_size = 4*1024*1024,
+ },
+ {
+ .name = "ZyXEL ES-2108-G",
+ .mach_type = MACH_ADM5120_ES2108G,
+ .has_usb = 0,
+ .iface_num = 0,
+ .flash0_size = 4*1024*1024,
+ },
+ {
+ .name = "ZyXEL ES-2108-LC",
+ .mach_type = MACH_ADM5120_ES2108LC,
+ .has_usb = 0,
+ .iface_num = 0,
+ .flash0_size = 4*1024*1024,
+ },
+ {
+ .name = "ZyXEL ES-2108PWR",
+ .mach_type = MACH_ADM5120_ES2108PWR,
+ .has_usb = 0,
+ .iface_num = 0,
+ .flash0_size = 4*1024*1024,
+ },
+ {
.name = "ZyXEL HomeSafe 100/100W",
.mach_type = MACH_ADM5120_HS100,
.has_usb = 0,
@@ -367,8 +402,7 @@ static int __init cfe_present(void)
return 0;
}
- /* cfe_a1_val must be 0, because only one CPU present in the ADM5120 SoC
-*/
+ /* cfe_a1_val must be 0, because only one CPU present in the ADM5120 */
if (cfe_a1_val != 0) {
return 0;
}
@@ -434,75 +468,111 @@ out:
/*
* RouterBOOT based boards
*/
-static int __init routerboot_find_tag(u8 *buf, u16 tagid, void **tagval,
- u16 *taglen)
+static int __init routerboot_load_hs(u8 *buf, u16 buflen,
+ struct rb_hard_settings *hs)
{
u16 id,len;
- int ret;
+ u8 *mac;
+ int i,j;
+
+ if (buflen < 4)
+ return -1;
+
+ if (read_le32(buf) != RB_MAGIC_HARD)
+ return -1;
+
+ /* skip magic value */
+ buf += 4;
+ buflen -= 4;
- ret = -1;
- /* skip header */
- buf += 8;
- for (;;) {
+ while (buflen > 2) {
id = read_le16(buf);
buf += 2;
- if (id == RB_ID_TERMINATOR)
+ buflen -= 2;
+ if (id == RB_ID_TERMINATOR || buflen < 2)
break;
len = read_le16(buf);
buf += 2;
- if (id == tagid) {
- *tagval = buf;
- *taglen = len;
- ret = 0;
+ buflen -= 2;
+
+ if (buflen < len)
+ break;
+
+ switch (id) {
+ case RB_ID_BIOS_VERSION:
+ hs->bios_ver = (char *)buf;
+ break;
+ case RB_ID_BOARD_NAME:
+ hs->name = (char *)buf;
+ break;
+ case RB_ID_MEMORY_SIZE:
+ hs->mem_size = read_le32(buf);
+ break;
+ case RB_ID_MAC_ADDRESS_COUNT:
+ hs->mac_count = read_le32(buf);
+ break;
+ case RB_ID_MAC_ADDRESS_PACK:
+ hs->mac_count = len/RB_MAC_SIZE;
+ if (hs->mac_count > RB_MAX_MAC_COUNT)
+ hs->mac_count = RB_MAX_MAC_COUNT;
+ mac = buf;
+ for (i=0; i < hs->mac_count; i++) {
+ for (j=0; j < RB_MAC_SIZE; j++)
+ hs->macs[i][j] = mac[j];
+ mac += RB_MAC_SIZE;
+ }
break;
}
buf += len;
+ buflen -= len;
+
}
- return ret;
+ return 0;
}
-#define RB_HS_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x1000)
-#define RB_SS_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x2000)
-#define RB_FW_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x10000)
+#define RB_BS_OFFS 0x14
+#define RB_OFFS_MAX (128*1024)
static unsigned long __init routerboot_detect_board(void)
{
struct routerboard *board;
- u32 magic;
- char *name;
- u16 namelen;
+ struct rb_hard_settings hs;
+ struct rb_bios_settings *bs;
+ u8 *base;
+ u32 off,len;
unsigned long ret;
ret = MACH_ADM5120_UNKNOWN;
- magic = le32_to_cpu(*(u32 *)RB_HS_ADDR);
- if (magic != RB_MAGIC_HARD)
- goto out;
+ base = (u8 *)KSEG1ADDR(ADM5120_SRAM0_BASE);
+ bs = (struct rb_bios_settings *)(base + RB_BS_OFFS);
- magic = le32_to_cpu(*(u32 *)RB_SS_ADDR);
- if ((magic != RB_MAGIC_SOFT) && (magic != RB_MAGIC_DAWN))
- goto out;
+ off = read_le32(&bs->hs_offs);
+ len = read_le32(&bs->hs_size);
+ if (off > RB_OFFS_MAX)
+ return ret;
- if (routerboot_find_tag((u8 *)RB_HS_ADDR, RB_ID_BOARD_NAME,
- (void *)&name, &namelen))
- goto out;
+ memset(&hs, 0, sizeof(hs));
+ if (routerboot_load_hs(base+off, len, &hs) != 0)
+ return ret;
+
+ /* assume RouterBOOT as the boot-loader */
+ adm5120_boot_loader = BOOT_LOADER_ROUTERBOOT;
+
+ if (hs.name == NULL)
+ return ret;
for (board = routerboards; board->mach_type != MACH_ADM5120_UNKNOWN;
board++) {
- if (strncmp(board->name, name, strlen(board->name)) == 0) {
+ if (strncmp(board->name, hs.name, strlen(board->name)) == 0) {
ret = board->mach_type;
break;
}
-
}
- /* assume RouterBOOT as the boot-loader */
- adm5120_boot_loader = BOOT_LOADER_ROUTERBOOT;
-
-out:
return ret;
}
diff --git a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/routerboot.h b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/routerboot.h
index 1e2b973679..2a593e9336 100644
--- a/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/routerboot.h
+++ b/target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/routerboot.h
@@ -14,6 +14,25 @@
#ifndef _ROUTERBOOT_H
#define _ROUTERBOOT_H
+#define RB_MAC_SIZE 6
+#define RB_MAX_MAC_COUNT 6
+
+struct rb_bios_settings {
+ u32 hs_offs; /* hard settings offset */
+ u32 hs_size; /* hard settings size */
+ u32 fw_offs; /* firmware offset */
+ u32 ss_offs; /* soft settings offset */
+ u32 ss_size; /* soft settings size */
+};
+
+struct rb_hard_settings {
+ char *name; /* board name */
+ char *bios_ver; /* BIOS version */
+ u32 mem_size; /* memory size in bytes */
+ u32 mac_count; /* number of mac addresses */
+ u8 macs[RB_MAC_SIZE][RB_MAX_MAC_COUNT]; /* mac addresses */
+};
+
/*
* Magic numbers
*/