diff options
Diffstat (limited to 'arch/mips/mti-malta/malta-init.c')
-rw-r--r-- | arch/mips/mti-malta/malta-init.c | 153 |
1 files changed, 31 insertions, 122 deletions
diff --git a/arch/mips/mti-malta/malta-init.c b/arch/mips/mti-malta/malta-init.c index c2cbce9e435e..ff8caffd3266 100644 --- a/arch/mips/mti-malta/malta-init.c +++ b/arch/mips/mti-malta/malta-init.c | |||
@@ -1,54 +1,28 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 1999, 2000, 2004, 2005 MIPS Technologies, Inc. | 2 | * This file is subject to the terms and conditions of the GNU General Public |
3 | * All rights reserved. | 3 | * License. See the file "COPYING" in the main directory of this archive |
4 | * Authors: Carsten Langgaard <carstenl@mips.com> | 4 | * for more details. |
5 | * Maciej W. Rozycki <macro@mips.com> | ||
6 | * | ||
7 | * This program is free software; you can distribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License (Version 2) as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
14 | * for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
19 | * | 5 | * |
20 | * PROM library initialisation code. | 6 | * PROM library initialisation code. |
7 | * | ||
8 | * Copyright (C) 1999,2000,2004,2005,2012 MIPS Technologies, Inc. | ||
9 | * All rights reserved. | ||
10 | * Authors: Carsten Langgaard <carstenl@mips.com> | ||
11 | * Maciej W. Rozycki <macro@mips.com> | ||
12 | * Steven J. Hill <sjhill@mips.com> | ||
21 | */ | 13 | */ |
22 | #include <linux/init.h> | 14 | #include <linux/init.h> |
23 | #include <linux/string.h> | 15 | #include <linux/string.h> |
24 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
25 | 17 | ||
26 | #include <asm/bootinfo.h> | ||
27 | #include <asm/gt64120.h> | ||
28 | #include <asm/io.h> | ||
29 | #include <asm/cacheflush.h> | 18 | #include <asm/cacheflush.h> |
30 | #include <asm/smp-ops.h> | 19 | #include <asm/smp-ops.h> |
31 | #include <asm/traps.h> | 20 | #include <asm/traps.h> |
32 | 21 | #include <asm/fw/fw.h> | |
33 | #include <asm/gcmpregs.h> | 22 | #include <asm/gcmpregs.h> |
34 | #include <asm/mips-boards/prom.h> | ||
35 | #include <asm/mips-boards/generic.h> | 23 | #include <asm/mips-boards/generic.h> |
36 | #include <asm/mips-boards/bonito64.h> | ||
37 | #include <asm/mips-boards/msc01_pci.h> | ||
38 | |||
39 | #include <asm/mips-boards/malta.h> | 24 | #include <asm/mips-boards/malta.h> |
40 | 25 | ||
41 | int prom_argc; | ||
42 | int *_prom_argv, *_prom_envp; | ||
43 | |||
44 | /* | ||
45 | * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer. | ||
46 | * This macro take care of sign extension, if running in 64-bit mode. | ||
47 | */ | ||
48 | #define prom_envp(index) ((char *)(long)_prom_envp[(index)]) | ||
49 | |||
50 | int init_debug; | ||
51 | |||
52 | static int mips_revision_corid; | 26 | static int mips_revision_corid; |
53 | int mips_revision_sconid; | 27 | int mips_revision_sconid; |
54 | 28 | ||
@@ -62,74 +36,6 @@ unsigned long _pcictrl_gt64120; | |||
62 | /* MIPS System controller register base */ | 36 | /* MIPS System controller register base */ |
63 | unsigned long _pcictrl_msc; | 37 | unsigned long _pcictrl_msc; |
64 | 38 | ||
65 | char *prom_getenv(char *envname) | ||
66 | { | ||
67 | /* | ||
68 | * Return a pointer to the given environment variable. | ||
69 | * In 64-bit mode: we're using 64-bit pointers, but all pointers | ||
70 | * in the PROM structures are only 32-bit, so we need some | ||
71 | * workarounds, if we are running in 64-bit mode. | ||
72 | */ | ||
73 | int i, index=0; | ||
74 | |||
75 | i = strlen(envname); | ||
76 | |||
77 | while (prom_envp(index)) { | ||
78 | if(strncmp(envname, prom_envp(index), i) == 0) { | ||
79 | return(prom_envp(index+1)); | ||
80 | } | ||
81 | index += 2; | ||
82 | } | ||
83 | |||
84 | return NULL; | ||
85 | } | ||
86 | |||
87 | static inline unsigned char str2hexnum(unsigned char c) | ||
88 | { | ||
89 | if (c >= '0' && c <= '9') | ||
90 | return c - '0'; | ||
91 | if (c >= 'a' && c <= 'f') | ||
92 | return c - 'a' + 10; | ||
93 | return 0; /* foo */ | ||
94 | } | ||
95 | |||
96 | static inline void str2eaddr(unsigned char *ea, unsigned char *str) | ||
97 | { | ||
98 | int i; | ||
99 | |||
100 | for (i = 0; i < 6; i++) { | ||
101 | unsigned char num; | ||
102 | |||
103 | if((*str == '.') || (*str == ':')) | ||
104 | str++; | ||
105 | num = str2hexnum(*str++) << 4; | ||
106 | num |= (str2hexnum(*str++)); | ||
107 | ea[i] = num; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | int get_ethernet_addr(char *ethernet_addr) | ||
112 | { | ||
113 | char *ethaddr_str; | ||
114 | |||
115 | ethaddr_str = prom_getenv("ethaddr"); | ||
116 | if (!ethaddr_str) { | ||
117 | printk("ethaddr not set in boot prom\n"); | ||
118 | return -1; | ||
119 | } | ||
120 | str2eaddr(ethernet_addr, ethaddr_str); | ||
121 | |||
122 | if (init_debug > 1) { | ||
123 | int i; | ||
124 | printk("get_ethernet_addr: "); | ||
125 | for (i=0; i<5; i++) | ||
126 | printk("%02x:", (unsigned char)*(ethernet_addr+i)); | ||
127 | printk("%02x\n", *(ethernet_addr+i)); | ||
128 | } | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | #ifdef CONFIG_SERIAL_8250_CONSOLE | 39 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
134 | static void __init console_config(void) | 40 | static void __init console_config(void) |
135 | { | 41 | { |
@@ -138,17 +44,23 @@ static void __init console_config(void) | |||
138 | char parity = '\0', bits = '\0', flow = '\0'; | 44 | char parity = '\0', bits = '\0', flow = '\0'; |
139 | char *s; | 45 | char *s; |
140 | 46 | ||
141 | if ((strstr(prom_getcmdline(), "console=")) == NULL) { | 47 | if ((strstr(fw_getcmdline(), "console=")) == NULL) { |
142 | s = prom_getenv("modetty0"); | 48 | s = fw_getenv("modetty0"); |
143 | if (s) { | 49 | if (s) { |
144 | while (*s >= '0' && *s <= '9') | 50 | while (*s >= '0' && *s <= '9') |
145 | baud = baud*10 + *s++ - '0'; | 51 | baud = baud*10 + *s++ - '0'; |
146 | if (*s == ',') s++; | 52 | if (*s == ',') |
147 | if (*s) parity = *s++; | 53 | s++; |
148 | if (*s == ',') s++; | 54 | if (*s) |
149 | if (*s) bits = *s++; | 55 | parity = *s++; |
150 | if (*s == ',') s++; | 56 | if (*s == ',') |
151 | if (*s == 'h') flow = 'r'; | 57 | s++; |
58 | if (*s) | ||
59 | bits = *s++; | ||
60 | if (*s == ',') | ||
61 | s++; | ||
62 | if (*s == 'h') | ||
63 | flow = 'r'; | ||
152 | } | 64 | } |
153 | if (baud == 0) | 65 | if (baud == 0) |
154 | baud = 38400; | 66 | baud = 38400; |
@@ -158,8 +70,9 @@ static void __init console_config(void) | |||
158 | bits = '8'; | 70 | bits = '8'; |
159 | if (flow == '\0') | 71 | if (flow == '\0') |
160 | flow = 'r'; | 72 | flow = 'r'; |
161 | sprintf(console_string, " console=ttyS0,%d%c%c%c", baud, parity, bits, flow); | 73 | sprintf(console_string, " console=ttyS0,%d%c%c%c", baud, |
162 | strcat(prom_getcmdline(), console_string); | 74 | parity, bits, flow); |
75 | strcat(fw_getcmdline(), console_string); | ||
163 | pr_info("Config serial console:%s\n", console_string); | 76 | pr_info("Config serial console:%s\n", console_string); |
164 | } | 77 | } |
165 | } | 78 | } |
@@ -193,10 +106,6 @@ extern struct plat_smp_ops msmtc_smp_ops; | |||
193 | 106 | ||
194 | void __init prom_init(void) | 107 | void __init prom_init(void) |
195 | { | 108 | { |
196 | prom_argc = fw_arg0; | ||
197 | _prom_argv = (int *) fw_arg1; | ||
198 | _prom_envp = (int *) fw_arg2; | ||
199 | |||
200 | mips_display_message("LINUX"); | 109 | mips_display_message("LINUX"); |
201 | 110 | ||
202 | /* | 111 | /* |
@@ -306,7 +215,7 @@ void __init prom_init(void) | |||
306 | case MIPS_REVISION_SCON_SOCIT: | 215 | case MIPS_REVISION_SCON_SOCIT: |
307 | case MIPS_REVISION_SCON_ROCIT: | 216 | case MIPS_REVISION_SCON_ROCIT: |
308 | _pcictrl_msc = (unsigned long)ioremap(MIPS_MSC01_PCI_REG_BASE, 0x2000); | 217 | _pcictrl_msc = (unsigned long)ioremap(MIPS_MSC01_PCI_REG_BASE, 0x2000); |
309 | mips_pci_controller: | 218 | mips_pci_controller: |
310 | mb(); | 219 | mb(); |
311 | MSC_READ(MSC01_PCI_CFG, data); | 220 | MSC_READ(MSC01_PCI_CFG, data); |
312 | MSC_WRITE(MSC01_PCI_CFG, data & ~MSC01_PCI_CFG_EN_BIT); | 221 | MSC_WRITE(MSC01_PCI_CFG, data & ~MSC01_PCI_CFG_EN_BIT); |
@@ -348,13 +257,13 @@ void __init prom_init(void) | |||
348 | default: | 257 | default: |
349 | /* Unknown system controller */ | 258 | /* Unknown system controller */ |
350 | mips_display_message("SC Error"); | 259 | mips_display_message("SC Error"); |
351 | while (1); /* We die here... */ | 260 | while (1); /* We die here... */ |
352 | } | 261 | } |
353 | board_nmi_handler_setup = mips_nmi_setup; | 262 | board_nmi_handler_setup = mips_nmi_setup; |
354 | board_ejtag_handler_setup = mips_ejtag_setup; | 263 | board_ejtag_handler_setup = mips_ejtag_setup; |
355 | 264 | ||
356 | prom_init_cmdline(); | 265 | fw_init_cmdline(); |
357 | prom_meminit(); | 266 | fw_meminit(); |
358 | #ifdef CONFIG_SERIAL_8250_CONSOLE | 267 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
359 | console_config(); | 268 | console_config(); |
360 | #endif | 269 | #endif |