ACPI: sbs: probe smart battery vis SMBus controller
[pandora-kernel.git] / arch / mips / momentum / ocelot_3 / prom.c
1 /*
2  * Copyright 2002 Momentum Computer Inc.
3  * Author: Matthew Dharm <mdharm@momenco.com>
4  *
5  * Louis Hamilton, Red Hat, Inc.
6  *   hamilton@redhat.com  [MIPS64 modifications]
7  *
8  * Copyright 2004 PMC-Sierra
9  * Author: Manish Lachwani (lachwani@pmc-sierra.com)
10  *
11  * Based on Ocelot Linux port, which is
12  * Copyright 2001 MontaVista Software Inc.
13  * Author: jsun@mvista.com or jsun@junsun.net
14  *
15  * This program is free software; you can redistribute  it and/or modify it
16  * under  the terms of  the GNU General  Public License as published by the
17  * Free Software Foundation;  either version 2 of the  License, or (at your
18  * option) any later version.
19  *
20  * Copyright (C) 2004 MontaVista Software Inc.
21  * Author: Manish Lachwani, mlachwani@mvista.com
22  *
23  */
24 #include <linux/init.h>
25 #include <linux/bootmem.h>
26 #include <linux/mv643xx.h>
27
28 #include <asm/addrspace.h>
29 #include <asm/bootinfo.h>
30 #include <asm/pmon.h>
31 #include "ocelot_3_fpga.h"
32
33 struct callvectors* debug_vectors;
34 extern unsigned long marvell_base;
35 extern unsigned long cpu_clock;
36
37 const char *get_system_type(void)
38 {
39         return "Momentum Ocelot-3";
40 }
41
42 #ifdef CONFIG_64BIT
43
44 unsigned long signext(unsigned long addr)
45 {
46         addr &= 0xffffffff;
47         return (unsigned long)((int)addr);
48 }
49
50 void *get_arg(unsigned long args, int arc)
51 {
52         unsigned long ul;
53         unsigned char *puc, uc;
54
55         args += (arc * 4);
56         ul = (unsigned long)signext(args);
57         puc = (unsigned char *)ul;
58         if (puc == 0)
59                 return (void *)0;
60
61 #ifdef CONFIG_CPU_LITTLE_ENDIAN
62         uc = *puc++;
63         ul = (unsigned long)uc;
64         uc = *puc++;
65         ul |= (((unsigned long)uc) << 8);
66         uc = *puc++;
67         ul |= (((unsigned long)uc) << 16);
68         uc = *puc++;
69         ul |= (((unsigned long)uc) << 24);
70 #else  /* CONFIG_CPU_LITTLE_ENDIAN */
71         uc = *puc++;
72         ul = ((unsigned long)uc) << 24;
73         uc = *puc++;
74         ul |= (((unsigned long)uc) << 16);
75         uc = *puc++;
76         ul |= (((unsigned long)uc) << 8);
77         uc = *puc++;
78         ul |= ((unsigned long)uc);
79 #endif  /* CONFIG_CPU_LITTLE_ENDIAN */
80         ul = signext(ul);
81         return (void *)ul;
82 }
83
84 char *arg64(unsigned long addrin, int arg_index)
85 {
86         unsigned long args;
87         char *p;
88
89         args = signext(addrin);
90         p = (char *)get_arg(args, arg_index);
91
92         return p;
93 }
94 #endif  /* CONFIG_64BIT */
95
96 void __init prom_init(void)
97 {
98         int argc = fw_arg0;
99         char **arg = (char **) fw_arg1;
100         char **env = (char **) fw_arg2;
101         struct callvectors *cv = (struct callvectors *) fw_arg3;
102         int i;
103
104 #ifdef CONFIG_64BIT
105         char *ptr;
106         printk("prom_init - MIPS64\n");
107
108         /* save the PROM vectors for debugging use */
109         debug_vectors = (struct callvectors *)signext((unsigned long)cv);
110
111         /* arg[0] is "g", the rest is boot parameters */
112         arcs_cmdline[0] = '\0';
113
114         for (i = 1; i < argc; i++) {
115                 ptr = (char *)arg64((unsigned long)arg, i);
116                 if ((strlen(arcs_cmdline) + strlen(ptr) + 1) >=
117                     sizeof(arcs_cmdline))
118                         break;
119                 strcat(arcs_cmdline, ptr);
120                 strcat(arcs_cmdline, " ");
121         }
122         i = 0;
123
124         while (1) {
125                 ptr = (char *)arg64((unsigned long)env, i);
126                 if (! ptr)
127                         break;
128
129                 if (strncmp("gtbase", ptr, strlen("gtbase")) == 0) {
130                         marvell_base = simple_strtol(ptr + strlen("gtbase="),
131                                                         NULL, 16);
132
133                         if ((marvell_base & 0xffffffff00000000) == 0)
134                                 marvell_base |= 0xffffffff00000000;
135
136                         printk("marvell_base set to 0x%016lx\n", marvell_base);
137                 }
138                 if (strncmp("cpuclock", ptr, strlen("cpuclock")) == 0) {
139                         cpu_clock = simple_strtol(ptr + strlen("cpuclock="),
140                                                         NULL, 10);
141                         printk("cpu_clock set to %d\n", cpu_clock);
142                 }
143                 i++;
144         }
145         printk("arcs_cmdline: %s\n", arcs_cmdline);
146
147 #else   /* CONFIG_64BIT */
148
149         /* save the PROM vectors for debugging use */
150         debug_vectors = cv;
151
152         /* arg[0] is "g", the rest is boot parameters */
153         arcs_cmdline[0] = '\0';
154         for (i = 1; i < argc; i++) {
155                 if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
156                     >= sizeof(arcs_cmdline))
157                         break;
158                 strcat(arcs_cmdline, arg[i]);
159                 strcat(arcs_cmdline, " ");
160         }
161
162         while (*env) {
163                 if (strncmp("gtbase", *env, strlen("gtbase")) == 0) {
164                         marvell_base = simple_strtol(*env + strlen("gtbase="),
165                                                         NULL, 16);
166                 }
167                 if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0) {
168                         cpu_clock = simple_strtol(*env + strlen("cpuclock="),
169                                                         NULL, 10);
170                 }
171                 env++;
172         }
173 #endif /* CONFIG_64BIT */
174
175         mips_machgroup = MACH_GROUP_MOMENCO;
176         mips_machtype = MACH_MOMENCO_OCELOT_3;
177
178 #ifndef CONFIG_64BIT
179         debug_vectors->printf("Booting Linux kernel...\n");
180 #endif
181 }
182
183 void __init prom_free_prom_memory(void)
184 {
185 }
186
187 void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
188 {
189 }