From: Hauke Mehrtens Date: Wed, 18 Sep 2013 14:33:54 +0000 (+0000) Subject: brcm47xx: update board detection patches X-Git-Tag: reboot~9262 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=4c52ed50d73492f1e4a1443a9479abe5c938a552;p=openwrt%2Fstaging%2Fchunkeey.git brcm47xx: update board detection patches This is now the version which was send for mainline Linux kernel inclusion. The data needed to detection a board is now stored in init data. Signed-off-by: Hauke Mehrtens SVN-Revision: 38036 --- diff --git a/package/kernel/broadcom-diag/src/diag.c b/package/kernel/broadcom-diag/src/diag.c index d4ba0b0fbe..78cb764629 100644 --- a/package/kernel/broadcom-diag/src/diag.c +++ b/package/kernel/broadcom-diag/src/diag.c @@ -1344,7 +1344,7 @@ static struct platform_t __init *platform_detect(void) board = bcm47xx_board_get(); board_name = bcm47xx_board_get_name(); - if (board != BCM47XX_BOARD_UNKNOWN && board != BCM47XX_BOARD_NON) + if (board != BCM47XX_BOARD_UNKNOWN && board != BCM47XX_BOARD_NO) printk(MODULE_NAME ": kernel found a \"%s\"\n", board_name); switch(board) { @@ -1447,7 +1447,7 @@ static struct platform_t __init *platform_detect(void) case BCM47XX_BOARD_NETGEAR_WNDR3700V3: return &platforms[WNDR3700V3]; case BCM47XX_BOARD_UNKNOWN: - case BCM47XX_BOARD_NON: + case BCM47XX_BOARD_NO: printk(MODULE_NAME ": unknown board found, try legacy detect\n"); printk(MODULE_NAME ": please open a ticket at https://dev.openwrt.org and attach the complete nvram\n"); return platform_detect_legacy(); diff --git a/target/linux/brcm47xx/patches-3.10/260-MIPS-BCM47XX-add-board-detection.patch b/target/linux/brcm47xx/patches-3.10/260-MIPS-BCM47XX-add-board-detection.patch index 3929cae513..f7ec1642f9 100644 --- a/target/linux/brcm47xx/patches-3.10/260-MIPS-BCM47XX-add-board-detection.patch +++ b/target/linux/brcm47xx/patches-3.10/260-MIPS-BCM47XX-add-board-detection.patch @@ -8,7 +8,7 @@ obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o --- /dev/null +++ b/arch/mips/bcm47xx/board.c -@@ -0,0 +1,289 @@ +@@ -0,0 +1,296 @@ +#include +#include +#include @@ -37,8 +37,6 @@ + const char *value3; +}; + -+static const struct bcm47xx_board_type *bcm47xx_board = NULL; -+ +/* model_name */ +static const struct bcm47xx_board_type_list1 bcm47xx_board_list_model_name[] = { + {{BCM47XX_BOARD_DLINK_DIR130, "D-Link DIR-130"}, "DIR-130"}, @@ -118,15 +116,19 @@ + +/* boot_hw_model, boot_hw_ver */ +static const struct bcm47xx_board_type_list2 bcm47xx_board_list_boot_hw[] = { -+ {{BCM47XX_BOARD_CISCO_M10V1, "Cisco M10"}, "M10", "1.0"}, /* like WRT160N v3.0 */ -+ {{BCM47XX_BOARD_CISCO_M20V1, "Cisco M20"}, "M20", "1.0"}, /* like WRT310N v2.0 */ ++ /* like WRT160N v3.0 */ ++ {{BCM47XX_BOARD_CISCO_M10V1, "Cisco M10"}, "M10", "1.0"}, ++ /* like WRT310N v2.0 */ ++ {{BCM47XX_BOARD_CISCO_M20V1, "Cisco M20"}, "M20", "1.0"}, + {{BCM47XX_BOARD_LINKSYS_E900V1, "Linksys E900 V1"}, "E900", "1.0"}, -+ {{BCM47XX_BOARD_LINKSYS_E1000V1, "Linksys E1000 V1"}, "E100", "1.0"}, /* like WRT160N v3.0 */ ++ /* like WRT160N v3.0 */ ++ {{BCM47XX_BOARD_LINKSYS_E1000V1, "Linksys E1000 V1"}, "E100", "1.0"}, + {{BCM47XX_BOARD_LINKSYS_E1000V2, "Linksys E1000 V2"}, "E1000", "2.0"}, + {{BCM47XX_BOARD_LINKSYS_E1000V21, "Linksys E1000 V2.1"}, "E1000", "2.1"}, + {{BCM47XX_BOARD_LINKSYS_E1200V2, "Linksys E1200 V2"}, "E1200", "2.0"}, + {{BCM47XX_BOARD_LINKSYS_E2000V1, "Linksys E2000 V1"}, "Linksys E2000", "1.0"}, -+ {{BCM47XX_BOARD_LINKSYS_E3000V1, "Linksys E3000 V1"}, "E300", "1.0"}, /* like WRT610N v2.0 */ ++ /* like WRT610N v2.0 */ ++ {{BCM47XX_BOARD_LINKSYS_E3000V1, "Linksys E3000 V1"}, "E300", "1.0"}, + {{BCM47XX_BOARD_LINKSYS_E3200V1, "Linksys E3200 V1"}, "E3200", "1.0"}, + {{BCM47XX_BOARD_LINKSYS_E4200V1, "Linksys E4200 V1"}, "E4200", "1.0"}, + {{BCM47XX_BOARD_LINKSYS_WRT150NV11, "Linksys WRT150N V1.1"}, "WRT150N", "1.1"}, @@ -165,9 +167,9 @@ + +/* boardtype, boardnum, boardrev */ +static const struct bcm47xx_board_type_list3 bcm47xx_board_list_board[] = { -+ {{BCM47XX_BOARD_ZTE_H218N, "ZTE H218N"}, "0x053d", "1234", "0x1305"}, + {{BCM47XX_BOARD_HUAWEI_E970, "Huawei E970"}, "0x048e", "0x5347", "0x11"}, + {{BCM47XX_BOARD_PHICOMM_M1, "Phicomm M1"}, "0x0590", "80", "0x1104"}, ++ {{BCM47XX_BOARD_ZTE_H218N, "ZTE H218N"}, "0x053d", "1234", "0x1305"}, + { {0}, 0}, +}; + @@ -175,10 +177,11 @@ + {BCM47XX_BOARD_UNKNOWN, "Unknown Board"}, +}; + -+static inline int startswith(char *source, char *cmp) -+{ -+ return !strncmp(source, cmp, strlen(cmp)); -+} ++static const struct bcm47xx_board_type bcm47xx_board_no[] = { ++ {BCM47XX_BOARD_NO, "No Board"}, ++}; ++ ++static const struct bcm47xx_board_type *bcm47xx_board = bcm47xx_board_no; + +static const struct bcm47xx_board_type *bcm47xx_board_get_nvram(void) +{ @@ -271,18 +274,22 @@ + +static void bcm47xx_board_detect(void) +{ -+ char buf[15]; ++ int err; ++ char buf[10]; + -+ if (bcm47xx_board != NULL) ++ if (bcm47xx_board != bcm47xx_board_no) + return; ++ + /* check if the nvram is available */ -+ if (bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf)) == -ENXIO) { -+ bcm47xx_board = bcm47xx_board_unknown; ++ err = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf)); ++ ++ /* init of nvram failed, probably too early now */ ++ if (err == -ENXIO) { + return; + } + + bcm47xx_board = bcm47xx_board_get_nvram(); -+ pr_info("Found board: \"%s\"\n", bcm47xx_board->name); ++ pr_debug("Found board: \"%s\"\n", bcm47xx_board->name); +} + +enum bcm47xx_board bcm47xx_board_get(void) @@ -300,7 +307,7 @@ +EXPORT_SYMBOL(bcm47xx_board_get_name); --- /dev/null +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h -@@ -0,0 +1,108 @@ +@@ -0,0 +1,107 @@ +#ifndef __BCM47XX_BOARD_H +#define __BCM47XX_BOARD_H + @@ -396,16 +403,15 @@ + + BCM47XX_BOARD_PHICOMM_M1, + -+ /* TODO */ + BCM47XX_BOARD_SIMPLETECH_SIMPLESHARE, + + BCM47XX_BOARD_ZTE_H218N, + + BCM47XX_BOARD_UNKNOWN, -+ BCM47XX_BOARD_NON, ++ BCM47XX_BOARD_NO, +}; + -+extern enum bcm47xx_board bcm47xx_board_get(void); -+extern const char *bcm47xx_board_get_name(void); ++enum bcm47xx_board bcm47xx_board_get(void); ++const char *bcm47xx_board_get_name(void); + +#endif /* __BCM47XX_BOARD_H */ diff --git a/target/linux/brcm47xx/patches-3.10/261-MIPS-BCM47XX-print-board-name-in-proc-cpuinfo.patch b/target/linux/brcm47xx/patches-3.10/261-MIPS-BCM47XX-print-board-name-in-proc-cpuinfo.patch index abfa4004f2..63874552d6 100644 --- a/target/linux/brcm47xx/patches-3.10/261-MIPS-BCM47XX-print-board-name-in-proc-cpuinfo.patch +++ b/target/linux/brcm47xx/patches-3.10/261-MIPS-BCM47XX-print-board-name-in-proc-cpuinfo.patch @@ -25,7 +25,7 @@ const char *get_system_type(void) { - return "Broadcom BCM47XX"; -+ static char buf[128]; ++ static char buf[50]; + u16 chip_id = get_chip_id(); + + snprintf(buf, sizeof(buf), diff --git a/target/linux/brcm47xx/patches-3.10/262-MIPS-BCM47XX-use-init-const-in-board-detect.patch b/target/linux/brcm47xx/patches-3.10/262-MIPS-BCM47XX-use-init-const-in-board-detect.patch new file mode 100644 index 0000000000..f7b46288b3 --- /dev/null +++ b/target/linux/brcm47xx/patches-3.10/262-MIPS-BCM47XX-use-init-const-in-board-detect.patch @@ -0,0 +1,189 @@ +--- a/arch/mips/bcm47xx/board.c ++++ b/arch/mips/bcm47xx/board.c +@@ -26,27 +26,36 @@ struct bcm47xx_board_type_list3 { + const char *value3; + }; + ++struct bcm47xx_board_store { ++ enum bcm47xx_board board; ++ char name[BCM47XX_BOARD_MAX_NAME]; ++}; ++ + /* model_name */ +-static const struct bcm47xx_board_type_list1 bcm47xx_board_list_model_name[] = { ++static const ++struct bcm47xx_board_type_list1 bcm47xx_board_list_model_name[] __initconst = { + {{BCM47XX_BOARD_DLINK_DIR130, "D-Link DIR-130"}, "DIR-130"}, + {{BCM47XX_BOARD_DLINK_DIR330, "D-Link DIR-330"}, "DIR-330"}, + { {0}, 0}, + }; + + /* model_no */ +-static const struct bcm47xx_board_type_list1 bcm47xx_board_list_model_no[] = { ++static const ++struct bcm47xx_board_type_list1 bcm47xx_board_list_model_no[] __initconst = { + {{BCM47XX_BOARD_ASUS_WL700GE, "Asus WL700"}, "WL700"}, + { {0}, 0}, + }; + + /* machine_name */ +-static const struct bcm47xx_board_type_list1 bcm47xx_board_list_machine_name[] = { ++static const ++struct bcm47xx_board_type_list1 bcm47xx_board_list_machine_name[] __initconst = { + {{BCM47XX_BOARD_LINKSYS_WRTSL54GS, "Linksys WRTSL54GS"}, "WRTSL54GS"}, + { {0}, 0}, + }; + + /* hardware_version */ +-static const struct bcm47xx_board_type_list1 bcm47xx_board_list_hardware_version[] = { ++static const ++struct bcm47xx_board_type_list1 bcm47xx_board_list_hardware_version[] __initconst = { + {{BCM47XX_BOARD_ASUS_RTN16, "Asus RT-N16"}, "RT-N16-"}, + {{BCM47XX_BOARD_ASUS_WL320GE, "Asus WL320GE"}, "WL320G-"}, + {{BCM47XX_BOARD_ASUS_WL330GE, "Asus WL330GE"}, "WL330GE-"}, +@@ -61,7 +70,8 @@ static const struct bcm47xx_board_type_l + }; + + /* productid */ +-static const struct bcm47xx_board_type_list1 bcm47xx_board_list_productid[] = { ++static const ++struct bcm47xx_board_type_list1 bcm47xx_board_list_productid[] __initconst = { + {{BCM47XX_BOARD_ASUS_RTAC66U, "Asus RT-AC66U"}, "RT-AC66U"}, + {{BCM47XX_BOARD_ASUS_RTN10, "Asus RT-N10"}, "RT-N10"}, + {{BCM47XX_BOARD_ASUS_RTN10D, "Asus RT-N10D"}, "RT-N10D"}, +@@ -81,7 +91,8 @@ static const struct bcm47xx_board_type_l + }; + + /* ModelId */ +-static const struct bcm47xx_board_type_list1 bcm47xx_board_list_ModelId[] = { ++static const ++struct bcm47xx_board_type_list1 bcm47xx_board_list_ModelId[] __initconst = { + {{BCM47XX_BOARD_DELL_TM2300, "Dell WX-5565"}, "WX-5565"}, + {{BCM47XX_BOARD_MOTOROLA_WE800G, "Motorola WE800G"}, "WE800G"}, + {{BCM47XX_BOARD_MOTOROLA_WR850GP, "Motorola WR850GP"}, "WR850GP"}, +@@ -90,7 +101,8 @@ static const struct bcm47xx_board_type_l + }; + + /* melco_id or buf1falo_id */ +-static const struct bcm47xx_board_type_list1 bcm47xx_board_list_melco_id[] = { ++static const ++struct bcm47xx_board_type_list1 bcm47xx_board_list_melco_id[] __initconst = { + {{BCM47XX_BOARD_BUFFALO_WBR2_G54, "Buffalo WBR2-G54"}, "29bb0332"}, + {{BCM47XX_BOARD_BUFFALO_WHR2_A54G54, "Buffalo WHR2-A54G54"}, "290441dd"}, + {{BCM47XX_BOARD_BUFFALO_WHR_G125, "Buffalo WHR-G125"}, "32093"}, +@@ -104,7 +116,8 @@ static const struct bcm47xx_board_type_l + }; + + /* boot_hw_model, boot_hw_ver */ +-static const struct bcm47xx_board_type_list2 bcm47xx_board_list_boot_hw[] = { ++static const ++struct bcm47xx_board_type_list2 bcm47xx_board_list_boot_hw[] __initconst = { + /* like WRT160N v3.0 */ + {{BCM47XX_BOARD_CISCO_M10V1, "Cisco M10"}, "M10", "1.0"}, + /* like WRT310N v2.0 */ +@@ -134,7 +147,8 @@ static const struct bcm47xx_board_type_l + }; + + /* board_id */ +-static const struct bcm47xx_board_type_list1 bcm47xx_board_list_board_id[] = { ++static const ++struct bcm47xx_board_type_list1 bcm47xx_board_list_board_id[] __initconst = { + {{BCM47XX_BOARD_NETGEAR_WGR614V8, "Netgear WGR614 V8"}, "U12H072T00_NETGEAR"}, + {{BCM47XX_BOARD_NETGEAR_WGR614V9, "Netgear WGR614 V9"}, "U12H094T00_NETGEAR"}, + {{BCM47XX_BOARD_NETGEAR_WNDR3300, "Netgear WNDR3300"}, "U12H093T00_NETGEAR"}, +@@ -155,24 +169,22 @@ static const struct bcm47xx_board_type_l + }; + + /* boardtype, boardnum, boardrev */ +-static const struct bcm47xx_board_type_list3 bcm47xx_board_list_board[] = { ++static const ++struct bcm47xx_board_type_list3 bcm47xx_board_list_board[] __initconst = { + {{BCM47XX_BOARD_HUAWEI_E970, "Huawei E970"}, "0x048e", "0x5347", "0x11"}, + {{BCM47XX_BOARD_PHICOMM_M1, "Phicomm M1"}, "0x0590", "80", "0x1104"}, + {{BCM47XX_BOARD_ZTE_H218N, "ZTE H218N"}, "0x053d", "1234", "0x1305"}, + { {0}, 0}, + }; + +-static const struct bcm47xx_board_type bcm47xx_board_unknown[] = { ++static const ++struct bcm47xx_board_type bcm47xx_board_unknown[] __initconst = { + {BCM47XX_BOARD_UNKNOWN, "Unknown Board"}, + }; + +-static const struct bcm47xx_board_type bcm47xx_board_no[] = { +- {BCM47XX_BOARD_NO, "No Board"}, +-}; +- +-static const struct bcm47xx_board_type *bcm47xx_board = bcm47xx_board_no; ++static struct bcm47xx_board_store bcm47xx_board = {BCM47XX_BOARD_NO, "Unknown Board"}; + +-static const struct bcm47xx_board_type *bcm47xx_board_get_nvram(void) ++static __init const struct bcm47xx_board_type *bcm47xx_board_get_nvram(void) + { + char buf1[30]; + char buf2[30]; +@@ -261,12 +273,13 @@ static const struct bcm47xx_board_type * + return bcm47xx_board_unknown; + } + +-static void bcm47xx_board_detect(void) ++void __init bcm47xx_board_detect(void) + { + int err; + char buf[10]; ++ const struct bcm47xx_board_type *board_detected; + +- if (bcm47xx_board != bcm47xx_board_no) ++ if (bcm47xx_board.board != BCM47XX_BOARD_NO) + return; + + /* check if the nvram is available */ +@@ -277,20 +290,20 @@ static void bcm47xx_board_detect(void) + return; + } + +- bcm47xx_board = bcm47xx_board_get_nvram(); +- pr_debug("Found board: \"%s\"\n", bcm47xx_board->name); ++ board_detected = bcm47xx_board_get_nvram(); ++ bcm47xx_board.board = board_detected->board; ++ strncpy(bcm47xx_board.name, board_detected->name, BCM47XX_BOARD_MAX_NAME); ++ bcm47xx_board.name[BCM47XX_BOARD_MAX_NAME - 1] = 0; + } + + enum bcm47xx_board bcm47xx_board_get(void) + { +- bcm47xx_board_detect(); +- return bcm47xx_board->board; ++ return bcm47xx_board.board; + } + EXPORT_SYMBOL(bcm47xx_board_get); + + const char *bcm47xx_board_get_name(void) + { +- bcm47xx_board_detect(); +- return bcm47xx_board->name; ++ return bcm47xx_board.name; + } + EXPORT_SYMBOL(bcm47xx_board_get_name); +--- a/arch/mips/bcm47xx/setup.c ++++ b/arch/mips/bcm47xx/setup.c +@@ -252,6 +252,7 @@ void __init plat_mem_setup(void) + _machine_restart = bcm47xx_machine_restart; + _machine_halt = bcm47xx_machine_halt; + pm_power_off = bcm47xx_machine_halt; ++ bcm47xx_board_detect(); + } + + static int __init bcm47xx_register_bus_complete(void) +--- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h ++++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h +@@ -101,6 +101,9 @@ enum bcm47xx_board { + BCM47XX_BOARD_NO, + }; + ++#define BCM47XX_BOARD_MAX_NAME 30 ++ ++void bcm47xx_board_detect(void); + enum bcm47xx_board bcm47xx_board_get(void); + const char *bcm47xx_board_get_name(void); + diff --git a/target/linux/brcm47xx/patches-3.10/830-huawei_e970_support.patch b/target/linux/brcm47xx/patches-3.10/830-huawei_e970_support.patch index 12539fd9be..19adf6ff10 100644 --- a/target/linux/brcm47xx/patches-3.10/830-huawei_e970_support.patch +++ b/target/linux/brcm47xx/patches-3.10/830-huawei_e970_support.patch @@ -14,8 +14,8 @@ union bcm47xx_bus bcm47xx_bus; EXPORT_SYMBOL(bcm47xx_bus); -@@ -254,6 +256,33 @@ void __init plat_mem_setup(void) - pm_power_off = bcm47xx_machine_halt; +@@ -255,6 +257,33 @@ void __init plat_mem_setup(void) + bcm47xx_board_detect(); } +static struct gpio_wdt_platform_data gpio_wdt_data; @@ -48,7 +48,7 @@ static int __init bcm47xx_register_bus_complete(void) { switch (bcm47xx_bus_type) { -@@ -268,6 +297,8 @@ static int __init bcm47xx_register_bus_c +@@ -269,6 +298,8 @@ static int __init bcm47xx_register_bus_c break; #endif }