add initial 2.6.28 support for brcm47xx target
[openwrt.git] / target / linux / brcm47xx / patches-2.6.28 / 800-fix_cfe_detection.patch
1 diff --git a/arch/mips/bcm47xx/prom.c b/arch/mips/bcm47xx/prom.c
2 --- a/arch/mips/bcm47xx/prom.c
3 +++ b/arch/mips/bcm47xx/prom.c
4 @@ -32,6 +32,7 @@
5  #include <asm/fw/cfe/cfe_error.h>
6  
7  static int cfe_cons_handle;
8 +static void (* __prom_putchar)(char c);
9  
10  const char *get_system_type(void)
11  {
12 @@ -40,65 +41,40 @@ const char *get_system_type(void)
13  
14  void prom_putchar(char c)
15  {
16 +       if (__prom_putchar)
17 +               __prom_putchar(c);
18 +}
19 +
20 +void prom_putchar_cfe(char c)
21 +{
22         while (cfe_write(cfe_cons_handle, &c, 1) == 0)
23                 ;
24  }
25  
26 -static __init void prom_init_cfe(void)
27 +static __init int prom_init_cfe(void)
28  {
29         uint32_t cfe_ept;
30         uint32_t cfe_handle;
31         uint32_t cfe_eptseal;
32 -       int argc = fw_arg0;
33 -       char **envp = (char **) fw_arg2;
34 -       int *prom_vec = (int *) fw_arg3;
35  
36 -       /*
37 -        * Check if a loader was used; if NOT, the 4 arguments are
38 -        * what CFE gives us (handle, 0, EPT and EPTSEAL)
39 -        */
40 -       if (argc < 0) {
41 -               cfe_handle = (uint32_t)argc;
42 -               cfe_ept = (uint32_t)envp;
43 -               cfe_eptseal = (uint32_t)prom_vec;
44 -       } else {
45 -               if ((int)prom_vec < 0) {
46 -                       /*
47 -                        * Old loader; all it gives us is the handle,
48 -                        * so use the "known" entrypoint and assume
49 -                        * the seal.
50 -                        */
51 -                       cfe_handle = (uint32_t)prom_vec;
52 -                       cfe_ept = 0xBFC00500;
53 -                       cfe_eptseal = CFE_EPTSEAL;
54 -               } else {
55 -                       /*
56 -                        * Newer loaders bundle the handle/ept/eptseal
57 -                        * Note: prom_vec is in the loader's useg
58 -                        * which is still alive in the TLB.
59 -                        */
60 -                       cfe_handle = prom_vec[0];
61 -                       cfe_ept = prom_vec[2];
62 -                       cfe_eptseal = prom_vec[3];
63 -               }
64 -       }
65 +       cfe_eptseal = (uint32_t) fw_arg3;
66 +       cfe_handle = (uint32_t) fw_arg0;
67 +       cfe_ept = (uint32_t) fw_arg2;
68  
69 -       if (cfe_eptseal != CFE_EPTSEAL) {
70 -               /* too early for panic to do any good */
71 -               printk(KERN_ERR "CFE's entrypoint seal doesn't match.");
72 -               while (1) ;
73 -       }
74 +       if (cfe_eptseal != CFE_EPTSEAL)
75 +               return -1;
76  
77         cfe_init(cfe_handle, cfe_ept);
78 +       return 0;
79  }
80  
81 -static __init void prom_init_console(void)
82 +static __init void prom_init_console_cfe(void)
83  {
84         /* Initialize CFE console */
85         cfe_cons_handle = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE);
86  }
87  
88 -static __init void prom_init_cmdline(void)
89 +static __init void prom_init_cmdline_cfe(void)
90  {
91         char buf[CL_SIZE];
92  
93 @@ -146,9 +122,12 @@ static __init void prom_init_mem(void)
94  
95  void __init prom_init(void)
96  {
97 -       prom_init_cfe();
98 -       prom_init_console();
99 -       prom_init_cmdline();
100 +       if (prom_init_cfe() == 0) {
101 +               prom_init_console_cfe();
102 +               prom_init_cmdline_cfe();
103 +               __prom_putchar = prom_putchar_cfe;
104 +       }
105 +
106         prom_init_mem();
107  }
108