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