diff options
Diffstat (limited to 'arch/mips/powertv/init.c')
-rw-r--r-- | arch/mips/powertv/init.c | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/arch/mips/powertv/init.c b/arch/mips/powertv/init.c new file mode 100644 index 000000000000..5f4e4c304e48 --- /dev/null +++ b/arch/mips/powertv/init.c | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1999, 2000, 2004, 2005 MIPS Technologies, Inc. | ||
3 | * All rights reserved. | ||
4 | * Authors: Carsten Langgaard <carstenl@mips.com> | ||
5 | * Maciej W. Rozycki <macro@mips.com> | ||
6 | * Portions copyright (C) 2009 Cisco Systems, Inc. | ||
7 | * | ||
8 | * This program is free software; you can distribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License (Version 2) as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
15 | * for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License along | ||
18 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
20 | * | ||
21 | * PROM library initialisation code. | ||
22 | */ | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/string.h> | ||
25 | #include <linux/kernel.h> | ||
26 | |||
27 | #include <asm/bootinfo.h> | ||
28 | #include <linux/io.h> | ||
29 | #include <asm/system.h> | ||
30 | #include <asm/cacheflush.h> | ||
31 | #include <asm/traps.h> | ||
32 | |||
33 | #include <asm/mips-boards/prom.h> | ||
34 | #include <asm/mips-boards/generic.h> | ||
35 | #include <asm/mach-powertv/asic.h> | ||
36 | |||
37 | #include "init.h" | ||
38 | |||
39 | int prom_argc; | ||
40 | int *_prom_argv, *_prom_envp; | ||
41 | unsigned long _prom_memsize; | ||
42 | |||
43 | /* | ||
44 | * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer. | ||
45 | * This macro take care of sign extension, if running in 64-bit mode. | ||
46 | */ | ||
47 | #define prom_envp(index) ((char *)(long)_prom_envp[(index)]) | ||
48 | |||
49 | char *prom_getenv(char *envname) | ||
50 | { | ||
51 | char *result = NULL; | ||
52 | |||
53 | if (_prom_envp != NULL) { | ||
54 | /* | ||
55 | * Return a pointer to the given environment variable. | ||
56 | * In 64-bit mode: we're using 64-bit pointers, but all pointers | ||
57 | * in the PROM structures are only 32-bit, so we need some | ||
58 | * workarounds, if we are running in 64-bit mode. | ||
59 | */ | ||
60 | int i, index = 0; | ||
61 | |||
62 | i = strlen(envname); | ||
63 | |||
64 | while (prom_envp(index)) { | ||
65 | if (strncmp(envname, prom_envp(index), i) == 0) { | ||
66 | result = prom_envp(index + 1); | ||
67 | break; | ||
68 | } | ||
69 | index += 2; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | return result; | ||
74 | } | ||
75 | |||
76 | /* TODO: Verify on linux-mips mailing list that the following two */ | ||
77 | /* functions are correct */ | ||
78 | /* TODO: Copy NMI and EJTAG exception vectors to memory from the */ | ||
79 | /* BootROM exception vectors. Flush their cache entries. test it. */ | ||
80 | |||
81 | static void __init mips_nmi_setup(void) | ||
82 | { | ||
83 | void *base; | ||
84 | #if defined(CONFIG_CPU_MIPS32_R1) | ||
85 | base = cpu_has_veic ? | ||
86 | (void *)(CAC_BASE + 0xa80) : | ||
87 | (void *)(CAC_BASE + 0x380); | ||
88 | #elif defined(CONFIG_CPU_MIPS32_R2) | ||
89 | base = (void *)0xbfc00000; | ||
90 | #else | ||
91 | #error NMI exception handler address not defined | ||
92 | #endif | ||
93 | } | ||
94 | |||
95 | static void __init mips_ejtag_setup(void) | ||
96 | { | ||
97 | void *base; | ||
98 | |||
99 | #if defined(CONFIG_CPU_MIPS32_R1) | ||
100 | base = cpu_has_veic ? | ||
101 | (void *)(CAC_BASE + 0xa00) : | ||
102 | (void *)(CAC_BASE + 0x300); | ||
103 | #elif defined(CONFIG_CPU_MIPS32_R2) | ||
104 | base = (void *)0xbfc00480; | ||
105 | #else | ||
106 | #error EJTAG exception handler address not defined | ||
107 | #endif | ||
108 | } | ||
109 | |||
110 | void __init prom_init(void) | ||
111 | { | ||
112 | prom_argc = fw_arg0; | ||
113 | _prom_argv = (int *) fw_arg1; | ||
114 | _prom_envp = (int *) fw_arg2; | ||
115 | _prom_memsize = (unsigned long) fw_arg3; | ||
116 | |||
117 | board_nmi_handler_setup = mips_nmi_setup; | ||
118 | board_ejtag_handler_setup = mips_ejtag_setup; | ||
119 | |||
120 | pr_info("\nLINUX started...\n"); | ||
121 | prom_init_cmdline(); | ||
122 | configure_platform(); | ||
123 | prom_meminit(); | ||
124 | |||
125 | #ifndef CONFIG_BOOTLOADER_DRIVER | ||
126 | pr_info("\nBootloader driver isn't loaded...\n"); | ||
127 | #endif | ||
128 | } | ||