1*54fd6939SJiyong Park /* 2*54fd6939SJiyong Park * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. 3*54fd6939SJiyong Park * 4*54fd6939SJiyong Park * SPDX-License-Identifier: BSD-3-Clause 5*54fd6939SJiyong Park */ 6*54fd6939SJiyong Park 7*54fd6939SJiyong Park #ifndef CCN_H 8*54fd6939SJiyong Park #define CCN_H 9*54fd6939SJiyong Park 10*54fd6939SJiyong Park /* 11*54fd6939SJiyong Park * This macro defines the maximum number of master interfaces that reside on 12*54fd6939SJiyong Park * Request nodes which the CCN driver can accommodate. The driver APIs to add 13*54fd6939SJiyong Park * and remove Request nodes from snoop/dvm domains take a bit map of master 14*54fd6939SJiyong Park * interfaces as inputs. The largest C data type that can be used is a 64-bit 15*54fd6939SJiyong Park * unsigned integer. Hence the value of 64. The platform will have to ensure 16*54fd6939SJiyong Park * that the master interfaces are numbered from 0-63. 17*54fd6939SJiyong Park */ 18*54fd6939SJiyong Park #define CCN_MAX_RN_MASTERS 64 19*54fd6939SJiyong Park 20*54fd6939SJiyong Park /* 21*54fd6939SJiyong Park * The following constants define the various run modes that the platform can 22*54fd6939SJiyong Park * request the CCN driver to place the L3 cache in. These map to the 23*54fd6939SJiyong Park * programmable P-State values in a HN-F P-state register. 24*54fd6939SJiyong Park */ 25*54fd6939SJiyong Park #define CCN_L3_RUN_MODE_NOL3 0x0 /* HNF_PM_NOL3 */ 26*54fd6939SJiyong Park #define CCN_L3_RUN_MODE_SFONLY 0x1 /* HNF_PM_SFONLY */ 27*54fd6939SJiyong Park #define CCN_L3_RUN_MODE_HAM 0x2 /* HNF_PM_HALF */ 28*54fd6939SJiyong Park #define CCN_L3_RUN_MODE_FAM 0x3 /* HNF_PM_FULL */ 29*54fd6939SJiyong Park 30*54fd6939SJiyong Park /* part 0 IDs for various CCN variants */ 31*54fd6939SJiyong Park #define CCN_502_PART0_ID 0x30 32*54fd6939SJiyong Park #define CCN_504_PART0_ID 0x26 33*54fd6939SJiyong Park #define CCN_505_PART0_ID 0x27 34*54fd6939SJiyong Park #define CCN_508_PART0_ID 0x28 35*54fd6939SJiyong Park #define CCN_512_PART0_ID 0x29 36*54fd6939SJiyong Park 37*54fd6939SJiyong Park /* 38*54fd6939SJiyong Park * The following macro takes the value returned from a read of a HN-F P-state 39*54fd6939SJiyong Park * status register and returns the retention state value. 40*54fd6939SJiyong Park */ 41*54fd6939SJiyong Park #define CCN_GET_RETENTION_STATE(pstate) ((pstate >> 4) & 0x3) 42*54fd6939SJiyong Park 43*54fd6939SJiyong Park /* 44*54fd6939SJiyong Park * The following macro takes the value returned from a read of a HN-F P-state 45*54fd6939SJiyong Park * status register and returns the run state value. 46*54fd6939SJiyong Park */ 47*54fd6939SJiyong Park #define CCN_GET_RUN_STATE(pstate) (pstate & 0xf) 48*54fd6939SJiyong Park 49*54fd6939SJiyong Park #ifndef __ASSEMBLER__ 50*54fd6939SJiyong Park #include <stdint.h> 51*54fd6939SJiyong Park 52*54fd6939SJiyong Park /* 53*54fd6939SJiyong Park * This structure describes some of the implementation defined attributes of the 54*54fd6939SJiyong Park * CCN IP. It is used by the platform port to specify these attributes in order 55*54fd6939SJiyong Park * to initialise the CCN driver. The attributes are described below. 56*54fd6939SJiyong Park * 57*54fd6939SJiyong Park * 1. The 'num_masters' field specifies the total number of master interfaces 58*54fd6939SJiyong Park * resident on Request nodes. 59*54fd6939SJiyong Park * 60*54fd6939SJiyong Park * 2. The 'master_to_rn_id_map' field is a ponter to an array in which each 61*54fd6939SJiyong Park * index corresponds to a master interface and its value corresponds to the 62*54fd6939SJiyong Park * Request node on which the master interface resides. 63*54fd6939SJiyong Park * This field is not simply defined as an array of size CCN_MAX_RN_MASTERS. 64*54fd6939SJiyong Park * In reality, a platform will have much fewer master * interfaces than 65*54fd6939SJiyong Park * CCN_MAX_RN_MASTERS. With an array of this size, it would also have to 66*54fd6939SJiyong Park * set the unused entries to a suitable value. Zeroing the array would not 67*54fd6939SJiyong Park * be enough since 0 is also a valid node id. Hence, such an array is not 68*54fd6939SJiyong Park * used. 69*54fd6939SJiyong Park * 70*54fd6939SJiyong Park * 3. The 'periphbase' field is the base address of the programmer's view of the 71*54fd6939SJiyong Park * CCN IP. 72*54fd6939SJiyong Park */ 73*54fd6939SJiyong Park typedef struct ccn_desc { 74*54fd6939SJiyong Park unsigned int num_masters; 75*54fd6939SJiyong Park const unsigned char *master_to_rn_id_map; 76*54fd6939SJiyong Park uintptr_t periphbase; 77*54fd6939SJiyong Park } ccn_desc_t; 78*54fd6939SJiyong Park 79*54fd6939SJiyong Park /* Enum used to loop through all types of nodes in CCN*/ 80*54fd6939SJiyong Park typedef enum node_types { 81*54fd6939SJiyong Park NODE_TYPE_RNF = 0, 82*54fd6939SJiyong Park NODE_TYPE_RNI, 83*54fd6939SJiyong Park NODE_TYPE_RND, 84*54fd6939SJiyong Park NODE_TYPE_HNF, 85*54fd6939SJiyong Park NODE_TYPE_HNI, 86*54fd6939SJiyong Park NODE_TYPE_SN, 87*54fd6939SJiyong Park NUM_NODE_TYPES 88*54fd6939SJiyong Park } node_types_t; 89*54fd6939SJiyong Park 90*54fd6939SJiyong Park void ccn_init(const ccn_desc_t *plat_ccn_desc); 91*54fd6939SJiyong Park void ccn_enter_snoop_dvm_domain(unsigned long long master_iface_map); 92*54fd6939SJiyong Park void ccn_exit_snoop_dvm_domain(unsigned long long master_iface_map); 93*54fd6939SJiyong Park void ccn_enter_dvm_domain(unsigned long long master_iface_map); 94*54fd6939SJiyong Park void ccn_exit_dvm_domain(unsigned long long master_iface_map); 95*54fd6939SJiyong Park void ccn_set_l3_run_mode(unsigned int mode); 96*54fd6939SJiyong Park void ccn_program_sys_addrmap(unsigned int sn0_id, 97*54fd6939SJiyong Park unsigned int sn1_id, 98*54fd6939SJiyong Park unsigned int sn2_id, 99*54fd6939SJiyong Park unsigned int top_addr_bit0, 100*54fd6939SJiyong Park unsigned int top_addr_bit1, 101*54fd6939SJiyong Park unsigned char three_sn_en); 102*54fd6939SJiyong Park unsigned int ccn_get_l3_run_mode(void); 103*54fd6939SJiyong Park int ccn_get_part0_id(uintptr_t periphbase); 104*54fd6939SJiyong Park 105*54fd6939SJiyong Park void ccn_write_node_reg(node_types_t node_type, unsigned int node_id, 106*54fd6939SJiyong Park unsigned int reg_offset, 107*54fd6939SJiyong Park unsigned long long val); 108*54fd6939SJiyong Park unsigned long long ccn_read_node_reg(node_types_t node_type, 109*54fd6939SJiyong Park unsigned int node_id, 110*54fd6939SJiyong Park unsigned int reg_offset); 111*54fd6939SJiyong Park 112*54fd6939SJiyong Park #endif /* __ASSEMBLER__ */ 113*54fd6939SJiyong Park #endif /* CCN_H */ 114