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>
18 #include <asm/bootinfo.h>
19 #include <asm/addrspace.h>
21 #include <asm/mach-adm5120/adm5120_info.h>
22 #include <asm/mach-adm5120/adm5120_defs.h>
23 #include <asm/mach-adm5120/adm5120_uart.h>
26 #include <prom/generic.h>
27 #include <prom/routerboot.h>
28 #include <prom/myloader.h>
29 #include <prom/zynos.h>
31 unsigned int adm5120_prom_type
= ADM5120_PROM_GENERIC
;
34 unsigned long mach_type
;
38 #define DEFBOARD(n, mt) { .mach_type = (mt), .name = (n)}
39 static struct board_desc common_boards
[] __initdata
= {
40 /* Cellvision/SparkLAN boards */
41 DEFBOARD("CAS-630", MACH_ADM5120_CAS630
),
42 DEFBOARD("CAS-670", MACH_ADM5120_CAS670
),
43 DEFBOARD("CAS-700", MACH_ADM5120_CAS700
),
44 DEFBOARD("CAS-771", MACH_ADM5120_CAS771
),
45 DEFBOARD("CAS-790", MACH_ADM5120_CAS790
),
46 DEFBOARD("CAS-861", MACH_ADM5120_CAS861
),
47 DEFBOARD("NFS-101U", MACH_ADM5120_NFS101U
),
49 DEFBOARD("WP54G-WRT", MACH_ADM5120_WP54G_WRT
),
51 DEFBOARD("BR-6104K", MACH_ADM5120_BR6104K
),
52 DEFBOARD("BR-6104KP", MACH_ADM5120_BR6104KP
),
53 DEFBOARD("BR-6104WG", MACH_ADM5120_BR61X4WG
),
54 DEFBOARD("BR-6114WG", MACH_ADM5120_BR61X4WG
),
56 DEFBOARD("EASY 5120P-ATA", MACH_ADM5120_EASY5120PATA
),
57 DEFBOARD("EASY 5120-RT", MACH_ADM5120_EASY5120RT
),
58 DEFBOARD("EASY 5120-WVoIP", MACH_ADM5120_EASY5120WVOIP
),
59 DEFBOARD("EASY 83000", MACH_ADM5120_EASY83000
),
60 /* Mikrotik RouterBOARDs */
61 DEFBOARD("111", MACH_ADM5120_RB_11X
),
62 DEFBOARD("112", MACH_ADM5120_RB_11X
),
63 DEFBOARD("133", MACH_ADM5120_RB_133
),
64 DEFBOARD("133C", MACH_ADM5120_RB_133C
),
65 DEFBOARD("133C3", MACH_ADM5120_RB_133C
),
66 DEFBOARD("150", MACH_ADM5120_RB_153
), /* it's intentional */
67 DEFBOARD("153", MACH_ADM5120_RB_153
),
68 DEFBOARD("192", MACH_ADM5120_RB_192
),
69 DEFBOARD("miniROUTER", MACH_ADM5120_RB_150
),
72 static unsigned long __init
find_machtype_byname(char *name
)
77 ret
= MACH_ADM5120_GENERIC
;
84 for (i
= 0; i
< ARRAY_SIZE(common_boards
); i
++) {
85 if (strcmp(common_boards
[i
].name
, name
) == 0) {
86 ret
= common_boards
[i
].mach_type
;
95 static unsigned long __init
detect_machtype_routerboot(void)
99 name
= routerboot_get_boardname();
100 return find_machtype_byname(name
);
103 static unsigned long __init
detect_machtype_generic(void)
107 name
= generic_prom_getenv("board_name");
108 return find_machtype_byname(name
);
111 unsigned long __init
detect_machtype_cfe(void)
115 name
= cfe_getenv("BOARD_NAME");
116 return find_machtype_byname(name
);
120 unsigned long mach_type
;
123 } zynos_boards
[] __initdata
= {
124 #define ZYNOS_BOARD(vi, bi, mt) \
125 {.vendor_id = (vi), .board_id = (bi), .mach_type = (mt)}
127 #define ZYXEL_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_ZYXEL, bi, mt)
128 #define DLINK_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_DLINK, bi, mt)
129 #define LUCENT_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_LUCENT, bi, mt)
130 ZYXEL_BOARD(ZYNOS_BOARD_HS100
, MACH_ADM5120_HS100
),
131 ZYXEL_BOARD(ZYNOS_BOARD_P334U
, MACH_ADM5120_P334U
),
132 ZYXEL_BOARD(ZYNOS_BOARD_P334W
, MACH_ADM5120_P334W
),
133 ZYXEL_BOARD(ZYNOS_BOARD_P334WH
, MACH_ADM5120_P334WH
),
134 ZYXEL_BOARD(ZYNOS_BOARD_P334WHD
, MACH_ADM5120_P334WHD
),
135 ZYXEL_BOARD(ZYNOS_BOARD_P334WT
, MACH_ADM5120_P334WT
),
136 ZYXEL_BOARD(ZYNOS_BOARD_P334WT_ALT
, MACH_ADM5120_P334WT
),
137 ZYXEL_BOARD(ZYNOS_BOARD_P335
, MACH_ADM5120_P335
),
138 ZYXEL_BOARD(ZYNOS_BOARD_P335PLUS
, MACH_ADM5120_P335PLUS
),
139 ZYXEL_BOARD(ZYNOS_BOARD_P335U
, MACH_ADM5120_P335U
)
142 static unsigned long __init
detect_machtype_bootbase(void)
146 for (i
= 0; i
< ARRAY_SIZE(zynos_boards
); i
++) {
147 if (zynos_boards
[i
].vendor_id
== bootbase_info
.vendor_id
&&
148 zynos_boards
[i
].board_id
== bootbase_info
.board_id
) {
149 return zynos_boards
[i
].mach_type
;
154 printk(KERN_WARNING
"Unknown ZyXEL model (%u)\n",
155 bootbase_info
.board_id
);
156 return MACH_ADM5120_GENERIC
;
160 unsigned long mach_type
;
165 } mylo_boards
[] __initdata
= {
166 #define MYLO_BOARD(v, d, sv, sd, mt) \
167 {.vid = (v), .did = (d), .svid = (sv), .sdid = (sd), .mach_type = (mt)}
168 #define COMPEX_BOARD(d, mt) \
169 MYLO_BOARD(VENID_COMPEX, (d), VENID_COMPEX, (d), (mt))
171 COMPEX_BOARD(DEVID_COMPEX_NP27G
, MACH_ADM5120_NP27G
),
172 COMPEX_BOARD(DEVID_COMPEX_NP28G
, MACH_ADM5120_NP28G
),
173 COMPEX_BOARD(DEVID_COMPEX_NP28GHS
, MACH_ADM5120_NP28GHS
),
174 COMPEX_BOARD(DEVID_COMPEX_WP54G
, MACH_ADM5120_WP54
),
175 COMPEX_BOARD(DEVID_COMPEX_WP54Gv1C
, MACH_ADM5120_WP54Gv1C
),
176 COMPEX_BOARD(DEVID_COMPEX_WP54AG
, MACH_ADM5120_WP54
),
177 COMPEX_BOARD(DEVID_COMPEX_WPP54G
, MACH_ADM5120_WP54
),
178 COMPEX_BOARD(DEVID_COMPEX_WPP54AG
, MACH_ADM5120_WP54
),
181 static unsigned long __init
detect_machtype_myloader(void)
186 ret
= MACH_ADM5120_GENERIC
;
187 for (i
= 0; i
< ARRAY_SIZE(mylo_boards
); i
++) {
188 if (mylo_boards
[i
].vid
== myloader_info
.vid
&&
189 mylo_boards
[i
].did
== myloader_info
.did
&&
190 mylo_boards
[i
].svid
== myloader_info
.svid
&&
191 mylo_boards
[i
].sdid
== myloader_info
.sdid
) {
192 ret
= mylo_boards
[i
].mach_type
;
200 static void __init
prom_detect_machtype(void)
202 if (bootbase_present()) {
203 adm5120_prom_type
= ADM5120_PROM_BOOTBASE
;
204 mips_machtype
= detect_machtype_bootbase();
209 adm5120_prom_type
= ADM5120_PROM_CFE
;
210 mips_machtype
= detect_machtype_cfe();
214 if (myloader_present()) {
215 adm5120_prom_type
= ADM5120_PROM_MYLOADER
;
216 mips_machtype
= detect_machtype_myloader();
220 if (routerboot_present()) {
221 adm5120_prom_type
= ADM5120_PROM_ROUTERBOOT
;
222 mips_machtype
= detect_machtype_routerboot();
226 if (generic_prom_present()) {
227 adm5120_prom_type
= ADM5120_PROM_GENERIC
;
228 mips_machtype
= detect_machtype_generic();
232 mips_machtype
= MACH_ADM5120_GENERIC
;
235 /* TODO: this is an ugly hack for RouterBOARDS */
236 extern char _image_cmdline
;
237 static void __init
prom_init_cmdline(void)
241 /* init command line, register a default kernel command line */
242 cmd
= &_image_cmdline
+ 8;
244 strcpy(arcs_cmdline
, cmd
);
246 strcpy(arcs_cmdline
, CONFIG_CMDLINE
);
250 #define UART_READ(r) \
251 __raw_readl((void __iomem *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r)))
252 #define UART_WRITE(r, v) \
253 __raw_writel((v), (void __iomem *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r)))
255 void __init
prom_putchar(char ch
)
257 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
258 UART_WRITE(UART_REG_DATA
, ch
);
259 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
262 void __init
prom_init(void)
264 prom_detect_machtype();
269 void __init
prom_free_prom_memory(void)
271 /* We do not have to prom memory to free */