cam_cpas_api.h 25 KB

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