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 * Based on Ocelot Linux port, which is
9 * Copyright 2001 MontaVista Software Inc.
10 * Author: jsun@mvista.com or jsun@junsun.net
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
17 #include <linux/init.h>
19 #include <linux/sched.h>
20 #include <linux/bootmem.h>
21 #include <linux/mv643xx.h>
23 #include <asm/addrspace.h>
24 #include <asm/bootinfo.h>
27 #include "ocelot_c_fpga.h"
29 struct callvectors* debug_vectors;
31 extern unsigned long marvell_base;
32 extern unsigned int cpu_clock;
34 const char *get_system_type(void)
36 #ifdef CONFIG_CPU_SR71000
37 return "Momentum Ocelot-CS";
39 return "Momentum Ocelot-C";
45 unsigned long signext(unsigned long addr)
48 return (unsigned long)((int)addr);
51 void *get_arg(unsigned long args, int arc)
54 unsigned char *puc, uc;
57 ul = (unsigned long)signext(args);
58 puc = (unsigned char *)ul;
62 #ifdef CONFIG_CPU_LITTLE_ENDIAN
64 ul = (unsigned long)uc;
66 ul |= (((unsigned long)uc) << 8);
68 ul |= (((unsigned long)uc) << 16);
70 ul |= (((unsigned long)uc) << 24);
71 #else /* CONFIG_CPU_LITTLE_ENDIAN */
73 ul = ((unsigned long)uc) << 24;
75 ul |= (((unsigned long)uc) << 16);
77 ul |= (((unsigned long)uc) << 8);
79 ul |= ((unsigned long)uc);
80 #endif /* CONFIG_CPU_LITTLE_ENDIAN */
85 char *arg64(unsigned long addrin, int arg_index)
89 args = signext(addrin);
90 p = (char *)get_arg(args, arg_index);
93 #endif /* CONFIG_64BIT */
96 void __init prom_init(void)
99 char **arg = (char **) fw_arg1;
100 char **env = (char **) fw_arg2;
101 struct callvectors *cv = (struct callvectors *) fw_arg3;
107 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))
119 strcat(arcs_cmdline, ptr);
120 strcat(arcs_cmdline, " ");
124 ptr = (char *)arg64((unsigned long)env, i);
128 if (strncmp("gtbase", ptr, strlen("gtbase")) == 0) {
129 marvell_base = simple_strtol(ptr + strlen("gtbase="),
132 if ((marvell_base & 0xffffffff00000000) == 0)
133 marvell_base |= 0xffffffff00000000;
135 printk("marvell_base set to 0x%016lx\n", marvell_base);
137 if (strncmp("cpuclock", ptr, strlen("cpuclock")) == 0) {
138 cpu_clock = simple_strtol(ptr + strlen("cpuclock="),
140 printk("cpu_clock set to %d\n", cpu_clock);
144 printk("arcs_cmdline: %s\n", arcs_cmdline);
146 #else /* CONFIG_64BIT */
147 /* save the PROM vectors for debugging use */
150 /* arg[0] is "g", the rest is boot parameters */
151 arcs_cmdline[0] = '\0';
152 for (i = 1; i < argc; i++) {
153 if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
154 >= sizeof(arcs_cmdline))
156 strcat(arcs_cmdline, arg[i]);
157 strcat(arcs_cmdline, " ");
161 if (strncmp("gtbase", *env, strlen("gtbase")) == 0) {
162 marvell_base = simple_strtol(*env + strlen("gtbase="),
165 if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0) {
166 cpu_clock = simple_strtol(*env + strlen("cpuclock="),
171 #endif /* CONFIG_64BIT */
173 mips_machgroup = MACH_GROUP_MOMENCO;
174 mips_machtype = MACH_MOMENCO_OCELOT_C;
177 debug_vectors->printf("Booting Linux kernel...\n");
181 unsigned long __init prom_free_prom_memory(void)