xref: /openbmc/u-boot/arch/powerpc/cpu/mpc85xx/fdt.c (revision db977abfc87eebf22dfed374528c89130949dce2)
1a47a12beSStefan Roese /*
28f3a7fa4SKumar Gala  * Copyright 2007-2010 Freescale Semiconductor, Inc.
3a47a12beSStefan Roese  *
4a47a12beSStefan Roese  * (C) Copyright 2000
5a47a12beSStefan Roese  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6a47a12beSStefan Roese  *
7a47a12beSStefan Roese  * See file CREDITS for list of people who contributed to this
8a47a12beSStefan Roese  * project.
9a47a12beSStefan Roese  *
10a47a12beSStefan Roese  * This program is free software; you can redistribute it and/or
11a47a12beSStefan Roese  * modify it under the terms of the GNU General Public License as
12a47a12beSStefan Roese  * published by the Free Software Foundation; either version 2 of
13a47a12beSStefan Roese  * the License, or (at your option) any later version.
14a47a12beSStefan Roese  *
15a47a12beSStefan Roese  * This program is distributed in the hope that it will be useful,
16a47a12beSStefan Roese  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17a47a12beSStefan Roese  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18a47a12beSStefan Roese  * GNU General Public License for more details.
19a47a12beSStefan Roese  *
20a47a12beSStefan Roese  * You should have received a copy of the GNU General Public License
21a47a12beSStefan Roese  * along with this program; if not, write to the Free Software
22a47a12beSStefan Roese  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23a47a12beSStefan Roese  * MA 02111-1307 USA
24a47a12beSStefan Roese  */
25a47a12beSStefan Roese 
26a47a12beSStefan Roese #include <common.h>
27a47a12beSStefan Roese #include <libfdt.h>
28a47a12beSStefan Roese #include <fdt_support.h>
29a47a12beSStefan Roese #include <asm/processor.h>
30a47a12beSStefan Roese #include <linux/ctype.h>
316aba33e9SKumar Gala #include <asm/io.h>
32*db977abfSKumar Gala #include <asm/fsl_portals.h>
33a47a12beSStefan Roese #ifdef CONFIG_FSL_ESDHC
34a47a12beSStefan Roese #include <fsl_esdhc.h>
35a47a12beSStefan Roese #endif
36a47a12beSStefan Roese 
37a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR;
38a47a12beSStefan Roese 
39a47a12beSStefan Roese extern void ft_qe_setup(void *blob);
40a47a12beSStefan Roese extern void ft_fixup_num_cores(void *blob);
41a47a12beSStefan Roese 
42a47a12beSStefan Roese #ifdef CONFIG_MP
43a47a12beSStefan Roese #include "mp.h"
44a47a12beSStefan Roese 
45a47a12beSStefan Roese void ft_fixup_cpu(void *blob, u64 memory_limit)
46a47a12beSStefan Roese {
47a47a12beSStefan Roese 	int off;
48a47a12beSStefan Roese 	ulong spin_tbl_addr = get_spin_phys_addr();
49a47a12beSStefan Roese 	u32 bootpg = determine_mp_bootpg();
50a47a12beSStefan Roese 	u32 id = get_my_id();
51a47a12beSStefan Roese 
52a47a12beSStefan Roese 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
53a47a12beSStefan Roese 	while (off != -FDT_ERR_NOTFOUND) {
54a47a12beSStefan Roese 		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
55a47a12beSStefan Roese 
56a47a12beSStefan Roese 		if (reg) {
57a47a12beSStefan Roese 			if (*reg == id) {
58a47a12beSStefan Roese 				fdt_setprop_string(blob, off, "status", "okay");
59a47a12beSStefan Roese 			} else {
60a47a12beSStefan Roese 				u64 val = *reg * SIZE_BOOT_ENTRY + spin_tbl_addr;
61a47a12beSStefan Roese 				val = cpu_to_fdt32(val);
62a47a12beSStefan Roese 				fdt_setprop_string(blob, off, "status",
63a47a12beSStefan Roese 								"disabled");
64a47a12beSStefan Roese 				fdt_setprop_string(blob, off, "enable-method",
65a47a12beSStefan Roese 								"spin-table");
66a47a12beSStefan Roese 				fdt_setprop(blob, off, "cpu-release-addr",
67a47a12beSStefan Roese 						&val, sizeof(val));
68a47a12beSStefan Roese 			}
69a47a12beSStefan Roese 		} else {
70a47a12beSStefan Roese 			printf ("cpu NULL\n");
71a47a12beSStefan Roese 		}
72a47a12beSStefan Roese 		off = fdt_node_offset_by_prop_value(blob, off,
73a47a12beSStefan Roese 				"device_type", "cpu", 4);
74a47a12beSStefan Roese 	}
75a47a12beSStefan Roese 
76a47a12beSStefan Roese 	/* Reserve the boot page so OSes dont use it */
77a47a12beSStefan Roese 	if ((u64)bootpg < memory_limit) {
78a47a12beSStefan Roese 		off = fdt_add_mem_rsv(blob, bootpg, (u64)4096);
79a47a12beSStefan Roese 		if (off < 0)
80a47a12beSStefan Roese 			printf("%s: %s\n", __FUNCTION__, fdt_strerror(off));
81a47a12beSStefan Roese 	}
82a47a12beSStefan Roese }
83a47a12beSStefan Roese #endif
84a47a12beSStefan Roese 
856aba33e9SKumar Gala #ifdef CONFIG_SYS_FSL_CPC
866aba33e9SKumar Gala static inline void ft_fixup_l3cache(void *blob, int off)
876aba33e9SKumar Gala {
886aba33e9SKumar Gala 	u32 line_size, num_ways, size, num_sets;
896aba33e9SKumar Gala 	cpc_corenet_t *cpc = (void *)CONFIG_SYS_FSL_CPC_ADDR;
906aba33e9SKumar Gala 	u32 cfg0 = in_be32(&cpc->cpccfg0);
916aba33e9SKumar Gala 
926aba33e9SKumar Gala 	size = CPC_CFG0_SZ_K(cfg0) * 1024 * CONFIG_SYS_NUM_CPC;
936aba33e9SKumar Gala 	num_ways = CPC_CFG0_NUM_WAYS(cfg0);
946aba33e9SKumar Gala 	line_size = CPC_CFG0_LINE_SZ(cfg0);
956aba33e9SKumar Gala 	num_sets = size / (line_size * num_ways);
966aba33e9SKumar Gala 
976aba33e9SKumar Gala 	fdt_setprop(blob, off, "cache-unified", NULL, 0);
986aba33e9SKumar Gala 	fdt_setprop_cell(blob, off, "cache-block-size", line_size);
996aba33e9SKumar Gala 	fdt_setprop_cell(blob, off, "cache-size", size);
1006aba33e9SKumar Gala 	fdt_setprop_cell(blob, off, "cache-sets", num_sets);
1016aba33e9SKumar Gala 	fdt_setprop_cell(blob, off, "cache-level", 3);
1026aba33e9SKumar Gala #ifdef CONFIG_SYS_CACHE_STASHING
1036aba33e9SKumar Gala 	fdt_setprop_cell(blob, off, "cache-stash-id", 1);
1046aba33e9SKumar Gala #endif
1056aba33e9SKumar Gala }
1066aba33e9SKumar Gala #else
107a47a12beSStefan Roese #define ft_fixup_l3cache(x, y)
1086aba33e9SKumar Gala #endif
109a47a12beSStefan Roese 
110a47a12beSStefan Roese #if defined(CONFIG_L2_CACHE)
111a47a12beSStefan Roese /* return size in kilobytes */
112a47a12beSStefan Roese static inline u32 l2cache_size(void)
113a47a12beSStefan Roese {
114a47a12beSStefan Roese 	volatile ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
115a47a12beSStefan Roese 	volatile u32 l2siz_field = (l2cache->l2ctl >> 28) & 0x3;
116a47a12beSStefan Roese 	u32 ver = SVR_SOC_VER(get_svr());
117a47a12beSStefan Roese 
118a47a12beSStefan Roese 	switch (l2siz_field) {
119a47a12beSStefan Roese 	case 0x0:
120a47a12beSStefan Roese 		break;
121a47a12beSStefan Roese 	case 0x1:
122a47a12beSStefan Roese 		if (ver == SVR_8540 || ver == SVR_8560   ||
123a47a12beSStefan Roese 		    ver == SVR_8541 || ver == SVR_8541_E ||
124a47a12beSStefan Roese 		    ver == SVR_8555 || ver == SVR_8555_E)
125a47a12beSStefan Roese 			return 128;
126a47a12beSStefan Roese 		else
127a47a12beSStefan Roese 			return 256;
128a47a12beSStefan Roese 		break;
129a47a12beSStefan Roese 	case 0x2:
130a47a12beSStefan Roese 		if (ver == SVR_8540 || ver == SVR_8560   ||
131a47a12beSStefan Roese 		    ver == SVR_8541 || ver == SVR_8541_E ||
132a47a12beSStefan Roese 		    ver == SVR_8555 || ver == SVR_8555_E)
133a47a12beSStefan Roese 			return 256;
134a47a12beSStefan Roese 		else
135a47a12beSStefan Roese 			return 512;
136a47a12beSStefan Roese 		break;
137a47a12beSStefan Roese 	case 0x3:
138a47a12beSStefan Roese 		return 1024;
139a47a12beSStefan Roese 		break;
140a47a12beSStefan Roese 	}
141a47a12beSStefan Roese 
142a47a12beSStefan Roese 	return 0;
143a47a12beSStefan Roese }
144a47a12beSStefan Roese 
145a47a12beSStefan Roese static inline void ft_fixup_l2cache(void *blob)
146a47a12beSStefan Roese {
147a47a12beSStefan Roese 	int len, off;
148a47a12beSStefan Roese 	u32 *ph;
149a47a12beSStefan Roese 	struct cpu_type *cpu = identify_cpu(SVR_SOC_VER(get_svr()));
150a47a12beSStefan Roese 	char compat_buf[38];
151a47a12beSStefan Roese 
152a47a12beSStefan Roese 	const u32 line_size = 32;
153a47a12beSStefan Roese 	const u32 num_ways = 8;
154a47a12beSStefan Roese 	const u32 size = l2cache_size() * 1024;
155a47a12beSStefan Roese 	const u32 num_sets = size / (line_size * num_ways);
156a47a12beSStefan Roese 
157a47a12beSStefan Roese 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
158a47a12beSStefan Roese 	if (off < 0) {
159a47a12beSStefan Roese 		debug("no cpu node fount\n");
160a47a12beSStefan Roese 		return;
161a47a12beSStefan Roese 	}
162a47a12beSStefan Roese 
163a47a12beSStefan Roese 	ph = (u32 *)fdt_getprop(blob, off, "next-level-cache", 0);
164a47a12beSStefan Roese 
165a47a12beSStefan Roese 	if (ph == NULL) {
166a47a12beSStefan Roese 		debug("no next-level-cache property\n");
167a47a12beSStefan Roese 		return ;
168a47a12beSStefan Roese 	}
169a47a12beSStefan Roese 
170a47a12beSStefan Roese 	off = fdt_node_offset_by_phandle(blob, *ph);
171a47a12beSStefan Roese 	if (off < 0) {
172a47a12beSStefan Roese 		printf("%s: %s\n", __func__, fdt_strerror(off));
173a47a12beSStefan Roese 		return ;
174a47a12beSStefan Roese 	}
175a47a12beSStefan Roese 
176a47a12beSStefan Roese 	if (cpu) {
177a47a12beSStefan Roese 		if (isdigit(cpu->name[0]))
178a47a12beSStefan Roese 			len = sprintf(compat_buf,
179a47a12beSStefan Roese 				"fsl,mpc%s-l2-cache-controller", cpu->name);
180a47a12beSStefan Roese 		else
181a47a12beSStefan Roese 			len = sprintf(compat_buf,
182a47a12beSStefan Roese 				"fsl,%c%s-l2-cache-controller",
183a47a12beSStefan Roese 				tolower(cpu->name[0]), cpu->name + 1);
184a47a12beSStefan Roese 
185a47a12beSStefan Roese 		sprintf(&compat_buf[len + 1], "cache");
186a47a12beSStefan Roese 	}
187a47a12beSStefan Roese 	fdt_setprop(blob, off, "cache-unified", NULL, 0);
188a47a12beSStefan Roese 	fdt_setprop_cell(blob, off, "cache-block-size", line_size);
189a47a12beSStefan Roese 	fdt_setprop_cell(blob, off, "cache-size", size);
190a47a12beSStefan Roese 	fdt_setprop_cell(blob, off, "cache-sets", num_sets);
191a47a12beSStefan Roese 	fdt_setprop_cell(blob, off, "cache-level", 2);
192a47a12beSStefan Roese 	fdt_setprop(blob, off, "compatible", compat_buf, sizeof(compat_buf));
193a47a12beSStefan Roese 
194a47a12beSStefan Roese 	/* we dont bother w/L3 since no platform of this type has one */
195a47a12beSStefan Roese }
196a47a12beSStefan Roese #elif defined(CONFIG_BACKSIDE_L2_CACHE)
197a47a12beSStefan Roese static inline void ft_fixup_l2cache(void *blob)
198a47a12beSStefan Roese {
199a47a12beSStefan Roese 	int off, l2_off, l3_off = -1;
200a47a12beSStefan Roese 	u32 *ph;
201a47a12beSStefan Roese 	u32 l2cfg0 = mfspr(SPRN_L2CFG0);
202a47a12beSStefan Roese 	u32 size, line_size, num_ways, num_sets;
203a47a12beSStefan Roese 
204a47a12beSStefan Roese 	size = (l2cfg0 & 0x3fff) * 64 * 1024;
205a47a12beSStefan Roese 	num_ways = ((l2cfg0 >> 14) & 0x1f) + 1;
206a47a12beSStefan Roese 	line_size = (((l2cfg0 >> 23) & 0x3) + 1) * 32;
207a47a12beSStefan Roese 	num_sets = size / (line_size * num_ways);
208a47a12beSStefan Roese 
209a47a12beSStefan Roese 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
210a47a12beSStefan Roese 
211a47a12beSStefan Roese 	while (off != -FDT_ERR_NOTFOUND) {
212a47a12beSStefan Roese 		ph = (u32 *)fdt_getprop(blob, off, "next-level-cache", 0);
213a47a12beSStefan Roese 
214a47a12beSStefan Roese 		if (ph == NULL) {
215a47a12beSStefan Roese 			debug("no next-level-cache property\n");
216a47a12beSStefan Roese 			goto next;
217a47a12beSStefan Roese 		}
218a47a12beSStefan Roese 
219a47a12beSStefan Roese 		l2_off = fdt_node_offset_by_phandle(blob, *ph);
220a47a12beSStefan Roese 		if (l2_off < 0) {
221a47a12beSStefan Roese 			printf("%s: %s\n", __func__, fdt_strerror(off));
222a47a12beSStefan Roese 			goto next;
223a47a12beSStefan Roese 		}
224a47a12beSStefan Roese 
225a47a12beSStefan Roese #ifdef CONFIG_SYS_CACHE_STASHING
226a47a12beSStefan Roese 		{
227a47a12beSStefan Roese 			u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
228a47a12beSStefan Roese 			if (reg)
229a47a12beSStefan Roese 				fdt_setprop_cell(blob, l2_off, "cache-stash-id",
230a47a12beSStefan Roese 					 (*reg * 2) + 32 + 1);
231a47a12beSStefan Roese 		}
232a47a12beSStefan Roese #endif
233a47a12beSStefan Roese 
234a47a12beSStefan Roese 		fdt_setprop(blob, l2_off, "cache-unified", NULL, 0);
235a47a12beSStefan Roese 		fdt_setprop_cell(blob, l2_off, "cache-block-size", line_size);
236a47a12beSStefan Roese 		fdt_setprop_cell(blob, l2_off, "cache-size", size);
237a47a12beSStefan Roese 		fdt_setprop_cell(blob, l2_off, "cache-sets", num_sets);
238a47a12beSStefan Roese 		fdt_setprop_cell(blob, l2_off, "cache-level", 2);
239a47a12beSStefan Roese 		fdt_setprop(blob, l2_off, "compatible", "cache", 6);
240a47a12beSStefan Roese 
241a47a12beSStefan Roese 		if (l3_off < 0) {
242a47a12beSStefan Roese 			ph = (u32 *)fdt_getprop(blob, l2_off, "next-level-cache", 0);
243a47a12beSStefan Roese 
244a47a12beSStefan Roese 			if (ph == NULL) {
245a47a12beSStefan Roese 				debug("no next-level-cache property\n");
246a47a12beSStefan Roese 				goto next;
247a47a12beSStefan Roese 			}
248a47a12beSStefan Roese 			l3_off = *ph;
249a47a12beSStefan Roese 		}
250a47a12beSStefan Roese next:
251a47a12beSStefan Roese 		off = fdt_node_offset_by_prop_value(blob, off,
252a47a12beSStefan Roese 				"device_type", "cpu", 4);
253a47a12beSStefan Roese 	}
254a47a12beSStefan Roese 	if (l3_off > 0) {
255a47a12beSStefan Roese 		l3_off = fdt_node_offset_by_phandle(blob, l3_off);
256a47a12beSStefan Roese 		if (l3_off < 0) {
257a47a12beSStefan Roese 			printf("%s: %s\n", __func__, fdt_strerror(off));
258a47a12beSStefan Roese 			return ;
259a47a12beSStefan Roese 		}
260a47a12beSStefan Roese 		ft_fixup_l3cache(blob, l3_off);
261a47a12beSStefan Roese 	}
262a47a12beSStefan Roese }
263a47a12beSStefan Roese #else
264a47a12beSStefan Roese #define ft_fixup_l2cache(x)
265a47a12beSStefan Roese #endif
266a47a12beSStefan Roese 
267a47a12beSStefan Roese static inline void ft_fixup_cache(void *blob)
268a47a12beSStefan Roese {
269a47a12beSStefan Roese 	int off;
270a47a12beSStefan Roese 
271a47a12beSStefan Roese 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
272a47a12beSStefan Roese 
273a47a12beSStefan Roese 	while (off != -FDT_ERR_NOTFOUND) {
274a47a12beSStefan Roese 		u32 l1cfg0 = mfspr(SPRN_L1CFG0);
275a47a12beSStefan Roese 		u32 l1cfg1 = mfspr(SPRN_L1CFG1);
276a47a12beSStefan Roese 		u32 isize, iline_size, inum_sets, inum_ways;
277a47a12beSStefan Roese 		u32 dsize, dline_size, dnum_sets, dnum_ways;
278a47a12beSStefan Roese 
279a47a12beSStefan Roese 		/* d-side config */
280a47a12beSStefan Roese 		dsize = (l1cfg0 & 0x7ff) * 1024;
281a47a12beSStefan Roese 		dnum_ways = ((l1cfg0 >> 11) & 0xff) + 1;
282a47a12beSStefan Roese 		dline_size = (((l1cfg0 >> 23) & 0x3) + 1) * 32;
283a47a12beSStefan Roese 		dnum_sets = dsize / (dline_size * dnum_ways);
284a47a12beSStefan Roese 
285a47a12beSStefan Roese 		fdt_setprop_cell(blob, off, "d-cache-block-size", dline_size);
286a47a12beSStefan Roese 		fdt_setprop_cell(blob, off, "d-cache-size", dsize);
287a47a12beSStefan Roese 		fdt_setprop_cell(blob, off, "d-cache-sets", dnum_sets);
288a47a12beSStefan Roese 
289a47a12beSStefan Roese #ifdef CONFIG_SYS_CACHE_STASHING
290a47a12beSStefan Roese 		{
291a47a12beSStefan Roese 			u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
292a47a12beSStefan Roese 			if (reg)
293a47a12beSStefan Roese 				fdt_setprop_cell(blob, off, "cache-stash-id",
294a47a12beSStefan Roese 					 (*reg * 2) + 32 + 0);
295a47a12beSStefan Roese 		}
296a47a12beSStefan Roese #endif
297a47a12beSStefan Roese 
298a47a12beSStefan Roese 		/* i-side config */
299a47a12beSStefan Roese 		isize = (l1cfg1 & 0x7ff) * 1024;
300a47a12beSStefan Roese 		inum_ways = ((l1cfg1 >> 11) & 0xff) + 1;
301a47a12beSStefan Roese 		iline_size = (((l1cfg1 >> 23) & 0x3) + 1) * 32;
302a47a12beSStefan Roese 		inum_sets = isize / (iline_size * inum_ways);
303a47a12beSStefan Roese 
304a47a12beSStefan Roese 		fdt_setprop_cell(blob, off, "i-cache-block-size", iline_size);
305a47a12beSStefan Roese 		fdt_setprop_cell(blob, off, "i-cache-size", isize);
306a47a12beSStefan Roese 		fdt_setprop_cell(blob, off, "i-cache-sets", inum_sets);
307a47a12beSStefan Roese 
308a47a12beSStefan Roese 		off = fdt_node_offset_by_prop_value(blob, off,
309a47a12beSStefan Roese 				"device_type", "cpu", 4);
310a47a12beSStefan Roese 	}
311a47a12beSStefan Roese 
312a47a12beSStefan Roese 	ft_fixup_l2cache(blob);
313a47a12beSStefan Roese }
314a47a12beSStefan Roese 
315a47a12beSStefan Roese 
316a47a12beSStefan Roese void fdt_add_enet_stashing(void *fdt)
317a47a12beSStefan Roese {
318a47a12beSStefan Roese 	do_fixup_by_compat(fdt, "gianfar", "bd-stash", NULL, 0, 1);
319a47a12beSStefan Roese 
320a47a12beSStefan Roese 	do_fixup_by_compat_u32(fdt, "gianfar", "rx-stash-len", 96, 1);
321a47a12beSStefan Roese 
322a47a12beSStefan Roese 	do_fixup_by_compat_u32(fdt, "gianfar", "rx-stash-idx", 0, 1);
323a47a12beSStefan Roese }
324a47a12beSStefan Roese 
325a47a12beSStefan Roese #if defined(CONFIG_SYS_DPAA_FMAN) || defined(CONFIG_SYS_DPAA_PME)
3261b942f74SKumar Gala static void ft_fixup_clks(void *blob, const char *compat, u32 offset,
3271b942f74SKumar Gala 			  unsigned long freq)
328a47a12beSStefan Roese {
3291b942f74SKumar Gala 	phys_addr_t phys = offset + CONFIG_SYS_CCSRBAR_PHYS;
3301b942f74SKumar Gala 	int off = fdt_node_offset_by_compat_reg(blob, compat, phys);
331a47a12beSStefan Roese 
332a47a12beSStefan Roese 	if (off >= 0) {
333a47a12beSStefan Roese 		off = fdt_setprop_cell(blob, off, "clock-frequency", freq);
334a47a12beSStefan Roese 		if (off > 0)
335a47a12beSStefan Roese 			printf("WARNING enable to set clock-frequency "
3361b942f74SKumar Gala 				"for %s: %s\n", compat, fdt_strerror(off));
337a47a12beSStefan Roese 	}
338a47a12beSStefan Roese }
339a47a12beSStefan Roese 
340a47a12beSStefan Roese static void ft_fixup_dpaa_clks(void *blob)
341a47a12beSStefan Roese {
342a47a12beSStefan Roese 	sys_info_t sysinfo;
343a47a12beSStefan Roese 
344a47a12beSStefan Roese 	get_sys_info(&sysinfo);
3451b942f74SKumar Gala 	ft_fixup_clks(blob, "fsl,fman", CONFIG_SYS_FSL_FM1_OFFSET,
3461b942f74SKumar Gala 			sysinfo.freqFMan[0]);
347a47a12beSStefan Roese 
348a47a12beSStefan Roese #if (CONFIG_SYS_NUM_FMAN == 2)
3491b942f74SKumar Gala 	ft_fixup_clks(blob, "fsl,fman", CONFIG_SYS_FSL_FM2_OFFSET,
3501b942f74SKumar Gala 			sysinfo.freqFMan[1]);
351a47a12beSStefan Roese #endif
352a47a12beSStefan Roese 
353a47a12beSStefan Roese #ifdef CONFIG_SYS_DPAA_PME
3541b942f74SKumar Gala 	do_fixup_by_compat_u32(blob, "fsl,pme",
3551b942f74SKumar Gala 		"clock-frequency", sysinfo.freqPME, 1);
356a47a12beSStefan Roese #endif
357a47a12beSStefan Roese }
358a47a12beSStefan Roese #else
359a47a12beSStefan Roese #define ft_fixup_dpaa_clks(x)
360a47a12beSStefan Roese #endif
361a47a12beSStefan Roese 
362a47a12beSStefan Roese #ifdef CONFIG_QE
363a47a12beSStefan Roese static void ft_fixup_qe_snum(void *blob)
364a47a12beSStefan Roese {
365a47a12beSStefan Roese 	unsigned int svr;
366a47a12beSStefan Roese 
367a47a12beSStefan Roese 	svr = mfspr(SPRN_SVR);
368a47a12beSStefan Roese 	if (SVR_SOC_VER(svr) == SVR_8569_E) {
369a47a12beSStefan Roese 		if(IS_SVR_REV(svr, 1, 0))
370a47a12beSStefan Roese 			do_fixup_by_compat_u32(blob, "fsl,qe",
371a47a12beSStefan Roese 				"fsl,qe-num-snums", 46, 1);
372a47a12beSStefan Roese 		else
373a47a12beSStefan Roese 			do_fixup_by_compat_u32(blob, "fsl,qe",
374a47a12beSStefan Roese 				"fsl,qe-num-snums", 76, 1);
375a47a12beSStefan Roese 	}
376a47a12beSStefan Roese }
377a47a12beSStefan Roese #endif
378a47a12beSStefan Roese 
379a47a12beSStefan Roese void ft_cpu_setup(void *blob, bd_t *bd)
380a47a12beSStefan Roese {
381a47a12beSStefan Roese 	int off;
382a47a12beSStefan Roese 	int val;
383a47a12beSStefan Roese 	sys_info_t sysinfo;
384a47a12beSStefan Roese 
385a47a12beSStefan Roese 	/* delete crypto node if not on an E-processor */
386a47a12beSStefan Roese 	if (!IS_E_PROCESSOR(get_svr()))
387a47a12beSStefan Roese 		fdt_fixup_crypto_node(blob, 0);
388a47a12beSStefan Roese 
389a47a12beSStefan Roese 	fdt_fixup_ethernet(blob);
390a47a12beSStefan Roese 
391a47a12beSStefan Roese 	fdt_add_enet_stashing(blob);
392a47a12beSStefan Roese 
393a47a12beSStefan Roese 	do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
394a47a12beSStefan Roese 		"timebase-frequency", get_tbclk(), 1);
395a47a12beSStefan Roese 	do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
396a47a12beSStefan Roese 		"bus-frequency", bd->bi_busfreq, 1);
397a47a12beSStefan Roese 	get_sys_info(&sysinfo);
398a47a12beSStefan Roese 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
399a47a12beSStefan Roese 	while (off != -FDT_ERR_NOTFOUND) {
400a47a12beSStefan Roese 		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
401a47a12beSStefan Roese 		val = cpu_to_fdt32(sysinfo.freqProcessor[*reg]);
402a47a12beSStefan Roese 		fdt_setprop(blob, off, "clock-frequency", &val, 4);
403a47a12beSStefan Roese 		off = fdt_node_offset_by_prop_value(blob, off, "device_type",
404a47a12beSStefan Roese 							"cpu", 4);
405a47a12beSStefan Roese 	}
406a47a12beSStefan Roese 	do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
407a47a12beSStefan Roese 		"bus-frequency", bd->bi_busfreq, 1);
408a47a12beSStefan Roese 
409a47a12beSStefan Roese 	do_fixup_by_compat_u32(blob, "fsl,pq3-localbus",
410a47a12beSStefan Roese 		"bus-frequency", gd->lbc_clk, 1);
411a47a12beSStefan Roese 	do_fixup_by_compat_u32(blob, "fsl,elbc",
412a47a12beSStefan Roese 		"bus-frequency", gd->lbc_clk, 1);
413a47a12beSStefan Roese #ifdef CONFIG_QE
414a47a12beSStefan Roese 	ft_qe_setup(blob);
415a47a12beSStefan Roese 	ft_fixup_qe_snum(blob);
416a47a12beSStefan Roese #endif
417a47a12beSStefan Roese 
418a47a12beSStefan Roese #ifdef CONFIG_SYS_NS16550
419a47a12beSStefan Roese 	do_fixup_by_compat_u32(blob, "ns16550",
420a47a12beSStefan Roese 		"clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
421a47a12beSStefan Roese #endif
422a47a12beSStefan Roese 
423a47a12beSStefan Roese #ifdef CONFIG_CPM2
424a47a12beSStefan Roese 	do_fixup_by_compat_u32(blob, "fsl,cpm2-scc-uart",
425a47a12beSStefan Roese 		"current-speed", bd->bi_baudrate, 1);
426a47a12beSStefan Roese 
427a47a12beSStefan Roese 	do_fixup_by_compat_u32(blob, "fsl,cpm2-brg",
428a47a12beSStefan Roese 		"clock-frequency", bd->bi_brgfreq, 1);
429a47a12beSStefan Roese #endif
430a47a12beSStefan Roese 
43185f8cda3SKumar Gala #ifdef CONFIG_FSL_CORENET
43285f8cda3SKumar Gala 	do_fixup_by_compat_u32(blob, "fsl,qoriq-clockgen-1.0",
43385f8cda3SKumar Gala 		"clock-frequency", CONFIG_SYS_CLK_FREQ, 1);
43485f8cda3SKumar Gala #endif
43585f8cda3SKumar Gala 
436a47a12beSStefan Roese 	fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
437a47a12beSStefan Roese 
438a47a12beSStefan Roese #ifdef CONFIG_MP
439a47a12beSStefan Roese 	ft_fixup_cpu(blob, (u64)bd->bi_memstart + (u64)bd->bi_memsize);
440a47a12beSStefan Roese 	ft_fixup_num_cores(blob);
4418f3a7fa4SKumar Gala #endif
442a47a12beSStefan Roese 
443a47a12beSStefan Roese 	ft_fixup_cache(blob);
444a47a12beSStefan Roese 
445a47a12beSStefan Roese #if defined(CONFIG_FSL_ESDHC)
446a47a12beSStefan Roese 	fdt_fixup_esdhc(blob, bd);
447a47a12beSStefan Roese #endif
448a47a12beSStefan Roese 
449a47a12beSStefan Roese 	ft_fixup_dpaa_clks(blob);
450*db977abfSKumar Gala 
451*db977abfSKumar Gala #if defined(CONFIG_SYS_BMAN_MEM_PHYS)
452*db977abfSKumar Gala 	fdt_portal(blob, "fsl,bman-portal", "bman-portals",
453*db977abfSKumar Gala 			(u64)CONFIG_SYS_BMAN_MEM_PHYS,
454*db977abfSKumar Gala 			CONFIG_SYS_BMAN_MEM_SIZE);
455*db977abfSKumar Gala #endif
456*db977abfSKumar Gala 
457*db977abfSKumar Gala #if defined(CONFIG_SYS_QMAN_MEM_PHYS)
458*db977abfSKumar Gala 	fdt_portal(blob, "fsl,qman-portal", "qman-portals",
459*db977abfSKumar Gala 			(u64)CONFIG_SYS_QMAN_MEM_PHYS,
460*db977abfSKumar Gala 			CONFIG_SYS_QMAN_MEM_SIZE);
461*db977abfSKumar Gala 
462*db977abfSKumar Gala 	fdt_fixup_qportals(blob);
463*db977abfSKumar Gala #endif
464a47a12beSStefan Roese }
465