xref: /linux-6.15/include/linux/soc/qcom/llcc-qcom.h (revision cfc826c8)
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_MDMHPFX     20
28 #define LLCC_MDMPNG      21
29 #define LLCC_AUDHW       22
30 #define LLCC_NPU         23
31 #define LLCC_WLHW        24
32 #define LLCC_CVP         28
33 #define LLCC_MODPE       29
34 #define LLCC_APTCM       30
35 #define LLCC_WRCACHE     31
36 #define LLCC_CVPFW       32
37 #define LLCC_CPUSS1      33
38 #define LLCC_CPUHWT      36
39 
40 /**
41  * struct llcc_slice_desc - Cache slice descriptor
42  * @slice_id: llcc slice id
43  * @slice_size: Size allocated for the llcc slice
44  */
45 struct llcc_slice_desc {
46 	u32 slice_id;
47 	size_t slice_size;
48 };
49 
50 /**
51  * struct llcc_edac_reg_data - llcc edac registers data for each error type
52  * @name: Name of the error
53  * @synd_reg: Syndrome register address
54  * @count_status_reg: Status register address to read the error count
55  * @ways_status_reg: Status register address to read the error ways
56  * @reg_cnt: Number of registers
57  * @count_mask: Mask value to get the error count
58  * @ways_mask: Mask value to get the error ways
59  * @count_shift: Shift value to get the error count
60  * @ways_shift: Shift value to get the error ways
61  */
62 struct llcc_edac_reg_data {
63 	char *name;
64 	u64 synd_reg;
65 	u64 count_status_reg;
66 	u64 ways_status_reg;
67 	u32 reg_cnt;
68 	u32 count_mask;
69 	u32 ways_mask;
70 	u8  count_shift;
71 	u8  ways_shift;
72 };
73 
74 /**
75  * struct llcc_drv_data - Data associated with the llcc driver
76  * @regmap: regmap associated with the llcc device
77  * @bcast_regmap: regmap associated with llcc broadcast offset
78  * @cfg: pointer to the data structure for slice configuration
79  * @lock: mutex associated with each slice
80  * @cfg_size: size of the config data table
81  * @max_slices: max slices as read from device tree
82  * @num_banks: Number of llcc banks
83  * @bitmap: Bit map to track the active slice ids
84  * @offsets: Pointer to the bank offsets array
85  * @ecc_irq: interrupt for llcc cache error detection and reporting
86  * @major_version: Indicates the LLCC major version
87  */
88 struct llcc_drv_data {
89 	struct regmap *regmap;
90 	struct regmap *bcast_regmap;
91 	const struct llcc_slice_config *cfg;
92 	struct mutex lock;
93 	u32 cfg_size;
94 	u32 max_slices;
95 	u32 num_banks;
96 	unsigned long *bitmap;
97 	u32 *offsets;
98 	int ecc_irq;
99 	u32 major_version;
100 };
101 
102 #if IS_ENABLED(CONFIG_QCOM_LLCC)
103 /**
104  * llcc_slice_getd - get llcc slice descriptor
105  * @uid: usecase_id of the client
106  */
107 struct llcc_slice_desc *llcc_slice_getd(u32 uid);
108 
109 /**
110  * llcc_slice_putd - llcc slice descritpor
111  * @desc: Pointer to llcc slice descriptor
112  */
113 void llcc_slice_putd(struct llcc_slice_desc *desc);
114 
115 /**
116  * llcc_get_slice_id - get slice id
117  * @desc: Pointer to llcc slice descriptor
118  */
119 int llcc_get_slice_id(struct llcc_slice_desc *desc);
120 
121 /**
122  * llcc_get_slice_size - llcc slice size
123  * @desc: Pointer to llcc slice descriptor
124  */
125 size_t llcc_get_slice_size(struct llcc_slice_desc *desc);
126 
127 /**
128  * llcc_slice_activate - Activate the llcc slice
129  * @desc: Pointer to llcc slice descriptor
130  */
131 int llcc_slice_activate(struct llcc_slice_desc *desc);
132 
133 /**
134  * llcc_slice_deactivate - Deactivate the llcc slice
135  * @desc: Pointer to llcc slice descriptor
136  */
137 int llcc_slice_deactivate(struct llcc_slice_desc *desc);
138 
139 #else
140 static inline struct llcc_slice_desc *llcc_slice_getd(u32 uid)
141 {
142 	return NULL;
143 }
144 
145 static inline void llcc_slice_putd(struct llcc_slice_desc *desc)
146 {
147 
148 };
149 
150 static inline int llcc_get_slice_id(struct llcc_slice_desc *desc)
151 {
152 	return -EINVAL;
153 }
154 
155 static inline size_t llcc_get_slice_size(struct llcc_slice_desc *desc)
156 {
157 	return 0;
158 }
159 static inline int llcc_slice_activate(struct llcc_slice_desc *desc)
160 {
161 	return -EINVAL;
162 }
163 
164 static inline int llcc_slice_deactivate(struct llcc_slice_desc *desc)
165 {
166 	return -EINVAL;
167 }
168 #endif
169 
170 #endif
171