4 * Copyright (C) 2007 OpenWrt.org
5 * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
6 * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <linux/types.h>
15 #include <linux/autoconf.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/module.h>
20 #include <asm/bootinfo.h>
21 #include <asm/addrspace.h>
22 #include <asm/string.h>
23 #include <asm/mach-bcm963xx/bootloaders.h>
25 static char *boot_loader_names[BOOT_LOADER_LAST+1] = {
26 [BOOT_LOADER_UNKNOWN] = "Unknown",
27 [BOOT_LOADER_CFE] = "CFE",
28 [BOOT_LOADER_REDBOOT] = "RedBoot",
29 [BOOT_LOADER_CFE2] = "CFEv2"
32 /* boot loaders specific definitions */
33 #define CFE_EPTSEAL 0x43464531 /* CFE1 is the magic number to recognize CFE from other bootloaders */
37 * Boot loader detection routines
39 static int __init detect_cfe(void)
42 * This method only works, when we are booted directly from the CFE.
44 uint32_t cfe_handle = (uint32_t) fw_arg0;
45 uint32_t cfe_a1_val = (uint32_t) fw_arg1;
46 uint32_t cfe_entry = (uint32_t) fw_arg2;
47 uint32_t cfe_seal = (uint32_t) fw_arg3;
49 /* Check for CFE by finding the CFE magic number */
50 if (cfe_seal != CFE_EPTSEAL)
51 /* We are not booted from CFE */
54 /* cfe_a1_val must be 0, because only one CPU present in the ADM5120 SoC */
58 /* The cfe_handle, and the cfe_entry must be kernel mode addresses */
59 if ((cfe_handle < KSEG0) || (cfe_entry < KSEG0))
65 static int __init detect_redboot(void)
67 /* On Inventel Livebox, the boot loader is passed as a command line argument, check for it */
68 if (!strncmp(arcs_cmdline, "boot_loader=RedBoot", 19))
73 void __init detect_bootloader(void)
76 boot_loader_type = BOOT_LOADER_CFE;
79 if (detect_redboot()) {
80 boot_loader_type = BOOT_LOADER_REDBOOT;
83 /* Some devices are using CFE, but it is not detected as is */
84 boot_loader_type = BOOT_LOADER_CFE2;
86 printk("Boot loader is : %s\n", boot_loader_names[boot_loader_type]);
89 void __init detect_board(void)
91 switch (boot_loader_type)
95 case BOOT_LOADER_REDBOOT:
102 EXPORT_SYMBOL(boot_loader_type);