xref: /openbmc/u-boot/arch/powerpc/cpu/mpc86xx/fdt.c (revision e246b728)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright 2008, 2011 Freescale Semiconductor, Inc.
4  */
5 
6 #include <common.h>
7 #include <linux/libfdt.h>
8 #include <fdt_support.h>
9 #include <asm/mp.h>
10 
11 extern void ft_fixup_num_cores(void *blob);
12 extern void ft_srio_setup(void *blob);
13 
14 void ft_cpu_setup(void *blob, bd_t *bd)
15 {
16 #ifdef CONFIG_MP
17 	int off;
18 	u32 bootpg = determine_mp_bootpg(NULL);
19 #endif
20 
21 	do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
22 			     "timebase-frequency", bd->bi_busfreq / 4, 1);
23 	do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
24 			     "bus-frequency", bd->bi_busfreq, 1);
25 	do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
26 			     "clock-frequency", bd->bi_intfreq, 1);
27 	do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
28 			     "bus-frequency", bd->bi_busfreq, 1);
29 
30 	fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
31 
32 #ifdef CONFIG_SYS_NS16550
33 	do_fixup_by_compat_u32(blob, "ns16550",
34 			       "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
35 #endif
36 
37 #ifdef CONFIG_MP
38 	/* Reserve the boot page so OSes dont use it */
39 	off = fdt_add_mem_rsv(blob, bootpg, (u64)4096);
40 	if (off < 0)
41 		printf("%s: %s\n", __FUNCTION__, fdt_strerror(off));
42 
43 	ft_fixup_num_cores(blob);
44 #endif
45 
46 #ifdef CONFIG_SYS_SRIO
47 	ft_srio_setup(blob);
48 #endif
49 }
50