Merge git://git.infradead.org/users/willy/linux-nvme
[linux/fpc-iii.git] / arch / mips / mti-sead3 / sead3-init.c
blobf95abaa1aa5db6a06b4d8b80696c99120ed48711
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 */
8 #include <linux/init.h>
9 #include <linux/io.h>
11 #include <asm/bootinfo.h>
12 #include <asm/cacheflush.h>
13 #include <asm/traps.h>
14 #include <asm/mips-boards/generic.h>
15 #include <asm/mips-boards/prom.h>
17 extern void prom_init_early_console(char port);
19 extern char except_vec_nmi;
20 extern char except_vec_ejtag_debug;
22 int prom_argc;
23 int *_prom_argv, *_prom_envp;
25 #define prom_envp(index) ((char *)(long)_prom_envp[(index)])
27 char *prom_getenv(char *envname)
30 * Return a pointer to the given environment variable.
31 * In 64-bit mode: we're using 64-bit pointers, but all pointers
32 * in the PROM structures are only 32-bit, so we need some
33 * workarounds, if we are running in 64-bit mode.
35 int i, index = 0;
37 i = strlen(envname);
39 while (prom_envp(index)) {
40 if (strncmp(envname, prom_envp(index), i) == 0)
41 return prom_envp(index+1);
42 index += 2;
45 return NULL;
48 static void __init mips_nmi_setup(void)
50 void *base;
52 base = cpu_has_veic ?
53 (void *)(CAC_BASE + 0xa80) :
54 (void *)(CAC_BASE + 0x380);
55 memcpy(base, &except_vec_nmi, 0x80);
56 flush_icache_range((unsigned long)base, (unsigned long)base + 0x80);
59 static void __init mips_ejtag_setup(void)
61 void *base;
63 base = cpu_has_veic ?
64 (void *)(CAC_BASE + 0xa00) :
65 (void *)(CAC_BASE + 0x300);
66 memcpy(base, &except_vec_ejtag_debug, 0x80);
67 flush_icache_range((unsigned long)base, (unsigned long)base + 0x80);
70 void __init prom_init(void)
72 prom_argc = fw_arg0;
73 _prom_argv = (int *) fw_arg1;
74 _prom_envp = (int *) fw_arg2;
76 board_nmi_handler_setup = mips_nmi_setup;
77 board_ejtag_handler_setup = mips_ejtag_setup;
79 prom_init_cmdline();
80 #ifdef CONFIG_EARLY_PRINTK
81 if ((strstr(prom_getcmdline(), "console=ttyS0")) != NULL)
82 prom_init_early_console(0);
83 else if ((strstr(prom_getcmdline(), "console=ttyS1")) != NULL)
84 prom_init_early_console(1);
85 #endif
86 #ifdef CONFIG_SERIAL_8250_CONSOLE
87 if ((strstr(prom_getcmdline(), "console=")) == NULL)
88 strcat(prom_getcmdline(), " console=ttyS0,38400n8r");
89 #endif
92 void prom_free_prom_memory(void)