Linux 2.6.17.7
[linux/fpc-iii.git] / arch / mips / galileo-boards / ev96100 / init.c
bloba01fe9b36f2c58c1d292663af3f8c1dd199249b6
1 /*
2 * Copyright 2000 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc.
4 * ppopov@mvista.com or source@mvista.com
6 * This file was derived from Carsten Langgaard's
7 * arch/mips/mips-boards/generic/generic.c
9 * Carsten Langgaard, carstenl@mips.com
10 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
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 * 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.
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.
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>
39 #include <asm/addrspace.h>
40 #include <asm/bootinfo.h>
41 #include <asm/gt64120.h>
44 /* Environment variable */
46 typedef struct {
47 char *name;
48 char *val;
49 } t_env_var;
51 int prom_argc;
52 char **prom_argv, **prom_envp;
54 int init_debug = 0;
56 char * __init prom_getcmdline(void)
58 return &(arcs_cmdline[0]);
61 unsigned long __init prom_free_prom_memory(void)
63 return 0;
66 void __init prom_init_cmdline(void)
68 char *cp;
69 int actr;
71 actr = 1; /* Always ignore argv[0] */
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++;
80 if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
81 --cp;
82 *cp = '\0';
85 char *prom_getenv(char *envname)
88 * Return a pointer to the given environment variable.
91 t_env_var *env = (t_env_var *) prom_envp;
92 int i;
94 i = strlen(envname);
96 while (env->name) {
97 if (strncmp(envname, env->name, i) == 0) {
98 return (env->val);
100 env++;
102 return (NULL);
105 static inline unsigned char str2hexnum(unsigned char c)
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 */
114 static inline void str2eaddr(unsigned char *ea, unsigned char *str)
116 int i;
118 for (i = 0; i < 6; i++) {
119 unsigned char num;
121 if ((*str == '.') || (*str == ':'))
122 str++;
123 num = str2hexnum(*str++) << 4;
124 num |= (str2hexnum(*str++));
125 ea[i] = num;
129 int get_ethernet_addr(char *ethernet_addr)
131 char *ethaddr_str;
133 ethaddr_str = prom_getenv("ethaddr");
134 if (!ethaddr_str) {
135 printk("ethaddr not set in boot prom\n");
136 return -1;
138 str2eaddr(ethernet_addr, ethaddr_str);
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));
149 return 0;
152 const char *get_system_type(void)
154 return "Galileo EV96100";
157 void __init prom_init(void)
159 volatile unsigned char *uart;
160 char ppbuf[8];
162 prom_argc = fw_arg0;
163 prom_argv = (char **) fw_arg1;
164 prom_envp = (char **) fw_arg2;
166 mips_machgroup = MACH_GROUP_GALILEO;
167 mips_machtype = MACH_EV96100;
169 prom_init_cmdline();
171 /* 32 MB upgradable */
172 add_memory_region(0, 32 << 20, BOOT_MEM_RAM);