blob: dd99155a28d5d427310172b0d351717346b23080 [file] [log] [blame]
Jon Loeliger84640c92008-02-18 14:01:56 -06001/*
Kumar Gala3cdbd002011-01-04 17:07:54 -06002 * Copyright 2008, 2011 Freescale Semiconductor, Inc.
Jon Loeliger84640c92008-02-18 14:01:56 -06003 *
Tom Rinie2378802016-01-14 22:05:13 -05004 * SPDX-License-Identifier: GPL-2.0
Jon Loeliger84640c92008-02-18 14:01:56 -06005 */
6
7#include <common.h>
8#include <libfdt.h>
9#include <fdt_support.h>
Kumar Gala56d150e2009-03-31 23:02:38 -050010#include <asm/mp.h>
Becky Bruced1cb6cb2008-11-03 15:44:01 -060011
12DECLARE_GLOBAL_DATA_PTR;
Jon Loeliger84640c92008-02-18 14:01:56 -060013
Poonam Aggrwal4ca72ae2009-09-02 19:40:36 +053014extern void ft_fixup_num_cores(void *blob);
Kumar Gala3cdbd002011-01-04 17:07:54 -060015extern void ft_srio_setup(void *blob);
Poonam Aggrwal4ca72ae2009-09-02 19:40:36 +053016
Jon Loeliger84640c92008-02-18 14:01:56 -060017void ft_cpu_setup(void *blob, bd_t *bd)
18{
Kumar Gala56d150e2009-03-31 23:02:38 -050019#ifdef CONFIG_MP
Becky Bruced1cb6cb2008-11-03 15:44:01 -060020 int off;
York Suna28496f2012-10-08 07:44:25 +000021 u32 bootpg = determine_mp_bootpg(NULL);
Becky Bruced1cb6cb2008-11-03 15:44:01 -060022#endif
23
Jon Loeliger84640c92008-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
Trent Piephobc424c92008-12-03 15:16:38 -080033#if defined(CONFIG_MPC8641)
34 do_fixup_by_compat_u32(blob, "fsl,mpc8641-localbus",
Simon Glassa8b57392012-12-13 20:48:48 +000035 "bus-frequency", gd->arch.lbc_clk, 1);
Trent Piephobc424c92008-12-03 15:16:38 -080036#endif
37 do_fixup_by_compat_u32(blob, "fsl,elbc",
Simon Glassa8b57392012-12-13 20:48:48 +000038 "bus-frequency", gd->arch.lbc_clk, 1);
Trent Piephobc424c92008-12-03 15:16:38 -080039
Jon Loeliger84640c92008-02-18 14:01:56 -060040 fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
41
42#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) \
43 || defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
Kumar Galafabda922008-08-19 15:41:18 -050044 fdt_fixup_ethernet(blob);
Jon Loeliger84640c92008-02-18 14:01:56 -060045#endif
46
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020047#ifdef CONFIG_SYS_NS16550
Jon Loeliger84640c92008-02-18 14:01:56 -060048 do_fixup_by_compat_u32(blob, "ns16550",
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020049 "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
Jon Loeliger84640c92008-02-18 14:01:56 -060050#endif
Becky Bruced1cb6cb2008-11-03 15:44:01 -060051
Kumar Gala56d150e2009-03-31 23:02:38 -050052#ifdef CONFIG_MP
Becky Bruced1cb6cb2008-11-03 15:44:01 -060053 /* Reserve the boot page so OSes dont use it */
54 off = fdt_add_mem_rsv(blob, bootpg, (u64)4096);
55 if (off < 0)
56 printf("%s: %s\n", __FUNCTION__, fdt_strerror(off));
Kumar Gala819a4792010-06-09 22:33:53 -050057
Poonam Aggrwal4ca72ae2009-09-02 19:40:36 +053058 ft_fixup_num_cores(blob);
Kumar Gala819a4792010-06-09 22:33:53 -050059#endif
Kumar Gala3cdbd002011-01-04 17:07:54 -060060
61#ifdef CONFIG_SYS_SRIO
62 ft_srio_setup(blob);
63#endif
Jon Loeliger84640c92008-02-18 14:01:56 -060064}