cam_cpas_api.h 31 KB

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