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 modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17 #include <linux/string.h>
21 #include <asm/bootinfo.h>
22 #include <asm/addrspace.h>
24 #include <adm5120_info.h>
25 #include <adm5120_defs.h>
26 #include <adm5120_uart.h>
29 #include <prom/generic.h>
30 #include <prom/routerboot.h>
31 #include <prom/myloader.h>
32 #include <prom/zynos.h>
34 unsigned int adm5120_prom_type
= ADM5120_PROM_GENERIC
;
37 unsigned long mach_type
;
41 #define DEFBOARD(n, mt) { .mach_type = (mt), .name = (n)}
42 static struct board_desc common_boards
[] __initdata
= {
43 /* Cellvision/SparkLAN boards */
44 DEFBOARD("CAS-630", MACH_ADM5120_CAS630
),
45 DEFBOARD("CAS-670", MACH_ADM5120_CAS670
),
46 DEFBOARD("CAS-700", MACH_ADM5120_CAS700
),
47 DEFBOARD("CAS-771", MACH_ADM5120_CAS771
),
48 DEFBOARD("CAS-790", MACH_ADM5120_CAS790
),
49 DEFBOARD("CAS-861", MACH_ADM5120_CAS861
),
50 DEFBOARD("NFS-101U", MACH_ADM5120_NFS101U
),
52 DEFBOARD("WP54G-WRT", MACH_ADM5120_WP54G_WRT
),
54 DEFBOARD("BR-6104K", MACH_ADM5120_BR6104K
),
55 DEFBOARD("BR-6104KP", MACH_ADM5120_BR6104K
),
56 DEFBOARD("BR-6104WG", MACH_ADM5120_BR61x4WG
),
57 DEFBOARD("BR-6114WG", MACH_ADM5120_BR61x4WG
),
59 DEFBOARD("EASY 5120P-ATA", MACH_ADM5120_EASY5120PATA
),
60 DEFBOARD("EASY 5120-RT", MACH_ADM5120_EASY5120RT
),
61 DEFBOARD("EASY 5120-WVoIP", MACH_ADM5120_EASY5120WVOIP
),
62 DEFBOARD("EASY 83000", MACH_ADM5120_EASY83000
),
63 /* Mikrotik RouterBOARDs */
64 DEFBOARD("111", MACH_ADM5120_RB_111
),
65 DEFBOARD("112", MACH_ADM5120_RB_112
),
66 DEFBOARD("133", MACH_ADM5120_RB_133
),
67 DEFBOARD("133C", MACH_ADM5120_RB_133C
),
68 DEFBOARD("133C3", MACH_ADM5120_RB_133C
),
69 DEFBOARD("150", MACH_ADM5120_RB_153
), /* it's intentional */
70 DEFBOARD("153", MACH_ADM5120_RB_153
),
71 DEFBOARD("192", MACH_ADM5120_RB_192
),
72 DEFBOARD("miniROUTER", MACH_ADM5120_RB_150
),
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_P334
, MACH_ADM5120_P334
),
135 ZYXEL_BOARD(ZYNOS_BOARD_P334U
, MACH_ADM5120_P334U
),
136 ZYXEL_BOARD(ZYNOS_BOARD_P334W
, MACH_ADM5120_P334W
),
137 ZYXEL_BOARD(ZYNOS_BOARD_P334WH
, MACH_ADM5120_P334WH
),
138 ZYXEL_BOARD(ZYNOS_BOARD_P334WHD
, MACH_ADM5120_P334WHD
),
139 ZYXEL_BOARD(ZYNOS_BOARD_P334WT
, MACH_ADM5120_P334WT
),
140 ZYXEL_BOARD(ZYNOS_BOARD_P334WT_ALT
, MACH_ADM5120_P334WT
),
141 ZYXEL_BOARD(ZYNOS_BOARD_P335
, MACH_ADM5120_P335
),
142 ZYXEL_BOARD(ZYNOS_BOARD_P335PLUS
, MACH_ADM5120_P335PLUS
),
143 ZYXEL_BOARD(ZYNOS_BOARD_P335U
, MACH_ADM5120_P335U
)
146 static unsigned long __init
detect_machtype_bootbase(void)
150 for (i
= 0; i
< ARRAY_SIZE(zynos_boards
); i
++) {
151 if (zynos_boards
[i
].vendor_id
== bootbase_info
.vendor_id
&&
152 zynos_boards
[i
].board_id
== bootbase_info
.board_id
) {
153 return zynos_boards
[i
].mach_type
;
158 printk(KERN_WARNING
"Unknown ZyXEL model (%u)\n",
159 bootbase_info
.board_id
);
160 return MACH_ADM5120_GENERIC
;
164 unsigned long mach_type
;
169 } mylo_boards
[] __initdata
= {
170 #define MYLO_BOARD(v, d, sv, sd, mt) \
171 {.vid = (v), .did = (d), .svid = (sv), .sdid = (sd), .mach_type = (mt)}
172 #define COMPEX_BOARD(d, mt) \
173 MYLO_BOARD(VENID_COMPEX, (d), VENID_COMPEX, (d), (mt))
175 COMPEX_BOARD(DEVID_COMPEX_NP27G
, MACH_ADM5120_NP27G
),
176 COMPEX_BOARD(DEVID_COMPEX_NP28G
, MACH_ADM5120_NP28G
),
177 COMPEX_BOARD(DEVID_COMPEX_NP28GHS
, MACH_ADM5120_NP28GHS
),
178 COMPEX_BOARD(DEVID_COMPEX_WP54G
, MACH_ADM5120_WP54G
),
179 COMPEX_BOARD(DEVID_COMPEX_WP54Gv1C
, MACH_ADM5120_WP54Gv1C
),
180 COMPEX_BOARD(DEVID_COMPEX_WP54AG
, MACH_ADM5120_WP54AG
),
181 COMPEX_BOARD(DEVID_COMPEX_WPP54G
, MACH_ADM5120_WPP54G
),
182 COMPEX_BOARD(DEVID_COMPEX_WPP54AG
, MACH_ADM5120_WPP54AG
),
185 static unsigned long __init
detect_machtype_myloader(void)
190 ret
= MACH_ADM5120_GENERIC
;
191 for (i
= 0; i
< ARRAY_SIZE(mylo_boards
); i
++) {
192 if (mylo_boards
[i
].vid
== myloader_info
.vid
&&
193 mylo_boards
[i
].did
== myloader_info
.did
&&
194 mylo_boards
[i
].svid
== myloader_info
.svid
&&
195 mylo_boards
[i
].sdid
== myloader_info
.sdid
) {
196 ret
= mylo_boards
[i
].mach_type
;
204 static void __init
prom_detect_machtype(void)
206 if (bootbase_present()) {
207 adm5120_prom_type
= ADM5120_PROM_BOOTBASE
;
208 mips_machtype
= detect_machtype_bootbase();
213 adm5120_prom_type
= ADM5120_PROM_CFE
;
214 mips_machtype
= detect_machtype_cfe();
218 if (myloader_present()) {
219 adm5120_prom_type
= ADM5120_PROM_MYLOADER
;
220 mips_machtype
= detect_machtype_myloader();
224 if (routerboot_present()) {
225 adm5120_prom_type
= ADM5120_PROM_ROUTERBOOT
;
226 mips_machtype
= detect_machtype_routerboot();
230 if (generic_prom_present()) {
231 adm5120_prom_type
= ADM5120_PROM_GENERIC
;
232 mips_machtype
= detect_machtype_generic();
236 mips_machtype
= MACH_ADM5120_GENERIC
;
239 /* TODO: this is an ugly hack for RouterBOARDS */
240 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
+ 8;
248 strcpy(arcs_cmdline
, cmd
);
250 strcpy(arcs_cmdline
, CONFIG_CMDLINE
);
254 #define UART_READ(r) \
255 __raw_readl((void __iomem *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r)))
256 #define UART_WRITE(r, v) \
257 __raw_writel((v), (void __iomem *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r)))
259 void __init
prom_putchar(char ch
)
261 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
262 UART_WRITE(UART_REG_DATA
, ch
);
263 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
266 void __init
prom_init(void)
268 prom_detect_machtype();
273 void __init
prom_free_prom_memory(void)
275 /* We do not have to prom memory to free */