diff options
Diffstat (limited to 'arch/mips/mti-sead3/sead3-init.c')
-rw-r--r-- | arch/mips/mti-sead3/sead3-init.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/arch/mips/mti-sead3/sead3-init.c b/arch/mips/mti-sead3/sead3-init.c new file mode 100644 index 000000000000..a958cad6fff6 --- /dev/null +++ b/arch/mips/mti-sead3/sead3-init.c | |||
@@ -0,0 +1,91 @@ | |||
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. | ||
5 | * | ||
6 | * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. | ||
7 | */ | ||
8 | #include <linux/init.h> | ||
9 | #include <linux/io.h> | ||
10 | |||
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> | ||
16 | |||
17 | extern void prom_init_early_console(char port); | ||
18 | |||
19 | extern char except_vec_nmi; | ||
20 | extern char except_vec_ejtag_debug; | ||
21 | |||
22 | int prom_argc; | ||
23 | int *_prom_argv, *_prom_envp; | ||
24 | |||
25 | #define prom_envp(index) ((char *)(long)_prom_envp[(index)]) | ||
26 | |||
27 | char *prom_getenv(char *envname) | ||
28 | { | ||
29 | /* | ||
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. | ||
34 | */ | ||
35 | int i, index = 0; | ||
36 | |||
37 | i = strlen(envname); | ||
38 | |||
39 | while (prom_envp(index)) { | ||
40 | if (strncmp(envname, prom_envp(index), i) == 0) | ||
41 | return prom_envp(index+1); | ||
42 | index += 2; | ||
43 | } | ||
44 | |||
45 | return NULL; | ||
46 | } | ||
47 | |||
48 | static void __init mips_nmi_setup(void) | ||
49 | { | ||
50 | void *base; | ||
51 | |||
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); | ||
57 | } | ||
58 | |||
59 | static void __init mips_ejtag_setup(void) | ||
60 | { | ||
61 | void *base; | ||
62 | |||
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); | ||
68 | } | ||
69 | |||
70 | void __init prom_init(void) | ||
71 | { | ||
72 | prom_argc = fw_arg0; | ||
73 | _prom_argv = (int *) fw_arg1; | ||
74 | _prom_envp = (int *) fw_arg2; | ||
75 | |||
76 | board_nmi_handler_setup = mips_nmi_setup; | ||
77 | board_ejtag_handler_setup = mips_ejtag_setup; | ||
78 | |||
79 | prom_init_cmdline(); | ||
80 | prom_meminit(); | ||
81 | #ifdef CONFIG_EARLY_PRINTK | ||
82 | if ((strstr(prom_getcmdline(), "console=ttyS0")) != NULL) | ||
83 | prom_init_early_console(0); | ||
84 | else if ((strstr(prom_getcmdline(), "console=ttyS1")) != NULL) | ||
85 | prom_init_early_console(1); | ||
86 | #endif | ||
87 | #ifdef CONFIG_SERIAL_8250_CONSOLE | ||
88 | if ((strstr(prom_getcmdline(), "console=")) == NULL) | ||
89 | strcat(prom_getcmdline(), " console=ttyS0,38400n8r"); | ||
90 | #endif | ||
91 | } | ||