ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / momentum / ocelot_g / prom.c
1 /*
2  * Copyright 2002 Momentum Computer Inc.
3  * Author: Matthew Dharm <mdharm@momenco.com>
4  *
5  * Based on Ocelot Linux port, which is
6  * Copyright 2001 MontaVista Software Inc.
7  * Author: jsun@mvista.com or jsun@junsun.net
8  *
9  * This program is free software; you can redistribute  it and/or modify it
10  * under  the terms of  the GNU General  Public License as published by the
11  * Free Software Foundation;  either version 2 of the  License, or (at your
12  * option) any later version.
13  */
14 #include <linux/config.h>
15 #include <linux/init.h>
16 #include <linux/mm.h>
17 #include <linux/sched.h>
18 #include <linux/bootmem.h>
19
20 #include <asm/addrspace.h>
21 #include <asm/bootinfo.h>
22
23 #include "gt64240.h"
24 #include "ocelot_pld.h"
25
26 struct callvectors {
27         int     (*open) (char*, int, int);
28         int     (*close) (int);
29         int     (*read) (int, void*, int);
30         int     (*write) (int, void*, int);
31         off_t   (*lseek) (int, off_t, int);
32         int     (*printf) (const char*, ...);
33         void    (*cacheflush) (void);
34         char*   (*gets) (char*);
35 };
36
37 struct callvectors* debug_vectors;
38
39 extern unsigned long gt64240_base;
40 extern unsigned long bus_clock;
41
42 #ifdef CONFIG_GALILLEO_GT64240_ETH
43 extern unsigned char prom_mac_addr_base[6];
44 #endif
45
46 const char *get_system_type(void)
47 {
48         return "Momentum Ocelot";
49 }
50
51 /* [jsun@junsun.net] PMON passes arguments in C main() style */
52 void __init prom_init(void)
53 {
54         uint32_t tmp;
55         int argc = fw_arg0;
56         char **arg = (char **) fw_arg1;
57         char **env = (char **) fw_arg2;
58         struct callvectors *cv = (struct callvectors *) fw_arg3;
59         int i;
60
61         /* save the PROM vectors for debugging use */
62         debug_vectors = cv;
63
64         /* arg[0] is "g", the rest is boot parameters */
65         arcs_cmdline[0] = '\0';
66         for (i = 1; i < argc; i++) {
67                 if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
68                     >= sizeof(arcs_cmdline))
69                         break;
70                 strcat(arcs_cmdline, arg[i]);
71                 strcat(arcs_cmdline, " ");
72         }
73
74         mips_machgroup = MACH_GROUP_MOMENCO;
75         mips_machtype = MACH_MOMENCO_OCELOT_G;
76
77 #ifdef CONFIG_GALILLEO_GT64240_ETH
78         /* get the base MAC address for on-board ethernet ports */
79         memcpy(prom_mac_addr_base, (void*)0xfc807cf2, 6);
80 #endif
81
82         while (*env) {
83                 if (strncmp("gtbase", *env, strlen("gtbase")) == 0) {
84                         gt64240_base = simple_strtol(*env + strlen("gtbase="),
85                                                         NULL, 16);
86                 }
87                 if (strncmp("busclock", *env, strlen("busclock")) == 0) {
88                         bus_clock = simple_strtol(*env + strlen("busclock="),
89                                                         NULL, 10);
90                 }
91                 *env++;
92         }
93
94         debug_vectors->printf("Booting Linux kernel...\n");
95 }
96
97 unsigned long __init prom_free_prom_memory(void)
98 {
99         return 0;
100 }