cuboot-hotfoot.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Old U-boot compatibility for Esteem 195E Hotfoot CPU Board
  4. *
  5. * Author: Solomon Peachy <solomon@linux-wlan.com>
  6. */
  7. #include "ops.h"
  8. #include "stdio.h"
  9. #include "reg.h"
  10. #include "dcr.h"
  11. #include "4xx.h"
  12. #include "cuboot.h"
  13. #define TARGET_4xx
  14. #define TARGET_HOTFOOT
  15. #include "ppcboot-hotfoot.h"
  16. static bd_t bd;
  17. #define NUM_REGS 3
  18. static void hotfoot_fixups(void)
  19. {
  20. u32 uart = mfdcr(DCRN_CPC0_UCR) & 0x7f;
  21. dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
  22. dt_fixup_cpu_clocks(bd.bi_procfreq, bd.bi_procfreq, 0);
  23. dt_fixup_clock("/plb", bd.bi_plb_busfreq);
  24. dt_fixup_clock("/plb/opb", bd.bi_opbfreq);
  25. dt_fixup_clock("/plb/ebc", bd.bi_pci_busfreq);
  26. dt_fixup_clock("/plb/opb/serial@ef600300", bd.bi_procfreq / uart);
  27. dt_fixup_clock("/plb/opb/serial@ef600400", bd.bi_procfreq / uart);
  28. dt_fixup_mac_address_by_alias("ethernet0", bd.bi_enetaddr);
  29. dt_fixup_mac_address_by_alias("ethernet1", bd.bi_enet1addr);
  30. /* Is this a single eth/serial board? */
  31. if ((bd.bi_enet1addr[0] == 0) &&
  32. (bd.bi_enet1addr[1] == 0) &&
  33. (bd.bi_enet1addr[2] == 0) &&
  34. (bd.bi_enet1addr[3] == 0) &&
  35. (bd.bi_enet1addr[4] == 0) &&
  36. (bd.bi_enet1addr[5] == 0)) {
  37. void *devp;
  38. printf("Trimming devtree for single serial/eth board\n");
  39. devp = finddevice("/plb/opb/serial@ef600300");
  40. if (!devp)
  41. fatal("Can't find node for /plb/opb/serial@ef600300");
  42. del_node(devp);
  43. devp = finddevice("/plb/opb/ethernet@ef600900");
  44. if (!devp)
  45. fatal("Can't find node for /plb/opb/ethernet@ef600900");
  46. del_node(devp);
  47. }
  48. ibm4xx_quiesce_eth((u32 *)0xef600800, (u32 *)0xef600900);
  49. /* Fix up flash size in fdt for 4M boards. */
  50. if (bd.bi_flashsize < 0x800000) {
  51. u32 regs[NUM_REGS];
  52. void *devp = finddevice("/plb/ebc/nor_flash@0");
  53. if (!devp)
  54. fatal("Can't find FDT node for nor_flash!??");
  55. printf("Fixing devtree for 4M Flash\n");
  56. /* First fix up the base addresse */
  57. getprop(devp, "reg", regs, sizeof(regs));
  58. regs[0] = 0;
  59. regs[1] = 0xffc00000;
  60. regs[2] = 0x00400000;
  61. setprop(devp, "reg", regs, sizeof(regs));
  62. /* Then the offsets */
  63. devp = finddevice("/plb/ebc/nor_flash@0/partition@0");
  64. if (!devp)
  65. fatal("Can't find FDT node for partition@0");
  66. getprop(devp, "reg", regs, 2*sizeof(u32));
  67. regs[0] -= 0x400000;
  68. setprop(devp, "reg", regs, 2*sizeof(u32));
  69. devp = finddevice("/plb/ebc/nor_flash@0/partition@1");
  70. if (!devp)
  71. fatal("Can't find FDT node for partition@1");
  72. getprop(devp, "reg", regs, 2*sizeof(u32));
  73. regs[0] -= 0x400000;
  74. setprop(devp, "reg", regs, 2*sizeof(u32));
  75. devp = finddevice("/plb/ebc/nor_flash@0/partition@2");
  76. if (!devp)
  77. fatal("Can't find FDT node for partition@2");
  78. getprop(devp, "reg", regs, 2*sizeof(u32));
  79. regs[0] -= 0x400000;
  80. setprop(devp, "reg", regs, 2*sizeof(u32));
  81. devp = finddevice("/plb/ebc/nor_flash@0/partition@3");
  82. if (!devp)
  83. fatal("Can't find FDT node for partition@3");
  84. getprop(devp, "reg", regs, 2*sizeof(u32));
  85. regs[0] -= 0x400000;
  86. setprop(devp, "reg", regs, 2*sizeof(u32));
  87. devp = finddevice("/plb/ebc/nor_flash@0/partition@4");
  88. if (!devp)
  89. fatal("Can't find FDT node for partition@4");
  90. getprop(devp, "reg", regs, 2*sizeof(u32));
  91. regs[0] -= 0x400000;
  92. setprop(devp, "reg", regs, 2*sizeof(u32));
  93. devp = finddevice("/plb/ebc/nor_flash@0/partition@6");
  94. if (!devp)
  95. fatal("Can't find FDT node for partition@6");
  96. getprop(devp, "reg", regs, 2*sizeof(u32));
  97. regs[0] -= 0x400000;
  98. setprop(devp, "reg", regs, 2*sizeof(u32));
  99. /* Delete the FeatFS node */
  100. devp = finddevice("/plb/ebc/nor_flash@0/partition@5");
  101. if (!devp)
  102. fatal("Can't find FDT node for partition@5");
  103. del_node(devp);
  104. }
  105. }
  106. void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  107. unsigned long r6, unsigned long r7)
  108. {
  109. CUBOOT_INIT();
  110. platform_ops.fixups = hotfoot_fixups;
  111. platform_ops.exit = ibm40x_dbcr_reset;
  112. fdt_init(_dtb_start);
  113. serial_console_init();
  114. }