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_MODHW 9 20 #define LLCC_CMPT 10 21 #define LLCC_GPUHTW 11 22 #define LLCC_GPU 12 23 #define LLCC_MMUHWT 13 24 #define LLCC_CMPTDMA 15 25 #define LLCC_DISP 16 26 #define LLCC_VIDFW 17 27 #define LLCC_CAMFW 18 28 #define LLCC_MDMHPFX 20 29 #define LLCC_MDMPNG 21 30 #define LLCC_AUDHW 22 31 #define LLCC_NPU 23 32 #define LLCC_WLHW 24 33 #define LLCC_PIMEM 25 34 #define LLCC_ECC 26 35 #define LLCC_CVP 28 36 #define LLCC_MODPE 29 37 #define LLCC_APTCM 30 38 #define LLCC_WRCACHE 31 39 #define LLCC_CVPFW 32 40 #define LLCC_CPUSS1 33 41 #define LLCC_CAMEXP0 34 42 #define LLCC_CPUMTE 35 43 #define LLCC_CPUHWT 36 44 #define LLCC_MDMCLAD2 37 45 #define LLCC_CAMEXP1 38 46 #define LLCC_CMPTHCP 39 47 #define LLCC_LCPDARE 40 48 #define LLCC_AENPU 45 49 #define LLCC_ISLAND1 46 50 #define LLCC_ISLAND2 47 51 #define LLCC_ISLAND3 48 52 #define LLCC_ISLAND4 49 53 #define LLCC_CAMEXP2 50 54 #define LLCC_CAMEXP3 51 55 #define LLCC_CAMEXP4 52 56 #define LLCC_DISP_WB 53 57 #define LLCC_DISP_1 54 58 #define LLCC_VIEYE 57 59 #define LLCC_VIDPTH 58 60 #define LLCC_GPUMV 59 61 #define LLCC_EVA_LEFT 60 62 #define LLCC_EVA_RIGHT 61 63 #define LLCC_EVAGAIN 62 64 #define LLCC_VIPTH 63 65 #define LLCC_VIDVSP 64 66 #define LLCC_DISP_LEFT 65 67 #define LLCC_DISP_RIGHT 66 68 #define LLCC_EVCS_LEFT 67 69 #define LLCC_EVCS_RIGHT 68 70 #define LLCC_SPAD 69 71 #define LLCC_VIDDEC 70 72 #define LLCC_CAMOFE 71 73 #define LLCC_CAMRTIP 72 74 #define LLCC_CAMSRTIP 73 75 #define LLCC_CAMRTRF 74 76 #define LLCC_CAMSRTRF 75 77 #define LLCC_OOBM_NS 81 78 #define LLCC_OOBM_S 82 79 #define LLCC_VIDEO_APV 83 80 #define LLCC_COMPUTE1 87 81 #define LLCC_CPUSS_OPP 88 82 #define LLCC_CPUSSMPAM 89 83 #define LLCC_VIDSC_VSP1 91 84 #define LLCC_CAM_IPE_STROV 92 85 #define LLCC_CAM_OFE_STROV 93 86 #define LLCC_CPUSS_HEU 94 87 #define LLCC_PCIE_TCU 97 88 #define LLCC_MDM_PNG_FIXED 100 89 90 /** 91 * struct llcc_slice_desc - Cache slice descriptor 92 * @slice_id: llcc slice id 93 * @slice_size: Size allocated for the llcc slice 94 * @refcount: Atomic counter to track activate/deactivate calls 95 */ 96 struct llcc_slice_desc { 97 u32 slice_id; 98 size_t slice_size; 99 refcount_t refcount; 100 }; 101 102 /** 103 * struct llcc_edac_reg_data - llcc edac registers data for each error type 104 * @name: Name of the error 105 * @reg_cnt: Number of registers 106 * @count_mask: Mask value to get the error count 107 * @ways_mask: Mask value to get the error ways 108 * @count_shift: Shift value to get the error count 109 * @ways_shift: Shift value to get the error ways 110 */ 111 struct llcc_edac_reg_data { 112 char *name; 113 u32 reg_cnt; 114 u32 count_mask; 115 u32 ways_mask; 116 u8 count_shift; 117 u8 ways_shift; 118 }; 119 120 struct llcc_edac_reg_offset { 121 /* LLCC TRP registers */ 122 u32 trp_ecc_error_status0; 123 u32 trp_ecc_error_status1; 124 u32 trp_ecc_sb_err_syn0; 125 u32 trp_ecc_db_err_syn0; 126 u32 trp_ecc_error_cntr_clear; 127 u32 trp_interrupt_0_status; 128 u32 trp_interrupt_0_clear; 129 u32 trp_interrupt_0_enable; 130 131 /* LLCC Common registers */ 132 u32 cmn_status0; 133 u32 cmn_interrupt_0_enable; 134 u32 cmn_interrupt_2_enable; 135 136 /* LLCC DRP registers */ 137 u32 drp_ecc_error_cfg; 138 u32 drp_ecc_error_cntr_clear; 139 u32 drp_interrupt_status; 140 u32 drp_interrupt_clear; 141 u32 drp_interrupt_enable; 142 u32 drp_ecc_error_status0; 143 u32 drp_ecc_error_status1; 144 u32 drp_ecc_sb_err_syn0; 145 u32 drp_ecc_db_err_syn0; 146 }; 147 148 /** 149 * struct llcc_drv_data - Data associated with the llcc driver 150 * @regmaps: regmaps associated with the llcc device 151 * @bcast_regmap: regmap associated with llcc broadcast OR offset 152 * @bcast_and_regmap: regmap associated with llcc broadcast AND offset 153 * @cfg: pointer to the data structure for slice configuration 154 * @edac_reg_offset: Offset of the LLCC EDAC registers 155 * @lock: mutex associated with each slice 156 * @cfg_size: size of the config data table 157 * @num_banks: Number of llcc banks 158 * @ecc_irq: interrupt for llcc cache error detection and reporting 159 * @ecc_irq_configured: 'True' if firmware has already configured the irq propagation 160 * @desc: Array pointer of pre-allocated LLCC slice descriptors 161 * @version: Indicates the LLCC version 162 */ 163 struct llcc_drv_data { 164 struct regmap **regmaps; 165 struct regmap *bcast_regmap; 166 struct regmap *bcast_and_regmap; 167 const struct llcc_slice_config *cfg; 168 const struct llcc_edac_reg_offset *edac_reg_offset; 169 struct mutex lock; 170 u32 cfg_size; 171 u32 num_banks; 172 int ecc_irq; 173 bool ecc_irq_configured; 174 u32 version; 175 struct llcc_slice_desc *desc; 176 }; 177 178 #if IS_ENABLED(CONFIG_QCOM_LLCC) 179 /** 180 * llcc_slice_getd - get llcc slice descriptor 181 * @uid: usecase_id of the client 182 */ 183 struct llcc_slice_desc *llcc_slice_getd(u32 uid); 184 185 /** 186 * llcc_slice_putd - llcc slice descritpor 187 * @desc: Pointer to llcc slice descriptor 188 */ 189 void llcc_slice_putd(struct llcc_slice_desc *desc); 190 191 /** 192 * llcc_get_slice_id - get slice id 193 * @desc: Pointer to llcc slice descriptor 194 */ 195 int llcc_get_slice_id(struct llcc_slice_desc *desc); 196 197 /** 198 * llcc_get_slice_size - llcc slice size 199 * @desc: Pointer to llcc slice descriptor 200 */ 201 size_t llcc_get_slice_size(struct llcc_slice_desc *desc); 202 203 /** 204 * llcc_slice_activate - Activate the llcc slice 205 * @desc: Pointer to llcc slice descriptor 206 */ 207 int llcc_slice_activate(struct llcc_slice_desc *desc); 208 209 /** 210 * llcc_slice_deactivate - Deactivate the llcc slice 211 * @desc: Pointer to llcc slice descriptor 212 */ 213 int llcc_slice_deactivate(struct llcc_slice_desc *desc); 214 215 #else 216 static inline struct llcc_slice_desc *llcc_slice_getd(u32 uid) 217 { 218 return NULL; 219 } 220 221 static inline void llcc_slice_putd(struct llcc_slice_desc *desc) 222 { 223 224 }; 225 226 static inline int llcc_get_slice_id(struct llcc_slice_desc *desc) 227 { 228 return -EINVAL; 229 } 230 231 static inline size_t llcc_get_slice_size(struct llcc_slice_desc *desc) 232 { 233 return 0; 234 } 235 static inline int llcc_slice_activate(struct llcc_slice_desc *desc) 236 { 237 return -EINVAL; 238 } 239 240 static inline int llcc_slice_deactivate(struct llcc_slice_desc *desc) 241 { 242 return -EINVAL; 243 } 244 #endif 245 246 #endif 247