cam_cpas_api.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_CPAS_API_H_
  6. #define _CAM_CPAS_API_H_
  7. #include <linux/device.h>
  8. #include <linux/platform_device.h>
  9. #include <media/cam_cpas.h>
  10. #include "cam_soc_util.h"
  11. #define CAM_HW_IDENTIFIER_LENGTH 128
  12. /* Default AXI Bandwidth vote */
  13. #define CAM_CPAS_DEFAULT_AXI_BW 1024
  14. /* Default RT AXI Bandwidth vote */
  15. #define CAM_CPAS_DEFAULT_RT_AXI_BW 2000000000L
  16. #define CAM_CPAS_MAX_PATHS_PER_CLIENT 15
  17. #define CAM_CPAS_API_PATH_DATA_STD_START 512
  18. /* Qos Selection mask */
  19. #define CAM_CPAS_QOS_DEFAULT_SETTINGS_MASK 0x1
  20. #define CAM_CPAS_QOS_CUSTOM_SETTINGS_MASK 0x2
  21. /**
  22. * enum cam_cpas_reg_base - Enum for register base identifier. These
  23. * are the identifiers used in generic register
  24. * write/read APIs provided by cpas driver.
  25. */
  26. enum cam_cpas_reg_base {
  27. CAM_CPAS_REG_CPASTOP,
  28. CAM_CPAS_REG_CAMNOC,
  29. CAM_CPAS_REG_CAMSS,
  30. CAM_CPAS_REG_RPMH,
  31. CAM_CPAS_REG_MAX
  32. };
  33. /**
  34. * enum cam_cpas_hw_index - Enum for identify HW index
  35. */
  36. enum cam_cpas_hw_index {
  37. CAM_CPAS_HW_IDX_ANY = 0,
  38. CAM_CPAS_HW_IDX_0 = 1<<0,
  39. CAM_CPAS_HW_IDX_1 = 1<<1,
  40. CAM_CPAS_HW_IDX_2 = 1<<2,
  41. CAM_CPAS_HW_IDX_3 = 1<<3,
  42. CAM_CPAS_HW_IDX_4 = 1<<4,
  43. CAM_CPAS_HW_IDX_5 = 1<<5,
  44. CAM_CPAS_HW_IDX_6 = 1<<6,
  45. CAM_CPAS_HW_IDX_7 = 1<<7,
  46. CAM_CPAS_HW_IDX_MAX = 1<<8
  47. };
  48. /**
  49. * enum cam_cpas_camera_version Enum for Titan Camera Versions
  50. */
  51. enum cam_cpas_camera_version {
  52. CAM_CPAS_CAMERA_VERSION_NONE = 0,
  53. CAM_CPAS_CAMERA_VERSION_150 = 0x00010500,
  54. CAM_CPAS_CAMERA_VERSION_170 = 0x00010700,
  55. CAM_CPAS_CAMERA_VERSION_175 = 0x00010705,
  56. CAM_CPAS_CAMERA_VERSION_480 = 0x00040800,
  57. CAM_CPAS_CAMERA_VERSION_520 = 0x00050200,
  58. CAM_CPAS_CAMERA_VERSION_540 = 0x00050400,
  59. CAM_CPAS_CAMERA_VERSION_580 = 0x00050800,
  60. CAM_CPAS_CAMERA_VERSION_545 = 0x00050405,
  61. CAM_CPAS_CAMERA_VERSION_570 = 0x00050700,
  62. CAM_CPAS_CAMERA_VERSION_680 = 0x00060800,
  63. CAM_CPAS_CAMERA_VERSION_165 = 0x00010605,
  64. CAM_CPAS_CAMERA_VERSION_780 = 0x00070800,
  65. CAM_CPAS_CAMERA_VERSION_640 = 0x00060400,
  66. CAM_CPAS_CAMERA_VERSION_MAX
  67. };
  68. /**
  69. * enum cam_cpas_version Enum for Titan CPAS Versions
  70. */
  71. enum cam_cpas_version {
  72. CAM_CPAS_VERSION_NONE = 0,
  73. CAM_CPAS_VERSION_100 = 0x10000000,
  74. CAM_CPAS_VERSION_101 = 0x10000001,
  75. CAM_CPAS_VERSION_110 = 0x10010000,
  76. CAM_CPAS_VERSION_120 = 0x10020000,
  77. CAM_CPAS_VERSION_130 = 0x10030000,
  78. CAM_CPAS_VERSION_200 = 0x20000000,
  79. CAM_CPAS_VERSION_MAX
  80. };
  81. /**
  82. * enum cam_cpas_camera_version_map_id Enum for camera version map id
  83. * This enum is mapped with cam_cpas_camera_version
  84. */
  85. enum cam_cpas_camera_version_map_id {
  86. CAM_CPAS_CAMERA_VERSION_ID_150 = 0x0,
  87. CAM_CPAS_CAMERA_VERSION_ID_170 = 0x1,
  88. CAM_CPAS_CAMERA_VERSION_ID_175 = 0x2,
  89. CAM_CPAS_CAMERA_VERSION_ID_480 = 0x3,
  90. CAM_CPAS_CAMERA_VERSION_ID_580 = 0x4,
  91. CAM_CPAS_CAMERA_VERSION_ID_520 = 0x5,
  92. CAM_CPAS_CAMERA_VERSION_ID_540 = 0x6,
  93. CAM_CPAS_CAMERA_VERSION_ID_545 = 0x7,
  94. CAM_CPAS_CAMERA_VERSION_ID_570 = 0x8,
  95. CAM_CPAS_CAMERA_VERSION_ID_680 = 0x9,
  96. CAM_CPAS_CAMERA_VERSION_ID_165 = 0xA,
  97. CAM_CPAS_CAMERA_VERSION_ID_780 = 0xB,
  98. CAM_CPAS_CAMERA_VERSION_ID_640 = 0xC,
  99. CAM_CPAS_CAMERA_VERSION_ID_MAX
  100. };
  101. /**
  102. * enum cam_cpas_version_map_id Enum for cpas version map id
  103. * This enum is mapped with cam_cpas_version
  104. */
  105. enum cam_cpas_version_map_id {
  106. CAM_CPAS_VERSION_ID_100 = 0x0,
  107. CAM_CPAS_VERSION_ID_101 = 0x1,
  108. CAM_CPAS_VERSION_ID_110 = 0x2,
  109. CAM_CPAS_VERSION_ID_120 = 0x3,
  110. CAM_CPAS_VERSION_ID_130 = 0x4,
  111. CAM_CPAS_VERSION_ID_200 = 0x5,
  112. CAM_CPAS_VERSION_ID_MAX
  113. };
  114. /**
  115. * enum cam_cpas_hw_version - Enum for Titan CPAS HW Versions
  116. */
  117. enum cam_cpas_hw_version {
  118. CAM_CPAS_TITAN_NONE = 0,
  119. CAM_CPAS_TITAN_150_V100 = 0x150100,
  120. CAM_CPAS_TITAN_165_V100 = 0x165100,
  121. CAM_CPAS_TITAN_170_V100 = 0x170100,
  122. CAM_CPAS_TITAN_170_V110 = 0x170110,
  123. CAM_CPAS_TITAN_170_V120 = 0x170120,
  124. CAM_CPAS_TITAN_170_V200 = 0x170200,
  125. CAM_CPAS_TITAN_175_V100 = 0x175100,
  126. CAM_CPAS_TITAN_175_V101 = 0x175101,
  127. CAM_CPAS_TITAN_175_V120 = 0x175120,
  128. CAM_CPAS_TITAN_175_V130 = 0x175130,
  129. CAM_CPAS_TITAN_480_V100 = 0x480100,
  130. CAM_CPAS_TITAN_580_V100 = 0x580100,
  131. CAM_CPAS_TITAN_540_V100 = 0x540100,
  132. CAM_CPAS_TITAN_520_V100 = 0x520100,
  133. CAM_CPAS_TITAN_545_V100 = 0x545100,
  134. CAM_CPAS_TITAN_570_V100 = 0x570100,
  135. CAM_CPAS_TITAN_570_V200 = 0x570200,
  136. CAM_CPAS_TITAN_680_V100 = 0x680100,
  137. CAM_CPAS_TITAN_680_V110 = 0x680110,
  138. CAM_CPAS_TITAN_780_V100 = 0x780100,
  139. CAM_CPAS_TITAN_640_V200 = 0x640200,
  140. CAM_CPAS_TITAN_MAX
  141. };
  142. /**
  143. * enum cam_camnoc_irq_type - Enum for camnoc irq types
  144. *
  145. * @CAM_CAMNOC_IRQ_SLAVE_ERROR: Each slave port in CAMNOC (3 QSB ports and
  146. * 1 QHB port) has an error logger. The error
  147. * observed at any slave port is logged into
  148. * the error logger register and an IRQ is
  149. * triggered
  150. * @CAM_CAMNOC_IRQ_IFE_UBWC_ENCODE_ERROR : Triggered if any error detected
  151. * in the IFE UBWC encoder instance
  152. * @CAM_CAMNOC_IRQ_IFE_UBWC_STATS_ENCODE_ERROR: Triggered if any error detected
  153. * in the IFE UBWC-Stats encoder
  154. * instance
  155. * @CAM_CAMNOC_IRQ_IFE02_UBWC_ENCODE_ERROR : Triggered if any error detected
  156. * in the IFE0 UBWC encoder instance
  157. * @CAM_CAMNOC_IRQ_IFE13_UBWC_ENCODE_ERROR : Triggered if any error detected
  158. * in the IFE1 or IFE3 UBWC encoder
  159. * instance
  160. * @CAM_CAMNOC_IRQ_IFE0_UBWC_ENCODE_ERROR : Triggered if any error detected
  161. * in the IFE0 UBWC encoder instance
  162. * @CAM_CAMNOC_IRQ_IFE1_WR_UBWC_ENCODE_ERROR : Triggered if any error detected
  163. * in the IFE1 UBWC encoder
  164. * instance
  165. * @CAM_CAMNOC_IRQ_IPE_UBWC_ENCODE_ERROR : Triggered if any error detected
  166. * in the IPE write path encoder
  167. * instance
  168. * @CAM_CAMNOC_IRQ_BPS_UBWC_ENCODE_ERROR : Triggered if any error detected
  169. * in the BPS write path encoder
  170. * instance
  171. * @CAM_CAMNOC_IRQ_IPE1_BPS_UBWC_DECODE_ERROR: Triggered if any error detected
  172. * in the IPE1/BPS read path decoder
  173. * instance
  174. * @CAM_CAMNOC_IRQ_IPE0_UBWC_DECODE_ERROR : Triggered if any error detected
  175. * in the IPE0 read path decoder
  176. * instance
  177. * @CAM_CAMNOC_IRQ_IPE1_UBWC_DECODE_ERROR : Triggered if any error detected
  178. * in the IPE1 read path decoder
  179. * instance
  180. * @CAM_CAMNOC_IRQ_IPE_BPS_UBWC_DECODE_ERROR: Triggered if any error detected
  181. * in the IPE/BPS UBWC decoder
  182. * instance
  183. * @CAM_CAMNOC_IRQ_IPE_BPS_UBWC_ENCODE_ERROR: Triggered if any error detected
  184. * in the IPE/BPS UBWC encoder
  185. * instance
  186. * @CAM_CAMNOC_IRQ_AHB_TIMEOUT : Triggered when the QHS_ICP slave
  187. * times out after 4000 AHB cycles
  188. */
  189. enum cam_camnoc_irq_type {
  190. CAM_CAMNOC_IRQ_SLAVE_ERROR,
  191. CAM_CAMNOC_IRQ_IFE_UBWC_ENCODE_ERROR,
  192. CAM_CAMNOC_IRQ_IFE_UBWC_STATS_ENCODE_ERROR,
  193. CAM_CAMNOC_IRQ_IFE_UBWC_STATS_1_ENCODE_ERROR,
  194. CAM_CAMNOC_IRQ_IFE02_UBWC_ENCODE_ERROR,
  195. CAM_CAMNOC_IRQ_IFE13_UBWC_ENCODE_ERROR,
  196. CAM_CAMNOC_IRQ_IFE0_UBWC_ENCODE_ERROR,
  197. CAM_CAMNOC_IRQ_IFE1_WRITE_UBWC_ENCODE_ERROR,
  198. CAM_CAMNOC_IRQ_IPE_UBWC_ENCODE_ERROR,
  199. CAM_CAMNOC_IRQ_BPS_UBWC_ENCODE_ERROR,
  200. CAM_CAMNOC_IRQ_IPE1_BPS_UBWC_DECODE_ERROR,
  201. CAM_CAMNOC_IRQ_IPE0_UBWC_DECODE_ERROR,
  202. CAM_CAMNOC_IRQ_IPE1_UBWC_DECODE_ERROR,
  203. CAM_CAMNOC_IRQ_IPE_BPS_UBWC_DECODE_ERROR,
  204. CAM_CAMNOC_IRQ_IPE_BPS_UBWC_ENCODE_ERROR,
  205. CAM_CAMNOC_IRQ_AHB_TIMEOUT,
  206. };
  207. /**
  208. * enum cam_sys_cache_config_types - Enum for camera llc's
  209. */
  210. enum cam_sys_cache_config_types {
  211. CAM_LLCC_SMALL_1 = 0,
  212. CAM_LLCC_SMALL_2 = 1,
  213. CAM_LLCC_MAX = 2,
  214. };
  215. /**
  216. * struct cam_camnoc_irq_slave_err_data : Data for Slave error.
  217. *
  218. * @mainctrl : Err logger mainctrl info
  219. * @errvld : Err logger errvld info
  220. * @errlog0_low : Err logger errlog0_low info
  221. * @errlog0_high : Err logger errlog0_high info
  222. * @errlog1_low : Err logger errlog1_low info
  223. * @errlog1_high : Err logger errlog1_high info
  224. * @errlog2_low : Err logger errlog2_low info
  225. * @errlog2_high : Err logger errlog2_high info
  226. * @errlog3_low : Err logger errlog3_low info
  227. * @errlog3_high : Err logger errlog3_high info
  228. *
  229. */
  230. struct cam_camnoc_irq_slave_err_data {
  231. union {
  232. struct {
  233. uint32_t stall_en : 1; /* bit 0 */
  234. uint32_t fault_en : 1; /* bit 1 */
  235. uint32_t rsv : 30; /* bits 2-31 */
  236. };
  237. uint32_t value;
  238. } mainctrl;
  239. union {
  240. struct {
  241. uint32_t err_vld : 1; /* bit 0 */
  242. uint32_t rsv : 31; /* bits 1-31 */
  243. };
  244. uint32_t value;
  245. } errvld;
  246. union {
  247. struct {
  248. uint32_t loginfo_vld : 1; /* bit 0 */
  249. uint32_t word_error : 1; /* bit 1 */
  250. uint32_t non_secure : 1; /* bit 2 */
  251. uint32_t device : 1; /* bit 3 */
  252. uint32_t opc : 3; /* bits 4 - 6 */
  253. uint32_t rsv0 : 1; /* bit 7 */
  254. uint32_t err_code : 3; /* bits 8 - 10 */
  255. uint32_t sizef : 3; /* bits 11 - 13 */
  256. uint32_t rsv1 : 2; /* bits 14 - 15 */
  257. uint32_t addr_space : 6; /* bits 16 - 21 */
  258. uint32_t rsv2 : 10; /* bits 22 - 31 */
  259. };
  260. uint32_t value;
  261. } errlog0_low;
  262. union {
  263. struct {
  264. uint32_t len1 : 10; /* bits 0 - 9 */
  265. uint32_t rsv : 22; /* bits 10 - 31 */
  266. };
  267. uint32_t value;
  268. } errlog0_high;
  269. union {
  270. struct {
  271. uint32_t path : 16; /* bits 0 - 15 */
  272. uint32_t rsv : 16; /* bits 16 - 31 */
  273. };
  274. uint32_t value;
  275. } errlog1_low;
  276. union {
  277. struct {
  278. uint32_t extid : 18; /* bits 0 - 17 */
  279. uint32_t rsv : 14; /* bits 18 - 31 */
  280. };
  281. uint32_t value;
  282. } errlog1_high;
  283. union {
  284. struct {
  285. uint32_t errlog2_lsb : 32; /* bits 0 - 31 */
  286. };
  287. uint32_t value;
  288. } errlog2_low;
  289. union {
  290. struct {
  291. uint32_t errlog2_msb : 16; /* bits 0 - 16 */
  292. uint32_t rsv : 16; /* bits 16 - 31 */
  293. };
  294. uint32_t value;
  295. } errlog2_high;
  296. union {
  297. struct {
  298. uint32_t errlog3_lsb : 32; /* bits 0 - 31 */
  299. };
  300. uint32_t value;
  301. } errlog3_low;
  302. union {
  303. struct {
  304. uint32_t errlog3_msb : 32; /* bits 0 - 31 */
  305. };
  306. uint32_t value;
  307. } errlog3_high;
  308. };
  309. /**
  310. * struct cam_camnoc_irq_ubwc_enc_data : Data for UBWC Encode error.
  311. *
  312. * @encerr_status : Encode error status
  313. *
  314. */
  315. struct cam_camnoc_irq_ubwc_enc_data {
  316. union {
  317. struct {
  318. uint32_t encerrstatus : 3; /* bits 0 - 2 */
  319. uint32_t rsv : 29; /* bits 3 - 31 */
  320. };
  321. uint32_t value;
  322. } encerr_status;
  323. };
  324. /**
  325. * struct cam_camnoc_irq_ubwc_dec_data : Data for UBWC Decode error.
  326. *
  327. * @decerr_status : Decoder error status
  328. * @thr_err : Set to 1 if
  329. * At least one of the bflc_len fields in the bit steam exceeds
  330. * its threshold value. This error is possible only for
  331. * RGBA1010102, TP10, and RGB565 formats
  332. * @fcl_err : Set to 1 if
  333. * Fast clear with a legal non-RGB format
  334. * @len_md_err : Set to 1 if
  335. * The calculated burst length does not match burst length
  336. * specified by the metadata value
  337. * @format_err : Set to 1 if
  338. * Illegal format
  339. * 1. bad format :2,3,6
  340. * 2. For 32B MAL, metadata=6
  341. * 3. For 32B MAL RGB565, Metadata != 0,1,7
  342. * 4. For 64B MAL RGB565, metadata[3:1] == 1,2
  343. *
  344. */
  345. struct cam_camnoc_irq_ubwc_dec_data {
  346. union {
  347. struct {
  348. uint32_t thr_err : 1; /* bit 0 */
  349. uint32_t fcl_err : 1; /* bit 1 */
  350. uint32_t len_md_err : 1; /* bit 2 */
  351. uint32_t format_err : 1; /* bit 3 */
  352. uint32_t rsv : 28; /* bits 4 - 31 */
  353. };
  354. uint32_t value;
  355. } decerr_status;
  356. };
  357. struct cam_camnoc_irq_ahb_timeout_data {
  358. uint32_t data;
  359. };
  360. /**
  361. * struct cam_cpas_irq_data : CAMNOC IRQ data
  362. *
  363. * @irq_type : To identify the type of IRQ
  364. * @u : Union of irq err data information
  365. * @slave_err : Data for Slave error.
  366. * Valid if type is CAM_CAMNOC_IRQ_SLAVE_ERROR
  367. * @enc_err : Data for UBWC Encode error.
  368. * Valid if type is one of below:
  369. * CAM_CAMNOC_IRQ_IFE02_UBWC_ENCODE_ERROR
  370. * CAM_CAMNOC_IRQ_IFE13_UBWC_ENCODE_ERROR
  371. * CAM_CAMNOC_IRQ_IPE_BPS_UBWC_ENCODE_ERROR
  372. * @dec_err : Data for UBWC Decode error.
  373. * Valid if type is CAM_CAMNOC_IRQ_IPE_BPS_UBWC_DECODE_ERROR
  374. * @ahb_err : Data for Slave error.
  375. * Valid if type is CAM_CAMNOC_IRQ_AHB_TIMEOUT
  376. *
  377. */
  378. struct cam_cpas_irq_data {
  379. enum cam_camnoc_irq_type irq_type;
  380. union {
  381. struct cam_camnoc_irq_slave_err_data slave_err;
  382. struct cam_camnoc_irq_ubwc_enc_data enc_err;
  383. struct cam_camnoc_irq_ubwc_dec_data dec_err;
  384. struct cam_camnoc_irq_ahb_timeout_data ahb_err;
  385. } u;
  386. };
  387. /**
  388. * struct cam_cpas_register_params : Register params for cpas client
  389. *
  390. * @identifier : Input identifier string which is the device label
  391. * from dt like vfe, ife, jpeg etc
  392. * @cell_index : Input integer identifier pointing to the cell index
  393. * from dt of the device. This can be used to form a
  394. * unique string with @identifier like vfe0, ife1,
  395. * jpeg0, etc
  396. * @dev : device handle
  397. * @userdata : Input private data which will be passed as
  398. * an argument while callback.
  399. * @cam_cpas_callback : Input callback pointer for triggering the
  400. * callbacks from CPAS driver.
  401. * @client_handle : CPAS client handle
  402. * @userdata : User data given at the time of register
  403. * @event_type : event type
  404. * @event_data : event data
  405. * @client_handle : Output Unique handle generated for this register
  406. *
  407. */
  408. struct cam_cpas_register_params {
  409. char identifier[CAM_HW_IDENTIFIER_LENGTH];
  410. uint32_t cell_index;
  411. struct device *dev;
  412. void *userdata;
  413. bool (*cam_cpas_client_cb)(
  414. uint32_t client_handle,
  415. void *userdata,
  416. struct cam_cpas_irq_data *irq_data);
  417. uint32_t client_handle;
  418. };
  419. /**
  420. * enum cam_vote_type - Enum for voting type
  421. *
  422. * @CAM_VOTE_ABSOLUTE : Absolute vote
  423. * @CAM_VOTE_DYNAMIC : Dynamic vote
  424. */
  425. enum cam_vote_type {
  426. CAM_VOTE_ABSOLUTE,
  427. CAM_VOTE_DYNAMIC,
  428. };
  429. /**
  430. * struct cam_ahb_vote : AHB vote
  431. *
  432. * @type : AHB voting type.
  433. * CAM_VOTE_ABSOLUTE : vote based on the value 'level' is set
  434. * CAM_VOTE_DYNAMIC : vote calculated dynamically using 'freq'
  435. * and 'dev' handle is set
  436. * @level : AHB vote level
  437. * @freq : AHB vote dynamic frequency
  438. *
  439. */
  440. struct cam_ahb_vote {
  441. enum cam_vote_type type;
  442. union {
  443. enum cam_vote_level level;
  444. unsigned long freq;
  445. } vote;
  446. };
  447. /**
  448. * struct cam_axi_vote : AXI vote
  449. *
  450. * @num_paths: Number of paths on which BW vote is sent to CPAS
  451. * @axi_path: Per path BW vote info
  452. *
  453. */
  454. struct cam_axi_vote {
  455. uint32_t num_paths;
  456. struct cam_axi_per_path_bw_vote axi_path[CAM_CPAS_MAX_PATHS_PER_CLIENT];
  457. };
  458. /**
  459. * cam_cpas_register_client()
  460. *
  461. * @brief: API to register cpas client
  462. *
  463. * @register_params: Input params to register as a client to CPAS
  464. *
  465. * @return 0 on success.
  466. *
  467. */
  468. int cam_cpas_register_client(
  469. struct cam_cpas_register_params *register_params);
  470. /**
  471. * cam_cpas_unregister_client()
  472. *
  473. * @brief: API to unregister cpas client
  474. *
  475. * @client_handle: Client handle to be unregistered
  476. *
  477. * @return 0 on success.
  478. *
  479. */
  480. int cam_cpas_unregister_client(uint32_t client_handle);
  481. /**
  482. * cam_cpas_start()
  483. *
  484. * @brief: API to start cpas client hw. Clients have to vote for minimal
  485. * bandwidth requirements for AHB, AXI. Use cam_cpas_update_ahb_vote
  486. * to scale bandwidth after start.
  487. *
  488. * @client_handle: client cpas handle
  489. * @ahb_vote : Pointer to ahb vote info
  490. * @axi_vote : Pointer to axi bandwidth vote info
  491. *
  492. * If AXI vote is not applicable to a particular client, use the value exposed
  493. * by CAM_CPAS_DEFAULT_AXI_BW as the default vote request.
  494. *
  495. * @return 0 on success.
  496. *
  497. */
  498. int cam_cpas_start(
  499. uint32_t client_handle,
  500. struct cam_ahb_vote *ahb_vote,
  501. struct cam_axi_vote *axi_vote);
  502. /**
  503. * cam_cpas_stop()
  504. *
  505. * @brief: API to stop cpas client hw. Bandwidth for AHB, AXI votes
  506. * would be removed for this client on this call. Clients should not
  507. * use cam_cpas_update_ahb_vote or cam_cpas_update_axi_vote
  508. * to remove their bandwidth vote.
  509. *
  510. * @client_handle: client cpas handle
  511. *
  512. * @return 0 on success.
  513. *
  514. */
  515. int cam_cpas_stop(uint32_t client_handle);
  516. /**
  517. * cam_cpas_update_ahb_vote()
  518. *
  519. * @brief: API to update AHB vote requirement. Use this function only
  520. * between cam_cpas_start and cam_cpas_stop in case clients wants
  521. * to scale to different vote level. Do not use this function to de-vote,
  522. * removing client's vote is implicit on cam_cpas_stop
  523. *
  524. * @client_handle : Client cpas handle
  525. * @ahb_vote : Pointer to ahb vote info
  526. *
  527. * @return 0 on success.
  528. *
  529. */
  530. int cam_cpas_update_ahb_vote(
  531. uint32_t client_handle,
  532. struct cam_ahb_vote *ahb_vote);
  533. /**
  534. * cam_cpas_update_axi_vote()
  535. *
  536. * @brief: API to update AXI vote requirement. Use this function only
  537. * between cam_cpas_start and cam_cpas_stop in case clients wants
  538. * to scale to different vote level. Do not use this function to de-vote,
  539. * removing client's vote is implicit on cam_cpas_stop
  540. *
  541. * @client_handle : Client cpas handle
  542. * @axi_vote : Pointer to axi bandwidth vote info
  543. *
  544. * @return 0 on success.
  545. *
  546. */
  547. int cam_cpas_update_axi_vote(
  548. uint32_t client_handle,
  549. struct cam_axi_vote *axi_vote);
  550. /**
  551. * cam_cpas_reg_write()
  552. *
  553. * @brief: API to write a register value in CPAS register space
  554. *
  555. * @client_handle : Client cpas handle
  556. * @reg_base : Register base identifier
  557. * @offset : Offset from the register base address
  558. * @mb : Whether to do reg write with memory barrier
  559. * @value : Value to be written in register
  560. *
  561. * @return 0 on success.
  562. *
  563. */
  564. int cam_cpas_reg_write(
  565. uint32_t client_handle,
  566. enum cam_cpas_reg_base reg_base,
  567. uint32_t offset,
  568. bool mb,
  569. uint32_t value);
  570. /**
  571. * cam_cpas_reg_read()
  572. *
  573. * @brief: API to read a register value from CPAS register space
  574. *
  575. * @client_handle : Client cpas handle
  576. * @reg_base : Register base identifier
  577. * @offset : Offset from the register base address
  578. * @mb : Whether to do reg read with memory barrier
  579. * @value : Value to be red from register
  580. *
  581. * @return 0 on success.
  582. *
  583. */
  584. int cam_cpas_reg_read(
  585. uint32_t client_handle,
  586. enum cam_cpas_reg_base reg_base,
  587. uint32_t offset,
  588. bool mb,
  589. uint32_t *value);
  590. /**
  591. * cam_cpas_get_hw_info()
  592. *
  593. * @brief: API to get camera hw information
  594. *
  595. * @camera_family : Camera family type. One of
  596. * CAM_FAMILY_CAMERA_SS
  597. * CAM_FAMILY_CPAS_SS
  598. * @camera_version : Camera platform version
  599. * @cpas_version : Camera cpas version
  600. * @cam_caps : Camera capability
  601. * @cam_fuse_info : Camera fuse info
  602. *
  603. * @return 0 on success.
  604. *
  605. */
  606. int cam_cpas_get_hw_info(
  607. uint32_t *camera_family,
  608. struct cam_hw_version *camera_version,
  609. struct cam_hw_version *cpas_version,
  610. uint32_t *cam_caps,
  611. struct cam_cpas_fuse_info *cam_fuse_info);
  612. /**
  613. * cam_cpas_get_cpas_hw_version()
  614. *
  615. * @brief: API to get camera cpas hw version
  616. *
  617. * @hw_version : Camera cpas hw version
  618. *
  619. * @return 0 on success.
  620. *
  621. */
  622. int cam_cpas_get_cpas_hw_version(
  623. uint32_t *hw_version);
  624. /**
  625. * cam_cpas_is_feature_supported()
  626. *
  627. * @brief: API to get camera features
  628. *
  629. * @flag : Camera hw features to check
  630. *
  631. * @hw_map : To indicate which HWs are supported
  632. *
  633. * @fule_val : Return fule value in case of value type feature
  634. *
  635. * @return 1 if feature is supported
  636. *
  637. */
  638. bool cam_cpas_is_feature_supported(uint32_t flag, uint32_t hw_map,
  639. uint32_t *fuse_val);
  640. /**
  641. * cam_cpas_axi_util_path_type_to_string()
  642. *
  643. * @brief: API to get string for given path type
  644. *
  645. * @path_data_type : Path type
  646. *
  647. * @return string.
  648. *
  649. */
  650. const char *cam_cpas_axi_util_path_type_to_string(
  651. uint32_t path_data_type);
  652. /**
  653. * cam_cpas_axi_util_trans_type_to_string()
  654. *
  655. * @brief: API to get string for given transaction type
  656. *
  657. * @path_data_type : Transaction type
  658. *
  659. * @return string.
  660. *
  661. */
  662. const char *cam_cpas_axi_util_trans_type_to_string(
  663. uint32_t path_data_type);
  664. /**
  665. * cam_cpas_log_votes()
  666. *
  667. * @brief: API to print the all bw votes of axi client. It also print the
  668. * applied camnoc axi clock vote value and ahb vote value
  669. *
  670. * @return 0 on success.
  671. *
  672. */
  673. void cam_cpas_log_votes(void);
  674. /**
  675. * cam_cpas_select_qos_settings()
  676. *
  677. * @brief: API to select specific qos settings based on usecase requirements
  678. *
  679. * @return 0 on success.
  680. *
  681. */
  682. int cam_cpas_select_qos_settings(uint32_t selection_mask);
  683. /**
  684. * cam_cpas_notify_event()
  685. *
  686. * @brief: API that clients can notify about their events. CPAS save the event
  687. * and any other useful information related to this event. This will
  688. * be printed while cpas state dump - cam_cpas_log_votes.
  689. * One such example is IFE notifiying SOF or EPOCH to cpas and cpas
  690. * saving axi clock information (camnoc_axi, mnoc_hf) at that point
  691. * and printing latest history on IFE overflow.
  692. *
  693. * @identifier_string: Identifier string passed by caller
  694. * @identifier_value: Identifier value passed by caller
  695. *
  696. * @return 0 on success.
  697. *
  698. */
  699. int cam_cpas_notify_event(const char *identifier_string,
  700. int32_t identifier_value);
  701. /**
  702. * cam_cpas_get_scid()
  703. *
  704. * @brief: API to obtain slice id for the given type
  705. *
  706. * @type: Cache type
  707. *
  708. * @return slice id, -1 for invalid id.
  709. *
  710. */
  711. int cam_cpas_get_scid(enum cam_sys_cache_config_types type);
  712. /**
  713. * cam_cpas_activate_llcc()
  714. *
  715. * @brief: API to activate system cache
  716. *
  717. * @type: Cache type
  718. *
  719. * @return 0 for success.
  720. *
  721. */
  722. int cam_cpas_activate_llcc(enum cam_sys_cache_config_types type);
  723. /**
  724. * cam_cpas_deactivate_llcc()
  725. *
  726. * @brief: API to de-activate system cache
  727. *
  728. * @type: Cache type
  729. *
  730. * @return 0 for success.
  731. *
  732. */
  733. int cam_cpas_deactivate_llcc(enum cam_sys_cache_config_types type);
  734. /**
  735. * cam_cpas_dump_camnoc_buff_fill_info()
  736. *
  737. * @brief: API to dump camnoc buffer fill level info
  738. *
  739. * @client_handle : Client cpas handle
  740. *
  741. * @return 0 on success
  742. *
  743. */
  744. int cam_cpas_dump_camnoc_buff_fill_info(uint32_t client_handle);
  745. #endif /* _CAM_CPAS_API_H_ */