2 * Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us>
4 * based on work of rb532 prom.c
5 * Copyright (C) 2003, Peter Sadik <peter.sadik@idt.com>
6 * Copyright (C) 2005-2006, P.Christeas <p_christ@hol.gr>
7 * Copyright (C) 2007, Gabor Juhos <juhosg@openwrt.org>
8 * Felix Fietkau <nbd@openwrt.org>
9 * Florian Fainelli <florian@openwrt.org>
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
16 #include <linux/init.h>
17 #include <linux/kernel.h>
18 #include <linux/types.h>
19 #include <linux/console.h>
20 #include <linux/string.h>
21 #include <linux/serial_core.h>
22 #include <asm/bootinfo.h>
26 register volatile struct global_data *gd asm ("k0");
28 void __init prom_free_prom_memory(void)
30 /* No prom memory to free */
33 static inline int match_tag(char *arg, const char *tag)
35 return strncmp(arg, tag, strlen(tag)) == 0;
38 static inline unsigned long tag2ul(char *arg, const char *tag)
42 num = arg + strlen(tag);
43 return simple_strtoul(num, 0, 10);
46 void __init prom_setup_cmdline(void)
54 prom_argv = (char **)KSEG0ADDR(fw_arg1);
56 cp = &(arcs_cmdline[0]);
57 for (i = 1; i < prom_argc; i++) {
58 prom_argv[i] = (char *)KSEG0ADDR(prom_argv[i]);
60 /* default bootargs has "console=/dev/ttyS0" yet console won't
61 * show up at all if you include the '/dev/' nowadays ... */
62 if (match_tag(prom_argv[i], "console=/dev/")) {
63 char *ptr = prom_argv[i] + strlen("console=/dev/");
65 strcpy(cp, "console=");
66 cp += strlen("console=");
72 strcpy(cp, prom_argv[i]);
73 cp += strlen(prom_argv[i]);
77 --cp; /* trailing space */
82 void __init prom_init(void)
87 memsize = bd->bi_memsize;
88 printk("Board info:\n");
89 printk(" RAM size: %d MB\n", (int)memsize/(1024*1024));
90 printk(" NOR start: %#lx\n", bd->bi_flashstart);
91 printk(" NOR size: %#lx\n", bd->bi_flashsize);
94 add_memory_region(0, memsize, BOOT_MEM_RAM);