| 1 | /* |
| 2 | * Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us> |
| 3 | * |
| 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> |
| 10 | * |
| 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 |
| 13 | * for more details. |
| 14 | */ |
| 15 | |
| 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> |
| 23 | #include <adm8668.h> |
| 24 | #include "u-boot.h" |
| 25 | |
| 26 | register volatile struct global_data *gd asm ("k0"); |
| 27 | |
| 28 | void __init prom_free_prom_memory(void) |
| 29 | { |
| 30 | /* No prom memory to free */ |
| 31 | } |
| 32 | |
| 33 | static inline int match_tag(char *arg, const char *tag) |
| 34 | { |
| 35 | return strncmp(arg, tag, strlen(tag)) == 0; |
| 36 | } |
| 37 | |
| 38 | static inline unsigned long tag2ul(char *arg, const char *tag) |
| 39 | { |
| 40 | char *num; |
| 41 | |
| 42 | num = arg + strlen(tag); |
| 43 | return simple_strtoul(num, 0, 10); |
| 44 | } |
| 45 | |
| 46 | void __init prom_setup_cmdline(void) |
| 47 | { |
| 48 | char *cp; |
| 49 | int prom_argc; |
| 50 | char **prom_argv; |
| 51 | int i; |
| 52 | |
| 53 | prom_argc = fw_arg0; |
| 54 | prom_argv = (char **)KSEG0ADDR(fw_arg1); |
| 55 | |
| 56 | cp = &(arcs_cmdline[0]); |
| 57 | for (i = 1; i < prom_argc; i++) { |
| 58 | prom_argv[i] = (char *)KSEG0ADDR(prom_argv[i]); |
| 59 | |
| 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/"); |
| 64 | |
| 65 | strcpy(cp, "console="); |
| 66 | cp += strlen("console="); |
| 67 | strcpy(cp, ptr); |
| 68 | cp += strlen(ptr); |
| 69 | *cp++ = ' '; |
| 70 | continue; |
| 71 | } |
| 72 | strcpy(cp, prom_argv[i]); |
| 73 | cp += strlen(prom_argv[i]); |
| 74 | *cp++ = ' '; |
| 75 | } |
| 76 | if (prom_argc > 1) |
| 77 | --cp; /* trailing space */ |
| 78 | |
| 79 | *cp = '\0'; |
| 80 | } |
| 81 | |
| 82 | void __init prom_init(void) |
| 83 | { |
| 84 | bd_t *bd = gd->bd; |
| 85 | int memsize; |
| 86 | |
| 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); |
| 92 | |
| 93 | prom_setup_cmdline(); |
| 94 | add_memory_region(0, memsize, BOOT_MEM_RAM); |
| 95 | } |
| 96 | |