2 * Copyright (C) 2007 OpenWrt.org
3 * Copyright (C) Gabor Juhos
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
11 #include <linux/types.h>
12 #include <linux/autoconf.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
16 #include <asm/bootinfo.h>
17 #include <asm/addrspace.h>
19 #include <adm5120_info.h>
22 /* boot loaders specific definitions */
23 #define CFE_EPTSEAL 0x43464531 /* CFE1 is the magic number to recognize CFE from other bootloaders */
26 struct adm5120_info adm5120_info
= {
27 .cpu_speed
= CPU_SPEED_175
,
28 .cpu_package
= CPU_PACKAGE_PQFP
,
29 .boot_loader
= BOOT_LOADER_UNKNOWN
,
30 .board_type
= BOARD_TYPE_UNKNOWN
33 static char *boot_loader_names
[BOOT_LOADER_LAST
+1] = {
34 [BOOT_LOADER_UNKNOWN
] = "Unknown",
35 [BOOT_LOADER_CFE
] = "CFE",
36 [BOOT_LOADER_UBOOT
] = "U-Boot",
37 [BOOT_LOADER_MYLOADER
] = "MyLoader"
41 * Boot loader detection routines
43 static int __init
detect_cfe(void)
46 * This method only works, when we are booted directly from the CFE.
48 uint32_t cfe_handle
= (uint32_t) fw_arg0
;
49 uint32_t cfe_a1_val
= (uint32_t) fw_arg1
;
50 uint32_t cfe_entry
= (uint32_t) fw_arg2
;
51 uint32_t cfe_seal
= (uint32_t) fw_arg3
;
53 /* Check for CFE by finding the CFE magic number */
54 if (cfe_seal
!= CFE_EPTSEAL
) {
55 /* We are not booted from CFE */
59 /* cfe_a1_val must be 0, because only one CPU present in the ADM5120 SoC */
60 if (cfe_a1_val
!= 0) {
64 /* The cfe_handle, and the cfe_entry must be kernel mode addresses */
65 if ((cfe_handle
< KSEG0
) || (cfe_entry
< KSEG0
)) {
72 static int __init
detect_uboot(void)
74 /* FIXME: not yet implemented */
78 static int __init
detect_myloader(void)
80 struct mylo_system_params
*sysp
;
81 struct mylo_board_params
*boardp
;
82 struct mylo_partition_table
*parts
;
84 sysp
= (struct mylo_system_params
*)(MYLO_MIPS_SYS_PARAMS
);
85 boardp
= (struct mylo_board_params
*)(MYLO_MIPS_BOARD_PARAMS
);
86 parts
= (struct mylo_partition_table
*)(MYLO_MIPS_PARTITIONS
);
88 /* Check for some magic numbers */
89 if ((sysp
->magic
!= MYLO_MAGIC_SYS_PARAMS
) ||
90 (boardp
->magic
!= MYLO_MAGIC_BOARD_PARAMS
) ||
91 (parts
->magic
!= MYLO_MAGIC_PARTITIONS
))
97 static int __init
detect_bootloader(void)
100 return BOOT_LOADER_CFE
;
103 return BOOT_LOADER_UBOOT
;
105 if (detect_myloader())
106 return BOOT_LOADER_MYLOADER
;
108 return BOOT_LOADER_UNKNOWN
;
111 void __init
adm5120_info_show(void)
113 printk("adm5120: boot loader is %s\n", boot_loader_names
[adm5120_info
.boot_loader
]);
116 void __init
adm5120_info_init(void)
118 adm5120_info
.boot_loader
= detect_bootloader();