llcc-qcom.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/platform_device.h>
  7. #include <linux/types.h>
  8. #ifndef __LLCC_QCOM__
  9. #define __LLCC_QCOM__
  10. #define LLCC_CPUSS 1
  11. #define LLCC_VIDSC0 2
  12. #define LLCC_VIDSC1 3
  13. #define LLCC_ROTATOR 4
  14. #define LLCC_VOICE 5
  15. #define LLCC_AUDIO 6
  16. #define LLCC_MDMHPGRW 7
  17. #define LLCC_MDM 8
  18. #define LLCC_MDMHW 9
  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_CAMFW 18
  27. #define LLCC_MDMHPFX 20
  28. #define LLCC_MDMPNG 21
  29. #define LLCC_AUDHW 22
  30. #define LLCC_NPU 23
  31. #define LLCC_WLNHW 24
  32. #define LLCC_PIMEM 25
  33. #define LLCC_ECC 26
  34. #define LLCC_CVP 28
  35. #define LLCC_MDMVPE 29
  36. #define LLCC_APTCM 30
  37. #define LLCC_WRTCH 31
  38. #define LLCC_CVPFW 32
  39. #define LLCC_CPUSS1 33
  40. #define LLCC_CAMEXP0 34
  41. #define LLCC_CPUMTE 35
  42. #define LLCC_CPUHWT 36
  43. #define LLCC_MDMCLAD2 37
  44. #define LLCC_CAMEXP1 38
  45. #define LLCC_CMPTHCP 39
  46. #define LLCC_LCPDARE 40
  47. #define LLCC_AENPU 45
  48. #define LLCC_ISLAND1 46
  49. #define LLCC_ISLAND2 47
  50. #define LLCC_ISLAND3 48
  51. #define LLCC_ISLAND4 49
  52. #define LLCC_CAMEXP2 50
  53. #define LLCC_CAMEXP3 51
  54. #define LLCC_CAMEXP4 52
  55. #define LLCC_DISP_WB 53
  56. #define LLCC_DISP_1 54
  57. #define LLCC_SAIL 55
  58. #define LLCC_VIDVSP 64
  59. #define LLCC_EVA_3DR 69
  60. /**
  61. * llcc_slice_desc - Cache slice descriptor
  62. * @slice_id: llcc slice id
  63. * @slice_size: Size allocated for the llcc slice
  64. */
  65. struct llcc_slice_desc {
  66. u32 slice_id;
  67. size_t slice_size;
  68. atomic_t refcount;
  69. };
  70. /**
  71. * llcc_edac_reg_data - llcc edac registers data for each error type
  72. * @name: Name of the error
  73. * @synd_reg: Syndrome register address
  74. * @count_status_reg: Status register address to read the error count
  75. * @ways_status_reg: Status register address to read the error ways
  76. * @reg_cnt: Number of registers
  77. * @count_mask: Mask value to get the error count
  78. * @ways_mask: Mask value to get the error ways
  79. * @count_shift: Shift value to get the error count
  80. * @ways_shift: Shift value to get the error ways
  81. */
  82. struct llcc_edac_reg_data {
  83. char *name;
  84. u64 synd_reg;
  85. u64 count_status_reg;
  86. u64 ways_status_reg;
  87. u32 reg_cnt;
  88. u32 count_mask;
  89. u32 ways_mask;
  90. u8 count_shift;
  91. u8 ways_shift;
  92. };
  93. struct llcc_edac_reg_offset {
  94. /* LLCC TRP registers */
  95. u32 trp_ecc_error_status0;
  96. u32 trp_ecc_error_status1;
  97. u32 trp_ecc_sb_err_syn0;
  98. u32 trp_ecc_db_err_syn0;
  99. u32 trp_ecc_error_cntr_clear;
  100. u32 trp_interrupt_0_status;
  101. u32 trp_interrupt_0_clear;
  102. u32 trp_interrupt_0_enable;
  103. /* LLCC Common registers */
  104. u32 cmn_status0;
  105. u32 cmn_interrupt_0_enable;
  106. u32 cmn_interrupt_2_enable;
  107. /* LLCC DRP registers */
  108. u32 drp_ecc_error_cfg;
  109. u32 drp_ecc_error_cntr_clear;
  110. u32 drp_interrupt_status;
  111. u32 drp_interrupt_clear;
  112. u32 drp_interrupt_enable;
  113. u32 drp_ecc_error_status0;
  114. u32 drp_ecc_error_status1;
  115. u32 drp_ecc_sb_err_syn0;
  116. u32 drp_ecc_db_err_syn0;
  117. };
  118. /**
  119. * llcc_drv_data - Data associated with the llcc driver
  120. * @regmap: regmap associated with the llcc device
  121. * @bcast_regmap: regmap associated with llcc broadcast offset
  122. * @cfg: pointer to the data structure for slice configuration
  123. * @edac_reg_offset: Offset of the LLCC EDAC registers
  124. * @lock: mutex associated with each slice
  125. * @cfg_index: index of config table if multiple configs present for a target
  126. * @cfg_size: size of the config data table
  127. * @max_slices: max slices as read from device tree
  128. * @num_banks: Number of llcc banks
  129. * @bitmap: Bit map to track the active slice ids
  130. * @offsets: Pointer to the bank offsets array
  131. * @ecc_irq: interrupt for llcc cache error detection and reporting
  132. * @llcc_ver: hardware version (20 for V2.0)
  133. * @desc: Array pointer of llcc_slice_desc
  134. */
  135. struct llcc_drv_data {
  136. struct regmap *regmap;
  137. struct regmap *bcast_regmap;
  138. const struct llcc_slice_config *cfg;
  139. const struct llcc_edac_reg_offset *edac_reg_offset;
  140. struct mutex lock;
  141. u32 cfg_index;
  142. u32 cfg_size;
  143. u32 max_slices;
  144. u32 num_banks;
  145. unsigned long *bitmap;
  146. u32 *offsets;
  147. int ecc_irq;
  148. int llcc_ver;
  149. bool cap_based_alloc_and_pwr_collapse;
  150. struct llcc_slice_desc *desc;
  151. };
  152. /**
  153. * Enum describing the various staling modes available for clients to use.
  154. */
  155. enum llcc_staling_mode {
  156. LLCC_STALING_MODE_CAPACITY, /* Default option on reset */
  157. LLCC_STALING_MODE_NOTIFY,
  158. LLCC_STALING_MODE_MAX
  159. };
  160. enum llcc_staling_notify_op {
  161. LLCC_NOTIFY_STALING_WRITEBACK,
  162. /* LLCC_NOTIFY_STALING_NO_WRITEBACK, */
  163. LLCC_NOTIFY_STALING_OPS_MAX
  164. };
  165. struct llcc_staling_mode_params {
  166. enum llcc_staling_mode staling_mode;
  167. union {
  168. /* STALING_MODE_CAPACITY needs no params */
  169. struct staling_mode_notify_params {
  170. u8 staling_distance;
  171. enum llcc_staling_notify_op op;
  172. } notify_params;
  173. };
  174. };
  175. #if IS_ENABLED(CONFIG_QCOM_LLCC)
  176. /**
  177. * llcc_slice_getd - get llcc slice descriptor
  178. * @uid: usecase_id of the client
  179. */
  180. struct llcc_slice_desc *llcc_slice_getd(u32 uid);
  181. /**
  182. * llcc_slice_putd - llcc slice descritpor
  183. * @desc: Pointer to llcc slice descriptor
  184. */
  185. void llcc_slice_putd(struct llcc_slice_desc *desc);
  186. /**
  187. * llcc_get_slice_id - get slice id
  188. * @desc: Pointer to llcc slice descriptor
  189. */
  190. int llcc_get_slice_id(struct llcc_slice_desc *desc);
  191. /**
  192. * llcc_get_slice_size - llcc slice size
  193. * @desc: Pointer to llcc slice descriptor
  194. */
  195. size_t llcc_get_slice_size(struct llcc_slice_desc *desc);
  196. /**
  197. * llcc_slice_activate - Activate the llcc slice
  198. * @desc: Pointer to llcc slice descriptor
  199. */
  200. int llcc_slice_activate(struct llcc_slice_desc *desc);
  201. /**
  202. * llcc_slice_deactivate - Deactivate the llcc slice
  203. * @desc: Pointer to llcc slice descriptor
  204. */
  205. int llcc_slice_deactivate(struct llcc_slice_desc *desc);
  206. /**
  207. * llcc_configure_staling_mode - Configure cache staling mode by setting the
  208. * staling_mode and corresponding
  209. * mode-specific params
  210. *
  211. * @desc: Pointer to llcc slice descriptor
  212. * @p: Staling mode-specific params
  213. *
  214. * Returns: zero on success or negative errno.
  215. */
  216. int llcc_configure_staling_mode(struct llcc_slice_desc *desc,
  217. struct llcc_staling_mode_params *p);
  218. /**
  219. * llcc_notif_staling_inc_counter - Trigger the staling of the sub-cache frame.
  220. *
  221. * @desc: Pointer to llcc slice descriptor
  222. *
  223. * Returns: zero on success or negative errno.
  224. */
  225. int llcc_notif_staling_inc_counter(struct llcc_slice_desc *desc);
  226. #else
  227. static inline struct llcc_slice_desc *llcc_slice_getd(u32 uid)
  228. {
  229. return NULL;
  230. }
  231. static inline void llcc_slice_putd(struct llcc_slice_desc *desc)
  232. {
  233. };
  234. static inline int llcc_get_slice_id(struct llcc_slice_desc *desc)
  235. {
  236. return -EINVAL;
  237. }
  238. static inline size_t llcc_get_slice_size(struct llcc_slice_desc *desc)
  239. {
  240. return 0;
  241. }
  242. static inline int llcc_slice_activate(struct llcc_slice_desc *desc)
  243. {
  244. return -EINVAL;
  245. }
  246. static inline int llcc_slice_deactivate(struct llcc_slice_desc *desc)
  247. {
  248. return -EINVAL;
  249. }
  250. static inline int llcc_configure_staling_mode(struct llcc_slice_desc *desc,
  251. struct llcc_staling_mode_params *p)
  252. {
  253. return -EINVAL;
  254. }
  255. static inline int llcc_notif_staling_inc_counter(struct llcc_slice_desc *desc)
  256. {
  257. return -EINVAL;
  258. }
  259. #endif
  260. #endif