cuboot-hotfoot.c 4.0 KB

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