cuboot-52xx.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. setprop(soc, "bus-frequency", &bd.bi_ipbfreq,
  35. sizeof(bd.bi_ipbfreq));
  36. if (!dt_xlate_reg(soc, 0, (void*)&reg, NULL))
  37. return;
  38. div = in_8(reg + 0x204) & 0x0020 ? 8 : 4;
  39. sysfreq = bd.bi_busfreq * div;
  40. setprop(soc, "system-frequency", &sysfreq, sizeof(sysfreq));
  41. }
  42. }
  43. void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  44. unsigned long r6, unsigned long r7)
  45. {
  46. CUBOOT_INIT();
  47. fdt_init(_dtb_start);
  48. serial_console_init();
  49. platform_ops.fixups = platform_fixups;
  50. }