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

source code of linux/arch/powerpc/boot/cuboot-hotfoot.c