diff options
Diffstat (limited to 'arch/mips/galileo-boards/ev96100/init.c')
-rw-r--r-- | arch/mips/galileo-boards/ev96100/init.c | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/arch/mips/galileo-boards/ev96100/init.c b/arch/mips/galileo-boards/ev96100/init.c new file mode 100644 index 000000000000..a01fe9b36f2c --- /dev/null +++ b/arch/mips/galileo-boards/ev96100/init.c | |||
@@ -0,0 +1,173 @@ | |||
1 | /* | ||
2 | * Copyright 2000 MontaVista Software Inc. | ||
3 | * Author: MontaVista Software, Inc. | ||
4 | * ppopov@mvista.com or source@mvista.com | ||
5 | * | ||
6 | * This file was derived from Carsten Langgaard's | ||
7 | * arch/mips/mips-boards/generic/generic.c | ||
8 | * | ||
9 | * Carsten Langgaard, carstenl@mips.com | ||
10 | * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
20 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
23 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
24 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | * | ||
28 | * You should have received a copy of the GNU General Public License along | ||
29 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
30 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
31 | */ | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/mm.h> | ||
34 | #include <linux/sched.h> | ||
35 | #include <linux/bootmem.h> | ||
36 | #include <linux/string.h> | ||
37 | #include <linux/kernel.h> | ||
38 | |||
39 | #include <asm/addrspace.h> | ||
40 | #include <asm/bootinfo.h> | ||
41 | #include <asm/gt64120.h> | ||
42 | |||
43 | |||
44 | /* Environment variable */ | ||
45 | |||
46 | typedef struct { | ||
47 | char *name; | ||
48 | char *val; | ||
49 | } t_env_var; | ||
50 | |||
51 | int prom_argc; | ||
52 | char **prom_argv, **prom_envp; | ||
53 | |||
54 | int init_debug = 0; | ||
55 | |||
56 | char * __init prom_getcmdline(void) | ||
57 | { | ||
58 | return &(arcs_cmdline[0]); | ||
59 | } | ||
60 | |||
61 | unsigned long __init prom_free_prom_memory(void) | ||
62 | { | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | void __init prom_init_cmdline(void) | ||
67 | { | ||
68 | char *cp; | ||
69 | int actr; | ||
70 | |||
71 | actr = 1; /* Always ignore argv[0] */ | ||
72 | |||
73 | cp = &(arcs_cmdline[0]); | ||
74 | while(actr < prom_argc) { | ||
75 | strcpy(cp, prom_argv[actr]); | ||
76 | cp += strlen(prom_argv[actr]); | ||
77 | *cp++ = ' '; | ||
78 | actr++; | ||
79 | } | ||
80 | if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */ | ||
81 | --cp; | ||
82 | *cp = '\0'; | ||
83 | } | ||
84 | |||
85 | char *prom_getenv(char *envname) | ||
86 | { | ||
87 | /* | ||
88 | * Return a pointer to the given environment variable. | ||
89 | */ | ||
90 | |||
91 | t_env_var *env = (t_env_var *) prom_envp; | ||
92 | int i; | ||
93 | |||
94 | i = strlen(envname); | ||
95 | |||
96 | while (env->name) { | ||
97 | if (strncmp(envname, env->name, i) == 0) { | ||
98 | return (env->val); | ||
99 | } | ||
100 | env++; | ||
101 | } | ||
102 | return (NULL); | ||
103 | } | ||
104 | |||
105 | static inline unsigned char str2hexnum(unsigned char c) | ||
106 | { | ||
107 | if (c >= '0' && c <= '9') | ||
108 | return c - '0'; | ||
109 | if (c >= 'a' && c <= 'f') | ||
110 | return c - 'a' + 10; | ||
111 | return 0; /* foo */ | ||
112 | } | ||
113 | |||
114 | static inline void str2eaddr(unsigned char *ea, unsigned char *str) | ||
115 | { | ||
116 | int i; | ||
117 | |||
118 | for (i = 0; i < 6; i++) { | ||
119 | unsigned char num; | ||
120 | |||
121 | if ((*str == '.') || (*str == ':')) | ||
122 | str++; | ||
123 | num = str2hexnum(*str++) << 4; | ||
124 | num |= (str2hexnum(*str++)); | ||
125 | ea[i] = num; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | int get_ethernet_addr(char *ethernet_addr) | ||
130 | { | ||
131 | char *ethaddr_str; | ||
132 | |||
133 | ethaddr_str = prom_getenv("ethaddr"); | ||
134 | if (!ethaddr_str) { | ||
135 | printk("ethaddr not set in boot prom\n"); | ||
136 | return -1; | ||
137 | } | ||
138 | str2eaddr(ethernet_addr, ethaddr_str); | ||
139 | |||
140 | if (init_debug > 1) { | ||
141 | int i; | ||
142 | printk("get_ethernet_addr: "); | ||
143 | for (i = 0; i < 5; i++) | ||
144 | printk("%02x:", | ||
145 | (unsigned char) *(ethernet_addr + i)); | ||
146 | printk("%02x\n", *(ethernet_addr + i)); | ||
147 | } | ||
148 | |||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | const char *get_system_type(void) | ||
153 | { | ||
154 | return "Galileo EV96100"; | ||
155 | } | ||
156 | |||
157 | void __init prom_init(void) | ||
158 | { | ||
159 | volatile unsigned char *uart; | ||
160 | char ppbuf[8]; | ||
161 | |||
162 | prom_argc = fw_arg0; | ||
163 | prom_argv = (char **) fw_arg1; | ||
164 | prom_envp = (char **) fw_arg2; | ||
165 | |||
166 | mips_machgroup = MACH_GROUP_GALILEO; | ||
167 | mips_machtype = MACH_EV96100; | ||
168 | |||
169 | prom_init_cmdline(); | ||
170 | |||
171 | /* 32 MB upgradable */ | ||
172 | add_memory_region(0, 32 << 20, BOOT_MEM_RAM); | ||
173 | } | ||