blob: 010b6d4fe60670236799535e6c7418ca373739b1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Jon Loeliger84640c92008-02-18 14:01:56 -06002/*
Kumar Gala3cdbd002011-01-04 17:07:54 -06003 * Copyright 2008, 2011 Freescale Semiconductor, Inc.
Jon Loeliger84640c92008-02-18 14:01:56 -06004 */
5
6#include <common.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +09007#include <linux/libfdt.h>
Jon Loeliger84640c92008-02-18 14:01:56 -06008#include <fdt_support.h>
Kumar Gala56d150e2009-03-31 23:02:38 -05009#include <asm/mp.h>
Becky Bruced1cb6cb2008-11-03 15:44:01 -060010
Stefan Roesea13a2aa2020-08-12 13:16:36 +020011DECLARE_GLOBAL_DATA_PTR;
12
Poonam Aggrwal4ca72ae2009-09-02 19:40:36 +053013extern void ft_fixup_num_cores(void *blob);
Kumar Gala3cdbd002011-01-04 17:07:54 -060014extern void ft_srio_setup(void *blob);
Poonam Aggrwal4ca72ae2009-09-02 19:40:36 +053015
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090016void ft_cpu_setup(void *blob, struct bd_info *bd)
Jon Loeliger84640c92008-02-18 14:01:56 -060017{
Kumar Gala56d150e2009-03-31 23:02:38 -050018#ifdef CONFIG_MP
Becky Bruced1cb6cb2008-11-03 15:44:01 -060019 int off;
York Suna28496f2012-10-08 07:44:25 +000020 u32 bootpg = determine_mp_bootpg(NULL);
Becky Bruced1cb6cb2008-11-03 15:44:01 -060021#endif
22
Jon Loeliger84640c92008-02-18 14:01:56 -060023 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
Stefan Roesea13a2aa2020-08-12 13:16:36 +020032 fdt_fixup_memory(blob, (u64)gd->ram_base, (u64)gd->ram_size);
Jon Loeliger84640c92008-02-18 14:01:56 -060033
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020034#ifdef CONFIG_SYS_NS16550
Jon Loeliger84640c92008-02-18 14:01:56 -060035 do_fixup_by_compat_u32(blob, "ns16550",
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020036 "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
Jon Loeliger84640c92008-02-18 14:01:56 -060037#endif
Becky Bruced1cb6cb2008-11-03 15:44:01 -060038
Kumar Gala56d150e2009-03-31 23:02:38 -050039#ifdef CONFIG_MP
Becky Bruced1cb6cb2008-11-03 15:44:01 -060040 /* 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));
Kumar Gala819a4792010-06-09 22:33:53 -050044
Poonam Aggrwal4ca72ae2009-09-02 19:40:36 +053045 ft_fixup_num_cores(blob);
Kumar Gala819a4792010-06-09 22:33:53 -050046#endif
Kumar Gala3cdbd002011-01-04 17:07:54 -060047
48#ifdef CONFIG_SYS_SRIO
49 ft_srio_setup(blob);
50#endif
Jon Loeliger84640c92008-02-18 14:01:56 -060051}