cuboot-52xx.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Old U-boot compatibility for MPC5200
  3. *
  4. * Author: Grant Likely <grant.likely@secretlab.ca>
  5. *
  6. * Copyright (c) 2007 Secret Lab Technologies Ltd.
  7. * Copyright (c) 2007 Freescale Semiconductor, Inc.
  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 "io.h"
  16. #include "cuboot.h"
  17. #define TARGET_PPC_MPC52xx
  18. #include "ppcboot.h"
  19. static bd_t bd;
  20. static void platform_fixups(void)
  21. {
  22. void *soc, *reg;
  23. int div;
  24. u32 sysfreq;
  25. dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
  26. dt_fixup_mac_addresses(bd.bi_enetaddr);
  27. dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 4, bd.bi_busfreq);
  28. /* Unfortunately, the specific model number is encoded in the
  29. * soc node name in existing dts files -- once that is fixed,
  30. * this can do a simple path lookup.
  31. */
  32. soc = find_node_by_devtype(NULL, "soc");
  33. if (!soc)
  34. soc = find_node_by_compatible(NULL, "fsl,mpc5200-immr");
  35. if (!soc)
  36. soc = find_node_by_compatible(NULL, "fsl,mpc5200b-immr");
  37. if (soc) {
  38. setprop(soc, "bus-frequency", &bd.bi_ipbfreq,
  39. sizeof(bd.bi_ipbfreq));
  40. if (!dt_xlate_reg(soc, 0, (void*)&reg, NULL))
  41. return;
  42. div = in_8(reg + 0x204) & 0x0020 ? 8 : 4;
  43. sysfreq = bd.bi_busfreq * div;
  44. setprop(soc, "system-frequency", &sysfreq, sizeof(sysfreq));
  45. }
  46. }
  47. void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  48. unsigned long r6, unsigned long r7)
  49. {
  50. CUBOOT_INIT();
  51. fdt_init(_dtb_start);
  52. serial_console_init();
  53. platform_ops.fixups = platform_fixups;
  54. }