cam_cpas_api.h 22 KB

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