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