redboot-8xx.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * RedBoot firmware support
  3. *
  4. * Author: Scott Wood <scottwood@freescale.com>
  5. *
  6. * Copyright (c) 2007 Freescale Semiconductor, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include "ops.h"
  13. #include "stdio.h"
  14. #include "redboot.h"
  15. #include "fsl-soc.h"
  16. #include "io.h"
  17. static bd_t bd;
  18. BSS_STACK(4096);
  19. #define MHZ(x) ((x + 500000) / 1000000)
  20. static void platform_fixups(void)
  21. {
  22. void *node;
  23. dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
  24. dt_fixup_mac_addresses(bd.bi_enetaddr);
  25. dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 16, bd.bi_busfreq);
  26. node = finddevice("/soc/cpm/brg");
  27. if (node) {
  28. printf("BRG clock-frequency <- 0x%x (%dMHz)\r\n",
  29. bd.bi_busfreq, MHZ(bd.bi_busfreq));
  30. setprop(node, "clock-frequency", &bd.bi_busfreq, 4);
  31. }
  32. }
  33. void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  34. unsigned long r6, unsigned long r7)
  35. {
  36. memcpy(&bd, (char *)r3, sizeof(bd));
  37. if (bd.bi_tag != 0x42444944)
  38. return;
  39. simple_alloc_init(_end,
  40. bd.bi_memstart + bd.bi_memsize - (unsigned long)_end,
  41. 32, 64);
  42. fdt_init(_dtb_start);
  43. serial_console_init();
  44. platform_ops.fixups = platform_fixups;
  45. loader_info.cmdline = (char *)bd.bi_cmdline;
  46. loader_info.cmdline_len = strlen((char *)bd.bi_cmdline);
  47. }