xref: /linux/include/linux/soc/qcom/llcc-qcom.h (revision 0be3ff0c)
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_CAMEXP0     34
39 #define LLCC_CPUMTE      35
40 #define LLCC_CPUHWT      36
41 #define LLCC_MDMCLAD2    37
42 #define LLCC_CAMEXP1     38
43 #define LLCC_AENPU       45
44 
45 /**
46  * struct llcc_slice_desc - Cache slice descriptor
47  * @slice_id: llcc slice id
48  * @slice_size: Size allocated for the llcc slice
49  */
50 struct llcc_slice_desc {
51 	u32 slice_id;
52 	size_t slice_size;
53 };
54 
55 /**
56  * struct llcc_edac_reg_data - llcc edac registers data for each error type
57  * @name: Name of the error
58  * @synd_reg: Syndrome register address
59  * @count_status_reg: Status register address to read the error count
60  * @ways_status_reg: Status register address to read the error ways
61  * @reg_cnt: Number of registers
62  * @count_mask: Mask value to get the error count
63  * @ways_mask: Mask value to get the error ways
64  * @count_shift: Shift value to get the error count
65  * @ways_shift: Shift value to get the error ways
66  */
67 struct llcc_edac_reg_data {
68 	char *name;
69 	u64 synd_reg;
70 	u64 count_status_reg;
71 	u64 ways_status_reg;
72 	u32 reg_cnt;
73 	u32 count_mask;
74 	u32 ways_mask;
75 	u8  count_shift;
76 	u8  ways_shift;
77 };
78 
79 /**
80  * struct 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  * @version: Indicates the LLCC version
92  */
93 struct llcc_drv_data {
94 	struct regmap *regmap;
95 	struct regmap *bcast_regmap;
96 	const struct llcc_slice_config *cfg;
97 	struct mutex lock;
98 	u32 cfg_size;
99 	u32 max_slices;
100 	u32 num_banks;
101 	unsigned long *bitmap;
102 	u32 *offsets;
103 	int ecc_irq;
104 	u32 version;
105 };
106 
107 #if IS_ENABLED(CONFIG_QCOM_LLCC)
108 /**
109  * llcc_slice_getd - get llcc slice descriptor
110  * @uid: usecase_id of the client
111  */
112 struct llcc_slice_desc *llcc_slice_getd(u32 uid);
113 
114 /**
115  * llcc_slice_putd - llcc slice descritpor
116  * @desc: Pointer to llcc slice descriptor
117  */
118 void llcc_slice_putd(struct llcc_slice_desc *desc);
119 
120 /**
121  * llcc_get_slice_id - get slice id
122  * @desc: Pointer to llcc slice descriptor
123  */
124 int llcc_get_slice_id(struct llcc_slice_desc *desc);
125 
126 /**
127  * llcc_get_slice_size - llcc slice size
128  * @desc: Pointer to llcc slice descriptor
129  */
130 size_t llcc_get_slice_size(struct llcc_slice_desc *desc);
131 
132 /**
133  * llcc_slice_activate - Activate the llcc slice
134  * @desc: Pointer to llcc slice descriptor
135  */
136 int llcc_slice_activate(struct llcc_slice_desc *desc);
137 
138 /**
139  * llcc_slice_deactivate - Deactivate the llcc slice
140  * @desc: Pointer to llcc slice descriptor
141  */
142 int llcc_slice_deactivate(struct llcc_slice_desc *desc);
143 
144 #else
145 static inline struct llcc_slice_desc *llcc_slice_getd(u32 uid)
146 {
147 	return NULL;
148 }
149 
150 static inline void llcc_slice_putd(struct llcc_slice_desc *desc)
151 {
152 
153 };
154 
155 static inline int llcc_get_slice_id(struct llcc_slice_desc *desc)
156 {
157 	return -EINVAL;
158 }
159 
160 static inline size_t llcc_get_slice_size(struct llcc_slice_desc *desc)
161 {
162 	return 0;
163 }
164 static inline int llcc_slice_activate(struct llcc_slice_desc *desc)
165 {
166 	return -EINVAL;
167 }
168 
169 static inline int llcc_slice_deactivate(struct llcc_slice_desc *desc)
170 {
171 	return -EINVAL;
172 }
173 #endif
174 
175 #endif
176