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