John Tsichritzis | d325554 | 2018-10-10 13:13:43 +0100 | [diff] [blame] | 1 | /* |
John Tsichritzis | 2eafdf2 | 2019-02-25 15:31:35 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
John Tsichritzis | d325554 | 2018-10-10 13:13:43 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <assert.h> |
John Tsichritzis | 2eafdf2 | 2019-02-25 15:31:35 +0000 | [diff] [blame] | 9 | #include <drivers/console.h> |
| 10 | #include <drivers/arm/gic_v2.h> |
John Tsichritzis | d325554 | 2018-10-10 13:13:43 +0100 | [diff] [blame] | 11 | #include <platform.h> |
| 12 | #include <platform_def.h> |
| 13 | |
| 14 | |
| 15 | static const mmap_region_t mmap[] = { |
John Tsichritzis | 317632b | 2018-10-22 15:54:44 +0100 | [diff] [blame] | 16 | MAP_REGION_FLAT(DRAM_BASE + TFTF_NVM_OFFSET, TFTF_NVM_SIZE, MT_MEMORY | MT_RW | MT_NS), |
| 17 | MAP_REGION_FLAT(GIC_BASE, GIC_SIZE, MT_DEVICE | MT_RW | MT_NS), |
| 18 | MAP_REGION_FLAT(SP805_WDOG_BASE, SP805_WDOG_SIZE, MT_DEVICE | MT_RW | MT_NS), |
| 19 | MAP_REGION_FLAT(SYS_CNT_BASE1, SYS_CNT_SIZE, MT_DEVICE | MT_RW | MT_NS), |
| 20 | MAP_REGION_FLAT(CRASH_CONSOLE_BASE, CRASH_CONSOLE_SIZE, MT_DEVICE | MT_RW | MT_NS), |
John Tsichritzis | d325554 | 2018-10-10 13:13:43 +0100 | [diff] [blame] | 21 | {0} |
| 22 | }; |
| 23 | |
| 24 | /* Power Domain Tree Descriptor array */ |
| 25 | const unsigned char hikey960_power_domain_tree_desc[] = { |
| 26 | /* Number of root nodes */ |
| 27 | 1, |
| 28 | /* Number of clusters */ |
| 29 | PLATFORM_CLUSTER_COUNT, |
| 30 | /* Number of children for the first cluster node */ |
John Tsichritzis | e223699 | 2018-10-25 10:05:39 +0100 | [diff] [blame] | 31 | PLATFORM_CORE_COUNT_PER_CLUSTER |
| 32 | /* |
| 33 | * TODO: Re-enable this code once power management issues on Hikey [1] |
| 34 | * are resolved. |
| 35 | * [1] https://bugs.96boards.org/show_bug.cgi?id=783 |
| 36 | */ |
John Tsichritzis | d325554 | 2018-10-10 13:13:43 +0100 | [diff] [blame] | 37 | /* Number of children for the second cluster node */ |
John Tsichritzis | e223699 | 2018-10-25 10:05:39 +0100 | [diff] [blame] | 38 | /* PLATFORM_CORE_COUNT_PER_CLUSTER, */ |
John Tsichritzis | d325554 | 2018-10-10 13:13:43 +0100 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | |
| 42 | const unsigned char *tftf_plat_get_pwr_domain_tree_desc(void) |
| 43 | { |
| 44 | return hikey960_power_domain_tree_desc; |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | * Generate the MPID from the core position. |
| 49 | */ |
| 50 | uint64_t tftf_plat_get_mpidr(unsigned int core_pos) |
| 51 | { |
| 52 | uint64_t mpid; |
| 53 | unsigned int coreid, clusterid; |
| 54 | |
| 55 | assert(core_pos < PLATFORM_CORE_COUNT); |
| 56 | |
| 57 | coreid = core_pos % PLATFORM_CORE_COUNT_PER_CLUSTER; |
| 58 | clusterid = core_pos / PLATFORM_CORE_COUNT_PER_CLUSTER; |
| 59 | |
| 60 | if (clusterid >= PLATFORM_CLUSTER_COUNT) |
| 61 | return INVALID_MPID; |
| 62 | |
| 63 | mpid = (coreid << MPIDR_AFF0_SHIFT) | (clusterid << MPIDR_AFF1_SHIFT); |
| 64 | |
| 65 | return mpid; |
| 66 | } |
| 67 | |
| 68 | void tftf_plat_arch_setup(void) |
| 69 | { |
| 70 | tftf_plat_configure_mmu(); |
| 71 | } |
| 72 | |
| 73 | void tftf_early_platform_setup(void) |
| 74 | { |
| 75 | console_init(CRASH_CONSOLE_BASE, PL011_UART_CLK_IN_HZ, |
| 76 | PL011_BAUDRATE); |
| 77 | } |
| 78 | |
| 79 | void tftf_platform_setup(void) |
| 80 | { |
| 81 | gicv2_init(GICC_REG_BASE, GICD_REG_BASE); |
John Tsichritzis | 0541db1 | 2018-10-22 16:34:39 +0100 | [diff] [blame] | 82 | gicv2_setup_distif(); |
John Tsichritzis | d325554 | 2018-10-10 13:13:43 +0100 | [diff] [blame] | 83 | gicv2_probe_gic_cpu_id(); |
| 84 | gicv2_setup_cpuif(); |
| 85 | } |
| 86 | |
| 87 | const mmap_region_t *tftf_platform_get_mmap(void) |
| 88 | { |
| 89 | return mmap; |
| 90 | } |