1 /* 2 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * Redistributions of source code must retain the above copyright notice, this 8 * list of conditions and the following disclaimer. 9 * 10 * Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 14 * Neither the name of ARM nor the names of its contributors may be used 15 * to endorse or promote products derived from this software without specific 16 * prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef __CCN_H__ 32 #define __CCN_H__ 33 34 /* 35 * This macro defines the maximum number of master interfaces that reside on 36 * Request nodes which the CCN driver can accommodate. The driver APIs to add 37 * and remove Request nodes from snoop/dvm domains take a bit map of master 38 * interfaces as inputs. The largest C data type that can be used is a 64-bit 39 * unsigned integer. Hence the value of 64. The platform will have to ensure 40 * that the master interfaces are numbered from 0-63. 41 */ 42 #define CCN_MAX_RN_MASTERS 64 43 44 /* 45 * The following constants define the various run modes that the platform can 46 * request the CCN driver to place the L3 cache in. These map to the 47 * programmable P-State values in a HN-F P-state register. 48 */ 49 #define CCN_L3_RUN_MODE_NOL3 0x0 /* HNF_PM_NOL3 */ 50 #define CCN_L3_RUN_MODE_SFONLY 0x1 /* HNF_PM_SFONLY */ 51 #define CCN_L3_RUN_MODE_HAM 0x2 /* HNF_PM_HALF */ 52 #define CCN_L3_RUN_MODE_FAM 0x3 /* HNF_PM_FULL */ 53 54 /* part 0 IDs for various CCN variants */ 55 #define CCN_502_PART0_ID 0x30 56 #define CCN_504_PART0_ID 0x26 57 #define CCN_505_PART0_ID 0x27 58 #define CCN_508_PART0_ID 0x28 59 #define CCN_512_PART0_ID 0x29 60 61 /* 62 * The following macro takes the value returned from a read of a HN-F P-state 63 * status register and returns the retention state value. 64 */ 65 #define CCN_GET_RETENTION_STATE(pstate) ((pstate >> 4) & 0x3) 66 67 /* 68 * The following macro takes the value returned from a read of a HN-F P-state 69 * status register and returns the run state value. 70 */ 71 #define CCN_GET_RUN_STATE(pstate) (pstate & 0xf) 72 73 #ifndef __ASSEMBLY__ 74 #include <stdint.h> 75 76 /* 77 * This structure describes some of the implementation defined attributes of the 78 * CCN IP. It is used by the platform port to specify these attributes in order 79 * to initialise the CCN driver. The attributes are described below. 80 * 81 * 1. The 'num_masters' field specifies the total number of master interfaces 82 * resident on Request nodes. 83 * 84 * 2. The 'master_to_rn_id_map' field is a ponter to an array in which each 85 * index corresponds to a master interface and its value corresponds to the 86 * Request node on which the master interface resides. 87 * This field is not simply defined as an array of size CCN_MAX_RN_MASTERS. 88 * In reality, a platform will have much fewer master * interfaces than 89 * CCN_MAX_RN_MASTERS. With an array of this size, it would also have to 90 * set the unused entries to a suitable value. Zeroing the array would not 91 * be enough since 0 is also a valid node id. Hence, such an array is not 92 * used. 93 * 94 * 3. The 'periphbase' field is the base address of the programmer's view of the 95 * CCN IP. 96 */ 97 typedef struct ccn_desc { 98 unsigned int num_masters; 99 const unsigned char *master_to_rn_id_map; 100 uintptr_t periphbase; 101 } ccn_desc_t; 102 103 104 void ccn_init(const ccn_desc_t *plat_ccn_desc); 105 void ccn_enter_snoop_dvm_domain(unsigned long long master_iface_map); 106 void ccn_exit_snoop_dvm_domain(unsigned long long master_iface_map); 107 void ccn_enter_dvm_domain(unsigned long long master_iface_map); 108 void ccn_exit_dvm_domain(unsigned long long master_iface_map); 109 void ccn_set_l3_run_mode(unsigned int mode); 110 void ccn_program_sys_addrmap(unsigned int sn0_id, 111 unsigned int sn1_id, 112 unsigned int sn2_id, 113 unsigned int top_addr_bit0, 114 unsigned int top_addr_bit1, 115 unsigned char three_sn_en); 116 unsigned int ccn_get_l3_run_mode(void); 117 int ccn_get_part0_id(uintptr_t periphbase); 118 119 #endif /* __ASSEMBLY__ */ 120 #endif /* __CCN_H__ */ 121