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 long cpu_clock
;
34 #ifdef CONFIG_MV643XX_ETH
35 extern unsigned char prom_mac_addr_base
[6];
38 const char *get_system_type(void)
40 #ifdef CONFIG_CPU_SR71000
41 return "Momentum Ocelot-CS";
43 return "Momentum Ocelot-C";
47 #ifdef CONFIG_MV643XX_ETH
48 static void burn_clocks(void)
52 /* this loop should burn at least 1us -- this should be plenty */
53 for (i
= 0; i
< 0x10000; i
++)
57 static u8
exchange_bit(u8 val
, u8 cs
)
60 OCELOT_FPGA_WRITE((val
<< 2) | cs
, EEPROM_MODE
);
63 /* turn the clock on */
64 OCELOT_FPGA_WRITE((val
<< 2) | cs
| 0x2, EEPROM_MODE
);
67 /* turn the clock off and read-strobe */
68 OCELOT_FPGA_WRITE((val
<< 2) | cs
| 0x10, EEPROM_MODE
);
71 return ((OCELOT_FPGA_READ(EEPROM_MODE
) >> 3) & 0x1);
74 void get_mac(char dest
[6])
76 u8 read_opcode
[12] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
79 for (i
= 0; i
< 12; i
++)
80 exchange_bit(read_opcode
[i
], 1);
82 for (j
= 0; j
< 6; j
++) {
84 for (i
= 0; i
< 8; i
++) {
86 dest
[j
] |= exchange_bit(0, 1);
98 unsigned long signext(unsigned long addr
)
101 return (unsigned long)((int)addr
);
104 void *get_arg(unsigned long args
, int arc
)
107 unsigned char *puc
, uc
;
110 ul
= (unsigned long)signext(args
);
111 puc
= (unsigned char *)ul
;
115 #ifdef CONFIG_CPU_LITTLE_ENDIAN
117 ul
= (unsigned long)uc
;
119 ul
|= (((unsigned long)uc
) << 8);
121 ul
|= (((unsigned long)uc
) << 16);
123 ul
|= (((unsigned long)uc
) << 24);
124 #else /* CONFIG_CPU_LITTLE_ENDIAN */
126 ul
= ((unsigned long)uc
) << 24;
128 ul
|= (((unsigned long)uc
) << 16);
130 ul
|= (((unsigned long)uc
) << 8);
132 ul
|= ((unsigned long)uc
);
133 #endif /* CONFIG_CPU_LITTLE_ENDIAN */
138 char *arg64(unsigned long addrin
, int arg_index
)
142 args
= signext(addrin
);
143 p
= (char *)get_arg(args
, arg_index
);
146 #endif /* CONFIG_64BIT */
149 void __init
prom_init(void)
152 char **arg
= (char **) fw_arg1
;
153 char **env
= (char **) fw_arg2
;
154 struct callvectors
*cv
= (struct callvectors
*) fw_arg3
;
160 printk("prom_init - MIPS64\n");
161 /* save the PROM vectors for debugging use */
162 debug_vectors
= (struct callvectors
*)signext((unsigned long)cv
);
164 /* arg[0] is "g", the rest is boot parameters */
165 arcs_cmdline
[0] = '\0';
167 for (i
= 1; i
< argc
; i
++) {
168 ptr
= (char *)arg64((unsigned long)arg
, i
);
169 if ((strlen(arcs_cmdline
) + strlen(ptr
) + 1) >=
170 sizeof(arcs_cmdline
))
172 strcat(arcs_cmdline
, ptr
);
173 strcat(arcs_cmdline
, " ");
177 ptr
= (char *)arg64((unsigned long)env
, i
);
181 if (strncmp("gtbase", ptr
, strlen("gtbase")) == 0) {
182 marvell_base
= simple_strtol(ptr
+ strlen("gtbase="),
185 if ((marvell_base
& 0xffffffff00000000) == 0)
186 marvell_base
|= 0xffffffff00000000;
188 printk("marvell_base set to 0x%016lx\n", marvell_base
);
190 if (strncmp("cpuclock", ptr
, strlen("cpuclock")) == 0) {
191 cpu_clock
= simple_strtol(ptr
+ strlen("cpuclock="),
193 printk("cpu_clock set to %d\n", cpu_clock
);
197 printk("arcs_cmdline: %s\n", arcs_cmdline
);
199 #else /* CONFIG_64BIT */
200 /* save the PROM vectors for debugging use */
203 /* arg[0] is "g", the rest is boot parameters */
204 arcs_cmdline
[0] = '\0';
205 for (i
= 1; i
< argc
; i
++) {
206 if (strlen(arcs_cmdline
) + strlen(arg
[i
] + 1)
207 >= sizeof(arcs_cmdline
))
209 strcat(arcs_cmdline
, arg
[i
]);
210 strcat(arcs_cmdline
, " ");
214 if (strncmp("gtbase", *env
, strlen("gtbase")) == 0) {
215 marvell_base
= simple_strtol(*env
+ strlen("gtbase="),
218 if (strncmp("cpuclock", *env
, strlen("cpuclock")) == 0) {
219 cpu_clock
= simple_strtol(*env
+ strlen("cpuclock="),
224 #endif /* CONFIG_64BIT */
226 mips_machgroup
= MACH_GROUP_MOMENCO
;
227 mips_machtype
= MACH_MOMENCO_OCELOT_C
;
229 #ifdef CONFIG_MV643XX_ETH
230 /* get the base MAC address for on-board ethernet ports */
231 get_mac(prom_mac_addr_base
);
235 debug_vectors
->printf("Booting Linux kernel...\n");
239 unsigned long __init
prom_free_prom_memory(void)