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