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_edac_reg_data - llcc edac registers data for each error type 42 * @name: Name of the error 43 * @synd_reg: Syndrome register address 44 * @count_status_reg: Status register address to read the error count 45 * @ways_status_reg: Status register address to read the error ways 46 * @reg_cnt: Number of registers 47 * @count_mask: Mask value to get the error count 48 * @ways_mask: Mask value to get the error ways 49 * @count_shift: Shift value to get the error count 50 * @ways_shift: Shift value to get the error ways 51 */ 52 struct llcc_edac_reg_data { 53 char *name; 54 u64 synd_reg; 55 u64 count_status_reg; 56 u64 ways_status_reg; 57 u32 reg_cnt; 58 u32 count_mask; 59 u32 ways_mask; 60 u8 count_shift; 61 u8 ways_shift; 62 }; 63 64 /** 65 * llcc_drv_data - Data associated with the llcc driver 66 * @regmap: regmap associated with the llcc device 67 * @bcast_regmap: regmap associated with llcc broadcast offset 68 * @cfg: pointer to the data structure for slice configuration 69 * @lock: mutex associated with each slice 70 * @cfg_size: size of the config data table 71 * @max_slices: max slices as read from device tree 72 * @num_banks: Number of llcc banks 73 * @bitmap: Bit map to track the active slice ids 74 * @offsets: Pointer to the bank offsets array 75 * @ecc_irq: interrupt for llcc cache error detection and reporting 76 */ 77 struct llcc_drv_data { 78 struct regmap *regmap; 79 struct regmap *bcast_regmap; 80 const struct llcc_slice_config *cfg; 81 struct mutex lock; 82 u32 cfg_size; 83 u32 max_slices; 84 u32 num_banks; 85 unsigned long *bitmap; 86 u32 *offsets; 87 int ecc_irq; 88 }; 89 90 #if IS_ENABLED(CONFIG_QCOM_LLCC) 91 /** 92 * llcc_slice_getd - get llcc slice descriptor 93 * @uid: usecase_id of the client 94 */ 95 struct llcc_slice_desc *llcc_slice_getd(u32 uid); 96 97 /** 98 * llcc_slice_putd - llcc slice descritpor 99 * @desc: Pointer to llcc slice descriptor 100 */ 101 void llcc_slice_putd(struct llcc_slice_desc *desc); 102 103 /** 104 * llcc_get_slice_id - get slice id 105 * @desc: Pointer to llcc slice descriptor 106 */ 107 int llcc_get_slice_id(struct llcc_slice_desc *desc); 108 109 /** 110 * llcc_get_slice_size - llcc slice size 111 * @desc: Pointer to llcc slice descriptor 112 */ 113 size_t llcc_get_slice_size(struct llcc_slice_desc *desc); 114 115 /** 116 * llcc_slice_activate - Activate the llcc slice 117 * @desc: Pointer to llcc slice descriptor 118 */ 119 int llcc_slice_activate(struct llcc_slice_desc *desc); 120 121 /** 122 * llcc_slice_deactivate - Deactivate the llcc slice 123 * @desc: Pointer to llcc slice descriptor 124 */ 125 int llcc_slice_deactivate(struct llcc_slice_desc *desc); 126 127 #else llcc_slice_getd(u32 uid)128static inline struct llcc_slice_desc *llcc_slice_getd(u32 uid) 129 { 130 return NULL; 131 } 132 llcc_slice_putd(struct llcc_slice_desc * desc)133static inline void llcc_slice_putd(struct llcc_slice_desc *desc) 134 { 135 136 }; 137 llcc_get_slice_id(struct llcc_slice_desc * desc)138static inline int llcc_get_slice_id(struct llcc_slice_desc *desc) 139 { 140 return -EINVAL; 141 } 142 llcc_get_slice_size(struct llcc_slice_desc * desc)143static inline size_t llcc_get_slice_size(struct llcc_slice_desc *desc) 144 { 145 return 0; 146 } llcc_slice_activate(struct llcc_slice_desc * desc)147static inline int llcc_slice_activate(struct llcc_slice_desc *desc) 148 { 149 return -EINVAL; 150 } 151 llcc_slice_deactivate(struct llcc_slice_desc * desc)152static inline int llcc_slice_deactivate(struct llcc_slice_desc *desc) 153 { 154 return -EINVAL; 155 } 156 #endif 157 158 #endif 159