diff options
author | Florian Fainelli <florian@openwrt.org> | 2007-05-13 21:56:34 +0000 |
---|---|---|
committer | Florian Fainelli <florian@openwrt.org> | 2007-05-13 21:56:34 +0000 |
commit | ec138625b6e8277de21b0c958f2c44fcb5cd0c31 (patch) | |
tree | bf9d2b36093e5839eb2c636034aa25fe086fd4cf | |
parent | b48e9f9d72c84343f89929bb2bdb54f99d9e73f7 (diff) | |
download | upstream-ec138625b6e8277de21b0c958f2c44fcb5cd0c31.tar.gz upstream-ec138625b6e8277de21b0c958f2c44fcb5cd0c31.tar.bz2 upstream-ec138625b6e8277de21b0c958f2c44fcb5cd0c31.zip |
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
3 files changed, 144 insertions, 50 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 */ diff --git a/target/linux/adm5120-2.6/patches/001-adm5120.patch b/target/linux/adm5120-2.6/patches/001-adm5120.patch index 925ef3c91c..a77d1218dd 100644 --- a/target/linux/adm5120-2.6/patches/001-adm5120.patch +++ b/target/linux/adm5120-2.6/patches/001-adm5120.patch @@ -50,7 +50,7 @@ diff -urN linux-2.6.19.2/arch/mips/pci/Makefile linux-2.6.19.2.new/arch/mips/pci diff -urN linux-2.6.19.2/include/asm-mips/bootinfo.h linux-2.6.19.2.new/include/asm-mips/bootinfo.h --- linux-2.6.19.2/include/asm-mips/bootinfo.h 2007-01-10 20:10:37.000000000 +0100 +++ linux-2.6.19.2.new/include/asm-mips/bootinfo.h 2007-01-23 14:49:40.000000000 +0100 -@@ -212,6 +212,37 @@ +@@ -212,6 +212,42 @@ #define MACH_GROUP_NEC_EMMA2RH 25 /* NEC EMMA2RH (was 23) */ #define MACH_NEC_MARKEINS 0 /* NEC EMMA2RH Mark-eins */ @@ -77,13 +77,18 @@ diff -urN linux-2.6.19.2/include/asm-mips/bootinfo.h linux-2.6.19.2.new/include/ +#define MACH_ADM5120_HS100 16 /* ZyXEL HomeSafe 100/100W */ +#define MACH_ADM5120_P334 17 /* ZyXEL Prestige 334 */ +#define MACH_ADM5120_P334U 18 /* ZyXEL Prestige 334U */ -+#define MACH_ADM5120_P334W 18 /* ZyXEL Prestige 334W */ -+#define MACH_ADM5120_P334WH 19 /* ZyXEL Prestige 334WH */ -+#define MACH_ADM5120_P334WHD 20 /* ZyXEL Prestige 334WHD */ -+#define MACH_ADM5120_P334WT 21 /* ZyXEL Prestige 334WT */ -+#define MACH_ADM5120_P335 22 /* ZyXEL Prestige 335/335WT */ -+#define MACH_ADM5120_P335PLUS 23 /* ZyXEL Prestige 335Plus */ -+#define MACH_ADM5120_P335U 24 /* ZyXEL Prestige 335U */ ++#define MACH_ADM5120_P334W 19 /* ZyXEL Prestige 334W */ ++#define MACH_ADM5120_P334WH 20 /* ZyXEL Prestige 334WH */ ++#define MACH_ADM5120_P334WHD 21 /* ZyXEL Prestige 334WHD */ ++#define MACH_ADM5120_P334WT 22 /* ZyXEL Prestige 334WT */ ++#define MACH_ADM5120_P335 23 /* ZyXEL Prestige 335/335WT */ ++#define MACH_ADM5120_P335PLUS 24 /* ZyXEL Prestige 335Plus */ ++#define MACH_ADM5120_P335U 25 /* ZyXEL Prestige 335U */ ++#define MACH_ADM5120_ES2108 26 /* ZyXEL Ethernet Switch 2108 */ ++#define MACH_ADM5120_ES2108F 27 /* ZyXEL Ethernet Switch 2108-F */ ++#define MACH_ADM5120_ES2108G 28 /* ZyXEL Ethernet Switch 2108-G */ ++#define MACH_ADM5120_ES2108LC 29 /* ZyXEL Ethernet Switch 2108-LC */ ++#define MACH_ADM5120_ES2108PWR 30 /* ZyXEL Ethernet Switch 2108-PWR */ + #define CL_SIZE COMMAND_LINE_SIZE |