allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / mips / momentum / ocelot_3 / prom.c
blob8e02df63578a6fd547fb0fd76c7626b4ecd418de
1 /*
2 * Copyright 2002 Momentum Computer Inc.
3 * Author: Matthew Dharm <mdharm@momenco.com>
5 * Louis Hamilton, Red Hat, Inc.
6 * hamilton@redhat.com [MIPS64 modifications]
8 * Copyright 2004 PMC-Sierra
9 * Author: Manish Lachwani (lachwani@pmc-sierra.com)
11 * Based on Ocelot Linux port, which is
12 * Copyright 2001 MontaVista Software Inc.
13 * Author: jsun@mvista.com or jsun@junsun.net
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.
20 * Copyright (C) 2004 MontaVista Software Inc.
21 * Author: Manish Lachwani, mlachwani@mvista.com
24 #include <linux/init.h>
25 #include <linux/bootmem.h>
26 #include <linux/mv643xx.h>
28 #include <asm/addrspace.h>
29 #include <asm/bootinfo.h>
30 #include <asm/pmon.h>
31 #include "ocelot_3_fpga.h"
33 struct callvectors* debug_vectors;
34 extern unsigned long marvell_base;
35 extern unsigned long cpu_clock;
37 const char *get_system_type(void)
39 return "Momentum Ocelot-3";
42 #ifdef CONFIG_64BIT
44 unsigned long signext(unsigned long addr)
46 addr &= 0xffffffff;
47 return (unsigned long)((int)addr);
50 void *get_arg(unsigned long args, int arc)
52 unsigned long ul;
53 unsigned char *puc, uc;
55 args += (arc * 4);
56 ul = (unsigned long)signext(args);
57 puc = (unsigned char *)ul;
58 if (puc == 0)
59 return (void *)0;
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;
84 char *arg64(unsigned long addrin, int arg_index)
86 unsigned long args;
87 char *p;
89 args = signext(addrin);
90 p = (char *)get_arg(args, arg_index);
92 return p;
94 #endif /* CONFIG_64BIT */
96 void __init prom_init(void)
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;
104 #ifdef CONFIG_64BIT
105 char *ptr;
106 printk("prom_init - MIPS64\n");
108 /* save the PROM vectors for debugging use */
109 debug_vectors = (struct callvectors *)signext((unsigned long)cv);
111 /* arg[0] is "g", the rest is boot parameters */
112 arcs_cmdline[0] = '\0';
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, " ");
122 i = 0;
124 while (1) {
125 ptr = (char *)arg64((unsigned long)env, i);
126 if (! ptr)
127 break;
129 if (strncmp("gtbase", ptr, strlen("gtbase")) == 0) {
130 marvell_base = simple_strtol(ptr + strlen("gtbase="),
131 NULL, 16);
133 if ((marvell_base & 0xffffffff00000000) == 0)
134 marvell_base |= 0xffffffff00000000;
136 printk("marvell_base set to 0x%016lx\n", marvell_base);
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);
143 i++;
145 printk("arcs_cmdline: %s\n", arcs_cmdline);
147 #else /* CONFIG_64BIT */
149 /* save the PROM vectors for debugging use */
150 debug_vectors = cv;
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, " ");
162 while (*env) {
163 if (strncmp("gtbase", *env, strlen("gtbase")) == 0) {
164 marvell_base = simple_strtol(*env + strlen("gtbase="),
165 NULL, 16);
167 if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0) {
168 cpu_clock = simple_strtol(*env + strlen("cpuclock="),
169 NULL, 10);
171 env++;
173 #endif /* CONFIG_64BIT */
175 mips_machgroup = MACH_GROUP_MOMENCO;
176 mips_machtype = MACH_MOMENCO_OCELOT_3;
178 #ifndef CONFIG_64BIT
179 debug_vectors->printf("Booting Linux kernel...\n");
180 #endif
183 void __init prom_free_prom_memory(void)
187 void __init prom_fixup_mem_map(unsigned long start, unsigned long end)