cam_cpas_api.h 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _CAM_CPAS_API_H_
  7. #define _CAM_CPAS_API_H_
  8. #include <linux/device.h>
  9. #include <linux/platform_device.h>
  10. #include <media/cam_cpas.h>
  11. #include "cam_soc_util.h"
  12. #define CAM_HW_IDENTIFIER_LENGTH 128
  13. /* Default AXI Bandwidth vote */
  14. #define CAM_CPAS_DEFAULT_AXI_BW 1024
  15. /* Default RT AXI Bandwidth vote */
  16. #define CAM_CPAS_DEFAULT_RT_AXI_BW 2000000000L
  17. #define CAM_CPAS_MAX_PATHS_PER_CLIENT 15
  18. #define CAM_CPAS_API_PATH_DATA_STD_START 512
  19. #define CAM_CPAS_VOTE_LEVEL_NONE 0
  20. #define CAM_CPAS_VOTE_LEVEL_MAX 3
  21. /* Qos Selection mask */
  22. #define CAM_CPAS_QOS_DEFAULT_SETTINGS_MASK 0x1
  23. #define CAM_CPAS_QOS_CUSTOM_SETTINGS_MASK 0x2
  24. /**
  25. * enum cam_cpas_regbase_types - Enum for cpas regbase available for clients
  26. * to read/write
  27. */
  28. enum cam_cpas_regbase_types {
  29. CAM_CPAS_REGBASE_CPASTOP,
  30. CAM_CPAS_REGBASE_MAX
  31. };
  32. /**
  33. * enum cam_cpas_vote_type - Enum for cpas vote type
  34. */
  35. enum cam_cpas_vote_type {
  36. CAM_CPAS_VOTE_TYPE_HLOS,
  37. CAM_CPAS_VOTE_TYPE_DRV,
  38. CAM_CPAS_VOTE_TYPE_MAX,
  39. };
  40. /**
  41. * enum cam_cpas_hw_index - Enum for identify HW index
  42. */
  43. enum cam_cpas_hw_index {
  44. CAM_CPAS_HW_IDX_ANY = 0,
  45. CAM_CPAS_HW_IDX_0 = 1<<0,
  46. CAM_CPAS_HW_IDX_1 = 1<<1,
  47. CAM_CPAS_HW_IDX_2 = 1<<2,
  48. CAM_CPAS_HW_IDX_3 = 1<<3,
  49. CAM_CPAS_HW_IDX_4 = 1<<4,
  50. CAM_CPAS_HW_IDX_5 = 1<<5,
  51. CAM_CPAS_HW_IDX_6 = 1<<6,
  52. CAM_CPAS_HW_IDX_7 = 1<<7,
  53. CAM_CPAS_HW_IDX_MAX = 1<<8
  54. };
  55. /**
  56. * enum cam_cpas_camera_version Enum for Titan Camera Versions
  57. */
  58. enum cam_cpas_camera_version {
  59. CAM_CPAS_CAMERA_VERSION_NONE = 0,
  60. CAM_CPAS_CAMERA_VERSION_150 = 0x00010500,
  61. CAM_CPAS_CAMERA_VERSION_170 = 0x00010700,
  62. CAM_CPAS_CAMERA_VERSION_175 = 0x00010705,
  63. CAM_CPAS_CAMERA_VERSION_480 = 0x00040800,
  64. CAM_CPAS_CAMERA_VERSION_520 = 0x00050200,
  65. CAM_CPAS_CAMERA_VERSION_540 = 0x00050400,
  66. CAM_CPAS_CAMERA_VERSION_580 = 0x00050800,
  67. CAM_CPAS_CAMERA_VERSION_545 = 0x00050405,
  68. CAM_CPAS_CAMERA_VERSION_570 = 0x00050700,
  69. CAM_CPAS_CAMERA_VERSION_680 = 0x00060800,
  70. CAM_CPAS_CAMERA_VERSION_165 = 0x00010605,
  71. CAM_CPAS_CAMERA_VERSION_780 = 0x00070800,
  72. CAM_CPAS_CAMERA_VERSION_640 = 0x00060400,
  73. CAM_CPAS_CAMERA_VERSION_880 = 0x00080800,
  74. CAM_CPAS_CAMERA_VERSION_980 = 0x00090800,
  75. CAM_CPAS_CAMERA_VERSION_MAX
  76. };
  77. /**
  78. * enum cam_cpas_version Enum for Titan CPAS Versions
  79. */
  80. enum cam_cpas_version {
  81. CAM_CPAS_VERSION_NONE = 0,
  82. CAM_CPAS_VERSION_100 = 0x10000000,
  83. CAM_CPAS_VERSION_101 = 0x10000001,
  84. CAM_CPAS_VERSION_110 = 0x10010000,
  85. CAM_CPAS_VERSION_120 = 0x10020000,
  86. CAM_CPAS_VERSION_130 = 0x10030000,
  87. CAM_CPAS_VERSION_200 = 0x20000000,
  88. CAM_CPAS_VERSION_MAX
  89. };
  90. /**
  91. * enum cam_cpas_camera_version_map_id Enum for camera version map id
  92. * This enum is mapped with cam_cpas_camera_version
  93. */
  94. enum cam_cpas_camera_version_map_id {
  95. CAM_CPAS_CAMERA_VERSION_ID_150 = 0x0,
  96. CAM_CPAS_CAMERA_VERSION_ID_170 = 0x1,
  97. CAM_CPAS_CAMERA_VERSION_ID_175 = 0x2,
  98. CAM_CPAS_CAMERA_VERSION_ID_480 = 0x3,
  99. CAM_CPAS_CAMERA_VERSION_ID_580 = 0x4,
  100. CAM_CPAS_CAMERA_VERSION_ID_520 = 0x5,
  101. CAM_CPAS_CAMERA_VERSION_ID_540 = 0x6,
  102. CAM_CPAS_CAMERA_VERSION_ID_545 = 0x7,
  103. CAM_CPAS_CAMERA_VERSION_ID_570 = 0x8,
  104. CAM_CPAS_CAMERA_VERSION_ID_680 = 0x9,
  105. CAM_CPAS_CAMERA_VERSION_ID_165 = 0xA,
  106. CAM_CPAS_CAMERA_VERSION_ID_780 = 0xB,
  107. CAM_CPAS_CAMERA_VERSION_ID_640 = 0xC,
  108. CAM_CPAS_CAMERA_VERSION_ID_880 = 0xD,
  109. CAM_CPAS_CAMERA_VERSION_ID_980 = 0xE,
  110. CAM_CPAS_CAMERA_VERSION_ID_MAX
  111. };
  112. /**
  113. * enum cam_cpas_version_map_id Enum for cpas version map id
  114. * This enum is mapped with cam_cpas_version
  115. */
  116. enum cam_cpas_version_map_id {
  117. CAM_CPAS_VERSION_ID_100 = 0x0,
  118. CAM_CPAS_VERSION_ID_101 = 0x1,
  119. CAM_CPAS_VERSION_ID_110 = 0x2,
  120. CAM_CPAS_VERSION_ID_120 = 0x3,
  121. CAM_CPAS_VERSION_ID_130 = 0x4,
  122. CAM_CPAS_VERSION_ID_200 = 0x5,
  123. CAM_CPAS_VERSION_ID_MAX
  124. };
  125. /**
  126. * enum cam_cpas_hw_version - Enum for Titan CPAS HW Versions
  127. */
  128. enum cam_cpas_hw_version {
  129. CAM_CPAS_TITAN_NONE = 0,
  130. CAM_CPAS_TITAN_150_V100 = 0x150100,
  131. CAM_CPAS_TITAN_165_V100 = 0x165100,
  132. CAM_CPAS_TITAN_170_V100 = 0x170100,
  133. CAM_CPAS_TITAN_170_V110 = 0x170110,
  134. CAM_CPAS_TITAN_170_V120 = 0x170120,
  135. CAM_CPAS_TITAN_170_V200 = 0x170200,
  136. CAM_CPAS_TITAN_175_V100 = 0x175100,
  137. CAM_CPAS_TITAN_175_V101 = 0x175101,
  138. CAM_CPAS_TITAN_175_V120 = 0x175120,
  139. CAM_CPAS_TITAN_175_V130 = 0x175130,
  140. CAM_CPAS_TITAN_480_V100 = 0x480100,
  141. CAM_CPAS_TITAN_580_V100 = 0x580100,
  142. CAM_CPAS_TITAN_540_V100 = 0x540100,
  143. CAM_CPAS_TITAN_520_V100 = 0x520100,
  144. CAM_CPAS_TITAN_545_V100 = 0x545100,
  145. CAM_CPAS_TITAN_570_V100 = 0x570100,
  146. CAM_CPAS_TITAN_570_V200 = 0x570200,
  147. CAM_CPAS_TITAN_680_V100 = 0x680100,
  148. CAM_CPAS_TITAN_680_V110 = 0x680110,
  149. CAM_CPAS_TITAN_780_V100 = 0x780100,
  150. CAM_CPAS_TITAN_640_V200 = 0x640200,
  151. CAM_CPAS_TITAN_880_V100 = 0x880100,
  152. CAM_CPAS_TITAN_980_V100 = 0x980100,
  153. CAM_CPAS_TITAN_MAX
  154. };
  155. /**
  156. * enum cam_camnoc_slave_error_codes - Enum for camnoc slave error codes
  157. *
  158. */
  159. enum cam_camnoc_slave_error_codes {
  160. CAM_CAMNOC_TARGET_ERROR,
  161. CAM_CAMNOC_ADDRESS_DECODE_ERROR,
  162. CAM_CAMNOC_UNSUPPORTED_REQUEST_ERROR,
  163. CAM_CAMNOC_DISCONNECTED_TARGET_ERROR,
  164. CAM_CAMNOC_SECURITY_VIOLATION,
  165. CAM_CAMNOC_HIDDEN_SECURITY_VIOLATION,
  166. CAM_CAMNOC_TIME_OUT,
  167. CAM_CAMNOC_UNUSED,
  168. };
  169. /**
  170. * enum cam_camnoc_irq_type - Enum for camnoc irq types
  171. *
  172. * @CAM_CAMNOC_IRQ_SLAVE_ERROR: Each slave port in CAMNOC (3 QSB ports and
  173. * 1 QHB port) has an error logger. The error
  174. * observed at any slave port is logged into
  175. * the error logger register and an IRQ is
  176. * triggered
  177. * @CAM_CAMNOC_IRQ_IFE_UBWC_ENCODE_ERROR : Triggered if any error detected
  178. * in the IFE UBWC encoder instance
  179. * @CAM_CAMNOC_IRQ_IFE_UBWC_STATS_ENCODE_ERROR: Triggered if any error detected
  180. * in the IFE UBWC-Stats encoder
  181. * instance
  182. * @CAM_CAMNOC_IRQ_IFE02_UBWC_ENCODE_ERROR : Triggered if any error detected
  183. * in the IFE0 UBWC encoder instance
  184. * @CAM_CAMNOC_IRQ_IFE13_UBWC_ENCODE_ERROR : Triggered if any error detected
  185. * in the IFE1 or IFE3 UBWC encoder
  186. * instance
  187. * @CAM_CAMNOC_IRQ_IFE0_UBWC_ENCODE_ERROR : Triggered if any error detected
  188. * in the IFE0 UBWC encoder instance
  189. * @CAM_CAMNOC_IRQ_IFE1_WR_UBWC_ENCODE_ERROR : Triggered if any error detected
  190. * in the IFE1 UBWC encoder
  191. * instance
  192. * @CAM_CAMNOC_IRQ_IPE_UBWC_ENCODE_ERROR : Triggered if any error detected
  193. * in the IPE write path encoder
  194. * instance
  195. * @CAM_CAMNOC_IRQ_BPS_UBWC_ENCODE_ERROR : Triggered if any error detected
  196. * in the BPS write path encoder
  197. * instance
  198. * @CAM_CAMNOC_IRQ_IPE1_BPS_UBWC_DECODE_ERROR: Triggered if any error detected
  199. * in the IPE1/BPS read path decoder
  200. * instance
  201. * @CAM_CAMNOC_IRQ_IPE0_UBWC_DECODE_ERROR : Triggered if any error detected
  202. * in the IPE0 read path decoder
  203. * instance
  204. * @CAM_CAMNOC_IRQ_IPE1_UBWC_DECODE_ERROR : Triggered if any error detected
  205. * in the IPE1 read path decoder
  206. * instance
  207. * @CAM_CAMNOC_IRQ_IPE_BPS_UBWC_DECODE_ERROR: Triggered if any error detected
  208. * in the IPE/BPS UBWC decoder
  209. * instance
  210. * @CAM_CAMNOC_IRQ_IPE_BPS_UBWC_ENCODE_ERROR: Triggered if any error detected
  211. * in the IPE/BPS UBWC encoder
  212. * instance
  213. * @CAM_CAMNOC_IRQ_OFE_WR_UBWC_ENCODE_ERROR : Triggered if any error detected
  214. * in the OFE write UBWC decoder
  215. * instance
  216. * @CAM_CAMNOC_IRQ_OFE_RD_UBWC_DECODE_ERROR : Triggered if any error detected
  217. * in the OFE read UBWC decoder
  218. * instance
  219. * @CAM_CAMNOC_IRQ_TFE_UBWC_ENCODE_ERROR : Triggered if any error detected
  220. * in the TFE UBWC encoder
  221. * instance
  222. * @CAM_CAMNOC_IRQ_AHB_TIMEOUT : Triggered when the QHS_ICP slave
  223. * times out after 4000 AHB cycles
  224. */
  225. enum cam_camnoc_irq_type {
  226. CAM_CAMNOC_IRQ_SLAVE_ERROR,
  227. CAM_CAMNOC_IRQ_IFE_UBWC_ENCODE_ERROR,
  228. CAM_CAMNOC_IRQ_IFE_UBWC_STATS_ENCODE_ERROR,
  229. CAM_CAMNOC_IRQ_IFE_UBWC_STATS_1_ENCODE_ERROR,
  230. CAM_CAMNOC_IRQ_IFE02_UBWC_ENCODE_ERROR,
  231. CAM_CAMNOC_IRQ_IFE13_UBWC_ENCODE_ERROR,
  232. CAM_CAMNOC_IRQ_IFE0_UBWC_ENCODE_ERROR,
  233. CAM_CAMNOC_IRQ_IFE1_WRITE_UBWC_ENCODE_ERROR,
  234. CAM_CAMNOC_IRQ_IPE_UBWC_ENCODE_ERROR,
  235. CAM_CAMNOC_IRQ_BPS_UBWC_ENCODE_ERROR,
  236. CAM_CAMNOC_IRQ_IPE1_BPS_UBWC_DECODE_ERROR,
  237. CAM_CAMNOC_IRQ_IPE0_UBWC_DECODE_ERROR,
  238. CAM_CAMNOC_IRQ_IPE1_UBWC_DECODE_ERROR,
  239. CAM_CAMNOC_IRQ_IPE_BPS_UBWC_DECODE_ERROR,
  240. CAM_CAMNOC_IRQ_IPE_BPS_UBWC_ENCODE_ERROR,
  241. CAM_CAMNOC_IRQ_OFE_WR_UBWC_ENCODE_ERROR,
  242. CAM_CAMNOC_IRQ_OFE_RD_UBWC_DECODE_ERROR,
  243. CAM_CAMNOC_IRQ_TFE_UBWC_ENCODE_ERROR,
  244. CAM_CAMNOC_IRQ_AHB_TIMEOUT,
  245. };
  246. /**
  247. * enum cam_sys_cache_config_types - Enum for camera llc's
  248. */
  249. enum cam_sys_cache_config_types {
  250. CAM_LLCC_SMALL_1 = 0,
  251. CAM_LLCC_SMALL_2 = 1,
  252. CAM_LLCC_LARGE_1 = 2,
  253. CAM_LLCC_LARGE_2 = 3,
  254. CAM_LLCC_LARGE_3 = 4,
  255. CAM_LLCC_LARGE_4 = 5,
  256. CAM_LLCC_MAX = 6,
  257. };
  258. /**
  259. * enum cam_sys_cache_llcc_staling_mode - Enum for camera llc's stalling mode
  260. */
  261. enum cam_sys_cache_llcc_staling_mode {
  262. CAM_LLCC_STALING_MODE_CAPACITY,
  263. CAM_LLCC_STALING_MODE_NOTIFY,
  264. CAM_LLCC_STALING_MODE_MAX,
  265. };
  266. /**
  267. * enum cam_sys_cache_llcc_staling_mode - Enum for camera llc's stalling mode
  268. */
  269. enum cam_sys_cache_llcc_staling_op_type {
  270. CAM_LLCC_NOTIFY_STALING_EVICT,
  271. CAM_LLCC_NOTIFY_STALING_FORGET,
  272. CAM_LLCC_NOTIFY_STALING_OPS_MAX
  273. };
  274. /**
  275. * struct cam_camnoc_irq_slave_err_data : Data for Slave error.
  276. *
  277. * @mainctrl : Err logger mainctrl info
  278. * @errvld : Err logger errvld info
  279. * @errlog0_low : Err logger errlog0_low info
  280. * @errlog0_high : Err logger errlog0_high info
  281. * @errlog1_low : Err logger errlog1_low info
  282. * @errlog1_high : Err logger errlog1_high info
  283. * @errlog2_low : Err logger errlog2_low info
  284. * @errlog2_high : Err logger errlog2_high info
  285. * @errlog3_low : Err logger errlog3_low info
  286. * @errlog3_high : Err logger errlog3_high info
  287. *
  288. */
  289. struct cam_camnoc_irq_slave_err_data {
  290. union {
  291. struct {
  292. uint32_t stall_en : 1; /* bit 0 */
  293. uint32_t fault_en : 1; /* bit 1 */
  294. uint32_t rsv : 30; /* bits 2-31 */
  295. };
  296. uint32_t value;
  297. } mainctrl;
  298. union {
  299. struct {
  300. uint32_t err_vld : 1; /* bit 0 */
  301. uint32_t rsv : 31; /* bits 1-31 */
  302. };
  303. uint32_t value;
  304. } errvld;
  305. union {
  306. struct {
  307. uint32_t loginfo_vld : 1; /* bit 0 */
  308. uint32_t word_error : 1; /* bit 1 */
  309. uint32_t non_secure : 1; /* bit 2 */
  310. uint32_t device : 1; /* bit 3 */
  311. uint32_t opc : 3; /* bits 4 - 6 */
  312. uint32_t rsv0 : 1; /* bit 7 */
  313. uint32_t err_code : 3; /* bits 8 - 10 */
  314. uint32_t sizef : 3; /* bits 11 - 13 */
  315. uint32_t rsv1 : 2; /* bits 14 - 15 */
  316. uint32_t addr_space : 6; /* bits 16 - 21 */
  317. uint32_t rsv2 : 10; /* bits 22 - 31 */
  318. };
  319. uint32_t value;
  320. } errlog0_low;
  321. union {
  322. struct {
  323. uint32_t len1 : 10; /* bits 0 - 9 */
  324. uint32_t rsv : 22; /* bits 10 - 31 */
  325. };
  326. uint32_t value;
  327. } errlog0_high;
  328. union {
  329. struct {
  330. uint32_t path : 16; /* bits 0 - 15 */
  331. uint32_t rsv : 16; /* bits 16 - 31 */
  332. };
  333. uint32_t value;
  334. } errlog1_low;
  335. union {
  336. struct {
  337. uint32_t extid : 18; /* bits 0 - 17 */
  338. uint32_t rsv : 14; /* bits 18 - 31 */
  339. };
  340. uint32_t value;
  341. } errlog1_high;
  342. union {
  343. struct {
  344. uint32_t errlog2_lsb : 32; /* bits 0 - 31 */
  345. };
  346. uint32_t value;
  347. } errlog2_low;
  348. union {
  349. struct {
  350. uint32_t errlog2_msb : 16; /* bits 0 - 16 */
  351. uint32_t rsv : 16; /* bits 16 - 31 */
  352. };
  353. uint32_t value;
  354. } errlog2_high;
  355. union {
  356. struct {
  357. uint32_t errlog3_lsb : 32; /* bits 0 - 31 */
  358. };
  359. uint32_t value;
  360. } errlog3_low;
  361. union {
  362. struct {
  363. uint32_t errlog3_msb : 32; /* bits 0 - 31 */
  364. };
  365. uint32_t value;
  366. } errlog3_high;
  367. };
  368. /**
  369. * struct cam_camnoc_irq_ubwc_enc_data : Data for UBWC Encode error.
  370. *
  371. * @encerr_status : Encode error status
  372. *
  373. */
  374. struct cam_camnoc_irq_ubwc_enc_data {
  375. union {
  376. struct {
  377. uint32_t encerrstatus : 3; /* bits 0 - 2 */
  378. uint32_t rsv : 29; /* bits 3 - 31 */
  379. };
  380. uint32_t value;
  381. } encerr_status;
  382. };
  383. /**
  384. * struct cam_camnoc_irq_ubwc_dec_data : Data for UBWC Decode error.
  385. *
  386. * @decerr_status : Decoder error status
  387. * @thr_err : Set to 1 if
  388. * At least one of the bflc_len fields in the bit steam exceeds
  389. * its threshold value. This error is possible only for
  390. * RGBA1010102, TP10, and RGB565 formats
  391. * @fcl_err : Set to 1 if
  392. * Fast clear with a legal non-RGB format
  393. * @len_md_err : Set to 1 if
  394. * The calculated burst length does not match burst length
  395. * specified by the metadata value
  396. * @format_err : Set to 1 if
  397. * Illegal format
  398. * 1. bad format :2,3,6
  399. * 2. For 32B MAL, metadata=6
  400. * 3. For 32B MAL RGB565, Metadata != 0,1,7
  401. * 4. For 64B MAL RGB565, metadata[3:1] == 1,2
  402. *
  403. */
  404. struct cam_camnoc_irq_ubwc_dec_data {
  405. union {
  406. struct {
  407. uint32_t thr_err : 1; /* bit 0 */
  408. uint32_t fcl_err : 1; /* bit 1 */
  409. uint32_t len_md_err : 1; /* bit 2 */
  410. uint32_t format_err : 1; /* bit 3 */
  411. uint32_t rsv : 28; /* bits 4 - 31 */
  412. };
  413. uint32_t value;
  414. } decerr_status;
  415. };
  416. struct cam_camnoc_irq_ahb_timeout_data {
  417. uint32_t data;
  418. };
  419. /**
  420. * struct cam_cpas_irq_data : CAMNOC IRQ data
  421. *
  422. * @irq_type : To identify the type of IRQ
  423. * @u : Union of irq err data information
  424. * @slave_err : Data for Slave error.
  425. * Valid if type is CAM_CAMNOC_IRQ_SLAVE_ERROR
  426. * @enc_err : Data for UBWC Encode error.
  427. * Valid if type is one of below:
  428. * CAM_CAMNOC_IRQ_IFE02_UBWC_ENCODE_ERROR
  429. * CAM_CAMNOC_IRQ_IFE13_UBWC_ENCODE_ERROR
  430. * CAM_CAMNOC_IRQ_IPE_BPS_UBWC_ENCODE_ERROR
  431. * @dec_err : Data for UBWC Decode error.
  432. * Valid if type is CAM_CAMNOC_IRQ_IPE_BPS_UBWC_DECODE_ERROR
  433. * @ahb_err : Data for Slave error.
  434. * Valid if type is CAM_CAMNOC_IRQ_AHB_TIMEOUT
  435. *
  436. */
  437. struct cam_cpas_irq_data {
  438. enum cam_camnoc_irq_type irq_type;
  439. union {
  440. struct cam_camnoc_irq_slave_err_data slave_err;
  441. struct cam_camnoc_irq_ubwc_enc_data enc_err;
  442. struct cam_camnoc_irq_ubwc_dec_data dec_err;
  443. struct cam_camnoc_irq_ahb_timeout_data ahb_err;
  444. } u;
  445. };
  446. /*
  447. * CPAS client callback
  448. *
  449. * @client_handle : CPAS client handle
  450. * @userdata : User data given at the time of register
  451. * @irq_data : Event data
  452. */
  453. typedef bool (*cam_cpas_client_cb_func)(
  454. uint32_t client_handle, void *userdata,
  455. struct cam_cpas_irq_data *irq_data);
  456. /**
  457. * struct cam_cpas_register_params : Register params for cpas client
  458. *
  459. * @identifier : Input identifier string which is the device label
  460. * from dt like vfe, ife, jpeg etc
  461. * @cell_index : Input integer identifier pointing to the cell index
  462. * from dt of the device. This can be used to form a
  463. * unique string with @identifier like vfe0, ife1,
  464. * jpeg0, etc
  465. * @dev : device handle
  466. * @userdata : Input private data which will be passed as
  467. * an argument while callback.
  468. * @cam_cpas_callback : Input callback pointer for triggering the
  469. * callbacks from CPAS driver.
  470. * @client_handle : Output Unique handle generated for this register
  471. *
  472. */
  473. struct cam_cpas_register_params {
  474. char identifier[CAM_HW_IDENTIFIER_LENGTH];
  475. uint32_t cell_index;
  476. struct device *dev;
  477. void *userdata;
  478. cam_cpas_client_cb_func cam_cpas_client_cb;
  479. uint32_t client_handle;
  480. };
  481. /**
  482. * enum cam_vote_type - Enum for voting type
  483. *
  484. * @CAM_VOTE_ABSOLUTE : Absolute vote
  485. * @CAM_VOTE_DYNAMIC : Dynamic vote
  486. */
  487. enum cam_vote_type {
  488. CAM_VOTE_ABSOLUTE,
  489. CAM_VOTE_DYNAMIC,
  490. };
  491. /**
  492. * struct cam_ahb_vote : AHB vote
  493. *
  494. * @type : AHB voting type.
  495. * CAM_VOTE_ABSOLUTE : vote based on the value 'level' is set
  496. * CAM_VOTE_DYNAMIC : vote calculated dynamically using 'freq'
  497. * and 'dev' handle is set
  498. * @level : AHB vote level
  499. * @freq : AHB vote dynamic frequency
  500. *
  501. */
  502. struct cam_ahb_vote {
  503. enum cam_vote_type type;
  504. union {
  505. enum cam_vote_level level;
  506. unsigned long freq;
  507. } vote;
  508. };
  509. /**
  510. * struct cam_cpas_axi_per_path_bw_vote - Internal per path bandwidth vote information
  511. *
  512. * @usage_data: client usage data (left/right/rdi)
  513. * @transac_type: Transaction type on the path (read/write)
  514. * @path_data_type: Path for which vote is given (video, display, rdi)
  515. * @vote_level: Vote level for this path
  516. * @camnoc_bw: CAMNOC bw for this path
  517. * @mnoc_ab_bw: MNOC AB bw for this path
  518. * @mnoc_ib_bw: MNOC IB bw for this path
  519. */
  520. struct cam_cpas_axi_per_path_bw_vote {
  521. uint32_t usage_data;
  522. uint32_t transac_type;
  523. uint32_t path_data_type;
  524. uint32_t vote_level;
  525. uint64_t camnoc_bw;
  526. uint64_t mnoc_ab_bw;
  527. uint64_t mnoc_ib_bw;
  528. };
  529. /**
  530. * struct cam_axi_vote : AXI vote
  531. *
  532. * @num_paths: Number of paths on which BW vote is sent to CPAS
  533. * @axi_path: Per path BW vote info
  534. *
  535. */
  536. struct cam_axi_vote {
  537. uint32_t num_paths;
  538. struct cam_cpas_axi_per_path_bw_vote axi_path[CAM_CPAS_MAX_PATHS_PER_CLIENT];
  539. };
  540. /**
  541. * cam_cpas_register_client()
  542. *
  543. * @brief: API to register cpas client
  544. *
  545. * @register_params: Input params to register as a client to CPAS
  546. *
  547. * @return 0 on success.
  548. *
  549. */
  550. int cam_cpas_register_client(
  551. struct cam_cpas_register_params *register_params);
  552. /**
  553. * cam_cpas_unregister_client()
  554. *
  555. * @brief: API to unregister cpas client
  556. *
  557. * @client_handle: Client handle to be unregistered
  558. *
  559. * @return 0 on success.
  560. *
  561. */
  562. int cam_cpas_unregister_client(uint32_t client_handle);
  563. /**
  564. * cam_cpas_start()
  565. *
  566. * @brief: API to start cpas client hw. Clients have to vote for minimal
  567. * bandwidth requirements for AHB, AXI. Use cam_cpas_update_ahb_vote
  568. * to scale bandwidth after start.
  569. *
  570. * @client_handle: client cpas handle
  571. * @ahb_vote : Pointer to ahb vote info
  572. * @axi_vote : Pointer to axi bandwidth vote info
  573. *
  574. * If AXI vote is not applicable to a particular client, use the value exposed
  575. * by CAM_CPAS_DEFAULT_AXI_BW as the default vote request.
  576. *
  577. * @return 0 on success.
  578. *
  579. */
  580. int cam_cpas_start(
  581. uint32_t client_handle,
  582. struct cam_ahb_vote *ahb_vote,
  583. struct cam_axi_vote *axi_vote);
  584. /**
  585. * cam_cpas_stop()
  586. *
  587. * @brief: API to stop cpas client hw. Bandwidth for AHB, AXI votes
  588. * would be removed for this client on this call. Clients should not
  589. * use cam_cpas_update_ahb_vote or cam_cpas_update_axi_vote
  590. * to remove their bandwidth vote.
  591. *
  592. * @client_handle: client cpas handle
  593. *
  594. * @return 0 on success.
  595. *
  596. */
  597. int cam_cpas_stop(uint32_t client_handle);
  598. /**
  599. * cam_cpas_update_ahb_vote()
  600. *
  601. * @brief: API to update AHB vote requirement. Use this function only
  602. * between cam_cpas_start and cam_cpas_stop in case clients wants
  603. * to scale to different vote level. Do not use this function to de-vote,
  604. * removing client's vote is implicit on cam_cpas_stop
  605. *
  606. * @client_handle : Client cpas handle
  607. * @ahb_vote : Pointer to ahb vote info
  608. *
  609. * @return 0 on success.
  610. *
  611. */
  612. int cam_cpas_update_ahb_vote(
  613. uint32_t client_handle,
  614. struct cam_ahb_vote *ahb_vote);
  615. /**
  616. * cam_cpas_update_axi_vote()
  617. *
  618. * @brief: API to update AXI vote requirement. Use this function only
  619. * between cam_cpas_start and cam_cpas_stop in case clients wants
  620. * to scale to different vote level. Do not use this function to de-vote,
  621. * removing client's vote is implicit on cam_cpas_stop
  622. *
  623. * @client_handle : Client cpas handle
  624. * @axi_vote : Pointer to axi bandwidth vote info
  625. *
  626. * @return 0 on success.
  627. *
  628. */
  629. int cam_cpas_update_axi_vote(
  630. uint32_t client_handle,
  631. struct cam_axi_vote *axi_vote);
  632. /**
  633. * cam_cpas_reg_write()
  634. *
  635. * @brief: API to write a register value in CPAS register space
  636. *
  637. * @client_handle : Client cpas handle
  638. * @reg_base : Register base identifier
  639. * @offset : Offset from the register base address
  640. * @mb : Whether to do reg write with memory barrier
  641. * @value : Value to be written in register
  642. *
  643. * @return 0 on success.
  644. *
  645. */
  646. int cam_cpas_reg_write(
  647. uint32_t client_handle,
  648. enum cam_cpas_regbase_types reg_base,
  649. uint32_t offset,
  650. bool mb,
  651. uint32_t value);
  652. /**
  653. * cam_cpas_reg_read()
  654. *
  655. * @brief: API to read a register value from CPAS register space
  656. *
  657. * @client_handle : Client cpas handle
  658. * @reg_base : Register base identifier
  659. * @offset : Offset from the register base address
  660. * @mb : Whether to do reg read with memory barrier
  661. * @value : Value to be red from register
  662. *
  663. * @return 0 on success.
  664. *
  665. */
  666. int cam_cpas_reg_read(
  667. uint32_t client_handle,
  668. enum cam_cpas_regbase_types reg_base,
  669. uint32_t offset,
  670. bool mb,
  671. uint32_t *value);
  672. /**
  673. * cam_cpas_get_hw_info()
  674. *
  675. * @brief: API to get camera hw information
  676. *
  677. * @camera_family : Camera family type. One of
  678. * CAM_FAMILY_CAMERA_SS
  679. * CAM_FAMILY_CPAS_SS
  680. * @camera_version : Camera platform version
  681. * @cpas_version : Camera cpas version
  682. * @cam_caps : Camera capability array
  683. * @num_cap_mask : number of capability masks
  684. * @cam_fuse_info : Camera fuse info
  685. * @domain_id_info : Domain id info
  686. *
  687. * @return 0 on success.
  688. *
  689. */
  690. int cam_cpas_get_hw_info(
  691. uint32_t *camera_family,
  692. struct cam_hw_version *camera_version,
  693. struct cam_hw_version *cpas_version,
  694. uint32_t **cam_caps,
  695. uint32_t *num_cap_mask,
  696. struct cam_cpas_fuse_info *cam_fuse_info,
  697. struct cam_cpas_domain_id_caps *domain_id_info);
  698. /**
  699. * cam_cpas_get_cpas_hw_version()
  700. *
  701. * @brief: API to get camera cpas hw version
  702. *
  703. * @hw_version : Camera cpas hw version
  704. *
  705. * @return 0 on success.
  706. *
  707. */
  708. int cam_cpas_get_cpas_hw_version(uint32_t *hw_version);
  709. /**
  710. * cam_cpas_is_feature_supported()
  711. *
  712. * @brief: API to get camera features
  713. *
  714. * @flag : Camera hw features to check
  715. *
  716. * @hw_map : To indicate which HWs are supported
  717. *
  718. * @fule_val : Return fule value in case of value type feature
  719. *
  720. * @return 1 if feature is supported
  721. *
  722. */
  723. bool cam_cpas_is_feature_supported(uint32_t flag, uint32_t hw_map,
  724. uint32_t *fuse_val);
  725. /**
  726. * cam_cpas_axi_util_path_type_to_string()
  727. *
  728. * @brief: API to get string for given path type
  729. *
  730. * @path_data_type : Path type
  731. *
  732. * @return string.
  733. *
  734. */
  735. const char *cam_cpas_axi_util_path_type_to_string(
  736. uint32_t path_data_type);
  737. /**
  738. * cam_cpas_axi_util_trans_type_to_string()
  739. *
  740. * @brief: API to get string for given transaction type
  741. *
  742. * @path_data_type : Transaction type
  743. *
  744. * @return string.
  745. *
  746. */
  747. const char *cam_cpas_axi_util_trans_type_to_string(
  748. uint32_t path_data_type);
  749. /**
  750. * cam_cpas_axi_util_drv_vote_lvl_to_string()
  751. *
  752. * @brief: API to get string for given DRV vote level
  753. *
  754. * @vote_lvl : DRV vote level
  755. *
  756. * @return string.
  757. *
  758. */
  759. const char *cam_cpas_axi_util_drv_vote_lvl_to_string(
  760. uint32_t vote_lvl);
  761. /**
  762. * cam_cpas_util_vote_type_to_string()
  763. *
  764. * @brief: API to get string for given vote type
  765. *
  766. * @vote_type : DRV vote level
  767. *
  768. * @return string.
  769. *
  770. */
  771. const char *cam_cpas_util_vote_type_to_string(enum cam_cpas_vote_type vote_type);
  772. /**
  773. * cam_cpas_log_votes()
  774. *
  775. * @brief: API to print the all bw votes of axi client. It also print the
  776. * applied camnoc axi clock vote value and ahb vote value
  777. *
  778. * @ddr_only: Print only DDR info
  779. *
  780. * @return 0 on success.
  781. *
  782. */
  783. void cam_cpas_log_votes(bool ddr_only);
  784. /**
  785. * cam_cpas_select_qos_settings()
  786. *
  787. * @brief: API to select specific qos settings based on usecase requirements
  788. *
  789. * @return 0 on success.
  790. *
  791. */
  792. int cam_cpas_select_qos_settings(uint32_t selection_mask);
  793. /**
  794. * cam_cpas_notify_event()
  795. *
  796. * @brief: API that clients can notify about their events. CPAS save the event
  797. * and any other useful information related to this event. This will
  798. * be printed while cpas state dump - cam_cpas_log_votes.
  799. * One such example is IFE notifiying SOF or EPOCH to cpas and cpas
  800. * saving axi clock information (camnoc_axi, mnoc_hf) at that point
  801. * and printing latest history on IFE overflow.
  802. *
  803. * @identifier_string: Identifier string passed by caller
  804. * @identifier_value: Identifier value passed by caller
  805. *
  806. * @return 0 on success.
  807. *
  808. */
  809. int cam_cpas_notify_event(const char *identifier_string,
  810. int32_t identifier_value);
  811. /**
  812. * cam_cpas_get_scid()
  813. *
  814. * @brief: API to obtain slice id for the given type
  815. *
  816. * @type: Cache type
  817. *
  818. * @return slice id, -1 for invalid id.
  819. *
  820. */
  821. int cam_cpas_get_scid(enum cam_sys_cache_config_types type);
  822. /**
  823. * cam_cpas_activate_llcc()
  824. *
  825. * @brief: API to activate system cache
  826. *
  827. * @type: Cache type
  828. *
  829. * @return 0 for success.
  830. *
  831. */
  832. int cam_cpas_activate_llcc(enum cam_sys_cache_config_types type);
  833. /**
  834. * cam_cpas_deactivate_llcc()
  835. *
  836. * @brief: API to de-activate system cache
  837. *
  838. * @type: Cache type
  839. *
  840. * @return 0 for success.
  841. *
  842. */
  843. int cam_cpas_deactivate_llcc(enum cam_sys_cache_config_types type);
  844. /**
  845. * cam_cpas_configure_staling_llcc()
  846. *
  847. * @brief: Configure cache staling mode by setting the
  848. * staling_mode and corresponding params
  849. *
  850. * @type: Cache type
  851. * @mode_param: llcc stalling mode params
  852. * @operation_type: cache operation type
  853. * @stalling_distance: llcc sys cache stalling distance
  854. *
  855. * @return 0 for success.
  856. *
  857. */
  858. int cam_cpas_configure_staling_llcc(
  859. enum cam_sys_cache_config_types type,
  860. enum cam_sys_cache_llcc_staling_mode mode_param,
  861. enum cam_sys_cache_llcc_staling_op_type operation_type,
  862. uint32_t staling_distance);
  863. /**
  864. * cam_cpas_notif_increment_staling_counter()
  865. *
  866. * @brief: This will increment the stalling counter
  867. * depends on what operation it does.
  868. * The operation mode what we have setup in other function.
  869. *
  870. * @type: Cache type
  871. *
  872. * @return 0 for success.
  873. *
  874. */
  875. int cam_cpas_notif_increment_staling_counter(
  876. enum cam_sys_cache_config_types type);
  877. /**
  878. * cam_cpas_dump_camnoc_buff_fill_info()
  879. *
  880. * @brief: API to dump camnoc buffer fill level info
  881. *
  882. * @client_handle : Client cpas handle
  883. *
  884. * @return 0 on success
  885. *
  886. */
  887. int cam_cpas_dump_camnoc_buff_fill_info(uint32_t client_handle);
  888. /**
  889. * cam_cpas_csid_input_core_info_update()
  890. *
  891. * @brief: API to communicate csid input core info to cpas
  892. *
  893. * @csid_idx: csid hw index connected to particular sfe
  894. * @sfe_idx: sfe idx to be connected to particular DRV path
  895. * @set_port: Indicates whether to set or reset DRV port info in dynamic client
  896. *
  897. * @return 0 on success
  898. *
  899. */
  900. int cam_cpas_csid_input_core_info_update(int csid_idx, int sfe_idx, bool set_port);
  901. /**
  902. * cam_cpas_csid_process_resume()
  903. *
  904. * @brief: API to process csid resume in cpas
  905. * @csid_idx: CSID idx to notify resume for
  906. *
  907. * @return 0 on success
  908. *
  909. */
  910. int cam_cpas_csid_process_resume(uint32_t csid_idx);
  911. /**
  912. * cam_cpas_query_drv_enable()
  913. *
  914. * @brief: API to indicate DRV enabled on hw or not
  915. * @is_ddr_drv_enabled: If DDR DRV enabled
  916. * @is_clk_drv_enabled: If Clock Cesta DRV enabled
  917. *
  918. * @return 0 on success
  919. *
  920. */
  921. int cam_cpas_query_drv_enable(bool *is_ddr_drv_enabled, bool *is_clk_drv_enabled);
  922. /**
  923. * cam_cpas_query_domain_id_security_support()
  924. * @brief: API to determine if target supports domain id feature
  925. * This information is determined by cpas during probe
  926. *
  927. * @return true if there's support, false otherwise
  928. */
  929. bool cam_cpas_query_domain_id_security_support(void);
  930. /**
  931. * cam_cpas_enable_clks_for_domain_id()
  932. *
  933. * @brief: API to enable/disable clocks for domain id support.
  934. * All CSIDs including those not in use for a ctxt
  935. * needs to be programmed in a secure session.
  936. * @enable: True to turn on, false otherwise.
  937. * @return 0 on success
  938. */
  939. int cam_cpas_enable_clks_for_domain_id(bool enable);
  940. /**
  941. * cam_cpas_is_notif_staling_supported()
  942. *
  943. * @brief: API to check stalling feature is supported or not
  944. *
  945. * @return rue if supported
  946. */
  947. bool cam_cpas_is_notif_staling_supported(void);
  948. #endif /* _CAM_CPAS_API_H_ */