Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / arch / mips / sgi-ip32 / ip32-setup.c
blob1024bf40bd9e79f1c63dd79f7be8289371e89caf
1 /*
2 * IP32 basic setup
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
8 * Copyright (C) 2000 Harald Koerfgen
9 * Copyright (C) 2002, 2003, 2005 Ilya A. Volynets
10 * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
12 #include <linux/console.h>
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/mc146818rtc.h>
16 #include <linux/param.h>
17 #include <linux/sched.h>
19 #include <asm/bootinfo.h>
20 #include <asm/mc146818-time.h>
21 #include <asm/mipsregs.h>
22 #include <asm/mmu_context.h>
23 #include <asm/sgialib.h>
24 #include <asm/time.h>
25 #include <asm/traps.h>
26 #include <asm/io.h>
27 #include <asm/ip32/crime.h>
28 #include <asm/ip32/mace.h>
29 #include <asm/ip32/ip32_ints.h>
31 extern void ip32_be_init(void);
32 extern void crime_init(void);
34 #ifdef CONFIG_SGI_O2MACE_ETH
36 * This is taken care of in here 'cause they say using Arc later on is
37 * problematic
39 extern char o2meth_eaddr[8];
40 static inline unsigned char str2hexnum(unsigned char c)
42 if (c >= '0' && c <= '9')
43 return c - '0';
44 if (c >= 'a' && c <= 'f')
45 return c - 'a' + 10;
46 return 0; /* foo */
49 static inline void str2eaddr(unsigned char *ea, unsigned char *str)
51 int i;
53 for (i = 0; i < 6; i++) {
54 unsigned char num;
56 if(*str == ':')
57 str++;
58 num = str2hexnum(*str++) << 4;
59 num |= (str2hexnum(*str++));
60 ea[i] = num;
63 #endif
65 unsigned long read_persistent_clock(void)
67 return mc146818_get_cmos_time();
70 /* An arbitrary time; this can be decreased if reliability looks good */
71 #define WAIT_MS 10
73 void __init plat_time_init(void)
75 printk(KERN_INFO "Calibrating system timer... ");
76 write_c0_count(0);
77 crime->timer = 0;
78 while (crime->timer < CRIME_MASTER_FREQ * WAIT_MS / 1000) ;
79 mips_hpt_frequency = read_c0_count() * 1000 / WAIT_MS;
80 printk("%d MHz CPU detected\n", mips_hpt_frequency * 2 / 1000000);
83 void __init plat_mem_setup(void)
85 board_be_init = ip32_be_init;
87 #ifdef CONFIG_SGI_O2MACE_ETH
89 char *mac = ArcGetEnvironmentVariable("eaddr");
90 str2eaddr(o2meth_eaddr, mac);
92 #endif
94 #if defined(CONFIG_SERIAL_CORE_CONSOLE)
96 char* con = ArcGetEnvironmentVariable("console");
97 if (con && *con == 'd') {
98 static char options[8];
99 char *baud = ArcGetEnvironmentVariable("dbaud");
100 if (baud)
101 strcpy(options, baud);
102 add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
103 baud ? options : NULL);
106 #endif