[adm5120] license cleanup
[openwrt.git] / target / linux / adm5120 / files / arch / mips / adm5120 / prom / cfe.c
1 /*
2  *  $Id$
3  *
4  *  Broadcom's CFE specific prom routines
5  *
6  *  Copyright (C) 2007 OpenWrt.org
7  *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
8  *
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.
12  *
13  */
14
15 #include <linux/types.h>
16 #include <linux/init.h>
17
18 #include <asm/bootinfo.h>
19 #include <asm/addrspace.h>
20
21 #include <prom/cfe.h>
22 #include "prom_read.h"
23
24 /*
25  * CFE based boards
26  */
27 #define CFE_EPTSEAL     0x43464531 /* CFE1 is the magic number to recognize CFE
28 from other bootloaders */
29
30 static int cfe_found;
31
32 static u32 cfe_handle;
33 static u32 cfe_entry;
34 static u32 cfe_seal;
35
36 int __init cfe_present(void)
37 {
38         /*
39          * This method only works, when we are booted directly from the CFE.
40          */
41         u32 a1 = (u32) fw_arg1;
42
43         if (cfe_found)
44                 return 1;
45
46         cfe_handle = (u32) fw_arg0;
47         cfe_entry = (u32) fw_arg2;
48         cfe_seal = (u32) fw_arg3;
49
50         /* Check for CFE by finding the CFE magic number */
51         if (cfe_seal != CFE_EPTSEAL)
52                 return 0;
53
54         /* cfe_a1_val must be 0, because only one CPU present in the ADM5120 */
55         if (a1 != 0)
56                 return 0;
57
58         /* The cfe_handle, and the cfe_entry must be kernel mode addresses */
59         if ((cfe_handle < KSEG0) || (cfe_entry < KSEG0))
60                 return 0;
61
62         cfe_found = 1;
63         return 1;
64 }
65
66 char *cfe_getenv(char *envname)
67 {
68         if (cfe_found == 0)
69                 return NULL;
70
71         return NULL;
72 }