4 * ADM5120 specific prom routines
6 * Copyright (C) 2007 OpenWrt.org
7 * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
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>
31 #include <asm/bootinfo.h>
32 #include <asm/addrspace.h>
34 #include <asm/mach-adm5120/adm5120_info.h>
35 #include <asm/mach-adm5120/adm5120_defs.h>
36 #include <asm/mach-adm5120/adm5120_uart.h>
39 #include <prom/generic.h>
40 #include <prom/routerboot.h>
41 #include <prom/myloader.h>
42 #include <prom/zynos.h>
44 unsigned int adm5120_prom_type
= ADM5120_PROM_GENERIC
;
47 unsigned long mach_type
;
51 #define DEFBOARD(n, mt) { .mach_type = (mt), .name = (n)}
52 static struct board_desc common_boards
[] __initdata
= {
53 /* Cellvision/SparkLAN boards */
54 DEFBOARD("CAS-630", MACH_ADM5120_CAS630
),
55 DEFBOARD("CAS-670", MACH_ADM5120_CAS670
),
56 DEFBOARD("CAS-771", MACH_ADM5120_CAS771
),
57 DEFBOARD("CAS-790", MACH_ADM5120_CAS790
),
58 DEFBOARD("CAS-861", MACH_ADM5120_CAS861
),
60 DEFBOARD("WP54G-WRT", MACH_ADM5120_WP54G_WRT
),
62 DEFBOARD("BR-6104K", MACH_ADM5120_BR6104K
),
63 DEFBOARD("BR-6104KP", MACH_ADM5120_BR6104K
),
65 DEFBOARD("EASY 5120P-ATA", MACH_ADM5120_EASY5120PATA
),
66 DEFBOARD("EASY 5120-RT", MACH_ADM5120_EASY5120RT
),
67 DEFBOARD("EASY 5120-WVoIP", MACH_ADM5120_EASY5120WVOIP
),
68 DEFBOARD("EASY 83000", MACH_ADM5120_EASY83000
),
69 /* Mikrotik RouterBOARDs */
70 DEFBOARD("111", MACH_ADM5120_RB_111
),
71 DEFBOARD("112", MACH_ADM5120_RB_112
),
72 DEFBOARD("133", MACH_ADM5120_RB_133
),
73 DEFBOARD("133C", MACH_ADM5120_RB_133C
),
74 DEFBOARD("133C3", MACH_ADM5120_RB_133C
),
75 DEFBOARD("150", MACH_ADM5120_RB_153
), /* it's intentional */
76 DEFBOARD("153", MACH_ADM5120_RB_153
),
77 DEFBOARD("miniROUTER", MACH_ADM5120_RB_150
),
80 static unsigned long __init
find_machtype_byname(char *name
)
85 ret
= MACH_ADM5120_GENERIC
;
92 for (i
=0; i
<ARRAY_SIZE(common_boards
); i
++) {
93 if (strcmp(common_boards
[i
].name
, name
) == 0) {
94 ret
= common_boards
[i
].mach_type
;
103 static unsigned long __init
detect_machtype_routerboot(void)
107 name
= routerboot_get_boardname();
108 return find_machtype_byname(name
);
111 static unsigned long __init
detect_machtype_generic(void)
115 name
= generic_prom_getenv("board_name");
116 return find_machtype_byname(name
);
119 unsigned long __init
detect_machtype_cfe(void)
123 name
= cfe_getenv("BOARD_NAME");
124 return find_machtype_byname(name
);
128 unsigned long mach_type
;
131 } zynos_boards
[] __initdata
= {
132 #define ZYNOS_BOARD(vi, bi, mt) { .vendor_id = (vi), .board_id = (bi), \
135 #define ZYXEL_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_ZYXEL, bi, mt)
136 #define DLINK_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_DLINK, bi, mt)
137 #define LUCENT_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_LUCENT, bi, mt)
138 ZYXEL_BOARD(ZYNOS_BOARD_HS100
, MACH_ADM5120_HS100
),
139 ZYXEL_BOARD(ZYNOS_BOARD_P334
, MACH_ADM5120_P334
),
140 ZYXEL_BOARD(ZYNOS_BOARD_P334U
, MACH_ADM5120_P334U
),
141 ZYXEL_BOARD(ZYNOS_BOARD_P334W
, MACH_ADM5120_P334W
),
142 ZYXEL_BOARD(ZYNOS_BOARD_P334WH
, MACH_ADM5120_P334WH
),
143 ZYXEL_BOARD(ZYNOS_BOARD_P334WHD
, MACH_ADM5120_P334WHD
),
144 ZYXEL_BOARD(ZYNOS_BOARD_P334WT
, MACH_ADM5120_P334WT
),
145 ZYXEL_BOARD(ZYNOS_BOARD_P335
, MACH_ADM5120_P335
),
146 ZYXEL_BOARD(ZYNOS_BOARD_P335PLUS
, MACH_ADM5120_P335PLUS
),
147 ZYXEL_BOARD(ZYNOS_BOARD_P335U
, MACH_ADM5120_P335U
)
150 static unsigned long __init
detect_machtype_bootbase(void)
155 ret
= MACH_ADM5120_GENERIC
;
156 for (i
=0; i
<ARRAY_SIZE(zynos_boards
); i
++) {
157 if (zynos_boards
[i
].vendor_id
== bootbase_info
.vendor_id
&&
158 zynos_boards
[i
].board_id
== bootbase_info
.board_id
) {
159 ret
= zynos_boards
[i
].mach_type
;
168 unsigned long mach_type
;
173 } mylo_boards
[] __initdata
= {
174 #define MYLO_BOARD(v,d,sv,sd,mt) { .vid = (v), .did = (d), .svid = (sv), \
175 .sdid = (sd), .mach_type = (mt) }
176 #define COMPEX_BOARD(d,mt) MYLO_BOARD(VENID_COMPEX,(d),VENID_COMPEX,(d),(mt))
178 COMPEX_BOARD(DEVID_COMPEX_NP27G
, MACH_ADM5120_NP27G
),
179 COMPEX_BOARD(DEVID_COMPEX_NP28G
, MACH_ADM5120_NP28G
),
180 COMPEX_BOARD(DEVID_COMPEX_NP28GHS
, MACH_ADM5120_NP28GHS
),
181 COMPEX_BOARD(DEVID_COMPEX_WP54G
, MACH_ADM5120_WP54G
),
182 COMPEX_BOARD(DEVID_COMPEX_WP54Gv1C
, MACH_ADM5120_WP54Gv1C
),
183 COMPEX_BOARD(DEVID_COMPEX_WP54AG
, MACH_ADM5120_WP54AG
),
184 COMPEX_BOARD(DEVID_COMPEX_WPP54G
, MACH_ADM5120_WPP54G
),
185 COMPEX_BOARD(DEVID_COMPEX_WPP54AG
, MACH_ADM5120_WPP54AG
),
188 static unsigned long __init
detect_machtype_myloader(void)
193 ret
= MACH_ADM5120_GENERIC
;
194 for (i
=0; i
<ARRAY_SIZE(mylo_boards
); i
++) {
195 if (mylo_boards
[i
].vid
== myloader_info
.vid
&&
196 mylo_boards
[i
].did
== myloader_info
.did
&&
197 mylo_boards
[i
].svid
== myloader_info
.svid
&&
198 mylo_boards
[i
].sdid
== myloader_info
.sdid
) {
199 ret
= mylo_boards
[i
].mach_type
;
207 static void __init
prom_detect_machtype(void)
209 if (bootbase_present()) {
210 adm5120_prom_type
= ADM5120_PROM_BOOTBASE
;
211 mips_machtype
= detect_machtype_bootbase();
216 adm5120_prom_type
= ADM5120_PROM_CFE
;
217 mips_machtype
= detect_machtype_cfe();
221 if (myloader_present()) {
222 adm5120_prom_type
= ADM5120_PROM_MYLOADER
;
223 mips_machtype
= detect_machtype_myloader();
227 if (routerboot_present()) {
228 adm5120_prom_type
= ADM5120_PROM_ROUTERBOOT
;
229 mips_machtype
= detect_machtype_routerboot();
233 if (generic_prom_present()) {
234 adm5120_prom_type
= ADM5120_PROM_GENERIC
;
235 mips_machtype
= detect_machtype_generic();
239 mips_machtype
= MACH_ADM5120_GENERIC
;
242 /* TODO: this is an ugly hack for RouterBOARDS */
243 extern char _image_cmdline
;
244 static void __init
prom_init_cmdline(void)
248 /* init command line, register a default kernel command line */
249 cmd
= &_image_cmdline
+ 8;
250 if( strlen(cmd
) > 0) strcpy( &(arcs_cmdline
[0]), cmd
);
251 else strcpy(&(arcs_cmdline
[0]), CONFIG_CMDLINE
);
255 #define UART_READ(r) *(volatile u32 *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r))
256 #define UART_WRITE(r,v) *(volatile u32 *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r))=(v)
258 void __init
prom_putchar(char ch
)
260 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
261 UART_WRITE(UART_REG_DATA
, ch
);
262 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
265 void __init
prom_init(void)
267 mips_machgroup
= MACH_GROUP_ADM5120
;
268 prom_detect_machtype();
273 void __init
prom_free_prom_memory(void)
275 /* We do not have to prom memory to free */