cam_cpas_api.h 30 KB

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