4 * ADM5120 specific prom routines
6 * Copyright (C) 2007 OpenWrt.org
7 * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
26 #include <linux/init.h>
27 #include <linux/kernel.h>
28 #include <linux/string.h>
32 #include <asm/bootinfo.h>
33 #include <asm/addrspace.h>
35 #include <adm5120_info.h>
36 #include <adm5120_defs.h>
37 #include <adm5120_uart.h>
40 #include <prom/generic.h>
41 #include <prom/routerboot.h>
42 #include <prom/myloader.h>
43 #include <prom/zynos.h>
45 unsigned int adm5120_prom_type
= ADM5120_PROM_GENERIC
;
48 unsigned long mach_type
;
52 #define DEFBOARD(n, mt) { .mach_type = (mt), .name = (n)}
53 static struct board_desc common_boards
[] __initdata
= {
54 /* Cellvision/SparkLAN boards */
55 DEFBOARD("CAS-630", MACH_ADM5120_CAS630
),
56 DEFBOARD("CAS-670", MACH_ADM5120_CAS670
),
57 DEFBOARD("CAS-771", MACH_ADM5120_CAS771
),
58 DEFBOARD("CAS-790", MACH_ADM5120_CAS790
),
59 DEFBOARD("CAS-861", MACH_ADM5120_CAS861
),
61 DEFBOARD("WP54G-WRT", MACH_ADM5120_WP54G_WRT
),
63 DEFBOARD("BR-6104K", MACH_ADM5120_BR6104K
),
64 DEFBOARD("BR-6104KP", MACH_ADM5120_BR6104K
),
65 DEFBOARD("BR-6104WG", MACH_ADM5120_BR61x4WG
),
67 DEFBOARD("EASY 5120P-ATA", MACH_ADM5120_EASY5120PATA
),
68 DEFBOARD("EASY 5120-RT", MACH_ADM5120_EASY5120RT
),
69 DEFBOARD("EASY 5120-WVoIP", MACH_ADM5120_EASY5120WVOIP
),
70 DEFBOARD("EASY 83000", MACH_ADM5120_EASY83000
),
71 /* Mikrotik RouterBOARDs */
72 DEFBOARD("111", MACH_ADM5120_RB_111
),
73 DEFBOARD("112", MACH_ADM5120_RB_112
),
74 DEFBOARD("133", MACH_ADM5120_RB_133
),
75 DEFBOARD("133C", MACH_ADM5120_RB_133C
),
76 DEFBOARD("133C3", MACH_ADM5120_RB_133C
),
77 DEFBOARD("150", MACH_ADM5120_RB_153
), /* it's intentional */
78 DEFBOARD("153", MACH_ADM5120_RB_153
),
79 DEFBOARD("192", MACH_ADM5120_RB_192
),
80 DEFBOARD("miniROUTER", MACH_ADM5120_RB_150
),
83 static unsigned long __init
find_machtype_byname(char *name
)
88 ret
= MACH_ADM5120_GENERIC
;
95 for (i
= 0; i
< ARRAY_SIZE(common_boards
); i
++) {
96 if (strcmp(common_boards
[i
].name
, name
) == 0) {
97 ret
= common_boards
[i
].mach_type
;
106 static unsigned long __init
detect_machtype_routerboot(void)
110 name
= routerboot_get_boardname();
111 return find_machtype_byname(name
);
114 static unsigned long __init
detect_machtype_generic(void)
118 name
= generic_prom_getenv("board_name");
119 return find_machtype_byname(name
);
122 unsigned long __init
detect_machtype_cfe(void)
126 name
= cfe_getenv("BOARD_NAME");
127 return find_machtype_byname(name
);
131 unsigned long mach_type
;
134 } zynos_boards
[] __initdata
= {
135 #define ZYNOS_BOARD(vi, bi, mt) \
136 {.vendor_id = (vi), .board_id = (bi), .mach_type = (mt)}
138 #define ZYXEL_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_ZYXEL, bi, mt)
139 #define DLINK_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_DLINK, bi, mt)
140 #define LUCENT_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_LUCENT, bi, mt)
141 ZYXEL_BOARD(ZYNOS_BOARD_HS100
, MACH_ADM5120_HS100
),
142 ZYXEL_BOARD(ZYNOS_BOARD_P334
, MACH_ADM5120_P334
),
143 ZYXEL_BOARD(ZYNOS_BOARD_P334U
, MACH_ADM5120_P334U
),
144 ZYXEL_BOARD(ZYNOS_BOARD_P334W
, MACH_ADM5120_P334W
),
145 ZYXEL_BOARD(ZYNOS_BOARD_P334WH
, MACH_ADM5120_P334WH
),
146 ZYXEL_BOARD(ZYNOS_BOARD_P334WHD
, MACH_ADM5120_P334WHD
),
147 ZYXEL_BOARD(ZYNOS_BOARD_P334WT
, MACH_ADM5120_P334WT
),
148 ZYXEL_BOARD(ZYNOS_BOARD_P335
, MACH_ADM5120_P335
),
149 ZYXEL_BOARD(ZYNOS_BOARD_P335PLUS
, MACH_ADM5120_P335PLUS
),
150 ZYXEL_BOARD(ZYNOS_BOARD_P335U
, MACH_ADM5120_P335U
)
153 static unsigned long __init
detect_machtype_bootbase(void)
158 ret
= MACH_ADM5120_GENERIC
;
159 for (i
= 0; i
< ARRAY_SIZE(zynos_boards
); i
++) {
160 if (zynos_boards
[i
].vendor_id
== bootbase_info
.vendor_id
&&
161 zynos_boards
[i
].board_id
== bootbase_info
.board_id
) {
162 ret
= zynos_boards
[i
].mach_type
;
171 unsigned long mach_type
;
176 } mylo_boards
[] __initdata
= {
177 #define MYLO_BOARD(v, d, sv, sd, mt) \
178 {.vid = (v), .did = (d), .svid = (sv), .sdid = (sd), .mach_type = (mt)}
179 #define COMPEX_BOARD(d, mt) \
180 MYLO_BOARD(VENID_COMPEX, (d), VENID_COMPEX, (d), (mt))
182 COMPEX_BOARD(DEVID_COMPEX_NP27G
, MACH_ADM5120_NP27G
),
183 COMPEX_BOARD(DEVID_COMPEX_NP28G
, MACH_ADM5120_NP28G
),
184 COMPEX_BOARD(DEVID_COMPEX_NP28GHS
, MACH_ADM5120_NP28GHS
),
185 COMPEX_BOARD(DEVID_COMPEX_WP54G
, MACH_ADM5120_WP54G
),
186 COMPEX_BOARD(DEVID_COMPEX_WP54Gv1C
, MACH_ADM5120_WP54Gv1C
),
187 COMPEX_BOARD(DEVID_COMPEX_WP54AG
, MACH_ADM5120_WP54AG
),
188 COMPEX_BOARD(DEVID_COMPEX_WPP54G
, MACH_ADM5120_WPP54G
),
189 COMPEX_BOARD(DEVID_COMPEX_WPP54AG
, MACH_ADM5120_WPP54AG
),
192 static unsigned long __init
detect_machtype_myloader(void)
197 ret
= MACH_ADM5120_GENERIC
;
198 for (i
= 0; i
< ARRAY_SIZE(mylo_boards
); i
++) {
199 if (mylo_boards
[i
].vid
== myloader_info
.vid
&&
200 mylo_boards
[i
].did
== myloader_info
.did
&&
201 mylo_boards
[i
].svid
== myloader_info
.svid
&&
202 mylo_boards
[i
].sdid
== myloader_info
.sdid
) {
203 ret
= mylo_boards
[i
].mach_type
;
211 static void __init
prom_detect_machtype(void)
213 if (bootbase_present()) {
214 adm5120_prom_type
= ADM5120_PROM_BOOTBASE
;
215 mips_machtype
= detect_machtype_bootbase();
220 adm5120_prom_type
= ADM5120_PROM_CFE
;
221 mips_machtype
= detect_machtype_cfe();
225 if (myloader_present()) {
226 adm5120_prom_type
= ADM5120_PROM_MYLOADER
;
227 mips_machtype
= detect_machtype_myloader();
231 if (routerboot_present()) {
232 adm5120_prom_type
= ADM5120_PROM_ROUTERBOOT
;
233 mips_machtype
= detect_machtype_routerboot();
237 if (generic_prom_present()) {
238 adm5120_prom_type
= ADM5120_PROM_GENERIC
;
239 mips_machtype
= detect_machtype_generic();
243 mips_machtype
= MACH_ADM5120_GENERIC
;
246 /* TODO: this is an ugly hack for RouterBOARDS */
247 extern char _image_cmdline
;
248 static void __init
prom_init_cmdline(void)
252 /* init command line, register a default kernel command line */
253 cmd
= &_image_cmdline
+ 8;
255 strcpy(arcs_cmdline
, cmd
);
257 strcpy(arcs_cmdline
, CONFIG_CMDLINE
);
261 #define UART_READ(r) \
262 __raw_readl((void __iomem *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r)))
263 #define UART_WRITE(r, v) \
264 __raw_writel((v), (void __iomem *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r)))
266 void __init
prom_putchar(char ch
)
268 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
269 UART_WRITE(UART_REG_DATA
, ch
);
270 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
273 void __init
prom_init(void)
275 mips_machgroup
= MACH_GROUP_ADM5120
;
276 prom_detect_machtype();
281 void __init
prom_free_prom_memory(void)
283 /* We do not have to prom memory to free */