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: usecase id for which the llcc slice is used 43 * @slice_id: llcc slice id assigned to each slice 44 * @max_cap: maximum capacity of the llcc slice 45 * @priority: priority of the llcc slice 46 * @fixed_size: whether the llcc slice can grow beyond its size 47 * @bonus_ways: bonus ways associated with llcc slice 48 * @res_ways: reserved ways associated with llcc slice 49 * @cache_mode: mode of the llcc slice 50 * @probe_target_ways: Probe only reserved and bonus ways on a cache miss 51 * @dis_cap_alloc: Disable capacity based allocation 52 * @retain_on_pc: Retain through power collapse 53 * @activate_on_init: activate the slice on init 54 */ 55 struct llcc_slice_config { 56 u32 usecase_id; 57 u32 slice_id; 58 u32 max_cap; 59 u32 priority; 60 bool fixed_size; 61 u32 bonus_ways; 62 u32 res_ways; 63 u32 cache_mode; 64 u32 probe_target_ways; 65 bool dis_cap_alloc; 66 bool retain_on_pc; 67 bool activate_on_init; 68 }; 69 70 /** 71 * llcc_drv_data - Data associated with the llcc driver 72 * @regmap: regmap associated with the llcc device 73 * @bcast_regmap: regmap associated with llcc broadcast offset 74 * @cfg: pointer to the data structure for slice configuration 75 * @lock: mutex associated with each slice 76 * @cfg_size: size of the config data table 77 * @max_slices: max slices as read from device tree 78 * @num_banks: Number of llcc banks 79 * @bitmap: Bit map to track the active slice ids 80 * @offsets: Pointer to the bank offsets array 81 * @ecc_irq: interrupt for llcc cache error detection and reporting 82 */ 83 struct llcc_drv_data { 84 struct regmap *regmap; 85 struct regmap *bcast_regmap; 86 const struct llcc_slice_config *cfg; 87 struct mutex lock; 88 u32 cfg_size; 89 u32 max_slices; 90 u32 num_banks; 91 unsigned long *bitmap; 92 u32 *offsets; 93 int ecc_irq; 94 }; 95 96 /** 97 * llcc_edac_reg_data - llcc edac registers data for each error type 98 * @name: Name of the error 99 * @synd_reg: Syndrome register address 100 * @count_status_reg: Status register address to read the error count 101 * @ways_status_reg: Status register address to read the error ways 102 * @reg_cnt: Number of registers 103 * @count_mask: Mask value to get the error count 104 * @ways_mask: Mask value to get the error ways 105 * @count_shift: Shift value to get the error count 106 * @ways_shift: Shift value to get the error ways 107 */ 108 struct llcc_edac_reg_data { 109 char *name; 110 u64 synd_reg; 111 u64 count_status_reg; 112 u64 ways_status_reg; 113 u32 reg_cnt; 114 u32 count_mask; 115 u32 ways_mask; 116 u8 count_shift; 117 u8 ways_shift; 118 }; 119 120 #if IS_ENABLED(CONFIG_QCOM_LLCC) 121 /** 122 * llcc_slice_getd - get llcc slice descriptor 123 * @uid: usecase_id of the client 124 */ 125 struct llcc_slice_desc *llcc_slice_getd(u32 uid); 126 127 /** 128 * llcc_slice_putd - llcc slice descritpor 129 * @desc: Pointer to llcc slice descriptor 130 */ 131 void llcc_slice_putd(struct llcc_slice_desc *desc); 132 133 /** 134 * llcc_get_slice_id - get slice id 135 * @desc: Pointer to llcc slice descriptor 136 */ 137 int llcc_get_slice_id(struct llcc_slice_desc *desc); 138 139 /** 140 * llcc_get_slice_size - llcc slice size 141 * @desc: Pointer to llcc slice descriptor 142 */ 143 size_t llcc_get_slice_size(struct llcc_slice_desc *desc); 144 145 /** 146 * llcc_slice_activate - Activate the llcc slice 147 * @desc: Pointer to llcc slice descriptor 148 */ 149 int llcc_slice_activate(struct llcc_slice_desc *desc); 150 151 /** 152 * llcc_slice_deactivate - Deactivate the llcc slice 153 * @desc: Pointer to llcc slice descriptor 154 */ 155 int llcc_slice_deactivate(struct llcc_slice_desc *desc); 156 157 /** 158 * qcom_llcc_probe - program the sct table 159 * @pdev: platform device pointer 160 * @table: soc sct table 161 * @sz: Size of the config table 162 */ 163 int qcom_llcc_probe(struct platform_device *pdev, 164 const struct llcc_slice_config *table, u32 sz); 165 166 /** 167 * qcom_llcc_remove - remove the sct table 168 * @pdev: Platform device pointer 169 */ 170 int qcom_llcc_remove(struct platform_device *pdev); 171 #else llcc_slice_getd(u32 uid)172static inline struct llcc_slice_desc *llcc_slice_getd(u32 uid) 173 { 174 return NULL; 175 } 176 llcc_slice_putd(struct llcc_slice_desc * desc)177static inline void llcc_slice_putd(struct llcc_slice_desc *desc) 178 { 179 180 }; 181 llcc_get_slice_id(struct llcc_slice_desc * desc)182static inline int llcc_get_slice_id(struct llcc_slice_desc *desc) 183 { 184 return -EINVAL; 185 } 186 llcc_get_slice_size(struct llcc_slice_desc * desc)187static inline size_t llcc_get_slice_size(struct llcc_slice_desc *desc) 188 { 189 return 0; 190 } llcc_slice_activate(struct llcc_slice_desc * desc)191static inline int llcc_slice_activate(struct llcc_slice_desc *desc) 192 { 193 return -EINVAL; 194 } 195 llcc_slice_deactivate(struct llcc_slice_desc * desc)196static inline int llcc_slice_deactivate(struct llcc_slice_desc *desc) 197 { 198 return -EINVAL; 199 } qcom_llcc_probe(struct platform_device * pdev,const struct llcc_slice_config * table,u32 sz)200static inline int qcom_llcc_probe(struct platform_device *pdev, 201 const struct llcc_slice_config *table, u32 sz) 202 { 203 return -ENODEV; 204 } 205 qcom_llcc_remove(struct platform_device * pdev)206static inline int qcom_llcc_remove(struct platform_device *pdev) 207 { 208 return -ENODEV; 209 } 210 #endif 211 212 #endif 213