prom.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #include <linux/init.h>
  16. #include <linux/kernel.h>
  17. #include <linux/types.h>
  18. #include <linux/console.h>
  19. #include <linux/string.h>
  20. #include <linux/serial_core.h>
  21. #include <asm/bootinfo.h>
  22. #include <adm8668.h>
  23. #include "u-boot.h"
  24. register volatile struct global_data *gd asm ("k0");
  25. void __init prom_free_prom_memory(void)
  26. {
  27. /* No prom memory to free */
  28. }
  29. static inline int match_tag(char *arg, const char *tag)
  30. {
  31. return strncmp(arg, tag, strlen(tag)) == 0;
  32. }
  33. static inline unsigned long tag2ul(char *arg, const char *tag)
  34. {
  35. char *num;
  36. num = arg + strlen(tag);
  37. return simple_strtoul(num, 0, 10);
  38. }
  39. void __init prom_setup_cmdline(void)
  40. {
  41. char *cp;
  42. int prom_argc;
  43. char **prom_argv;
  44. int i;
  45. prom_argc = fw_arg0;
  46. prom_argv = (char **)KSEG0ADDR(fw_arg1);
  47. cp = &(arcs_cmdline[0]);
  48. for (i = 1; i < prom_argc; i++) {
  49. prom_argv[i] = (char *)KSEG0ADDR(prom_argv[i]);
  50. /* default bootargs has "console=/dev/ttyS0" yet console won't
  51. * show up at all if you include the '/dev/' nowadays ... */
  52. if (match_tag(prom_argv[i], "console=/dev/")) {
  53. char *ptr = prom_argv[i] + strlen("console=/dev/");
  54. strcpy(cp, "console=");
  55. cp += strlen("console=");
  56. strcpy(cp, ptr);
  57. cp += strlen(ptr);
  58. *cp++ = ' ';
  59. continue;
  60. }
  61. strcpy(cp, prom_argv[i]);
  62. cp += strlen(prom_argv[i]);
  63. *cp++ = ' ';
  64. }
  65. if (prom_argc > 1)
  66. --cp; /* trailing space */
  67. *cp = '\0';
  68. }
  69. void __init prom_init(void)
  70. {
  71. bd_t *bd = gd->bd;
  72. int memsize;
  73. memsize = bd->bi_memsize;
  74. printk("Board info:\n");
  75. printk(" RAM size: %d MB\n", (int)memsize/(1024*1024));
  76. printk(" NOR start: %#lx\n", bd->bi_flashstart);
  77. printk(" NOR size: %#lx\n", bd->bi_flashsize);
  78. prom_setup_cmdline();
  79. add_memory_region(0, memsize, BOOT_MEM_RAM);
  80. }