Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 1 | /* |
Kumar Gala | 5655136 | 2011-01-04 17:07:54 -0600 | [diff] [blame] | 2 | * Copyright 2008, 2011 Freescale Semiconductor, Inc. |
Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 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> |
Kumar Gala | 7649a59 | 2009-03-31 23:02:38 -0500 | [diff] [blame] | 12 | #include <asm/mp.h> |
Becky Bruce | 1266df8 | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 15 | |
Poonam Aggrwal | f8027f6 | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 16 | extern void ft_fixup_num_cores(void *blob); |
Kumar Gala | 5655136 | 2011-01-04 17:07:54 -0600 | [diff] [blame] | 17 | extern void ft_srio_setup(void *blob); |
Poonam Aggrwal | f8027f6 | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 18 | |
Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 19 | void ft_cpu_setup(void *blob, bd_t *bd) |
| 20 | { |
Kumar Gala | 7649a59 | 2009-03-31 23:02:38 -0500 | [diff] [blame] | 21 | #ifdef CONFIG_MP |
Becky Bruce | 1266df8 | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 22 | int off; |
York Sun | eb53941 | 2012-10-08 07:44:25 +0000 | [diff] [blame] | 23 | u32 bootpg = determine_mp_bootpg(NULL); |
Becky Bruce | 1266df8 | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 24 | #endif |
| 25 | |
Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 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 | |
Trent Piepho | 58ec486 | 2008-12-03 15:16:38 -0800 | [diff] [blame] | 35 | #if defined(CONFIG_MPC8641) |
| 36 | do_fixup_by_compat_u32(blob, "fsl,mpc8641-localbus", |
Simon Glass | 67ac13b | 2012-12-13 20:48:48 +0000 | [diff] [blame] | 37 | "bus-frequency", gd->arch.lbc_clk, 1); |
Trent Piepho | 58ec486 | 2008-12-03 15:16:38 -0800 | [diff] [blame] | 38 | #endif |
| 39 | do_fixup_by_compat_u32(blob, "fsl,elbc", |
Simon Glass | 67ac13b | 2012-12-13 20:48:48 +0000 | [diff] [blame] | 40 | "bus-frequency", gd->arch.lbc_clk, 1); |
Trent Piepho | 58ec486 | 2008-12-03 15:16:38 -0800 | [diff] [blame] | 41 | |
Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 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) |
Kumar Gala | ba37aa0 | 2008-08-19 15:41:18 -0500 | [diff] [blame] | 46 | fdt_fixup_ethernet(blob); |
Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 47 | #endif |
| 48 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 49 | #ifdef CONFIG_SYS_NS16550 |
Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 50 | do_fixup_by_compat_u32(blob, "ns16550", |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 51 | "clock-frequency", CONFIG_SYS_NS16550_CLK, 1); |
Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 52 | #endif |
Becky Bruce | 1266df8 | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 53 | |
Kumar Gala | 7649a59 | 2009-03-31 23:02:38 -0500 | [diff] [blame] | 54 | #ifdef CONFIG_MP |
Becky Bruce | 1266df8 | 2008-11-03 15:44:01 -0600 | [diff] [blame] | 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)); |
Kumar Gala | 8f3a7fa | 2010-06-09 22:33:53 -0500 | [diff] [blame] | 59 | |
Poonam Aggrwal | f8027f6 | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 60 | ft_fixup_num_cores(blob); |
Kumar Gala | 8f3a7fa | 2010-06-09 22:33:53 -0500 | [diff] [blame] | 61 | #endif |
Kumar Gala | 5655136 | 2011-01-04 17:07:54 -0600 | [diff] [blame] | 62 | |
| 63 | #ifdef CONFIG_SYS_SRIO |
| 64 | ft_srio_setup(blob); |
| 65 | #endif |
Jon Loeliger | 13f5433 | 2008-02-18 14:01:56 -0600 | [diff] [blame] | 66 | } |