1 /* 2 * Arm SCP/MCP Software 3 * Copyright (c) 2017-2022, Arm Limited and Contributors. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 /* The use of "manager" may not be in sync with older versions of TRM */ 9 10 #ifndef MOD_CMN_SKEENA_H 11 #define MOD_CMN_SKEENA_H 12 13 #include <fwk_id.h> 14 15 #include <stdbool.h> 16 #include <stddef.h> 17 #include <stdint.h> 18 19 /*! 20 * \addtogroup GroupModules Modules 21 * \{ 22 */ 23 24 /*! 25 * \defgroup GroupModuleCMN_SKEENA CMN_SKEENA 26 * 27 * \brief Arm Coherent Mesh Network (CMN) Skeena module 28 * 29 * \details This module adds support for the CMN_SKEENA interconnect 30 * \{ 31 */ 32 33 /*! 34 * \brief Max entries of the Memory Map table 35 * for the Home Agent. 36 */ 37 #define MAX_HA_MMAP_ENTRIES 4 38 39 /*! 40 * \brief Module API indices 41 */ 42 enum mod_cmn_skeena_api_idx { 43 /*! Index of the PPU_V1 power state observer API */ 44 MOD_CMN_SKEENA_API_IDX_PPU_OBSERVER, 45 46 /*! Index of the CCIX config setup API */ 47 MOD_CMN_SKEENA_API_IDX_CCIX_CONFIG, 48 49 /*! Number of APIs */ 50 MOD_CMN_SKEENA_API_COUNT 51 }; 52 53 /*! 54 * \brief Memory region configuration type 55 */ 56 enum mod_cmn_skeena_memory_region_type { 57 /*! Input/Output region (serviced by dedicated HN-I and HN-D nodes) */ 58 MOD_CMN_SKEENA_MEMORY_REGION_TYPE_IO, 59 60 /*! 61 * Region backed by the system cache (serviced by all HN-F nodes in the 62 * system) 63 */ 64 MOD_CMN_SKEENA_MEMORY_REGION_TYPE_SYSCACHE, 65 66 /*! 67 * Sub region of the system cache for non-hashed access (serviced by 68 * HN-F nodes). 69 */ 70 MOD_CMN_SKEENA_REGION_TYPE_SYSCACHE_SUB, 71 72 /*! 73 * Region used for CCIX access. 74 */ 75 MOD_CMN_SKEENA_REGION_TYPE_CCIX, 76 77 /*! 78 * Non-hash regions in SYSCACHE group. 79 */ 80 MOD_CMN_SKEENA_REGION_TYPE_SYSCACHE_NONHASH, 81 }; 82 83 /*! 84 * \brief Memory region map descriptor 85 */ 86 struct mod_cmn_skeena_memory_region_map { 87 /*! Base address */ 88 uint64_t base; 89 90 /*! Region size in bytes */ 91 uint64_t size; 92 93 /*! Region configuration type */ 94 enum mod_cmn_skeena_memory_region_type type; 95 96 /*! 97 * \brief Target node identifier 98 * 99 * \note Not used for ::MOD_CMN_SKEENA_MEMORY_REGION_TYPE_SYSCACHE memory 100 * regions as it uses the pool of HN-F nodes available in the system. 101 */ 102 unsigned int node_id; 103 }; 104 105 /*! 106 * \brief HN-I region attributes 107 */ 108 /*! 109 * Used to map a given address region to physical memory 110 */ 111 #define CMN_SKEENA_HNI_REG_PHY_MEM_EN UINT64_C(0x0400000000000000) 112 /*! 113 * Used to serialize all writes within a given address region 114 */ 115 #define CMN_SKEENA_HNI_REG_SER_ALL_WR UINT64_C(0x0800000000000000) 116 /*! 117 * Used to serialize Device-nGnRnE writes within a given address region 118 */ 119 #define CMN_SKEENA_HNI_REG_SER_DEVNE_WR UINT64_C(0x1000000000000000) 120 /*! 121 * Enables sending early read receipts from HN-I in a given address region 122 */ 123 #define CMN_SKEENA_HNI_REG_EARLY_RDACK_EN UINT64_C(0x2000000000000000) 124 /*! 125 * Enables early write acknowledgement in a given address region 126 */ 127 #define CMN_SKEENA_HNI_REG_EARLY_WRCOMP_EN UINT64_C(0x4000000000000000) 128 /*! 129 * Indicates whether a given address region's fields are programmed and valid 130 */ 131 #define CMN_SKEENA_HNI_REG_VALID UINT64_C(0x8000000000000000) 132 133 /*! 134 * \brief RN-I Configuration 135 */ 136 /*! 137 * 'PCIe Root Present' bit position 138 */ 139 #define CMN_SKEENA_RNI_PCIE_MSTR_POS 5 140 /*! 141 * Indicates whether a PCIe Root is present upstream of RNI 142 */ 143 #define CMN_SKEENA_RNI_PCIE_MSTR_PRE \ 144 (UINT64_C(1) << CMN_SKEENA_RNI_PCIE_MSTR_POS) 145 146 /*! 147 * \brief HN-I Memory region map descriptor 148 */ 149 struct mod_cmn_skeena_hni_region_map { 150 /*! Base address */ 151 uint64_t base; 152 153 /*! Region size in bytes */ 154 uint64_t size; 155 156 /*! Region configuration flags */ 157 uint64_t flags; 158 159 /*! HN-I region node ID to which this region to be configured */ 160 unsigned int node_id; 161 162 /*! Region number to be programmed */ 163 uint8_t region_num; 164 }; 165 166 /*! 167 * \brief CMN_SKEENA configuration data 168 */ 169 struct mod_cmn_skeena_config { 170 /*! Peripheral base address. */ 171 uintptr_t base; 172 173 /*! Size along x-axis of the interconnect mesh */ 174 unsigned int mesh_size_x; 175 176 /*! Size along y-axis of the interconnect mesh */ 177 unsigned int mesh_size_y; 178 179 /*! Default HN-D node identifier containing the global configuration */ 180 unsigned int hnd_node_id; 181 182 /*! 183 * \brief Table of SN-Fs used as targets for the HN-F nodes 184 * 185 * \details Each entry of this table corresponds to a HN-F node in the 186 * system. The HN-F's logical identifiers are used as indices in this 187 * table 188 */ 189 const unsigned int *snf_table; 190 191 /*! Number of entries in the ::mod_cmn_skeena_config::snf_table */ 192 size_t snf_count; 193 194 /*! Host SA count */ 195 unsigned int sa_count; 196 197 /*! Table of region memory map entries */ 198 const struct mod_cmn_skeena_memory_region_map *mmap_table; 199 200 /*! Number of entries in the ::mod_cmn_skeena_config::mmap_table */ 201 size_t mmap_count; 202 203 /*! Table of RN-I node IDs with PCIe manager connected */ 204 const unsigned int *rni_pcie_table; 205 206 /*! Number of entries in the ::mod_cmn_skeena_config::rni_pcie_table */ 207 size_t rni_pcie_count; 208 209 /*! Table of HN-I region memory map entries */ 210 const struct mod_cmn_skeena_hni_region_map *hni_mmap_table; 211 212 /*! Number of entries in the ::mod_cmn_skeena_config::hni_mmap_table */ 213 size_t hni_mmap_count; 214 215 /*! Address space of the chip */ 216 uint64_t chip_addr_space; 217 218 /*! Identifier of the clock that this device depends on */ 219 fwk_id_t clock_id; 220 221 /*! 222 * \brief HN-F with CAL support flag 223 * \details When set to true, enables HN-F with CAL support. This flag will 224 * be used only if HN-F is found to be connected to CAL (When connected 225 * to a CAL port, node id of HN-F will be a odd number). 226 */ 227 bool hnf_cal_mode; 228 }; 229 230 /*! 231 * \brief CCIX HA memory table entry structure 232 */ 233 struct mod_cmn_skeena_ccix_ha_mmap { 234 /*! HA node ID */ 235 uint8_t ha_id; 236 237 /*! Base address */ 238 uint64_t base; 239 240 /*! Region size in bytes */ 241 uint64_t size; 242 }; 243 244 /*! 245 * \brief CMN_SKEENA CCIX configuration data from remote node 246 */ 247 struct mod_cmn_skeena_ccix_remote_node_config { 248 /*! 249 * Count of remote caching agent (RN-F) that can send request to local HNs 250 */ 251 uint8_t remote_rnf_count; 252 253 /*! Remote SA count */ 254 uint8_t remote_sa_count; 255 256 /*! Remote HA count */ 257 uint8_t remote_ha_count; 258 259 /*! PCIe traffic class used for CCIX Virtual Channel */ 260 uint8_t ccix_tc; 261 262 /*! CCIX message packing flag */ 263 bool ccix_msg_pack_enable; 264 265 /*! PCIe bus number on which CCIX link is enabled */ 266 uint8_t pcie_bus_num; 267 268 /*! CCIX link identifier */ 269 uint8_t ccix_link_id; 270 271 /*! optimised tlp mode */ 272 bool ccix_opt_tlp; 273 274 /*! Remote HA memory map table count */ 275 uint8_t remote_ha_mmap_count; 276 277 /*! SMP mode */ 278 bool smp_mode; 279 280 /*! Remote HA memory map table */ 281 struct mod_cmn_skeena_ccix_ha_mmap remote_ha_mmap[MAX_HA_MMAP_ENTRIES]; 282 283 /*! Max Packet Size */ 284 uint8_t ccix_max_packet_size; 285 }; 286 287 /*! 288 * \brief CMN_SKEENA CCIX configuration data from host node 289 */ 290 struct mod_cmn_skeena_ccix_host_node_config { 291 /*! Host RA count */ 292 uint8_t host_ra_count; 293 294 /*! Host SA count */ 295 uint8_t host_sa_count; 296 297 /*! Host HA count */ 298 uint8_t host_ha_count; 299 300 /*! CCIX HA memory map table count for endpoints */ 301 uint8_t ccix_host_mmap_count; 302 303 /*! CCIX HA memory map table for endpoints */ 304 struct mod_cmn_skeena_ccix_ha_mmap ccix_host_mmap[MAX_HA_MMAP_ENTRIES]; 305 306 /*! CCIX Maximum Memory Request send credits from Host */ 307 uint16_t ccix_request_credits; 308 309 /*! CCIX Maximum Snoop send credits from Host */ 310 uint16_t ccix_snoop_credits; 311 312 /*! CCIX Maximum Data send credits from Host */ 313 uint16_t ccix_data_credits; 314 315 /*! Max Packet Size */ 316 uint8_t ccix_max_packet_size; 317 318 /*! CCIX optimised tlp mode capabiltiy of Host */ 319 bool ccix_opt_tlp; 320 321 /*! CCIX message packing flag capability of Host */ 322 bool ccix_msg_pack_enable; 323 }; 324 325 /*! 326 * \brief CMN_SKEENA CCIX configuration interface 327 */ 328 struct mod_cmn_skeena_ccix_config_api { 329 /*! 330 * \brief Get the CCIX host configuration 331 * 332 * \param[out] config CCIX host configuration 333 * 334 * \retval ::FWK_SUCCESS if the operation succeed. 335 * \return one of the error code otherwise. 336 */ 337 int (*get_config)(struct mod_cmn_skeena_ccix_host_node_config *config); 338 /*! 339 * \brief set the CCIX endpoint configuration 340 * 341 * \param[in] config CCIX endpoint configuration 342 * 343 * \retval ::FWK_SUCCESS if the operation succeed. 344 * \return one of the error code otherwise. 345 */ 346 int (*set_config)(struct mod_cmn_skeena_ccix_remote_node_config *config); 347 /*! 348 * \brief Interface to trigger the protocol credit exchange 349 * 350 * \param link_id Link on which the protocol credit exchange 351 * would initiate. 352 * 353 * \retval ::FWK_SUCCESS if the operation succeed. 354 * \return one of the error code otherwise. 355 */ 356 int (*exchange_protocol_credit)(uint8_t link_id); 357 /*! 358 * \brief Interface to configure for system coherency 359 * 360 * \param link_id Link on which the coherency has to 361 * be enabled. 362 * 363 * \retval ::FWK_SUCCESS if the operation succeed. 364 * \return one of the error code otherwise. 365 */ 366 int (*enter_system_coherency)(uint8_t link_id); 367 /*! 368 * \brief Interface to enter DVM domain 369 * 370 * \param link_id Link on which DVM domain has to be enabled 371 * 372 * \retval ::FWK_SUCCESS if the operation succeed. 373 * \return one of the error code otherwise. 374 */ 375 int (*enter_dvm_domain)(uint8_t link_id); 376 }; 377 378 /*! 379 * \} 380 */ 381 382 /*! 383 * \} 384 */ 385 386 #endif /* MOD_CMN_SKEENA_H */ 387