redboot-83xx.c 1.4 KB

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