18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include <linux/errno.h> 38c2ecf20Sopenharmony_ci#include <linux/export.h> 48c2ecf20Sopenharmony_ci#include <linux/string.h> 58c2ecf20Sopenharmony_ci#include <bcm47xx.h> 68c2ecf20Sopenharmony_ci#include <bcm47xx_board.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_cistruct bcm47xx_board_type { 98c2ecf20Sopenharmony_ci const enum bcm47xx_board board; 108c2ecf20Sopenharmony_ci const char *name; 118c2ecf20Sopenharmony_ci}; 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list1 { 148c2ecf20Sopenharmony_ci struct bcm47xx_board_type board; 158c2ecf20Sopenharmony_ci const char *value1; 168c2ecf20Sopenharmony_ci}; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list2 { 198c2ecf20Sopenharmony_ci struct bcm47xx_board_type board; 208c2ecf20Sopenharmony_ci const char *value1; 218c2ecf20Sopenharmony_ci const char *value2; 228c2ecf20Sopenharmony_ci}; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list3 { 258c2ecf20Sopenharmony_ci struct bcm47xx_board_type board; 268c2ecf20Sopenharmony_ci const char *value1; 278c2ecf20Sopenharmony_ci const char *value2; 288c2ecf20Sopenharmony_ci const char *value3; 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistruct bcm47xx_board_store { 328c2ecf20Sopenharmony_ci enum bcm47xx_board board; 338c2ecf20Sopenharmony_ci char name[BCM47XX_BOARD_MAX_NAME]; 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* model_name */ 378c2ecf20Sopenharmony_cistatic const 388c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list1 bcm47xx_board_list_model_name[] __initconst = { 398c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_DLINK_DIR130, "D-Link DIR-130"}, "DIR-130"}, 408c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_DLINK_DIR330, "D-Link DIR-330"}, "DIR-330"}, 418c2ecf20Sopenharmony_ci { {0}, NULL}, 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* hardware_version */ 458c2ecf20Sopenharmony_cistatic const 468c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list1 bcm47xx_board_list_hardware_version[] __initconst = { 478c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN10U, "Asus RT-N10U"}, "RTN10U"}, 488c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN10D, "Asus RT-N10D"}, "RTN10D"}, 498c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN12, "Asus RT-N12"}, "RT-N12"}, 508c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN12B1, "Asus RT-N12B1"}, "RTN12B1"}, 518c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN12C1, "Asus RT-N12C1"}, "RTN12C1"}, 528c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN12D1, "Asus RT-N12D1"}, "RTN12D1"}, 538c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN12HP, "Asus RT-N12HP"}, "RTN12HP"}, 548c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN16, "Asus RT-N16"}, "RT-N16-"}, 558c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL320GE, "Asus WL320GE"}, "WL320G-"}, 568c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL330GE, "Asus WL330GE"}, "WL330GE-"}, 578c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL500GD, "Asus WL500GD"}, "WL500gd-"}, 588c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL500GPV1, "Asus WL500GP V1"}, "WL500gp-"}, 598c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL500GPV2, "Asus WL500GP V2"}, "WL500GPV2-"}, 608c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL500W, "Asus WL500W"}, "WL500gW-"}, 618c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL520GC, "Asus WL520GC"}, "WL520GC-"}, 628c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL520GU, "Asus WL520GU"}, "WL520GU-"}, 638c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BELKIN_F7D3301, "Belkin F7D3301"}, "F7D3301"}, 648c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BELKIN_F7D3302, "Belkin F7D3302"}, "F7D3302"}, 658c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BELKIN_F7D4301, "Belkin F7D4301"}, "F7D4301"}, 668c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BELKIN_F7D4302, "Belkin F7D4302"}, "F7D4302"}, 678c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BELKIN_F7D4401, "Belkin F7D4401"}, "F7D4401"}, 688c2ecf20Sopenharmony_ci { {0}, NULL}, 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* hardware_version, boardnum */ 728c2ecf20Sopenharmony_cistatic const 738c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list2 bcm47xx_board_list_hw_version_num[] __initconst = { 748c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_MICROSOFT_MN700, "Microsoft MN-700"}, "WL500-", "mn700"}, 758c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL500G, "Asus WL500G"}, "WL500-", "asusX"}, 768c2ecf20Sopenharmony_ci { {0}, NULL}, 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* productid */ 808c2ecf20Sopenharmony_cistatic const 818c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list1 bcm47xx_board_list_productid[] __initconst = { 828c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTAC66U, "Asus RT-AC66U"}, "RT-AC66U"}, 838c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN10, "Asus RT-N10"}, "RT-N10"}, 848c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN10D, "Asus RT-N10D"}, "RT-N10D"}, 858c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN15U, "Asus RT-N15U"}, "RT-N15U"}, 868c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN16, "Asus RT-N16"}, "RT-N16"}, 878c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN53, "Asus RT-N53"}, "RT-N53"}, 888c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_RTN66U, "Asus RT-N66U"}, "RT-N66U"}, 898c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL300G, "Asus WL300G"}, "WL300g"}, 908c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WLHDD, "Asus WLHDD"}, "WLHDD"}, 918c2ecf20Sopenharmony_ci { {0}, NULL}, 928c2ecf20Sopenharmony_ci}; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* ModelId */ 958c2ecf20Sopenharmony_cistatic const 968c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list1 bcm47xx_board_list_ModelId[] __initconst = { 978c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_DELL_TM2300, "Dell TrueMobile 2300"}, "WX-5565"}, 988c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_MOTOROLA_WE800G, "Motorola WE800G"}, "WE800G"}, 998c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_MOTOROLA_WR850GP, "Motorola WR850GP"}, "WR850GP"}, 1008c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_MOTOROLA_WR850GV2V3, "Motorola WR850G"}, "WR850G"}, 1018c2ecf20Sopenharmony_ci { {0}, NULL}, 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* melco_id or buf1falo_id */ 1058c2ecf20Sopenharmony_cistatic const 1068c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list1 bcm47xx_board_list_melco_id[] __initconst = { 1078c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BUFFALO_WBR2_G54, "Buffalo WBR2-G54"}, "29bb0332"}, 1088c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BUFFALO_WHR2_A54G54, "Buffalo WHR2-A54G54"}, "290441dd"}, 1098c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BUFFALO_WHR_G125, "Buffalo WHR-G125"}, "32093"}, 1108c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BUFFALO_WHR_G54S, "Buffalo WHR-G54S"}, "30182"}, 1118c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BUFFALO_WHR_HP_G54, "Buffalo WHR-HP-G54"}, "30189"}, 1128c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BUFFALO_WLA2_G54L, "Buffalo WLA2-G54L"}, "29129"}, 1138c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BUFFALO_WZR_G300N, "Buffalo WZR-G300N"}, "31120"}, 1148c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BUFFALO_WZR_RS_G54, "Buffalo WZR-RS-G54"}, "30083"}, 1158c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_BUFFALO_WZR_RS_G54HP, "Buffalo WZR-RS-G54HP"}, "30103"}, 1168c2ecf20Sopenharmony_ci { {0}, NULL}, 1178c2ecf20Sopenharmony_ci}; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci/* boot_hw_model, boot_hw_ver */ 1208c2ecf20Sopenharmony_cistatic const 1218c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list2 bcm47xx_board_list_boot_hw[] __initconst = { 1228c2ecf20Sopenharmony_ci /* like WRT160N v3.0 */ 1238c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_CISCO_M10V1, "Cisco M10"}, "M10", "1.0"}, 1248c2ecf20Sopenharmony_ci /* like WRT310N v2.0 */ 1258c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_CISCO_M20V1, "Cisco M20"}, "M20", "1.0"}, 1268c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_E900V1, "Linksys E900 V1"}, "E900", "1.0"}, 1278c2ecf20Sopenharmony_ci /* like WRT160N v3.0 */ 1288c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_E1000V1, "Linksys E1000 V1"}, "E100", "1.0"}, 1298c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_E1000V2, "Linksys E1000 V2"}, "E1000", "2.0"}, 1308c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_E1000V21, "Linksys E1000 V2.1"}, "E1000", "2.1"}, 1318c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_E1200V2, "Linksys E1200 V2"}, "E1200", "2.0"}, 1328c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_E2000V1, "Linksys E2000 V1"}, "Linksys E2000", "1.0"}, 1338c2ecf20Sopenharmony_ci /* like WRT610N v2.0 */ 1348c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_E3000V1, "Linksys E3000 V1"}, "E300", "1.0"}, 1358c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_E3200V1, "Linksys E3200 V1"}, "E3200", "1.0"}, 1368c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_E4200V1, "Linksys E4200 V1"}, "E4200", "1.0"}, 1378c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT150NV11, "Linksys WRT150N V1.1"}, "WRT150N", "1.1"}, 1388c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT150NV1, "Linksys WRT150N V1"}, "WRT150N", "1"}, 1398c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT160NV1, "Linksys WRT160N V1"}, "WRT160N", "1.0"}, 1408c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT160NV3, "Linksys WRT160N V3"}, "WRT160N", "3.0"}, 1418c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT300NV11, "Linksys WRT300N V1.1"}, "WRT300N", "1.1"}, 1428c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT310NV1, "Linksys WRT310N V1"}, "WRT310N", "1.0"}, 1438c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT310NV2, "Linksys WRT310N V2"}, "WRT310N", "2.0"}, 1448c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT54G3GV2, "Linksys WRT54G3GV2-VF"}, "WRT54G3GV2-VF", "1.0"}, 1458c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT610NV1, "Linksys WRT610N V1"}, "WRT610N", "1.0"}, 1468c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT610NV2, "Linksys WRT610N V2"}, "WRT610N", "2.0"}, 1478c2ecf20Sopenharmony_ci { {0}, NULL}, 1488c2ecf20Sopenharmony_ci}; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci/* board_id */ 1518c2ecf20Sopenharmony_cistatic const 1528c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list1 bcm47xx_board_list_board_id[] __initconst = { 1538c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_ABR_4400_V1, "Luxul ABR-4400 V1"}, "luxul_abr4400_v1"}, 1548c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_XAP_310_V1, "Luxul XAP-310 V1"}, "luxul_xap310_v1"}, 1558c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_XAP_1210_V1, "Luxul XAP-1210 V1"}, "luxul_xap1210_v1"}, 1568c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_XAP_1230_V1, "Luxul XAP-1230 V1"}, "luxul_xap1230_v1"}, 1578c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_XAP_1240_V1, "Luxul XAP-1240 V1"}, "luxul_xap1240_v1"}, 1588c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_XAP_1500_V1, "Luxul XAP-1500 V1"}, "luxul_xap1500_v1"}, 1598c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_XBR_4400_V1, "Luxul XBR-4400 V1"}, "luxul_xbr4400_v1"}, 1608c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_XVW_P30_V1, "Luxul XVW-P30 V1"}, "luxul_xvwp30_v1"}, 1618c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_XWR_600_V1, "Luxul XWR-600 V1"}, "luxul_xwr600_v1"}, 1628c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LUXUL_XWR_1750_V1, "Luxul XWR-1750 V1"}, "luxul_xwr1750_v1"}, 1638c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_R6200_V1, "Netgear R6200 V1"}, "U12H192T00_NETGEAR"}, 1648c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WGR614V8, "Netgear WGR614 V8"}, "U12H072T00_NETGEAR"}, 1658c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WGR614V9, "Netgear WGR614 V9"}, "U12H094T00_NETGEAR"}, 1668c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WGR614_V10, "Netgear WGR614 V10"}, "U12H139T01_NETGEAR"}, 1678c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNDR3300, "Netgear WNDR3300"}, "U12H093T00_NETGEAR"}, 1688c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNDR3400V1, "Netgear WNDR3400 V1"}, "U12H155T00_NETGEAR"}, 1698c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNDR3400V2, "Netgear WNDR3400 V2"}, "U12H187T00_NETGEAR"}, 1708c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNDR3400_V3, "Netgear WNDR3400 V3"}, "U12H208T00_NETGEAR"}, 1718c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNDR3400VCNA, "Netgear WNDR3400 Vcna"}, "U12H155T01_NETGEAR"}, 1728c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNDR3700V3, "Netgear WNDR3700 V3"}, "U12H194T00_NETGEAR"}, 1738c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNDR4000, "Netgear WNDR4000"}, "U12H181T00_NETGEAR"}, 1748c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNDR4500V1, "Netgear WNDR4500 V1"}, "U12H189T00_NETGEAR"}, 1758c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNDR4500V2, "Netgear WNDR4500 V2"}, "U12H224T00_NETGEAR"}, 1768c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNR1000_V3, "Netgear WNR1000 V3"}, "U12H139T00_NETGEAR"}, 1778c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNR1000_V3, "Netgear WNR1000 V3"}, "U12H139T50_NETGEAR"}, 1788c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNR2000, "Netgear WNR2000"}, "U12H114T00_NETGEAR"}, 1798c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNR3500L, "Netgear WNR3500L"}, "U12H136T99_NETGEAR"}, 1808c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNR3500U, "Netgear WNR3500U"}, "U12H136T00_NETGEAR"}, 1818c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNR3500V2, "Netgear WNR3500 V2"}, "U12H127T00_NETGEAR"}, 1828c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNR3500V2VC, "Netgear WNR3500 V2vc"}, "U12H127T70_NETGEAR"}, 1838c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNR834BV2, "Netgear WNR834B V2"}, "U12H081T00_NETGEAR"}, 1848c2ecf20Sopenharmony_ci { {0}, NULL}, 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci/* boardtype, boardnum, boardrev */ 1888c2ecf20Sopenharmony_cistatic const 1898c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list3 bcm47xx_board_list_board[] __initconst = { 1908c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_HUAWEI_E970, "Huawei E970"}, "0x048e", "0x5347", "0x11"}, 1918c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_PHICOMM_M1, "Phicomm M1"}, "0x0590", "80", "0x1104"}, 1928c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ZTE_H218N, "ZTE H218N"}, "0x053d", "1234", "0x1305"}, 1938c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_NETGEAR_WNR3500L, "Netgear WNR3500L"}, "0x04CF", "3500", "02"}, 1948c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0101, "Linksys WRT54G/GS/GL"}, "0x0101", "42", "0x10"}, 1958c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0467, "Linksys WRT54G/GS/GL"}, "0x0467", "42", "0x10"}, 1968c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0708, "Linksys WRT54G/GS/GL"}, "0x0708", "42", "0x10"}, 1978c2ecf20Sopenharmony_ci { {0}, NULL}, 1988c2ecf20Sopenharmony_ci}; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci/* boardtype, boardrev */ 2018c2ecf20Sopenharmony_cistatic const 2028c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list2 bcm47xx_board_list_board_type_rev[] __initconst = { 2038c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_SIEMENS_SE505V2, "Siemens SE505 V2"}, "0x0101", "0x10"}, 2048c2ecf20Sopenharmony_ci { {0}, NULL}, 2058c2ecf20Sopenharmony_ci}; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci/* 2088c2ecf20Sopenharmony_ci * Some devices don't use any common NVRAM entry for identification and they 2098c2ecf20Sopenharmony_ci * have only one model specific variable. 2108c2ecf20Sopenharmony_ci * They don't deserve own arrays, let's group them there using key-value array. 2118c2ecf20Sopenharmony_ci */ 2128c2ecf20Sopenharmony_cistatic const 2138c2ecf20Sopenharmony_cistruct bcm47xx_board_type_list2 bcm47xx_board_list_key_value[] __initconst = { 2148c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_ASUS_WL700GE, "Asus WL700"}, "model_no", "WL700"}, 2158c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT300N_V1, "Linksys WRT300N V1"}, "router_name", "WRT300N"}, 2168c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRT600N_V11, "Linksys WRT600N V1.1"}, "Model_Name", "WRT600N"}, 2178c2ecf20Sopenharmony_ci {{BCM47XX_BOARD_LINKSYS_WRTSL54GS, "Linksys WRTSL54GS"}, "machine_name", "WRTSL54GS"}, 2188c2ecf20Sopenharmony_ci { {0}, NULL}, 2198c2ecf20Sopenharmony_ci}; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_cistatic const 2228c2ecf20Sopenharmony_cistruct bcm47xx_board_type bcm47xx_board_unknown[] __initconst = { 2238c2ecf20Sopenharmony_ci {BCM47XX_BOARD_UNKNOWN, "Unknown Board"}, 2248c2ecf20Sopenharmony_ci}; 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_cistatic struct bcm47xx_board_store bcm47xx_board = {BCM47XX_BOARD_NO, "Unknown Board"}; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_cistatic __init const struct bcm47xx_board_type *bcm47xx_board_get_nvram(void) 2298c2ecf20Sopenharmony_ci{ 2308c2ecf20Sopenharmony_ci char buf1[30]; 2318c2ecf20Sopenharmony_ci char buf2[30]; 2328c2ecf20Sopenharmony_ci char buf3[30]; 2338c2ecf20Sopenharmony_ci const struct bcm47xx_board_type_list1 *e1; 2348c2ecf20Sopenharmony_ci const struct bcm47xx_board_type_list2 *e2; 2358c2ecf20Sopenharmony_ci const struct bcm47xx_board_type_list3 *e3; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("model_name", buf1, sizeof(buf1)) >= 0) { 2388c2ecf20Sopenharmony_ci for (e1 = bcm47xx_board_list_model_name; e1->value1; e1++) { 2398c2ecf20Sopenharmony_ci if (!strcmp(buf1, e1->value1)) 2408c2ecf20Sopenharmony_ci return &e1->board; 2418c2ecf20Sopenharmony_ci } 2428c2ecf20Sopenharmony_ci } 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("hardware_version", buf1, sizeof(buf1)) >= 0) { 2458c2ecf20Sopenharmony_ci for (e1 = bcm47xx_board_list_hardware_version; e1->value1; e1++) { 2468c2ecf20Sopenharmony_ci if (strstarts(buf1, e1->value1)) 2478c2ecf20Sopenharmony_ci return &e1->board; 2488c2ecf20Sopenharmony_ci } 2498c2ecf20Sopenharmony_ci } 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("hardware_version", buf1, sizeof(buf1)) >= 0 && 2528c2ecf20Sopenharmony_ci bcm47xx_nvram_getenv("boardnum", buf2, sizeof(buf2)) >= 0) { 2538c2ecf20Sopenharmony_ci for (e2 = bcm47xx_board_list_hw_version_num; e2->value1; e2++) { 2548c2ecf20Sopenharmony_ci if (!strstarts(buf1, e2->value1) && 2558c2ecf20Sopenharmony_ci !strcmp(buf2, e2->value2)) 2568c2ecf20Sopenharmony_ci return &e2->board; 2578c2ecf20Sopenharmony_ci } 2588c2ecf20Sopenharmony_ci } 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("productid", buf1, sizeof(buf1)) >= 0) { 2618c2ecf20Sopenharmony_ci for (e1 = bcm47xx_board_list_productid; e1->value1; e1++) { 2628c2ecf20Sopenharmony_ci if (!strcmp(buf1, e1->value1)) 2638c2ecf20Sopenharmony_ci return &e1->board; 2648c2ecf20Sopenharmony_ci } 2658c2ecf20Sopenharmony_ci } 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("ModelId", buf1, sizeof(buf1)) >= 0) { 2688c2ecf20Sopenharmony_ci for (e1 = bcm47xx_board_list_ModelId; e1->value1; e1++) { 2698c2ecf20Sopenharmony_ci if (!strcmp(buf1, e1->value1)) 2708c2ecf20Sopenharmony_ci return &e1->board; 2718c2ecf20Sopenharmony_ci } 2728c2ecf20Sopenharmony_ci } 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("melco_id", buf1, sizeof(buf1)) >= 0 || 2758c2ecf20Sopenharmony_ci bcm47xx_nvram_getenv("buf1falo_id", buf1, sizeof(buf1)) >= 0) { 2768c2ecf20Sopenharmony_ci /* buffalo hardware, check id for specific hardware matches */ 2778c2ecf20Sopenharmony_ci for (e1 = bcm47xx_board_list_melco_id; e1->value1; e1++) { 2788c2ecf20Sopenharmony_ci if (!strcmp(buf1, e1->value1)) 2798c2ecf20Sopenharmony_ci return &e1->board; 2808c2ecf20Sopenharmony_ci } 2818c2ecf20Sopenharmony_ci } 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("boot_hw_model", buf1, sizeof(buf1)) >= 0 && 2848c2ecf20Sopenharmony_ci bcm47xx_nvram_getenv("boot_hw_ver", buf2, sizeof(buf2)) >= 0) { 2858c2ecf20Sopenharmony_ci for (e2 = bcm47xx_board_list_boot_hw; e2->value1; e2++) { 2868c2ecf20Sopenharmony_ci if (!strcmp(buf1, e2->value1) && 2878c2ecf20Sopenharmony_ci !strcmp(buf2, e2->value2)) 2888c2ecf20Sopenharmony_ci return &e2->board; 2898c2ecf20Sopenharmony_ci } 2908c2ecf20Sopenharmony_ci } 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("board_id", buf1, sizeof(buf1)) >= 0) { 2938c2ecf20Sopenharmony_ci for (e1 = bcm47xx_board_list_board_id; e1->value1; e1++) { 2948c2ecf20Sopenharmony_ci if (!strcmp(buf1, e1->value1)) 2958c2ecf20Sopenharmony_ci return &e1->board; 2968c2ecf20Sopenharmony_ci } 2978c2ecf20Sopenharmony_ci } 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("boardtype", buf1, sizeof(buf1)) >= 0 && 3008c2ecf20Sopenharmony_ci bcm47xx_nvram_getenv("boardnum", buf2, sizeof(buf2)) >= 0 && 3018c2ecf20Sopenharmony_ci bcm47xx_nvram_getenv("boardrev", buf3, sizeof(buf3)) >= 0) { 3028c2ecf20Sopenharmony_ci for (e3 = bcm47xx_board_list_board; e3->value1; e3++) { 3038c2ecf20Sopenharmony_ci if (!strcmp(buf1, e3->value1) && 3048c2ecf20Sopenharmony_ci !strcmp(buf2, e3->value2) && 3058c2ecf20Sopenharmony_ci !strcmp(buf3, e3->value3)) 3068c2ecf20Sopenharmony_ci return &e3->board; 3078c2ecf20Sopenharmony_ci } 3088c2ecf20Sopenharmony_ci } 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv("boardtype", buf1, sizeof(buf1)) >= 0 && 3118c2ecf20Sopenharmony_ci bcm47xx_nvram_getenv("boardrev", buf2, sizeof(buf2)) >= 0 && 3128c2ecf20Sopenharmony_ci bcm47xx_nvram_getenv("boardnum", buf3, sizeof(buf3)) == -ENOENT) { 3138c2ecf20Sopenharmony_ci for (e2 = bcm47xx_board_list_board_type_rev; e2->value1; e2++) { 3148c2ecf20Sopenharmony_ci if (!strcmp(buf1, e2->value1) && 3158c2ecf20Sopenharmony_ci !strcmp(buf2, e2->value2)) 3168c2ecf20Sopenharmony_ci return &e2->board; 3178c2ecf20Sopenharmony_ci } 3188c2ecf20Sopenharmony_ci } 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci for (e2 = bcm47xx_board_list_key_value; e2->value1; e2++) { 3218c2ecf20Sopenharmony_ci if (bcm47xx_nvram_getenv(e2->value1, buf1, sizeof(buf1)) >= 0) { 3228c2ecf20Sopenharmony_ci if (!strcmp(buf1, e2->value2)) 3238c2ecf20Sopenharmony_ci return &e2->board; 3248c2ecf20Sopenharmony_ci } 3258c2ecf20Sopenharmony_ci } 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci return bcm47xx_board_unknown; 3288c2ecf20Sopenharmony_ci} 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_civoid __init bcm47xx_board_detect(void) 3318c2ecf20Sopenharmony_ci{ 3328c2ecf20Sopenharmony_ci int err; 3338c2ecf20Sopenharmony_ci char buf[10]; 3348c2ecf20Sopenharmony_ci const struct bcm47xx_board_type *board_detected; 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci if (bcm47xx_board.board != BCM47XX_BOARD_NO) 3378c2ecf20Sopenharmony_ci return; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci /* check if the nvram is available */ 3408c2ecf20Sopenharmony_ci err = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf)); 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci /* init of nvram failed, probably too early now */ 3438c2ecf20Sopenharmony_ci if (err == -ENXIO) 3448c2ecf20Sopenharmony_ci return; 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci board_detected = bcm47xx_board_get_nvram(); 3478c2ecf20Sopenharmony_ci bcm47xx_board.board = board_detected->board; 3488c2ecf20Sopenharmony_ci strlcpy(bcm47xx_board.name, board_detected->name, 3498c2ecf20Sopenharmony_ci BCM47XX_BOARD_MAX_NAME); 3508c2ecf20Sopenharmony_ci} 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_cienum bcm47xx_board bcm47xx_board_get(void) 3538c2ecf20Sopenharmony_ci{ 3548c2ecf20Sopenharmony_ci return bcm47xx_board.board; 3558c2ecf20Sopenharmony_ci} 3568c2ecf20Sopenharmony_ciEXPORT_SYMBOL(bcm47xx_board_get); 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ciconst char *bcm47xx_board_get_name(void) 3598c2ecf20Sopenharmony_ci{ 3608c2ecf20Sopenharmony_ci return bcm47xx_board.name; 3618c2ecf20Sopenharmony_ci} 3628c2ecf20Sopenharmony_ciEXPORT_SYMBOL(bcm47xx_board_get_name); 363