1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. 4 * 5 */ 6 7 #include <linux/platform_device.h> 8 #ifndef __LLCC_QCOM__ 9 #define __LLCC_QCOM__ 10 11 #define LLCC_CPUSS 1 12 #define LLCC_VIDSC0 2 13 #define LLCC_VIDSC1 3 14 #define LLCC_ROTATOR 4 15 #define LLCC_VOICE 5 16 #define LLCC_AUDIO 6 17 #define LLCC_MDMHPGRW 7 18 #define LLCC_MDM 8 19 #define LLCC_CMPT 10 20 #define LLCC_GPUHTW 11 21 #define LLCC_GPU 12 22 #define LLCC_MMUHWT 13 23 #define LLCC_CMPTDMA 15 24 #define LLCC_DISP 16 25 #define LLCC_VIDFW 17 26 #define LLCC_MDMHPFX 20 27 #define LLCC_MDMPNG 21 28 #define LLCC_AUDHW 22 29 30 /** 31 * llcc_slice_desc - Cache slice descriptor 32 * @slice_id: llcc slice id 33 * @slice_size: Size allocated for the llcc slice 34 */ 35 struct llcc_slice_desc { 36 u32 slice_id; 37 size_t slice_size; 38 }; 39 40 /** 41 * llcc_slice_config - Data associated with the llcc slice 42 * @usecase_id: Unique id for the client's use case 43 * @slice_id: llcc slice id for each client 44 * @max_cap: The maximum capacity of the cache slice provided in KB 45 * @priority: Priority of the client used to select victim line for replacement 46 * @fixed_size: Boolean indicating if the slice has a fixed capacity 47 * @bonus_ways: Bonus ways are additional ways to be used for any slice, 48 * if client ends up using more than reserved cache ways. Bonus 49 * ways are allocated only if they are not reserved for some 50 * other client. 51 * @res_ways: Reserved ways for the cache slice, the reserved ways cannot 52 * be used by any other client than the one its assigned to. 53 * @cache_mode: Each slice operates as a cache, this controls the mode of the 54 * slice: normal or TCM(Tightly Coupled Memory) 55 * @probe_target_ways: Determines what ways to probe for access hit. When 56 * configured to 1 only bonus and reserved ways are probed. 57 * When configured to 0 all ways in llcc are probed. 58 * @dis_cap_alloc: Disable capacity based allocation for a client 59 * @retain_on_pc: If this bit is set and client has maintained active vote 60 * then the ways assigned to this client are not flushed on power 61 * collapse. 62 * @activate_on_init: Activate the slice immediately after it is programmed 63 */ 64 struct llcc_slice_config { 65 u32 usecase_id; 66 u32 slice_id; 67 u32 max_cap; 68 u32 priority; 69 bool fixed_size; 70 u32 bonus_ways; 71 u32 res_ways; 72 u32 cache_mode; 73 u32 probe_target_ways; 74 bool dis_cap_alloc; 75 bool retain_on_pc; 76 bool activate_on_init; 77 }; 78 79 /** 80 * llcc_drv_data - Data associated with the llcc driver 81 * @regmap: regmap associated with the llcc device 82 * @bcast_regmap: regmap associated with llcc broadcast offset 83 * @cfg: pointer to the data structure for slice configuration 84 * @lock: mutex associated with each slice 85 * @cfg_size: size of the config data table 86 * @max_slices: max slices as read from device tree 87 * @num_banks: Number of llcc banks 88 * @bitmap: Bit map to track the active slice ids 89 * @offsets: Pointer to the bank offsets array 90 * @ecc_irq: interrupt for llcc cache error detection and reporting 91 */ 92 struct llcc_drv_data { 93 struct regmap *regmap; 94 struct regmap *bcast_regmap; 95 const struct llcc_slice_config *cfg; 96 struct mutex lock; 97 u32 cfg_size; 98 u32 max_slices; 99 u32 num_banks; 100 unsigned long *bitmap; 101 u32 *offsets; 102 int ecc_irq; 103 }; 104 105 /** 106 * llcc_edac_reg_data - llcc edac registers data for each error type 107 * @name: Name of the error 108 * @synd_reg: Syndrome register address 109 * @count_status_reg: Status register address to read the error count 110 * @ways_status_reg: Status register address to read the error ways 111 * @reg_cnt: Number of registers 112 * @count_mask: Mask value to get the error count 113 * @ways_mask: Mask value to get the error ways 114 * @count_shift: Shift value to get the error count 115 * @ways_shift: Shift value to get the error ways 116 */ 117 struct llcc_edac_reg_data { 118 char *name; 119 u64 synd_reg; 120 u64 count_status_reg; 121 u64 ways_status_reg; 122 u32 reg_cnt; 123 u32 count_mask; 124 u32 ways_mask; 125 u8 count_shift; 126 u8 ways_shift; 127 }; 128 129 #if IS_ENABLED(CONFIG_QCOM_LLCC) 130 /** 131 * llcc_slice_getd - get llcc slice descriptor 132 * @uid: usecase_id of the client 133 */ 134 struct llcc_slice_desc *llcc_slice_getd(u32 uid); 135 136 /** 137 * llcc_slice_putd - llcc slice descritpor 138 * @desc: Pointer to llcc slice descriptor 139 */ 140 void llcc_slice_putd(struct llcc_slice_desc *desc); 141 142 /** 143 * llcc_get_slice_id - get slice id 144 * @desc: Pointer to llcc slice descriptor 145 */ 146 int llcc_get_slice_id(struct llcc_slice_desc *desc); 147 148 /** 149 * llcc_get_slice_size - llcc slice size 150 * @desc: Pointer to llcc slice descriptor 151 */ 152 size_t llcc_get_slice_size(struct llcc_slice_desc *desc); 153 154 /** 155 * llcc_slice_activate - Activate the llcc slice 156 * @desc: Pointer to llcc slice descriptor 157 */ 158 int llcc_slice_activate(struct llcc_slice_desc *desc); 159 160 /** 161 * llcc_slice_deactivate - Deactivate the llcc slice 162 * @desc: Pointer to llcc slice descriptor 163 */ 164 int llcc_slice_deactivate(struct llcc_slice_desc *desc); 165 166 #else llcc_slice_getd(u32 uid)167static inline struct llcc_slice_desc *llcc_slice_getd(u32 uid) 168 { 169 return NULL; 170 } 171 llcc_slice_putd(struct llcc_slice_desc * desc)172static inline void llcc_slice_putd(struct llcc_slice_desc *desc) 173 { 174 175 }; 176 llcc_get_slice_id(struct llcc_slice_desc * desc)177static inline int llcc_get_slice_id(struct llcc_slice_desc *desc) 178 { 179 return -EINVAL; 180 } 181 llcc_get_slice_size(struct llcc_slice_desc * desc)182static inline size_t llcc_get_slice_size(struct llcc_slice_desc *desc) 183 { 184 return 0; 185 } llcc_slice_activate(struct llcc_slice_desc * desc)186static inline int llcc_slice_activate(struct llcc_slice_desc *desc) 187 { 188 return -EINVAL; 189 } 190 llcc_slice_deactivate(struct llcc_slice_desc * desc)191static inline int llcc_slice_deactivate(struct llcc_slice_desc *desc) 192 { 193 return -EINVAL; 194 } 195 #endif 196 197 #endif 198