cuboot-52xx.c 1.5 KB

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