2 * ADM5120 specific prom routines
4 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/string.h>
17 #include <asm/bootinfo.h>
18 #include <asm/mips_machine.h>
20 #include <asm/mach-adm5120/adm5120_info.h>
23 #include <prom/generic.h>
24 #include <prom/routerboot.h>
25 #include <prom/myloader.h>
26 #include <prom/zynos.h>
28 unsigned int adm5120_prom_type = ADM5120_PROM_GENERIC;
31 unsigned long mach_type;
35 #define DEFBOARD(n, mt) { .mach_type = (mt), .name = (n)}
36 static struct board_desc common_boards[] __initdata = {
37 /* Cellvision/SparkLAN boards */
38 DEFBOARD("CAS-630", MACH_ADM5120_CAS630),
39 DEFBOARD("CAS-670", MACH_ADM5120_CAS670),
40 DEFBOARD("CAS-700", MACH_ADM5120_CAS700),
41 DEFBOARD("CAS-771", MACH_ADM5120_CAS771),
42 DEFBOARD("CAS-790", MACH_ADM5120_CAS790),
43 DEFBOARD("CAS-861", MACH_ADM5120_CAS861),
44 DEFBOARD("NFS-101U", MACH_ADM5120_NFS101U),
46 DEFBOARD("WP54G-WRT", MACH_ADM5120_WP54G_WRT),
48 DEFBOARD("BR-6104K", MACH_ADM5120_BR6104K),
49 DEFBOARD("BR-6104KP", MACH_ADM5120_BR6104KP),
50 DEFBOARD("BR-6104WG", MACH_ADM5120_BR61X4WG),
51 DEFBOARD("BR-6114WG", MACH_ADM5120_BR61X4WG),
53 DEFBOARD("EASY 5120P-ATA", MACH_ADM5120_EASY5120PATA),
54 DEFBOARD("EASY 5120-RT", MACH_ADM5120_EASY5120RT),
55 DEFBOARD("EASY 5120-WVoIP", MACH_ADM5120_EASY5120WVOIP),
56 DEFBOARD("EASY 83000", MACH_ADM5120_EASY83000),
57 /* Mikrotik RouterBOARDs */
58 DEFBOARD("111", MACH_ADM5120_RB_11X),
59 DEFBOARD("112", MACH_ADM5120_RB_11X),
60 DEFBOARD("133", MACH_ADM5120_RB_133),
61 DEFBOARD("133C", MACH_ADM5120_RB_133C),
62 DEFBOARD("133C3", MACH_ADM5120_RB_133C),
63 DEFBOARD("150", MACH_ADM5120_RB_153), /* it's intentional */
64 DEFBOARD("153", MACH_ADM5120_RB_153),
65 DEFBOARD("192", MACH_ADM5120_RB_192),
66 DEFBOARD("miniROUTER", MACH_ADM5120_RB_150),
68 DEFBOARD("OSBRiDGE 5GXi", MACH_ADM5120_5GXI),
70 DEFBOARD("Powerline MU Gateway", MACH_ADM5120_PMUGW),
72 DEFBOARD("ADM5120", MACH_ADM5120_EB_214A),
75 static unsigned long __init find_machtype_byname(char *name)
80 ret = MACH_ADM5120_GENERIC;
87 for (i = 0; i < ARRAY_SIZE(common_boards); i++) {
88 if (strcmp(common_boards[i].name, name) == 0) {
89 ret = common_boards[i].mach_type;
98 static unsigned long __init detect_machtype_routerboot(void)
102 name = routerboot_get_boardname();
103 return find_machtype_byname(name);
106 static unsigned long __init detect_machtype_generic(void)
110 name = generic_prom_getenv("board_name");
111 return find_machtype_byname(name);
114 unsigned long __init detect_machtype_cfe(void)
118 name = cfe_getenv("BOARD_NAME");
119 return find_machtype_byname(name);
123 unsigned long mach_type;
126 } zynos_boards[] __initdata = {
127 #define ZYNOS_BOARD(vi, bi, mt) \
128 {.vendor_id = (vi), .board_id = (bi), .mach_type = (mt)}
130 #define ZYXEL_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_ZYXEL, bi, mt)
131 #define DLINK_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_DLINK, bi, mt)
132 #define LUCENT_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_LUCENT, bi, mt)
133 ZYXEL_BOARD(ZYNOS_BOARD_HS100, MACH_ADM5120_HS100),
134 ZYXEL_BOARD(ZYNOS_BOARD_P334U, MACH_ADM5120_P334U),
135 ZYXEL_BOARD(ZYNOS_BOARD_P334W, MACH_ADM5120_P334W),
136 ZYXEL_BOARD(ZYNOS_BOARD_P334WH, MACH_ADM5120_P334WH),
137 ZYXEL_BOARD(ZYNOS_BOARD_P334WHD, MACH_ADM5120_P334WHD),
138 ZYXEL_BOARD(ZYNOS_BOARD_P334WT, MACH_ADM5120_P334WT),
139 ZYXEL_BOARD(ZYNOS_BOARD_P334WT_ALT, MACH_ADM5120_P334WT),
140 ZYXEL_BOARD(ZYNOS_BOARD_P335, MACH_ADM5120_P335),
141 ZYXEL_BOARD(ZYNOS_BOARD_P335PLUS, MACH_ADM5120_P335PLUS),
142 ZYXEL_BOARD(ZYNOS_BOARD_P335U, MACH_ADM5120_P335U)
145 static unsigned long __init detect_machtype_bootbase(void)
149 for (i = 0; i < ARRAY_SIZE(zynos_boards); i++) {
150 if (zynos_boards[i].vendor_id == bootbase_info.vendor_id &&
151 zynos_boards[i].board_id == bootbase_info.board_id) {
152 return zynos_boards[i].mach_type;
157 printk(KERN_WARNING "Unknown ZyXEL model (%u)\n",
158 bootbase_info.board_id);
159 return MACH_ADM5120_GENERIC;
163 unsigned long mach_type;
168 } mylo_boards[] __initdata = {
169 #define MYLO_BOARD(v, d, sv, sd, mt) \
170 {.vid = (v), .did = (d), .svid = (sv), .sdid = (sd), .mach_type = (mt)}
171 #define COMPEX_BOARD(d, mt) \
172 MYLO_BOARD(VENID_COMPEX, (d), VENID_COMPEX, (d), (mt))
174 COMPEX_BOARD(DEVID_COMPEX_NP27G, MACH_ADM5120_NP27G),
175 COMPEX_BOARD(DEVID_COMPEX_NP28G, MACH_ADM5120_NP28G),
176 COMPEX_BOARD(DEVID_COMPEX_NP28GHS, MACH_ADM5120_NP28GHS),
177 COMPEX_BOARD(DEVID_COMPEX_WP54G, MACH_ADM5120_WP54),
178 COMPEX_BOARD(DEVID_COMPEX_WP54Gv1C, MACH_ADM5120_WP54Gv1C),
179 COMPEX_BOARD(DEVID_COMPEX_WP54AG, MACH_ADM5120_WP54),
180 COMPEX_BOARD(DEVID_COMPEX_WPP54G, MACH_ADM5120_WP54),
181 COMPEX_BOARD(DEVID_COMPEX_WPP54AG, MACH_ADM5120_WP54),
184 static unsigned long __init detect_machtype_myloader(void)
189 ret = MACH_ADM5120_GENERIC;
190 for (i = 0; i < ARRAY_SIZE(mylo_boards); i++) {
191 if (mylo_boards[i].vid == myloader_info.vid &&
192 mylo_boards[i].did == myloader_info.did &&
193 mylo_boards[i].svid == myloader_info.svid &&
194 mylo_boards[i].sdid == myloader_info.sdid) {
195 ret = mylo_boards[i].mach_type;
203 static void __init prom_detect_machtype(void)
205 if (bootbase_present()) {
206 adm5120_prom_type = ADM5120_PROM_BOOTBASE;
207 mips_machtype = detect_machtype_bootbase();
212 adm5120_prom_type = ADM5120_PROM_CFE;
213 mips_machtype = detect_machtype_cfe();
217 if (myloader_present()) {
218 adm5120_prom_type = ADM5120_PROM_MYLOADER;
219 mips_machtype = detect_machtype_myloader();
223 if (routerboot_present()) {
224 adm5120_prom_type = ADM5120_PROM_ROUTERBOOT;
225 mips_machtype = detect_machtype_routerboot();
229 if (generic_prom_present()) {
230 adm5120_prom_type = ADM5120_PROM_GENERIC;
231 mips_machtype = detect_machtype_generic();
235 mips_machtype = MACH_ADM5120_GENERIC;
238 #ifdef CONFIG_IMAGE_CMDLINE_HACK
239 extern char __image_cmdline[];
241 static void __init prom_init_cmdline(void)
245 /* init command line, register a default kernel command line */
246 cmd = __image_cmdline;
248 strlcpy(arcs_cmdline, cmd, sizeof(arcs_cmdline));
252 static inline void prom_init_cmdline(void) {}
253 #endif /* CONFIG_IMAGE_CMDLINE_HACK */
255 void __init prom_init(void)
257 prom_detect_machtype();
261 void __init prom_free_prom_memory(void)
263 /* We do not have to prom memory to free */