Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * IP32 basic setup
0003  *
0004  * This file is subject to the terms and conditions of the GNU General Public
0005  * License.  See the file "COPYING" in the main directory of this archive
0006  * for more details.
0007  *
0008  * Copyright (C) 2000 Harald Koerfgen
0009  * Copyright (C) 2002, 2003, 2005 Ilya A. Volynets
0010  * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
0011  */
0012 #include <linux/console.h>
0013 #include <linux/init.h>
0014 #include <linux/interrupt.h>
0015 #include <linux/param.h>
0016 #include <linux/sched.h>
0017 
0018 #include <asm/bootinfo.h>
0019 #include <asm/mipsregs.h>
0020 #include <asm/mmu_context.h>
0021 #include <asm/sgialib.h>
0022 #include <asm/time.h>
0023 #include <asm/traps.h>
0024 #include <asm/io.h>
0025 #include <asm/ip32/crime.h>
0026 #include <asm/ip32/mace.h>
0027 #include <asm/ip32/ip32_ints.h>
0028 
0029 extern void ip32_be_init(void);
0030 extern void crime_init(void);
0031 
0032 #ifdef CONFIG_SGI_O2MACE_ETH
0033 /*
0034  * This is taken care of in here 'cause they say using Arc later on is
0035  * problematic
0036  */
0037 extern char o2meth_eaddr[8];
0038 static inline unsigned char str2hexnum(unsigned char c)
0039 {
0040     if (c >= '0' && c <= '9')
0041         return c - '0';
0042     if (c >= 'a' && c <= 'f')
0043         return c - 'a' + 10;
0044     return 0; /* foo */
0045 }
0046 
0047 static inline void str2eaddr(unsigned char *ea, unsigned char *str)
0048 {
0049     int i;
0050 
0051     for (i = 0; i < 6; i++) {
0052         unsigned char num;
0053 
0054         if(*str == ':')
0055             str++;
0056         num = str2hexnum(*str++) << 4;
0057         num |= (str2hexnum(*str++));
0058         ea[i] = num;
0059     }
0060 }
0061 #endif
0062 
0063 /* An arbitrary time; this can be decreased if reliability looks good */
0064 #define WAIT_MS 10
0065 
0066 void __init plat_time_init(void)
0067 {
0068     printk(KERN_INFO "Calibrating system timer... ");
0069     write_c0_count(0);
0070     crime->timer = 0;
0071     while (crime->timer < CRIME_MASTER_FREQ * WAIT_MS / 1000) ;
0072     mips_hpt_frequency = read_c0_count() * 1000 / WAIT_MS;
0073     printk("%d MHz CPU detected\n", mips_hpt_frequency * 2 / 1000000);
0074 }
0075 
0076 void __init plat_mem_setup(void)
0077 {
0078     board_be_init = ip32_be_init;
0079 
0080 #ifdef CONFIG_SGI_O2MACE_ETH
0081     {
0082         char *mac = ArcGetEnvironmentVariable("eaddr");
0083         str2eaddr(o2meth_eaddr, mac);
0084     }
0085 #endif
0086 
0087 #if defined(CONFIG_SERIAL_CORE_CONSOLE)
0088     {
0089         char* con = ArcGetEnvironmentVariable("console");
0090         if (con && *con == 'd') {
0091             static char options[8] __initdata;
0092             char *baud = ArcGetEnvironmentVariable("dbaud");
0093             if (baud)
0094                 strcpy(options, baud);
0095             add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
0096                           baud ? options : NULL);
0097         }
0098     }
0099 #endif
0100 }