Vikram Kanigiri | fbb1301 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 1 | /* |
Daniel Boulby | 844b487 | 2018-09-18 13:36:39 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. |
Vikram Kanigiri | fbb1301 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Vikram Kanigiri | fbb1301 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 7 | #include <platform_def.h> |
| 8 | |
Vikram Kanigiri | fbb1301 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 9 | #include <arch.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <drivers/arm/ccn.h> |
Antonio Nino Diaz | bd7b740 | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 11 | #include <plat/arm/common/plat_arm.h> |
Vikram Kanigiri | fbb1301 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 12 | |
| 13 | static const unsigned char master_to_rn_id_map[] = { |
| 14 | PLAT_ARM_CLUSTER_TO_CCN_ID_MAP |
| 15 | }; |
| 16 | |
| 17 | static const ccn_desc_t arm_ccn_desc = { |
| 18 | .periphbase = PLAT_ARM_CCN_BASE, |
| 19 | .num_masters = ARRAY_SIZE(master_to_rn_id_map), |
| 20 | .master_to_rn_id_map = master_to_rn_id_map |
| 21 | }; |
| 22 | |
Soby Mathew | 7356b1e | 2016-03-24 10:12:42 +0000 | [diff] [blame] | 23 | CASSERT(PLAT_ARM_CLUSTER_COUNT == ARRAY_SIZE(master_to_rn_id_map), |
| 24 | assert_invalid_cluster_count_for_ccn_variant); |
| 25 | |
Vikram Kanigiri | fbb1301 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 26 | /****************************************************************************** |
| 27 | * The following functions are defined as weak to allow a platform to override |
| 28 | * the way ARM CCN driver is initialised and used. |
| 29 | *****************************************************************************/ |
| 30 | #pragma weak plat_arm_interconnect_init |
| 31 | #pragma weak plat_arm_interconnect_enter_coherency |
| 32 | #pragma weak plat_arm_interconnect_exit_coherency |
| 33 | |
| 34 | |
| 35 | /****************************************************************************** |
| 36 | * Helper function to initialize ARM CCN driver. |
| 37 | *****************************************************************************/ |
Daniel Boulby | 844b487 | 2018-09-18 13:36:39 +0100 | [diff] [blame] | 38 | void __init plat_arm_interconnect_init(void) |
Vikram Kanigiri | fbb1301 | 2016-02-15 11:54:14 +0000 | [diff] [blame] | 39 | { |
| 40 | ccn_init(&arm_ccn_desc); |
| 41 | } |
| 42 | |
| 43 | /****************************************************************************** |
| 44 | * Helper function to place current master into coherency |
| 45 | *****************************************************************************/ |
| 46 | void plat_arm_interconnect_enter_coherency(void) |
| 47 | { |
| 48 | ccn_enter_snoop_dvm_domain(1 << MPIDR_AFFLVL1_VAL(read_mpidr_el1())); |
| 49 | } |
| 50 | |
| 51 | /****************************************************************************** |
| 52 | * Helper function to remove current master from coherency |
| 53 | *****************************************************************************/ |
| 54 | void plat_arm_interconnect_exit_coherency(void) |
| 55 | { |
| 56 | ccn_exit_snoop_dvm_domain(1 << MPIDR_AFFLVL1_VAL(read_mpidr_el1())); |
| 57 | } |