Merge tag 'xilinx-for-v2021.01' of https://gitlab.denx.de/u-boot/custodians/u-boot...
[platform/kernel/u-boot.git] / arch / powerpc / cpu / mpc86xx / fdt.c
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 DECLARE_GLOBAL_DATA_PTR;
12
13 extern void ft_fixup_num_cores(void *blob);
14 extern void ft_srio_setup(void *blob);
15
16 void ft_cpu_setup(void *blob, struct bd_info *bd)
17 {
18 #ifdef CONFIG_MP
19         int off;
20         u32 bootpg = determine_mp_bootpg(NULL);
21 #endif
22
23         do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
24                              "timebase-frequency", bd->bi_busfreq / 4, 1);
25         do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
26                              "bus-frequency", bd->bi_busfreq, 1);
27         do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
28                              "clock-frequency", bd->bi_intfreq, 1);
29         do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
30                              "bus-frequency", bd->bi_busfreq, 1);
31
32         fdt_fixup_memory(blob, (u64)gd->ram_base, (u64)gd->ram_size);
33
34 #ifdef CONFIG_SYS_NS16550
35         do_fixup_by_compat_u32(blob, "ns16550",
36                                "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
37 #endif
38
39 #ifdef CONFIG_MP
40         /* Reserve the boot page so OSes dont use it */
41         off = fdt_add_mem_rsv(blob, bootpg, (u64)4096);
42         if (off < 0)
43                 printf("%s: %s\n", __FUNCTION__, fdt_strerror(off));
44
45         ft_fixup_num_cores(blob);
46 #endif
47
48 #ifdef CONFIG_SYS_SRIO
49         ft_srio_setup(blob);
50 #endif
51 }