diff options
author | Steven J. Hill <Steven.Hill@imgtec.com> | 2013-03-25 15:47:05 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2013-05-08 06:30:09 -0400 |
commit | b431f09d552cc85b19ee1d029eb1d3a992b73166 (patch) | |
tree | 004295e9c6dd55bf0164d1ddd48474642ac012a0 /arch/mips/mti-malta/malta-init.c | |
parent | 0be2abbceeb837bf938c85db03142b5b0e4675f4 (diff) |
MIPS: FW: malta: Use new common FW library variable processing.
Remove old YAMON prom code and use common firmware library code.
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Diffstat (limited to 'arch/mips/mti-malta/malta-init.c')
-rw-r--r-- | arch/mips/mti-malta/malta-init.c | 94 |
1 files changed, 6 insertions, 88 deletions
diff --git a/arch/mips/mti-malta/malta-init.c b/arch/mips/mti-malta/malta-init.c index c2cbce9e435e..9caadce48bfe 100644 --- a/arch/mips/mti-malta/malta-init.c +++ b/arch/mips/mti-malta/malta-init.c | |||
@@ -23,13 +23,12 @@ | |||
23 | #include <linux/string.h> | 23 | #include <linux/string.h> |
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | 25 | ||
26 | #include <asm/bootinfo.h> | ||
27 | #include <asm/gt64120.h> | 26 | #include <asm/gt64120.h> |
28 | #include <asm/io.h> | 27 | #include <asm/io.h> |
29 | #include <asm/cacheflush.h> | 28 | #include <asm/cacheflush.h> |
30 | #include <asm/smp-ops.h> | 29 | #include <asm/smp-ops.h> |
31 | #include <asm/traps.h> | 30 | #include <asm/traps.h> |
32 | 31 | #include <asm/fw/fw.h> | |
33 | #include <asm/gcmpregs.h> | 32 | #include <asm/gcmpregs.h> |
34 | #include <asm/mips-boards/prom.h> | 33 | #include <asm/mips-boards/prom.h> |
35 | #include <asm/mips-boards/generic.h> | 34 | #include <asm/mips-boards/generic.h> |
@@ -38,15 +37,6 @@ | |||
38 | 37 | ||
39 | #include <asm/mips-boards/malta.h> | 38 | #include <asm/mips-boards/malta.h> |
40 | 39 | ||
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; | 40 | int init_debug; |
51 | 41 | ||
52 | static int mips_revision_corid; | 42 | static int mips_revision_corid; |
@@ -62,74 +52,6 @@ unsigned long _pcictrl_gt64120; | |||
62 | /* MIPS System controller register base */ | 52 | /* MIPS System controller register base */ |
63 | unsigned long _pcictrl_msc; | 53 | unsigned long _pcictrl_msc; |
64 | 54 | ||
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 | 55 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
134 | static void __init console_config(void) | 56 | static void __init console_config(void) |
135 | { | 57 | { |
@@ -138,8 +60,8 @@ static void __init console_config(void) | |||
138 | char parity = '\0', bits = '\0', flow = '\0'; | 60 | char parity = '\0', bits = '\0', flow = '\0'; |
139 | char *s; | 61 | char *s; |
140 | 62 | ||
141 | if ((strstr(prom_getcmdline(), "console=")) == NULL) { | 63 | if ((strstr(fw_getcmdline(), "console=")) == NULL) { |
142 | s = prom_getenv("modetty0"); | 64 | s = fw_getenv("modetty0"); |
143 | if (s) { | 65 | if (s) { |
144 | while (*s >= '0' && *s <= '9') | 66 | while (*s >= '0' && *s <= '9') |
145 | baud = baud*10 + *s++ - '0'; | 67 | baud = baud*10 + *s++ - '0'; |
@@ -159,7 +81,7 @@ static void __init console_config(void) | |||
159 | if (flow == '\0') | 81 | if (flow == '\0') |
160 | flow = 'r'; | 82 | flow = 'r'; |
161 | sprintf(console_string, " console=ttyS0,%d%c%c%c", baud, parity, bits, flow); | 83 | sprintf(console_string, " console=ttyS0,%d%c%c%c", baud, parity, bits, flow); |
162 | strcat(prom_getcmdline(), console_string); | 84 | strcat(fw_getcmdline(), console_string); |
163 | pr_info("Config serial console:%s\n", console_string); | 85 | pr_info("Config serial console:%s\n", console_string); |
164 | } | 86 | } |
165 | } | 87 | } |
@@ -193,10 +115,6 @@ extern struct plat_smp_ops msmtc_smp_ops; | |||
193 | 115 | ||
194 | void __init prom_init(void) | 116 | void __init prom_init(void) |
195 | { | 117 | { |
196 | prom_argc = fw_arg0; | ||
197 | _prom_argv = (int *) fw_arg1; | ||
198 | _prom_envp = (int *) fw_arg2; | ||
199 | |||
200 | mips_display_message("LINUX"); | 118 | mips_display_message("LINUX"); |
201 | 119 | ||
202 | /* | 120 | /* |
@@ -353,8 +271,8 @@ void __init prom_init(void) | |||
353 | board_nmi_handler_setup = mips_nmi_setup; | 271 | board_nmi_handler_setup = mips_nmi_setup; |
354 | board_ejtag_handler_setup = mips_ejtag_setup; | 272 | board_ejtag_handler_setup = mips_ejtag_setup; |
355 | 273 | ||
356 | prom_init_cmdline(); | 274 | fw_init_cmdline(); |
357 | prom_meminit(); | 275 | fw_meminit(); |
358 | #ifdef CONFIG_SERIAL_8250_CONSOLE | 276 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
359 | console_config(); | 277 | console_config(); |
360 | #endif | 278 | #endif |