blob: 5f9ad6b0b6d44a3a1df97457b021e44c7101339d [file] [log] [blame]
Jon Loeliger13f54332008-02-18 14:01:56 -06001/*
Kumar Gala56551362011-01-04 17:07:54 -06002 * Copyright 2008, 2011 Freescale Semiconductor, Inc.
Jon Loeliger13f54332008-02-18 14:01:56 -06003 *
Tom Rini5b8031c2016-01-14 22:05:13 -05004 * SPDX-License-Identifier: GPL-2.0
Jon Loeliger13f54332008-02-18 14:01:56 -06005 */
6
7#include <common.h>
8#include <libfdt.h>
9#include <fdt_support.h>
Kumar Gala7649a592009-03-31 23:02:38 -050010#include <asm/mp.h>
Becky Bruce1266df82008-11-03 15:44:01 -060011
12DECLARE_GLOBAL_DATA_PTR;
Jon Loeliger13f54332008-02-18 14:01:56 -060013
Poonam Aggrwalf8027f62009-09-02 19:40:36 +053014extern void ft_fixup_num_cores(void *blob);
Kumar Gala56551362011-01-04 17:07:54 -060015extern void ft_srio_setup(void *blob);
Poonam Aggrwalf8027f62009-09-02 19:40:36 +053016
Jon Loeliger13f54332008-02-18 14:01:56 -060017void ft_cpu_setup(void *blob, bd_t *bd)
18{
Kumar Gala7649a592009-03-31 23:02:38 -050019#ifdef CONFIG_MP
Becky Bruce1266df82008-11-03 15:44:01 -060020 int off;
York Suneb539412012-10-08 07:44:25 +000021 u32 bootpg = determine_mp_bootpg(NULL);
Becky Bruce1266df82008-11-03 15:44:01 -060022#endif
23
Jon Loeliger13f54332008-02-18 14:01:56 -060024 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
25 "timebase-frequency", bd->bi_busfreq / 4, 1);
26 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
27 "bus-frequency", bd->bi_busfreq, 1);
28 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
29 "clock-frequency", bd->bi_intfreq, 1);
30 do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
31 "bus-frequency", bd->bi_busfreq, 1);
32
33 fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
34
35#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) \
36 || defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
Kumar Galaba37aa02008-08-19 15:41:18 -050037 fdt_fixup_ethernet(blob);
Jon Loeliger13f54332008-02-18 14:01:56 -060038#endif
39
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020040#ifdef CONFIG_SYS_NS16550
Jon Loeliger13f54332008-02-18 14:01:56 -060041 do_fixup_by_compat_u32(blob, "ns16550",
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020042 "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
Jon Loeliger13f54332008-02-18 14:01:56 -060043#endif
Becky Bruce1266df82008-11-03 15:44:01 -060044
Kumar Gala7649a592009-03-31 23:02:38 -050045#ifdef CONFIG_MP
Becky Bruce1266df82008-11-03 15:44:01 -060046 /* Reserve the boot page so OSes dont use it */
47 off = fdt_add_mem_rsv(blob, bootpg, (u64)4096);
48 if (off < 0)
49 printf("%s: %s\n", __FUNCTION__, fdt_strerror(off));
Kumar Gala8f3a7fa2010-06-09 22:33:53 -050050
Poonam Aggrwalf8027f62009-09-02 19:40:36 +053051 ft_fixup_num_cores(blob);
Kumar Gala8f3a7fa2010-06-09 22:33:53 -050052#endif
Kumar Gala56551362011-01-04 17:07:54 -060053
54#ifdef CONFIG_SYS_SRIO
55 ft_srio_setup(blob);
56#endif
Jon Loeliger13f54332008-02-18 14:01:56 -060057}