aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorSteven J. Hill <Steven.Hill@imgtec.com>2013-03-25 15:47:05 -0400
committerRalf Baechle <ralf@linux-mips.org>2013-05-08 06:30:09 -0400
commitb431f09d552cc85b19ee1d029eb1d3a992b73166 (patch)
tree004295e9c6dd55bf0164d1ddd48474642ac012a0 /arch/mips
parent0be2abbceeb837bf938c85db03142b5b0e4675f4 (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')
-rw-r--r--arch/mips/mti-malta/Makefile5
-rw-r--r--arch/mips/mti-malta/malta-cmdline.c59
-rw-r--r--arch/mips/mti-malta/malta-init.c94
-rw-r--r--arch/mips/mti-malta/malta-memory.c60
-rw-r--r--arch/mips/mti-malta/malta-setup.c9
5 files changed, 28 insertions, 199 deletions
diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
index 6079ef33b5f0..0388fc8b5613 100644
--- a/arch/mips/mti-malta/Makefile
+++ b/arch/mips/mti-malta/Makefile
@@ -5,9 +5,8 @@
5# Copyright (C) 2008 Wind River Systems, Inc. 5# Copyright (C) 2008 Wind River Systems, Inc.
6# written by Ralf Baechle <ralf@linux-mips.org> 6# written by Ralf Baechle <ralf@linux-mips.org>
7# 7#
8obj-y := malta-amon.o malta-cmdline.o \ 8obj-y := malta-amon.o malta-display.o malta-init.o \
9 malta-display.o malta-init.o malta-int.o \ 9 malta-int.o malta-memory.o malta-platform.o \
10 malta-memory.o malta-platform.o \
11 malta-reset.o malta-setup.o malta-time.o 10 malta-reset.o malta-setup.o malta-time.o
12 11
13obj-$(CONFIG_EARLY_PRINTK) += malta-console.o 12obj-$(CONFIG_EARLY_PRINTK) += malta-console.o
diff --git a/arch/mips/mti-malta/malta-cmdline.c b/arch/mips/mti-malta/malta-cmdline.c
deleted file mode 100644
index 5576a306a145..000000000000
--- a/arch/mips/mti-malta/malta-cmdline.c
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * Kernel command line creation using the prom monitor (YAMON) argc/argv.
19 */
20#include <linux/init.h>
21#include <linux/string.h>
22
23#include <asm/bootinfo.h>
24
25extern int prom_argc;
26extern int *_prom_argv;
27
28/*
29 * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer.
30 * This macro take care of sign extension.
31 */
32#define prom_argv(index) ((char *)(long)_prom_argv[(index)])
33
34char * __init prom_getcmdline(void)
35{
36 return &(arcs_cmdline[0]);
37}
38
39
40void __init prom_init_cmdline(void)
41{
42 char *cp;
43 int actr;
44
45 actr = 1; /* Always ignore argv[0] */
46
47 cp = &(arcs_cmdline[0]);
48 while(actr < prom_argc) {
49 strcpy(cp, prom_argv(actr));
50 cp += strlen(prom_argv(actr));
51 *cp++ = ' ';
52 actr++;
53 }
54 if (cp != &(arcs_cmdline[0])) {
55 /* get rid of trailing space */
56 --cp;
57 *cp = '\0';
58 }
59}
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
41int prom_argc;
42int *_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
50int init_debug; 40int init_debug;
51 41
52static int mips_revision_corid; 42static int mips_revision_corid;
@@ -62,74 +52,6 @@ unsigned long _pcictrl_gt64120;
62/* MIPS System controller register base */ 52/* MIPS System controller register base */
63unsigned long _pcictrl_msc; 53unsigned long _pcictrl_msc;
64 54
65char *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
87static 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
96static 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
111int 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
134static void __init console_config(void) 56static 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
194void __init prom_init(void) 116void __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
diff --git a/arch/mips/mti-malta/malta-memory.c b/arch/mips/mti-malta/malta-memory.c
index f3d43aa023a9..aacc79602fdd 100644
--- a/arch/mips/mti-malta/malta-memory.c
+++ b/arch/mips/mti-malta/malta-memory.c
@@ -27,30 +27,16 @@
27#include <asm/bootinfo.h> 27#include <asm/bootinfo.h>
28#include <asm/page.h> 28#include <asm/page.h>
29#include <asm/sections.h> 29#include <asm/sections.h>
30#include <asm/fw/fw.h>
30 31
31#include <asm/mips-boards/prom.h> 32#include <asm/mips-boards/prom.h>
32 33
33/*#define DEBUG*/ 34static fw_memblock_t mdesc[FW_MAX_MEMBLOCKS];
34
35enum yamon_memtypes {
36 yamon_dontuse,
37 yamon_prom,
38 yamon_free,
39};
40static struct prom_pmemblock mdesc[PROM_MAX_PMEMBLOCKS];
41
42#ifdef DEBUG
43static char *mtypes[3] = {
44 "Dont use memory",
45 "YAMON PROM memory",
46 "Free memory",
47};
48#endif
49 35
50/* determined physical memory size, not overridden by command line args */ 36/* determined physical memory size, not overridden by command line args */
51unsigned long physical_memsize = 0L; 37unsigned long physical_memsize = 0L;
52 38
53static struct prom_pmemblock * __init prom_getmdesc(void) 39fw_memblock_t * __init fw_getmdesc(void)
54{ 40{
55 char *memsize_str; 41 char *memsize_str;
56 unsigned int memsize; 42 unsigned int memsize;
@@ -58,15 +44,12 @@ static struct prom_pmemblock * __init prom_getmdesc(void)
58 static char cmdline[COMMAND_LINE_SIZE] __initdata; 44 static char cmdline[COMMAND_LINE_SIZE] __initdata;
59 45
60 /* otherwise look in the environment */ 46 /* otherwise look in the environment */
61 memsize_str = prom_getenv("memsize"); 47 memsize_str = fw_getenv("memsize");
62 if (!memsize_str) { 48 if (!memsize_str) {
63 printk(KERN_WARNING 49 printk(KERN_WARNING
64 "memsize not set in boot prom, set to default (32Mb)\n"); 50 "memsize not set in boot prom, set to default (32Mb)\n");
65 physical_memsize = 0x02000000; 51 physical_memsize = 0x02000000;
66 } else { 52 } else {
67#ifdef DEBUG
68 pr_debug("prom_memsize = %s\n", memsize_str);
69#endif
70 physical_memsize = simple_strtol(memsize_str, NULL, 0); 53 physical_memsize = simple_strtol(memsize_str, NULL, 0);
71 } 54 }
72 55
@@ -90,11 +73,11 @@ static struct prom_pmemblock * __init prom_getmdesc(void)
90 73
91 memset(mdesc, 0, sizeof(mdesc)); 74 memset(mdesc, 0, sizeof(mdesc));
92 75
93 mdesc[0].type = yamon_dontuse; 76 mdesc[0].type = fw_dontuse;
94 mdesc[0].base = 0x00000000; 77 mdesc[0].base = 0x00000000;
95 mdesc[0].size = 0x00001000; 78 mdesc[0].size = 0x00001000;
96 79
97 mdesc[1].type = yamon_prom; 80 mdesc[1].type = fw_code;
98 mdesc[1].base = 0x00001000; 81 mdesc[1].base = 0x00001000;
99 mdesc[1].size = 0x000ef000; 82 mdesc[1].size = 0x000ef000;
100 83
@@ -105,55 +88,44 @@ static struct prom_pmemblock * __init prom_getmdesc(void)
105 * This mean that this area can't be used as DMA memory for PCI 88 * This mean that this area can't be used as DMA memory for PCI
106 * devices. 89 * devices.
107 */ 90 */
108 mdesc[2].type = yamon_dontuse; 91 mdesc[2].type = fw_dontuse;
109 mdesc[2].base = 0x000f0000; 92 mdesc[2].base = 0x000f0000;
110 mdesc[2].size = 0x00010000; 93 mdesc[2].size = 0x00010000;
111 94
112 mdesc[3].type = yamon_dontuse; 95 mdesc[3].type = fw_dontuse;
113 mdesc[3].base = 0x00100000; 96 mdesc[3].base = 0x00100000;
114 mdesc[3].size = CPHYSADDR(PFN_ALIGN((unsigned long)&_end)) - mdesc[3].base; 97 mdesc[3].size = CPHYSADDR(PFN_ALIGN((unsigned long)&_end)) - mdesc[3].base;
115 98
116 mdesc[4].type = yamon_free; 99 mdesc[4].type = fw_free;
117 mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end)); 100 mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end));
118 mdesc[4].size = memsize - mdesc[4].base; 101 mdesc[4].size = memsize - mdesc[4].base;
119 102
120 return &mdesc[0]; 103 return &mdesc[0];
121} 104}
122 105
123static int __init prom_memtype_classify(unsigned int type) 106static int __init fw_memtype_classify(unsigned int type)
124{ 107{
125 switch (type) { 108 switch (type) {
126 case yamon_free: 109 case fw_free:
127 return BOOT_MEM_RAM; 110 return BOOT_MEM_RAM;
128 case yamon_prom: 111 case fw_code:
129 return BOOT_MEM_ROM_DATA; 112 return BOOT_MEM_ROM_DATA;
130 default: 113 default:
131 return BOOT_MEM_RESERVED; 114 return BOOT_MEM_RESERVED;
132 } 115 }
133} 116}
134 117
135void __init prom_meminit(void) 118void __init fw_meminit(void)
136{ 119{
137 struct prom_pmemblock *p; 120 fw_memblock_t *p;
138 121
139#ifdef DEBUG 122 p = fw_getmdesc();
140 pr_debug("YAMON MEMORY DESCRIPTOR dump:\n");
141 p = prom_getmdesc();
142 while (p->size) {
143 int i = 0;
144 pr_debug("[%d,%p]: base<%08lx> size<%08lx> type<%s>\n",
145 i, p, p->base, p->size, mtypes[p->type]);
146 p++;
147 i++;
148 }
149#endif
150 p = prom_getmdesc();
151 123
152 while (p->size) { 124 while (p->size) {
153 long type; 125 long type;
154 unsigned long base, size; 126 unsigned long base, size;
155 127
156 type = prom_memtype_classify(p->type); 128 type = fw_memtype_classify(p->type);
157 base = p->base; 129 base = p->base;
158 size = p->size; 130 size = p->size;
159 131
diff --git a/arch/mips/mti-malta/malta-setup.c b/arch/mips/mti-malta/malta-setup.c
index a85557171faa..9e3937602571 100644
--- a/arch/mips/mti-malta/malta-setup.c
+++ b/arch/mips/mti-malta/malta-setup.c
@@ -25,9 +25,8 @@
25#include <linux/screen_info.h> 25#include <linux/screen_info.h>
26#include <linux/time.h> 26#include <linux/time.h>
27 27
28#include <asm/bootinfo.h> 28#include <asm/fw/fw.h>
29#include <asm/mips-boards/generic.h> 29#include <asm/mips-boards/generic.h>
30#include <asm/mips-boards/prom.h>
31#include <asm/mips-boards/malta.h> 30#include <asm/mips-boards/malta.h>
32#include <asm/mips-boards/maltaint.h> 31#include <asm/mips-boards/maltaint.h>
33#include <asm/dma.h> 32#include <asm/dma.h>
@@ -176,7 +175,7 @@ static void __init pci_clock_check(void)
176 33, 20, 25, 30, 12, 16, 37, 10 175 33, 20, 25, 30, 12, 16, 37, 10
177 }; 176 };
178 int pciclock = pciclocks[jmpr]; 177 int pciclock = pciclocks[jmpr];
179 char *argptr = prom_getcmdline(); 178 char *argptr = fw_getcmdline();
180 179
181 if (pciclock != 33 && !strstr(argptr, "idebus=")) { 180 if (pciclock != 33 && !strstr(argptr, "idebus=")) {
182 printk(KERN_WARNING "WARNING: PCI clock is %dMHz, " 181 printk(KERN_WARNING "WARNING: PCI clock is %dMHz, "
@@ -214,7 +213,7 @@ static void __init bonito_quirks_setup(void)
214{ 213{
215 char *argptr; 214 char *argptr;
216 215
217 argptr = prom_getcmdline(); 216 argptr = fw_getcmdline();
218 if (strstr(argptr, "debug")) { 217 if (strstr(argptr, "debug")) {
219 BONITO_BONGENCFG |= BONITO_BONGENCFG_DEBUGMODE; 218 BONITO_BONGENCFG |= BONITO_BONGENCFG_DEBUGMODE;
220 printk(KERN_INFO "Enabled Bonito debug mode\n"); 219 printk(KERN_INFO "Enabled Bonito debug mode\n");
@@ -226,7 +225,7 @@ static void __init bonito_quirks_setup(void)
226 BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN; 225 BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN;
227 printk(KERN_INFO "Enabled Bonito CPU coherency\n"); 226 printk(KERN_INFO "Enabled Bonito CPU coherency\n");
228 227
229 argptr = prom_getcmdline(); 228 argptr = fw_getcmdline();
230 if (strstr(argptr, "iobcuncached")) { 229 if (strstr(argptr, "iobcuncached")) {
231 BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN; 230 BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN;
232 BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG & 231 BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG &