xref: /openbmc/u-boot/arch/powerpc/cpu/mpc86xx/fdt.c (revision 699c40e8)
1 /*
2  * Copyright 2008, 2011 Freescale Semiconductor, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * Version 2 as published by the Free Software Foundation.
7  */
8 
9 #include <common.h>
10 #include <libfdt.h>
11 #include <fdt_support.h>
12 #include <asm/mp.h>
13 
14 DECLARE_GLOBAL_DATA_PTR;
15 
16 extern void ft_fixup_num_cores(void *blob);
17 extern void ft_srio_setup(void *blob);
18 
19 void ft_cpu_setup(void *blob, bd_t *bd)
20 {
21 #ifdef CONFIG_MP
22 	int off;
23 	u32 bootpg = determine_mp_bootpg(NULL);
24 #endif
25 
26 	do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
27 			     "timebase-frequency", bd->bi_busfreq / 4, 1);
28 	do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
29 			     "bus-frequency", bd->bi_busfreq, 1);
30 	do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
31 			     "clock-frequency", bd->bi_intfreq, 1);
32 	do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
33 			     "bus-frequency", bd->bi_busfreq, 1);
34 
35 #if defined(CONFIG_MPC8641)
36 	do_fixup_by_compat_u32(blob, "fsl,mpc8641-localbus",
37 			       "bus-frequency", gd->lbc_clk, 1);
38 #endif
39 	do_fixup_by_compat_u32(blob, "fsl,elbc",
40 			       "bus-frequency", gd->lbc_clk, 1);
41 
42 	fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
43 
44 #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) \
45     || defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
46 	fdt_fixup_ethernet(blob);
47 #endif
48 
49 #ifdef CONFIG_SYS_NS16550
50 	do_fixup_by_compat_u32(blob, "ns16550",
51 			       "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
52 #endif
53 
54 #ifdef CONFIG_MP
55 	/* Reserve the boot page so OSes dont use it */
56 	off = fdt_add_mem_rsv(blob, bootpg, (u64)4096);
57 	if (off < 0)
58 		printf("%s: %s\n", __FUNCTION__, fdt_strerror(off));
59 
60 	ft_fixup_num_cores(blob);
61 #endif
62 
63 #ifdef CONFIG_SYS_SRIO
64 	ft_srio_setup(blob);
65 #endif
66 }
67