York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <libfdt.h> |
| 9 | #include <fdt_support.h> |
Yangbo Lu | d0e295d | 2015-03-20 19:28:31 -0700 | [diff] [blame^] | 10 | #ifdef CONFIG_FSL_ESDHC |
| 11 | #include <fsl_esdhc.h> |
| 12 | #endif |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 13 | #include "mp.h" |
| 14 | |
| 15 | #ifdef CONFIG_MP |
| 16 | void ft_fixup_cpu(void *blob) |
| 17 | { |
| 18 | int off; |
| 19 | __maybe_unused u64 spin_tbl_addr = (u64)get_spin_tbl_addr(); |
| 20 | fdt32_t *reg; |
| 21 | int addr_cells; |
Arnab Basu | 0cb1942 | 2015-01-06 13:18:41 -0800 | [diff] [blame] | 22 | u64 val, core_id; |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 23 | size_t *boot_code_size = &(__secondary_boot_code_size); |
| 24 | |
| 25 | off = fdt_path_offset(blob, "/cpus"); |
| 26 | if (off < 0) { |
| 27 | puts("couldn't find /cpus node\n"); |
| 28 | return; |
| 29 | } |
| 30 | of_bus_default_count_cells(blob, off, &addr_cells, NULL); |
| 31 | |
| 32 | off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4); |
| 33 | while (off != -FDT_ERR_NOTFOUND) { |
| 34 | reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0); |
Arnab Basu | 0cb1942 | 2015-01-06 13:18:41 -0800 | [diff] [blame] | 35 | core_id = of_read_number(reg, addr_cells); |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 36 | if (reg) { |
Arnab Basu | 0cb1942 | 2015-01-06 13:18:41 -0800 | [diff] [blame] | 37 | if (core_id == 0 || (is_core_online(core_id))) { |
| 38 | val = spin_tbl_addr; |
| 39 | val += id_to_core(core_id) * |
| 40 | SPIN_TABLE_ELEM_SIZE; |
| 41 | val = cpu_to_fdt64(val); |
| 42 | fdt_setprop_string(blob, off, "enable-method", |
| 43 | "spin-table"); |
| 44 | fdt_setprop(blob, off, "cpu-release-addr", |
| 45 | &val, sizeof(val)); |
| 46 | } else { |
| 47 | debug("skipping offline core\n"); |
| 48 | } |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 49 | } else { |
| 50 | puts("Warning: found cpu node without reg property\n"); |
| 51 | } |
| 52 | off = fdt_node_offset_by_prop_value(blob, off, "device_type", |
| 53 | "cpu", 4); |
| 54 | } |
| 55 | |
| 56 | fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code, |
| 57 | *boot_code_size); |
| 58 | } |
| 59 | #endif |
| 60 | |
| 61 | void ft_cpu_setup(void *blob, bd_t *bd) |
| 62 | { |
| 63 | #ifdef CONFIG_MP |
| 64 | ft_fixup_cpu(blob); |
| 65 | #endif |
Bhupesh Sharma | c771040 | 2015-01-06 13:18:44 -0800 | [diff] [blame] | 66 | |
| 67 | #ifdef CONFIG_SYS_NS16550 |
Scott Wood | 3e7fd6f | 2015-03-20 19:28:14 -0700 | [diff] [blame] | 68 | do_fixup_by_compat_u32(blob, "fsl,ns16550", |
Bhupesh Sharma | c771040 | 2015-01-06 13:18:44 -0800 | [diff] [blame] | 69 | "clock-frequency", CONFIG_SYS_NS16550_CLK, 1); |
| 70 | #endif |
Yangbo Lu | d0e295d | 2015-03-20 19:28:31 -0700 | [diff] [blame^] | 71 | |
| 72 | #if defined(CONFIG_FSL_ESDHC) |
| 73 | fdt_fixup_esdhc(blob, bd); |
| 74 | #endif |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 75 | } |