Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Old U-boot compatibility for Esteem 195E Hotfoot CPU Board
0004  *
0005  * Author: Solomon Peachy <solomon@linux-wlan.com>
0006  */
0007 
0008 #include "ops.h"
0009 #include "stdio.h"
0010 #include "reg.h"
0011 #include "dcr.h"
0012 #include "4xx.h"
0013 #include "cuboot.h"
0014 
0015 #define TARGET_4xx
0016 #define TARGET_HOTFOOT
0017 
0018 #include "ppcboot-hotfoot.h"
0019 
0020 static bd_t bd;
0021 
0022 #define NUM_REGS 3
0023 
0024 static void hotfoot_fixups(void)
0025 {
0026     u32 uart = mfdcr(DCRN_CPC0_UCR) & 0x7f;
0027 
0028     dt_fixup_memory(bd.bi_memstart, bd.bi_memsize); 
0029 
0030     dt_fixup_cpu_clocks(bd.bi_procfreq, bd.bi_procfreq, 0);
0031     dt_fixup_clock("/plb", bd.bi_plb_busfreq);
0032     dt_fixup_clock("/plb/opb", bd.bi_opbfreq);
0033     dt_fixup_clock("/plb/ebc", bd.bi_pci_busfreq);
0034     dt_fixup_clock("/plb/opb/serial@ef600300", bd.bi_procfreq / uart); 
0035     dt_fixup_clock("/plb/opb/serial@ef600400", bd.bi_procfreq / uart); 
0036     
0037     dt_fixup_mac_address_by_alias("ethernet0", bd.bi_enetaddr);
0038     dt_fixup_mac_address_by_alias("ethernet1", bd.bi_enet1addr);
0039 
0040     /* Is this a single eth/serial board? */
0041     if ((bd.bi_enet1addr[0] == 0) && 
0042         (bd.bi_enet1addr[1] == 0) &&
0043         (bd.bi_enet1addr[2] == 0) &&
0044         (bd.bi_enet1addr[3] == 0) &&
0045         (bd.bi_enet1addr[4] == 0) &&
0046         (bd.bi_enet1addr[5] == 0)) {
0047         void *devp;
0048 
0049         printf("Trimming devtree for single serial/eth board\n");
0050 
0051         devp = finddevice("/plb/opb/serial@ef600300");
0052         if (!devp)
0053             fatal("Can't find node for /plb/opb/serial@ef600300");
0054         del_node(devp);
0055 
0056         devp = finddevice("/plb/opb/ethernet@ef600900");
0057         if (!devp)
0058             fatal("Can't find node for /plb/opb/ethernet@ef600900");
0059         del_node(devp);
0060     }
0061 
0062     ibm4xx_quiesce_eth((u32 *)0xef600800, (u32 *)0xef600900);
0063 
0064     /* Fix up flash size in fdt for 4M boards. */
0065     if (bd.bi_flashsize < 0x800000) {
0066         u32 regs[NUM_REGS];
0067         void *devp = finddevice("/plb/ebc/nor_flash@0");
0068         if (!devp)
0069             fatal("Can't find FDT node for nor_flash!??");
0070 
0071         printf("Fixing devtree for 4M Flash\n");
0072         
0073         /* First fix up the base address */
0074         getprop(devp, "reg", regs, sizeof(regs));
0075         regs[0] = 0;
0076         regs[1] = 0xffc00000;
0077         regs[2] = 0x00400000;
0078         setprop(devp, "reg", regs, sizeof(regs));
0079         
0080         /* Then the offsets */
0081         devp = finddevice("/plb/ebc/nor_flash@0/partition@0");
0082         if (!devp)
0083             fatal("Can't find FDT node for partition@0");
0084         getprop(devp, "reg", regs, 2*sizeof(u32));
0085         regs[0] -= 0x400000;
0086         setprop(devp, "reg", regs,  2*sizeof(u32));
0087 
0088         devp = finddevice("/plb/ebc/nor_flash@0/partition@1");
0089         if (!devp)
0090             fatal("Can't find FDT node for partition@1");
0091         getprop(devp, "reg", regs, 2*sizeof(u32));
0092         regs[0] -= 0x400000;
0093         setprop(devp, "reg", regs,  2*sizeof(u32));
0094 
0095         devp = finddevice("/plb/ebc/nor_flash@0/partition@2");
0096         if (!devp)
0097             fatal("Can't find FDT node for partition@2");
0098         getprop(devp, "reg", regs, 2*sizeof(u32));
0099         regs[0] -= 0x400000;
0100         setprop(devp, "reg", regs,  2*sizeof(u32));
0101 
0102         devp = finddevice("/plb/ebc/nor_flash@0/partition@3");
0103         if (!devp)
0104             fatal("Can't find FDT node for partition@3");
0105         getprop(devp, "reg", regs, 2*sizeof(u32));
0106         regs[0] -= 0x400000;
0107         setprop(devp, "reg", regs,  2*sizeof(u32));
0108 
0109         devp = finddevice("/plb/ebc/nor_flash@0/partition@4");
0110         if (!devp)
0111             fatal("Can't find FDT node for partition@4");
0112         getprop(devp, "reg", regs, 2*sizeof(u32));
0113         regs[0] -= 0x400000;
0114         setprop(devp, "reg", regs,  2*sizeof(u32));
0115 
0116         devp = finddevice("/plb/ebc/nor_flash@0/partition@6");
0117         if (!devp)
0118             fatal("Can't find FDT node for partition@6");
0119         getprop(devp, "reg", regs, 2*sizeof(u32));
0120         regs[0] -= 0x400000;
0121         setprop(devp, "reg", regs,  2*sizeof(u32));
0122 
0123         /* Delete the FeatFS node */
0124         devp = finddevice("/plb/ebc/nor_flash@0/partition@5");
0125         if (!devp)
0126             fatal("Can't find FDT node for partition@5");
0127         del_node(devp);
0128     }
0129 }
0130 
0131 void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
0132            unsigned long r6, unsigned long r7)
0133 {
0134     CUBOOT_INIT();
0135     platform_ops.fixups = hotfoot_fixups;
0136         platform_ops.exit = ibm40x_dbcr_reset;
0137     fdt_init(_dtb_start);
0138     serial_console_init();
0139 }