Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Jon Loeliger | 84640c9 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 2 | /* |
Kumar Gala | 3cdbd00 | 2011-01-04 17:07:54 -0600 | [diff] [blame] | 3 | * Copyright 2008, 2011 Freescale Semiconductor, Inc. |
Jon Loeliger | 84640c9 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 7 | #include <asm/global_data.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 8 | #include <linux/libfdt.h> |
Jon Loeliger | 84640c9 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 9 | #include <fdt_support.h> |
Kumar Gala | 56d150e | 2009-03-31 23:02:38 -0500 | [diff] [blame] | 10 | #include <asm/mp.h> |
Becky Bruce | d1cb6cb | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 11 | |
Stefan Roese | a13a2aa | 2020-08-12 13:16:36 +0200 | [diff] [blame] | 12 | DECLARE_GLOBAL_DATA_PTR; |
| 13 | |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 14 | extern void ft_fixup_num_cores(void *blob); |
Kumar Gala | 3cdbd00 | 2011-01-04 17:07:54 -0600 | [diff] [blame] | 15 | extern void ft_srio_setup(void *blob); |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 16 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 17 | void ft_cpu_setup(void *blob, struct bd_info *bd) |
Jon Loeliger | 84640c9 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 18 | { |
Kumar Gala | 56d150e | 2009-03-31 23:02:38 -0500 | [diff] [blame] | 19 | #ifdef CONFIG_MP |
Becky Bruce | d1cb6cb | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 20 | int off; |
York Sun | a28496f | 2012-10-08 07:44:25 +0000 | [diff] [blame] | 21 | u32 bootpg = determine_mp_bootpg(NULL); |
Becky Bruce | d1cb6cb | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 22 | #endif |
| 23 | |
Jon Loeliger | 84640c9 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 24 | 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 | |
Stefan Roese | a13a2aa | 2020-08-12 13:16:36 +0200 | [diff] [blame] | 33 | fdt_fixup_memory(blob, (u64)gd->ram_base, (u64)gd->ram_size); |
Jon Loeliger | 84640c9 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 34 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 35 | #ifdef CONFIG_SYS_NS16550 |
Jon Loeliger | 84640c9 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 36 | do_fixup_by_compat_u32(blob, "ns16550", |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 37 | "clock-frequency", CONFIG_SYS_NS16550_CLK, 1); |
Jon Loeliger | 84640c9 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 38 | #endif |
Becky Bruce | d1cb6cb | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 39 | |
Kumar Gala | 56d150e | 2009-03-31 23:02:38 -0500 | [diff] [blame] | 40 | #ifdef CONFIG_MP |
Becky Bruce | d1cb6cb | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 41 | /* Reserve the boot page so OSes dont use it */ |
| 42 | off = fdt_add_mem_rsv(blob, bootpg, (u64)4096); |
| 43 | if (off < 0) |
| 44 | printf("%s: %s\n", __FUNCTION__, fdt_strerror(off)); |
Kumar Gala | 819a479 | 2010-06-09 22:33:53 -0500 | [diff] [blame] | 45 | |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 46 | ft_fixup_num_cores(blob); |
Kumar Gala | 819a479 | 2010-06-09 22:33:53 -0500 | [diff] [blame] | 47 | #endif |
Kumar Gala | 3cdbd00 | 2011-01-04 17:07:54 -0600 | [diff] [blame] | 48 | |
| 49 | #ifdef CONFIG_SYS_SRIO |
| 50 | ft_srio_setup(blob); |
| 51 | #endif |
Jon Loeliger | 84640c9 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 52 | } |