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 5120", MACH_ADM5120_EASY5120
),
66 DEFBOARD("EASY 5120-RT", MACH_ADM5120_EASY5120RT
),
67 DEFBOARD("EASY 5120P-ATA", MACH_ADM5120_EASY5120PATA
),
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("miniROUTER", MACH_ADM5120_RB_150
),
75 DEFBOARD("153", MACH_ADM5120_RB_153
),
78 static unsigned long __init
find_machtype_byname(char *name
)
83 ret
= MACH_ADM5120_GENERIC
;
90 for (i
=0; i
<ARRAY_SIZE(common_boards
); i
++) {
91 if (strcmp(common_boards
[i
].name
, name
) == 0) {
92 ret
= common_boards
[i
].mach_type
;
101 static unsigned long __init
detect_machtype_routerboot(void)
105 name
= routerboot_get_boardname();
106 return find_machtype_byname(name
);
109 static unsigned long __init
detect_machtype_generic(void)
113 name
= generic_prom_getenv("board_name");
114 return find_machtype_byname(name
);
117 unsigned long __init
detect_machtype_cfe(void)
121 name
= cfe_getenv("BOARD_NAME");
122 return find_machtype_byname(name
);
126 unsigned long mach_type
;
129 } zynos_boards
[] __initdata
= {
130 #define ZYNOS_BOARD(vi, bi, mt) { .vendor_id = (vi), .board_id = (bi), \
133 #define ZYXEL_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_ZYXEL, bi, mt)
134 #define DLINK_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_DLINK, bi, mt)
135 #define LUCENT_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_LUCENT, bi, mt)
136 ZYXEL_BOARD(ZYNOS_BOARD_HS100
, MACH_ADM5120_HS100
),
137 ZYXEL_BOARD(ZYNOS_BOARD_P334
, MACH_ADM5120_P334
),
138 ZYXEL_BOARD(ZYNOS_BOARD_P334U
, MACH_ADM5120_P334U
),
139 ZYXEL_BOARD(ZYNOS_BOARD_P334W
, MACH_ADM5120_P334W
),
140 ZYXEL_BOARD(ZYNOS_BOARD_P334WH
, MACH_ADM5120_P334WH
),
141 ZYXEL_BOARD(ZYNOS_BOARD_P334WHD
, MACH_ADM5120_P334WHD
),
142 ZYXEL_BOARD(ZYNOS_BOARD_P334WT
, MACH_ADM5120_P334WT
),
143 ZYXEL_BOARD(ZYNOS_BOARD_P335
, MACH_ADM5120_P335
),
144 ZYXEL_BOARD(ZYNOS_BOARD_P335PLUS
, MACH_ADM5120_P335PLUS
),
145 ZYXEL_BOARD(ZYNOS_BOARD_P335U
, MACH_ADM5120_P335U
)
148 static unsigned long __init
detect_machtype_bootbase(void)
153 ret
= MACH_ADM5120_GENERIC
;
154 for (i
=0; i
<ARRAY_SIZE(zynos_boards
); i
++) {
155 if (zynos_boards
[i
].vendor_id
== bootbase_info
.vendor_id
&&
156 zynos_boards
[i
].board_id
== bootbase_info
.board_id
) {
157 ret
= zynos_boards
[i
].mach_type
;
166 unsigned long mach_type
;
171 } mylo_boards
[] __initdata
= {
172 #define MYLO_BOARD(v,d,sv,sd,mt) { .vid = (v), .did = (d), .svid = (sv), \
173 .sdid = (sd), .mach_type = (mt) }
174 #define COMPEX_BOARD(d,mt) MYLO_BOARD(VENID_COMPEX,(d),VENID_COMPEX,(d),(mt))
176 COMPEX_BOARD(DEVID_COMPEX_NP27G
, MACH_ADM5120_NP27G
),
177 COMPEX_BOARD(DEVID_COMPEX_NP28G
, MACH_ADM5120_NP28G
),
178 COMPEX_BOARD(DEVID_COMPEX_NP28GHS
, MACH_ADM5120_NP28GHS
),
179 COMPEX_BOARD(DEVID_COMPEX_WP54G
, MACH_ADM5120_WP54G
),
180 COMPEX_BOARD(DEVID_COMPEX_WP54Gv1C
, MACH_ADM5120_WP54Gv1C
),
181 COMPEX_BOARD(DEVID_COMPEX_WP54AG
, MACH_ADM5120_WP54AG
),
182 COMPEX_BOARD(DEVID_COMPEX_WPP54G
, MACH_ADM5120_WPP54G
),
183 COMPEX_BOARD(DEVID_COMPEX_WPP54AG
, MACH_ADM5120_WPP54AG
),
186 static unsigned long __init
detect_machtype_myloader(void)
191 ret
= MACH_ADM5120_GENERIC
;
192 for (i
=0; i
<ARRAY_SIZE(mylo_boards
); i
++) {
193 if (mylo_boards
[i
].vid
== myloader_info
.vid
&&
194 mylo_boards
[i
].did
== myloader_info
.did
&&
195 mylo_boards
[i
].svid
== myloader_info
.svid
&&
196 mylo_boards
[i
].sdid
== myloader_info
.sdid
) {
197 ret
= mylo_boards
[i
].mach_type
;
205 static void __init
prom_detect_machtype(void)
207 if (bootbase_present()) {
208 adm5120_prom_type
= ADM5120_PROM_BOOTBASE
;
209 mips_machtype
= detect_machtype_bootbase();
214 adm5120_prom_type
= ADM5120_PROM_CFE
;
215 mips_machtype
= detect_machtype_cfe();
219 if (myloader_present()) {
220 adm5120_prom_type
= ADM5120_PROM_MYLOADER
;
221 mips_machtype
= detect_machtype_myloader();
225 if (routerboot_present()) {
226 adm5120_prom_type
= ADM5120_PROM_ROUTERBOOT
;
227 mips_machtype
= detect_machtype_routerboot();
231 if (generic_prom_present()) {
232 adm5120_prom_type
= ADM5120_PROM_GENERIC
;
233 mips_machtype
= detect_machtype_generic();
237 mips_machtype
= MACH_ADM5120_GENERIC
;
240 /* TODO: this is an ugly hack for RouterBOARDS */
241 extern char _image_cmdline
;
242 static void __init
prom_init_cmdline(void)
246 /* init command line, register a default kernel command line */
247 cmd
= &_image_cmdline
+ 8;
248 if( strlen(cmd
) > 0) strcpy( &(arcs_cmdline
[0]), cmd
);
249 else strcpy(&(arcs_cmdline
[0]), CONFIG_CMDLINE
);
253 #define UART_READ(r) *(volatile u32 *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r))
254 #define UART_WRITE(r,v) *(volatile u32 *)(KSEG1ADDR(ADM5120_UART0_BASE)+(r))=(v)
256 void __init
prom_putchar(char ch
)
258 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
259 UART_WRITE(UART_REG_DATA
, ch
);
260 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
263 void __init
prom_init(void)
265 mips_machgroup
= MACH_GROUP_ADM5120
;
266 prom_detect_machtype();
271 void __init
prom_free_prom_memory(void)
273 /* We do not have to prom memory to free */