[ar7] resync kernel configuration
[openwrt.git] / target / linux / sibyte / patches / 002-sibyte_remove_standalone_support.patch
1 CFE is the only supported and used bootloader on the SiByte boards,
2 the standalone kernel support has been never used outside Broadcom.
3 Remove it and make the kernel use CFE by default.
4
5 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
6
7 --- a/arch/mips/Makefile
8 +++ b/arch/mips/Makefile
9 @@ -167,7 +167,6 @@ libs-$(CONFIG_ARC) += arch/mips/fw/arc/
10 libs-$(CONFIG_CFE) += arch/mips/fw/cfe/
11 libs-$(CONFIG_SNIPROM) += arch/mips/fw/sni/
12 libs-y += arch/mips/fw/lib/
13 -libs-$(CONFIG_SIBYTE_CFE) += arch/mips/sibyte/cfe/
14
15 #
16 # Board-dependent options and extra files
17 --- a/arch/mips/sibyte/cfe/console.c
18 +++ /dev/null
19 @@ -1,79 +0,0 @@
20 -#include <linux/init.h>
21 -#include <linux/errno.h>
22 -#include <linux/console.h>
23 -
24 -#include <asm/sibyte/board.h>
25 -
26 -#include <asm/fw/cfe/cfe_api.h>
27 -#include <asm/fw/cfe/cfe_error.h>
28 -
29 -extern int cfe_cons_handle;
30 -
31 -static void cfe_console_write(struct console *cons, const char *str,
32 - unsigned int count)
33 -{
34 - int i, last, written;
35 -
36 - for (i=0, last=0; i<count; i++) {
37 - if (!str[i])
38 - /* XXXKW can/should this ever happen? */
39 - return;
40 - if (str[i] == '\n') {
41 - do {
42 - written = cfe_write(cfe_cons_handle, &str[last], i-last);
43 - if (written < 0)
44 - ;
45 - last += written;
46 - } while (last < i);
47 - while (cfe_write(cfe_cons_handle, "\r", 1) <= 0)
48 - ;
49 - }
50 - }
51 - if (last != count) {
52 - do {
53 - written = cfe_write(cfe_cons_handle, &str[last], count-last);
54 - if (written < 0)
55 - ;
56 - last += written;
57 - } while (last < count);
58 - }
59 -
60 -}
61 -
62 -static int cfe_console_setup(struct console *cons, char *str)
63 -{
64 - char consdev[32];
65 - /* XXXKW think about interaction with 'console=' cmdline arg */
66 - /* If none of the console options are configured, the build will break. */
67 - if (cfe_getenv("BOOT_CONSOLE", consdev, 32) >= 0) {
68 -#ifdef CONFIG_SERIAL_SB1250_DUART
69 - if (!strcmp(consdev, "uart0")) {
70 - setleds("u0cn");
71 - } else if (!strcmp(consdev, "uart1")) {
72 - setleds("u1cn");
73 -#endif
74 -#ifdef CONFIG_VGA_CONSOLE
75 - } else if (!strcmp(consdev, "pcconsole0")) {
76 - setleds("pccn");
77 -#endif
78 - } else
79 - return -ENODEV;
80 - }
81 - return 0;
82 -}
83 -
84 -static struct console sb1250_cfe_cons = {
85 - .name = "cfe",
86 - .write = cfe_console_write,
87 - .setup = cfe_console_setup,
88 - .flags = CON_PRINTBUFFER,
89 - .index = -1,
90 -};
91 -
92 -static int __init sb1250_cfe_console_init(void)
93 -{
94 - register_console(&sb1250_cfe_cons);
95 - return 0;
96 -}
97 -
98 -console_initcall(sb1250_cfe_console_init);
99 --- a/arch/mips/sibyte/cfe/Makefile
100 +++ /dev/null
101 @@ -1,2 +0,0 @@
102 -lib-y = setup.o
103 -lib-$(CONFIG_SIBYTE_CFE_CONSOLE) += console.o
104 --- a/arch/mips/sibyte/cfe/setup.c
105 +++ /dev/null
106 @@ -1,344 +0,0 @@
107 -/*
108 - * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
109 - *
110 - * This program is free software; you can redistribute it and/or
111 - * modify it under the terms of the GNU General Public License
112 - * as published by the Free Software Foundation; either version 2
113 - * of the License, or (at your option) any later version.
114 - *
115 - * This program is distributed in the hope that it will be useful,
116 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
117 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
118 - * GNU General Public License for more details.
119 - *
120 - * You should have received a copy of the GNU General Public License
121 - * along with this program; if not, write to the Free Software
122 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
123 - */
124 -
125 -#include <linux/init.h>
126 -#include <linux/kernel.h>
127 -#include <linux/linkage.h>
128 -#include <linux/mm.h>
129 -#include <linux/blkdev.h>
130 -#include <linux/bootmem.h>
131 -#include <linux/pm.h>
132 -#include <linux/smp.h>
133 -
134 -#include <asm/bootinfo.h>
135 -#include <asm/reboot.h>
136 -#include <asm/sibyte/board.h>
137 -#include <asm/smp-ops.h>
138 -
139 -#include <asm/fw/cfe/cfe_api.h>
140 -#include <asm/fw/cfe/cfe_error.h>
141 -
142 -/* Max ram addressable in 32-bit segments */
143 -#ifdef CONFIG_64BIT
144 -#define MAX_RAM_SIZE (~0ULL)
145 -#else
146 -#ifdef CONFIG_HIGHMEM
147 -#ifdef CONFIG_64BIT_PHYS_ADDR
148 -#define MAX_RAM_SIZE (~0ULL)
149 -#else
150 -#define MAX_RAM_SIZE (0xffffffffULL)
151 -#endif
152 -#else
153 -#define MAX_RAM_SIZE (0x1fffffffULL)
154 -#endif
155 -#endif
156 -
157 -#define SIBYTE_MAX_MEM_REGIONS 8
158 -phys_t board_mem_region_addrs[SIBYTE_MAX_MEM_REGIONS];
159 -phys_t board_mem_region_sizes[SIBYTE_MAX_MEM_REGIONS];
160 -unsigned int board_mem_region_count;
161 -
162 -int cfe_cons_handle;
163 -
164 -#ifdef CONFIG_BLK_DEV_INITRD
165 -extern unsigned long initrd_start, initrd_end;
166 -#endif
167 -
168 -static void __noreturn cfe_linux_exit(void *arg)
169 -{
170 - int warm = *(int *)arg;
171 -
172 - if (smp_processor_id()) {
173 - static int reboot_smp;
174 -
175 - /* Don't repeat the process from another CPU */
176 - if (!reboot_smp) {
177 - /* Get CPU 0 to do the cfe_exit */
178 - reboot_smp = 1;
179 - smp_call_function(cfe_linux_exit, arg, 0);
180 - }
181 - } else {
182 - printk("Passing control back to CFE...\n");
183 - cfe_exit(warm, 0);
184 - printk("cfe_exit returned??\n");
185 - }
186 - while (1);
187 -}
188 -
189 -static void __noreturn cfe_linux_restart(char *command)
190 -{
191 - static const int zero;
192 -
193 - cfe_linux_exit((void *)&zero);
194 -}
195 -
196 -static void __noreturn cfe_linux_halt(void)
197 -{
198 - static const int one = 1;
199 -
200 - cfe_linux_exit((void *)&one);
201 -}
202 -
203 -static __init void prom_meminit(void)
204 -{
205 - u64 addr, size, type; /* regardless of 64BIT_PHYS_ADDR */
206 - int mem_flags = 0;
207 - unsigned int idx;
208 - int rd_flag;
209 -#ifdef CONFIG_BLK_DEV_INITRD
210 - unsigned long initrd_pstart;
211 - unsigned long initrd_pend;
212 -
213 - initrd_pstart = CPHYSADDR(initrd_start);
214 - initrd_pend = CPHYSADDR(initrd_end);
215 - if (initrd_start &&
216 - ((initrd_pstart > MAX_RAM_SIZE)
217 - || (initrd_pend > MAX_RAM_SIZE))) {
218 - panic("initrd out of addressable memory");
219 - }
220 -
221 -#endif /* INITRD */
222 -
223 - for (idx = 0; cfe_enummem(idx, mem_flags, &addr, &size, &type) != CFE_ERR_NOMORE;
224 - idx++) {
225 - rd_flag = 0;
226 - if (type == CFE_MI_AVAILABLE) {
227 - /*
228 - * See if this block contains (any portion of) the
229 - * ramdisk
230 - */
231 -#ifdef CONFIG_BLK_DEV_INITRD
232 - if (initrd_start) {
233 - if ((initrd_pstart > addr) &&
234 - (initrd_pstart < (addr + size))) {
235 - add_memory_region(addr,
236 - initrd_pstart - addr,
237 - BOOT_MEM_RAM);
238 - rd_flag = 1;
239 - }
240 - if ((initrd_pend > addr) &&
241 - (initrd_pend < (addr + size))) {
242 - add_memory_region(initrd_pend,
243 - (addr + size) - initrd_pend,
244 - BOOT_MEM_RAM);
245 - rd_flag = 1;
246 - }
247 - }
248 -#endif
249 - if (!rd_flag) {
250 - if (addr > MAX_RAM_SIZE)
251 - continue;
252 - if (addr+size > MAX_RAM_SIZE)
253 - size = MAX_RAM_SIZE - (addr+size) + 1;
254 - /*
255 - * memcpy/__copy_user prefetch, which
256 - * will cause a bus error for
257 - * KSEG/KUSEG addrs not backed by RAM.
258 - * Hence, reserve some padding for the
259 - * prefetch distance.
260 - */
261 - if (size > 512)
262 - size -= 512;
263 - add_memory_region(addr, size, BOOT_MEM_RAM);
264 - }
265 - board_mem_region_addrs[board_mem_region_count] = addr;
266 - board_mem_region_sizes[board_mem_region_count] = size;
267 - board_mem_region_count++;
268 - if (board_mem_region_count ==
269 - SIBYTE_MAX_MEM_REGIONS) {
270 - /*
271 - * Too many regions. Need to configure more
272 - */
273 - while(1);
274 - }
275 - }
276 - }
277 -#ifdef CONFIG_BLK_DEV_INITRD
278 - if (initrd_start) {
279 - add_memory_region(initrd_pstart, initrd_pend - initrd_pstart,
280 - BOOT_MEM_RESERVED);
281 - }
282 -#endif
283 -}
284 -
285 -#ifdef CONFIG_BLK_DEV_INITRD
286 -static int __init initrd_setup(char *str)
287 -{
288 - char rdarg[64];
289 - int idx;
290 - char *tmp, *endptr;
291 - unsigned long initrd_size;
292 -
293 - /* Make a copy of the initrd argument so we can smash it up here */
294 - for (idx = 0; idx < sizeof(rdarg)-1; idx++) {
295 - if (!str[idx] || (str[idx] == ' ')) break;
296 - rdarg[idx] = str[idx];
297 - }
298 -
299 - rdarg[idx] = 0;
300 - str = rdarg;
301 -
302 - /*
303 - *Initrd location comes in the form "<hex size of ramdisk in bytes>@<location in memory>"
304 - * e.g. initrd=3abfd@80010000. This is set up by the loader.
305 - */
306 - for (tmp = str; *tmp != '@'; tmp++) {
307 - if (!*tmp) {
308 - goto fail;
309 - }
310 - }
311 - *tmp = 0;
312 - tmp++;
313 - if (!*tmp) {
314 - goto fail;
315 - }
316 - initrd_size = simple_strtoul(str, &endptr, 16);
317 - if (*endptr) {
318 - *(tmp-1) = '@';
319 - goto fail;
320 - }
321 - *(tmp-1) = '@';
322 - initrd_start = simple_strtoul(tmp, &endptr, 16);
323 - if (*endptr) {
324 - goto fail;
325 - }
326 - initrd_end = initrd_start + initrd_size;
327 - printk("Found initrd of %lx@%lx\n", initrd_size, initrd_start);
328 - return 1;
329 - fail:
330 - printk("Bad initrd argument. Disabling initrd\n");
331 - initrd_start = 0;
332 - initrd_end = 0;
333 - return 1;
334 -}
335 -
336 -#endif
337 -
338 -extern struct plat_smp_ops sb_smp_ops;
339 -extern struct plat_smp_ops bcm1480_smp_ops;
340 -
341 -/*
342 - * prom_init is called just after the cpu type is determined, from setup_arch()
343 - */
344 -void __init prom_init(void)
345 -{
346 - uint64_t cfe_ept, cfe_handle;
347 - unsigned int cfe_eptseal;
348 - int argc = fw_arg0;
349 - char **envp = (char **) fw_arg2;
350 - int *prom_vec = (int *) fw_arg3;
351 -
352 - _machine_restart = cfe_linux_restart;
353 - _machine_halt = cfe_linux_halt;
354 - pm_power_off = cfe_linux_halt;
355 -
356 - /*
357 - * Check if a loader was used; if NOT, the 4 arguments are
358 - * what CFE gives us (handle, 0, EPT and EPTSEAL)
359 - */
360 - if (argc < 0) {
361 - cfe_handle = (uint64_t)(long)argc;
362 - cfe_ept = (long)envp;
363 - cfe_eptseal = (uint32_t)(unsigned long)prom_vec;
364 - } else {
365 - if ((int32_t)(long)prom_vec < 0) {
366 - /*
367 - * Old loader; all it gives us is the handle,
368 - * so use the "known" entrypoint and assume
369 - * the seal.
370 - */
371 - cfe_handle = (uint64_t)(long)prom_vec;
372 - cfe_ept = (uint64_t)((int32_t)0x9fc00500);
373 - cfe_eptseal = CFE_EPTSEAL;
374 - } else {
375 - /*
376 - * Newer loaders bundle the handle/ept/eptseal
377 - * Note: prom_vec is in the loader's useg
378 - * which is still alive in the TLB.
379 - */
380 - cfe_handle = (uint64_t)((int32_t *)prom_vec)[0];
381 - cfe_ept = (uint64_t)((int32_t *)prom_vec)[2];
382 - cfe_eptseal = (unsigned int)((uint32_t *)prom_vec)[3];
383 - }
384 - }
385 - if (cfe_eptseal != CFE_EPTSEAL) {
386 - /* too early for panic to do any good */
387 - printk("CFE's entrypoint seal doesn't match. Spinning.");
388 - while (1) ;
389 - }
390 - cfe_init(cfe_handle, cfe_ept);
391 - /*
392 - * Get the handle for (at least) prom_putchar, possibly for
393 - * boot console
394 - */
395 - cfe_cons_handle = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE);
396 - if (cfe_getenv("LINUX_CMDLINE", arcs_cmdline, CL_SIZE) < 0) {
397 - if (argc >= 0) {
398 - /* The loader should have set the command line */
399 - /* too early for panic to do any good */
400 - printk("LINUX_CMDLINE not defined in cfe.");
401 - while (1) ;
402 - }
403 - }
404 -
405 -#ifdef CONFIG_BLK_DEV_INITRD
406 - {
407 - char *ptr;
408 - /* Need to find out early whether we've got an initrd. So scan
409 - the list looking now */
410 - for (ptr = arcs_cmdline; *ptr; ptr++) {
411 - while (*ptr == ' ') {
412 - ptr++;
413 - }
414 - if (!strncmp(ptr, "initrd=", 7)) {
415 - initrd_setup(ptr+7);
416 - break;
417 - } else {
418 - while (*ptr && (*ptr != ' ')) {
419 - ptr++;
420 - }
421 - }
422 - }
423 - }
424 -#endif /* CONFIG_BLK_DEV_INITRD */
425 -
426 - /* Not sure this is needed, but it's the safe way. */
427 - arcs_cmdline[CL_SIZE-1] = 0;
428 -
429 - prom_meminit();
430 -
431 -#if defined(CONFIG_SIBYTE_BCM112X) || defined(CONFIG_SIBYTE_SB1250)
432 - register_smp_ops(&sb_smp_ops);
433 -#endif
434 -#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
435 - register_smp_ops(&bcm1480_smp_ops);
436 -#endif
437 -}
438 -
439 -void __init prom_free_prom_memory(void)
440 -{
441 - /* Not sure what I'm supposed to do here. Nothing, I think */
442 -}
443 -
444 -void prom_putchar(char c)
445 -{
446 - int ret;
447 -
448 - while ((ret = cfe_write(cfe_cons_handle, &c, 1)) == 0)
449 - ;
450 -}
451 --- /dev/null
452 +++ b/arch/mips/sibyte/common/cfe.c
453 @@ -0,0 +1,350 @@
454 +/*
455 + * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
456 + *
457 + * This program is free software; you can redistribute it and/or
458 + * modify it under the terms of the GNU General Public License
459 + * as published by the Free Software Foundation; either version 2
460 + * of the License, or (at your option) any later version.
461 + *
462 + * This program is distributed in the hope that it will be useful,
463 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
464 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
465 + * GNU General Public License for more details.
466 + *
467 + * You should have received a copy of the GNU General Public License
468 + * along with this program; if not, write to the Free Software
469 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
470 + */
471 +
472 +#include <linux/init.h>
473 +#include <linux/kernel.h>
474 +#include <linux/linkage.h>
475 +#include <linux/mm.h>
476 +#include <linux/blkdev.h>
477 +#include <linux/bootmem.h>
478 +#include <linux/pm.h>
479 +#include <linux/smp.h>
480 +
481 +#include <asm/bootinfo.h>
482 +#include <asm/reboot.h>
483 +#include <asm/sibyte/board.h>
484 +#include <asm/smp-ops.h>
485 +
486 +#include <asm/fw/cfe/cfe_api.h>
487 +#include <asm/fw/cfe/cfe_error.h>
488 +
489 +/* Max ram addressable in 32-bit segments */
490 +#ifdef CONFIG_64BIT
491 +#define MAX_RAM_SIZE (~0ULL)
492 +#else
493 +#ifdef CONFIG_HIGHMEM
494 +#ifdef CONFIG_64BIT_PHYS_ADDR
495 +#define MAX_RAM_SIZE (~0ULL)
496 +#else
497 +#define MAX_RAM_SIZE (0xffffffffULL)
498 +#endif
499 +#else
500 +#define MAX_RAM_SIZE (0x1fffffffULL)
501 +#endif
502 +#endif
503 +
504 +#define SIBYTE_MAX_MEM_REGIONS 8
505 +phys_t board_mem_region_addrs[SIBYTE_MAX_MEM_REGIONS];
506 +phys_t board_mem_region_sizes[SIBYTE_MAX_MEM_REGIONS];
507 +unsigned int board_mem_region_count;
508 +
509 +int cfe_cons_handle;
510 +
511 +#ifdef CONFIG_BLK_DEV_INITRD
512 +extern unsigned long initrd_start, initrd_end;
513 +#endif
514 +
515 +static void __noreturn cfe_linux_exit(void *arg)
516 +{
517 + int warm = *(int *)arg;
518 +
519 + if (smp_processor_id()) {
520 + static int reboot_smp;
521 +
522 + /* Don't repeat the process from another CPU */
523 + if (!reboot_smp) {
524 + /* Get CPU 0 to do the cfe_exit */
525 + reboot_smp = 1;
526 + smp_call_function(cfe_linux_exit, arg, 0);
527 + }
528 + } else {
529 + printk("Passing control back to CFE...\n");
530 + cfe_exit(warm, 0);
531 + printk("cfe_exit returned??\n");
532 + }
533 + while (1);
534 +}
535 +
536 +static void __noreturn cfe_linux_restart(char *command)
537 +{
538 + static const int zero;
539 +
540 + cfe_linux_exit((void *)&zero);
541 +}
542 +
543 +static void __noreturn cfe_linux_halt(void)
544 +{
545 + static const int one = 1;
546 +
547 + cfe_linux_exit((void *)&one);
548 +}
549 +
550 +static __init void prom_meminit(void)
551 +{
552 + u64 addr, size, type; /* regardless of 64BIT_PHYS_ADDR */
553 + int mem_flags = 0;
554 + unsigned int idx;
555 + int rd_flag;
556 +#ifdef CONFIG_BLK_DEV_INITRD
557 + unsigned long initrd_pstart;
558 + unsigned long initrd_pend;
559 +
560 + initrd_pstart = CPHYSADDR(initrd_start);
561 + initrd_pend = CPHYSADDR(initrd_end);
562 + if (initrd_start &&
563 + ((initrd_pstart > MAX_RAM_SIZE)
564 + || (initrd_pend > MAX_RAM_SIZE))) {
565 + panic("initrd out of addressable memory");
566 + }
567 +
568 +#endif /* INITRD */
569 +
570 + for (idx = 0; cfe_enummem(idx, mem_flags, &addr, &size, &type) != CFE_ERR_NOMORE;
571 + idx++) {
572 + rd_flag = 0;
573 + if (type == CFE_MI_AVAILABLE) {
574 + /*
575 + * See if this block contains (any portion of) the
576 + * ramdisk
577 + */
578 +#ifdef CONFIG_BLK_DEV_INITRD
579 + if (initrd_start) {
580 + if ((initrd_pstart > addr) &&
581 + (initrd_pstart < (addr + size))) {
582 + add_memory_region(addr,
583 + initrd_pstart - addr,
584 + BOOT_MEM_RAM);
585 + rd_flag = 1;
586 + }
587 + if ((initrd_pend > addr) &&
588 + (initrd_pend < (addr + size))) {
589 + add_memory_region(initrd_pend,
590 + (addr + size) - initrd_pend,
591 + BOOT_MEM_RAM);
592 + rd_flag = 1;
593 + }
594 + }
595 +#endif
596 + if (!rd_flag) {
597 + if (addr > MAX_RAM_SIZE)
598 + continue;
599 + if (addr+size > MAX_RAM_SIZE)
600 + size = MAX_RAM_SIZE - (addr+size) + 1;
601 + /*
602 + * memcpy/__copy_user prefetch, which
603 + * will cause a bus error for
604 + * KSEG/KUSEG addrs not backed by RAM.
605 + * Hence, reserve some padding for the
606 + * prefetch distance.
607 + */
608 + if (size > 512)
609 + size -= 512;
610 + add_memory_region(addr, size, BOOT_MEM_RAM);
611 + }
612 + board_mem_region_addrs[board_mem_region_count] = addr;
613 + board_mem_region_sizes[board_mem_region_count] = size;
614 + board_mem_region_count++;
615 + if (board_mem_region_count ==
616 + SIBYTE_MAX_MEM_REGIONS) {
617 + /*
618 + * Too many regions. Need to configure more
619 + */
620 + while(1);
621 + }
622 + }
623 + }
624 +#ifdef CONFIG_BLK_DEV_INITRD
625 + if (initrd_start) {
626 + add_memory_region(initrd_pstart, initrd_pend - initrd_pstart,
627 + BOOT_MEM_RESERVED);
628 + }
629 +#endif
630 +}
631 +
632 +#ifdef CONFIG_BLK_DEV_INITRD
633 +static int __init initrd_setup(char *str)
634 +{
635 + char rdarg[64];
636 + int idx;
637 + char *tmp, *endptr;
638 + unsigned long initrd_size;
639 +
640 + /* Make a copy of the initrd argument so we can smash it up here */
641 + for (idx = 0; idx < sizeof(rdarg)-1; idx++) {
642 + if (!str[idx] || (str[idx] == ' ')) break;
643 + rdarg[idx] = str[idx];
644 + }
645 +
646 + rdarg[idx] = 0;
647 + str = rdarg;
648 +
649 + /*
650 + *Initrd location comes in the form "<hex size of ramdisk in bytes>@<location in memory>"
651 + * e.g. initrd=3abfd@80010000. This is set up by the loader.
652 + */
653 + for (tmp = str; *tmp != '@'; tmp++) {
654 + if (!*tmp) {
655 + goto fail;
656 + }
657 + }
658 + *tmp = 0;
659 + tmp++;
660 + if (!*tmp) {
661 + goto fail;
662 + }
663 + initrd_size = simple_strtoul(str, &endptr, 16);
664 + if (*endptr) {
665 + *(tmp-1) = '@';
666 + goto fail;
667 + }
668 + *(tmp-1) = '@';
669 + initrd_start = simple_strtoul(tmp, &endptr, 16);
670 + if (*endptr) {
671 + goto fail;
672 + }
673 + initrd_end = initrd_start + initrd_size;
674 + printk("Found initrd of %lx@%lx\n", initrd_size, initrd_start);
675 + return 1;
676 + fail:
677 + printk("Bad initrd argument. Disabling initrd\n");
678 + initrd_start = 0;
679 + initrd_end = 0;
680 + return 1;
681 +}
682 +
683 +#endif
684 +
685 +extern struct plat_smp_ops sb_smp_ops;
686 +extern struct plat_smp_ops bcm1480_smp_ops;
687 +
688 +/*
689 + * prom_init is called just after the cpu type is determined, from setup_arch()
690 + */
691 +void __init prom_init(void)
692 +{
693 + uint64_t cfe_ept, cfe_handle;
694 + unsigned int cfe_eptseal;
695 + int argc = fw_arg0;
696 + char **envp = (char **) fw_arg2;
697 + int *prom_vec = (int *) fw_arg3;
698 +
699 + _machine_restart = cfe_linux_restart;
700 + _machine_halt = cfe_linux_halt;
701 + pm_power_off = cfe_linux_halt;
702 +
703 + /*
704 + * Check if a loader was used; if NOT, the 4 arguments are
705 + * what CFE gives us (handle, 0, EPT and EPTSEAL)
706 + */
707 + if (argc < 0) {
708 + cfe_handle = (uint64_t)(long)argc;
709 + cfe_ept = (long)envp;
710 + cfe_eptseal = (uint32_t)(unsigned long)prom_vec;
711 + } else {
712 + if ((int32_t)(long)prom_vec < 0) {
713 + /*
714 + * Old loader; all it gives us is the handle,
715 + * so use the "known" entrypoint and assume
716 + * the seal.
717 + */
718 + cfe_handle = (uint64_t)(long)prom_vec;
719 + cfe_ept = (uint64_t)((int32_t)0x9fc00500);
720 + cfe_eptseal = CFE_EPTSEAL;
721 + } else {
722 + /*
723 + * Newer loaders bundle the handle/ept/eptseal
724 + * Note: prom_vec is in the loader's useg
725 + * which is still alive in the TLB.
726 + */
727 + cfe_handle = (uint64_t)((int32_t *)prom_vec)[0];
728 + cfe_ept = (uint64_t)((int32_t *)prom_vec)[2];
729 + cfe_eptseal = (unsigned int)((uint32_t *)prom_vec)[3];
730 + }
731 + }
732 + if (cfe_eptseal != CFE_EPTSEAL) {
733 + /* too early for panic to do any good */
734 + printk("CFE's entrypoint seal doesn't match. Spinning.");
735 + while (1) ;
736 + }
737 + cfe_init(cfe_handle, cfe_ept);
738 + /*
739 + * Get the handle for (at least) prom_putchar, possibly for
740 + * boot console
741 + */
742 + cfe_cons_handle = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE);
743 + if (cfe_getenv("LINUX_CMDLINE", arcs_cmdline, CL_SIZE) < 0) {
744 + if (argc < 0) {
745 + /*
746 + * It's OK for direct boot to not provide a
747 + * command line
748 + */
749 + strcpy(arcs_cmdline, "root=/dev/ram0 ");
750 + } else {
751 + /* The loader should have set the command line */
752 + /* too early for panic to do any good */
753 + printk("LINUX_CMDLINE not defined in cfe.");
754 + while (1) ;
755 + }
756 + }
757 +
758 +#ifdef CONFIG_BLK_DEV_INITRD
759 + {
760 + char *ptr;
761 + /* Need to find out early whether we've got an initrd. So scan
762 + the list looking now */
763 + for (ptr = arcs_cmdline; *ptr; ptr++) {
764 + while (*ptr == ' ') {
765 + ptr++;
766 + }
767 + if (!strncmp(ptr, "initrd=", 7)) {
768 + initrd_setup(ptr+7);
769 + break;
770 + } else {
771 + while (*ptr && (*ptr != ' ')) {
772 + ptr++;
773 + }
774 + }
775 + }
776 + }
777 +#endif /* CONFIG_BLK_DEV_INITRD */
778 +
779 + /* Not sure this is needed, but it's the safe way. */
780 + arcs_cmdline[CL_SIZE-1] = 0;
781 +
782 + prom_meminit();
783 +
784 +#if defined(CONFIG_SIBYTE_BCM112X) || defined(CONFIG_SIBYTE_SB1250)
785 + register_smp_ops(&sb_smp_ops);
786 +#endif
787 +#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
788 + register_smp_ops(&bcm1480_smp_ops);
789 +#endif
790 +}
791 +
792 +void __init prom_free_prom_memory(void)
793 +{
794 + /* Not sure what I'm supposed to do here. Nothing, I think */
795 +}
796 +
797 +void prom_putchar(char c)
798 +{
799 + int ret;
800 +
801 + while ((ret = cfe_write(cfe_cons_handle, &c, 1)) == 0)
802 + ;
803 +}
804 --- /dev/null
805 +++ b/arch/mips/sibyte/common/cfe_console.c
806 @@ -0,0 +1,79 @@
807 +#include <linux/init.h>
808 +#include <linux/errno.h>
809 +#include <linux/console.h>
810 +
811 +#include <asm/sibyte/board.h>
812 +
813 +#include <asm/fw/cfe/cfe_api.h>
814 +#include <asm/fw/cfe/cfe_error.h>
815 +
816 +extern int cfe_cons_handle;
817 +
818 +static void cfe_console_write(struct console *cons, const char *str,
819 + unsigned int count)
820 +{
821 + int i, last, written;
822 +
823 + for (i=0, last=0; i<count; i++) {
824 + if (!str[i])
825 + /* XXXKW can/should this ever happen? */
826 + return;
827 + if (str[i] == '\n') {
828 + do {
829 + written = cfe_write(cfe_cons_handle, &str[last], i-last);
830 + if (written < 0)
831 + ;
832 + last += written;
833 + } while (last < i);
834 + while (cfe_write(cfe_cons_handle, "\r", 1) <= 0)
835 + ;
836 + }
837 + }
838 + if (last != count) {
839 + do {
840 + written = cfe_write(cfe_cons_handle, &str[last], count-last);
841 + if (written < 0)
842 + ;
843 + last += written;
844 + } while (last < count);
845 + }
846 +
847 +}
848 +
849 +static int cfe_console_setup(struct console *cons, char *str)
850 +{
851 + char consdev[32];
852 + /* XXXKW think about interaction with 'console=' cmdline arg */
853 + /* If none of the console options are configured, the build will break. */
854 + if (cfe_getenv("BOOT_CONSOLE", consdev, 32) >= 0) {
855 +#ifdef CONFIG_SERIAL_SB1250_DUART
856 + if (!strcmp(consdev, "uart0")) {
857 + setleds("u0cn");
858 + } else if (!strcmp(consdev, "uart1")) {
859 + setleds("u1cn");
860 +#endif
861 +#ifdef CONFIG_VGA_CONSOLE
862 + } else if (!strcmp(consdev, "pcconsole0")) {
863 + setleds("pccn");
864 +#endif
865 + } else
866 + return -ENODEV;
867 + }
868 + return 0;
869 +}
870 +
871 +static struct console sb1250_cfe_cons = {
872 + .name = "cfe",
873 + .write = cfe_console_write,
874 + .setup = cfe_console_setup,
875 + .flags = CON_PRINTBUFFER,
876 + .index = -1,
877 +};
878 +
879 +static int __init sb1250_cfe_console_init(void)
880 +{
881 + register_console(&sb1250_cfe_cons);
882 + return 0;
883 +}
884 +
885 +console_initcall(sb1250_cfe_console_init);
886 --- a/arch/mips/sibyte/common/Makefile
887 +++ b/arch/mips/sibyte/common/Makefile
888 @@ -1,5 +1,5 @@
889 -obj-y :=
890 -
891 +obj-y := cfe.o
892 +obj-$(CONFIG_SIBYTE_CFE_CONSOLE) += cfe_console.o
893 obj-$(CONFIG_SIBYTE_TBPROF) += sb_tbprof.o
894
895 EXTRA_CFLAGS += -Werror
896 --- a/arch/mips/sibyte/Kconfig
897 +++ b/arch/mips/sibyte/Kconfig
898 @@ -75,6 +75,8 @@ config SIBYTE_SB1xxx_SOC
899 select SWAP_IO_SPACE
900 select SYS_SUPPORTS_32BIT_KERNEL
901 select SYS_SUPPORTS_64BIT_KERNEL
902 + select CFE
903 + select SYS_HAS_EARLY_PRINTK
904
905 choice
906 prompt "SiByte SOC Stepping"
907 @@ -136,34 +138,14 @@ config SB1_CERR_STALL
908 bool "Stall (rather than panic) on fatal cache error"
909 depends on SIBYTE_SB1xxx_SOC
910
911 -config SIBYTE_CFE
912 - bool "Booting from CFE"
913 - depends on SIBYTE_SB1xxx_SOC
914 - select CFE
915 - select SYS_HAS_EARLY_PRINTK
916 - help
917 - Make use of the CFE API for enumerating available memory,
918 - controlling secondary CPUs, and possibly console output.
919 -
920 config SIBYTE_CFE_CONSOLE
921 bool "Use firmware console"
922 - depends on SIBYTE_CFE
923 + depends on SIBYTE_SB1xxx_SOC
924 help
925 Use the CFE API's console write routines during boot. Other console
926 options (VT console, sb1250 duart console, etc.) should not be
927 configured.
928
929 -config SIBYTE_STANDALONE
930 - bool
931 - depends on SIBYTE_SB1xxx_SOC && !SIBYTE_CFE
932 - select SYS_HAS_EARLY_PRINTK
933 - default y
934 -
935 -config SIBYTE_STANDALONE_RAM_SIZE
936 - int "Memory size (in megabytes)"
937 - depends on SIBYTE_STANDALONE
938 - default "32"
939 -
940 config SIBYTE_BUS_WATCHER
941 bool "Support for Bus Watcher statistics"
942 depends on SIBYTE_SB1xxx_SOC
943 --- a/arch/mips/sibyte/sb1250/Makefile
944 +++ b/arch/mips/sibyte/sb1250/Makefile
945 @@ -1,7 +1,6 @@
946 obj-y := setup.o irq.o time.o
947
948 obj-$(CONFIG_SMP) += smp.o
949 -obj-$(CONFIG_SIBYTE_STANDALONE) += prom.o
950 obj-$(CONFIG_SIBYTE_BUS_WATCHER) += bus_watcher.o
951
952 EXTRA_CFLAGS += -Werror
953 --- a/arch/mips/sibyte/sb1250/prom.c
954 +++ /dev/null
955 @@ -1,96 +0,0 @@
956 -/*
957 - * Copyright (C) 2000, 2001 Broadcom Corporation
958 - *
959 - * This program is free software; you can redistribute it and/or
960 - * modify it under the terms of the GNU General Public License
961 - * as published by the Free Software Foundation; either version 2
962 - * of the License, or (at your option) any later version.
963 - *
964 - * This program is distributed in the hope that it will be useful,
965 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
966 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
967 - * GNU General Public License for more details.
968 - *
969 - * You should have received a copy of the GNU General Public License
970 - * along with this program; if not, write to the Free Software
971 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
972 - */
973 -
974 -#include <linux/init.h>
975 -#include <linux/kernel.h>
976 -#include <linux/mm.h>
977 -#include <linux/blkdev.h>
978 -#include <linux/bootmem.h>
979 -#include <linux/smp.h>
980 -#include <linux/initrd.h>
981 -#include <linux/pm.h>
982 -
983 -#include <asm/bootinfo.h>
984 -#include <asm/reboot.h>
985 -
986 -#define MAX_RAM_SIZE ((CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024) - 1)
987 -
988 -static __init void prom_meminit(void)
989 -{
990 -#ifdef CONFIG_BLK_DEV_INITRD
991 - unsigned long initrd_pstart;
992 - unsigned long initrd_pend;
993 -
994 - initrd_pstart = __pa(initrd_start);
995 - initrd_pend = __pa(initrd_end);
996 - if (initrd_start &&
997 - ((initrd_pstart > MAX_RAM_SIZE)
998 - || (initrd_pend > MAX_RAM_SIZE))) {
999 - panic("initrd out of addressable memory");
1000 - }
1001 -
1002 - add_memory_region(0, initrd_pstart,
1003 - BOOT_MEM_RAM);
1004 - add_memory_region(initrd_pstart, initrd_pend - initrd_pstart,
1005 - BOOT_MEM_RESERVED);
1006 - add_memory_region(initrd_pend,
1007 - (CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024) - initrd_pend,
1008 - BOOT_MEM_RAM);
1009 -#else
1010 - add_memory_region(0, CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024,
1011 - BOOT_MEM_RAM);
1012 -#endif
1013 -}
1014 -
1015 -void prom_cpu0_exit(void *unused)
1016 -{
1017 - while (1) ;
1018 -}
1019 -
1020 -static void prom_linux_exit(void)
1021 -{
1022 -#ifdef CONFIG_SMP
1023 - if (smp_processor_id()) {
1024 - smp_call_function(prom_cpu0_exit, NULL, 1);
1025 - }
1026 -#endif
1027 - while(1);
1028 -}
1029 -
1030 -/*
1031 - * prom_init is called just after the cpu type is determined, from setup_arch()
1032 - */
1033 -void __init prom_init(void)
1034 -{
1035 - _machine_restart = (void (*)(char *))prom_linux_exit;
1036 - _machine_halt = prom_linux_exit;
1037 - pm_power_off = prom_linux_exit;
1038 -
1039 - strcpy(arcs_cmdline, "root=/dev/ram0 ");
1040 -
1041 - prom_meminit();
1042 -}
1043 -
1044 -void __init prom_free_prom_memory(void)
1045 -{
1046 - /* Not sure what I'm supposed to do here. Nothing, I think */
1047 -}
1048 -
1049 -void prom_putchar(char c)
1050 -{
1051 -}
1052 --- a/arch/mips/sibyte/swarm/setup.c
1053 +++ b/arch/mips/sibyte/swarm/setup.c
1054 @@ -136,16 +136,6 @@ void __init plat_mem_setup(void)
1055 if (m41t81_probe())
1056 swarm_rtc_type = RTC_M4LT81;
1057
1058 - printk("This kernel optimized for "
1059 - "board"
1060 - " runs "
1061 -#ifdef CONFIG_SIBYTE_CFE
1062 - "with"
1063 -#else
1064 - "without"
1065 -#endif
1066 - " CFE\n");
1067 -
1068 #ifdef CONFIG_VT
1069 screen_info = (struct screen_info) {
1070 0, 0, /* orig-x, orig-y */
This page took 0.127185 seconds and 5 git commands to generate.