cam_cdm.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_CDM_H_
  6. #define _CAM_CDM_H_
  7. #include <linux/module.h>
  8. #include <linux/of_platform.h>
  9. #include <linux/random.h>
  10. #include <linux/spinlock_types.h>
  11. #include <linux/mutex.h>
  12. #include <linux/workqueue.h>
  13. #include <linux/bug.h>
  14. #include "cam_cdm_intf_api.h"
  15. #include "cam_soc_util.h"
  16. #include "cam_cpas_api.h"
  17. #include "cam_hw_intf.h"
  18. #include "cam_hw.h"
  19. #include "cam_debug_util.h"
  20. #define CAM_MAX_SW_CDM_VERSION_SUPPORTED 1
  21. #define CAM_SW_CDM_INDEX 0
  22. #define CAM_CDM_INFLIGHT_WORKS 5
  23. #define CAM_CDM_HW_RESET_TIMEOUT 300
  24. /*
  25. * Macros to get prepare and get information
  26. * from client CDM handles.
  27. */
  28. #define CAM_CDM_HW_ID_MASK 0xF
  29. #define CAM_CDM_HW_ID_SHIFT 0x10
  30. #define CAM_CDM_CLIENTS_ID_MASK 0xFF
  31. #define CAM_CDM_BL_FIFO_ID_MASK 0xF
  32. #define CAM_CDM_BL_FIFO_ID_SHIFT 0x8
  33. #define CAM_CDM_GET_HW_IDX(x) (((x) >> CAM_CDM_HW_ID_SHIFT) & \
  34. CAM_CDM_HW_ID_MASK)
  35. #define CAM_CDM_GET_BLFIFO_IDX(x) (((x) >> CAM_CDM_BL_FIFO_ID_SHIFT) & \
  36. CAM_CDM_BL_FIFO_ID_MASK)
  37. #define CAM_CDM_CREATE_CLIENT_HANDLE(hw_idx, priority, client_idx) \
  38. ((((hw_idx) & CAM_CDM_HW_ID_MASK) << CAM_CDM_HW_ID_SHIFT) | \
  39. (((priority) & CAM_CDM_BL_FIFO_ID_MASK) << CAM_CDM_BL_FIFO_ID_SHIFT)| \
  40. ((client_idx) & CAM_CDM_CLIENTS_ID_MASK))
  41. #define CAM_CDM_GET_CLIENT_IDX(x) ((x) & CAM_CDM_CLIENTS_ID_MASK)
  42. #define CAM_PER_CDM_MAX_REGISTERED_CLIENTS (CAM_CDM_CLIENTS_ID_MASK + 1)
  43. #define CAM_CDM_INTF_MGR_MAX_SUPPORTED_CDM (CAM_CDM_HW_ID_MASK + 1)
  44. /* Number of FIFO supported on CDM */
  45. #define CAM_CDM_NUM_BL_FIFO 0x4
  46. /* Max number of register set for different CDM */
  47. #define CAM_CDM_BL_FIFO_REG_NUM 0x4
  48. #define CAM_CDM_BL_FIFO_IRQ_REG_NUM 0x4
  49. #define CAM_CDM_BL_FIFO_PENDING_REQ_REG_NUM 0x2
  50. #define CAM_CDM_SCRATCH_REG_NUM 0xc
  51. #define CAM_CDM_COMP_WAIT_STATUS_REG_NUM 0x2
  52. #define CAM_CDM_PERF_MON_REG_NUM 0x2
  53. /* BL_FIFO configurations*/
  54. #define CAM_CDM_BL_FIFO_LENGTH_MAX_DEFAULT 0x40
  55. #define CAM_CDM_BL_FIFO_LENGTH_CFG_SHIFT 0x10
  56. #define CAM_CDM_BL_FIFO_FLUSH_SHIFT 0x3
  57. #define CAM_CDM_BL_FIFO_REQ_SIZE_MAX 0x00
  58. #define CAM_CDM_BL_FIFO_REQ_SIZE_MAX_DIV2 0x01
  59. #define CAM_CDM_BL_FIFO_REQ_SIZE_MAX_DIV4 0x10
  60. #define CAM_CDM_BL_FIFO_REQ_SIZE_MAX_DIV8 0x11
  61. /* CDM core status bitmap */
  62. #define CAM_CDM_HW_INIT_STATUS 0x0
  63. #define CAM_CDM_FIFO_0_BLDONE_STATUS 0x0
  64. #define CAM_CDM_FIFO_1_BLDONE_STATUS 0x1
  65. #define CAM_CDM_FIFO_2_BLDONE_STATUS 0x2
  66. #define CAM_CDM_FIFO_3_BLDONE_STATUS 0x3
  67. #define CAM_CDM_RESET_HW_STATUS 0x4
  68. #define CAM_CDM_ERROR_HW_STATUS 0x5
  69. #define CAM_CDM_FLUSH_HW_STATUS 0x6
  70. #define CAM_CDM_RESET_ERR_STATUS 0x7
  71. /* Curent used AHB masks and shifts */
  72. #define CAM_CDM_AHB_LOG_CID_SHIFT 28
  73. #define CAM_CDM_AHB_LOG_CID_MASK 0X30000000
  74. #define CAM_CDM_AHB_ADDR_MASK 0x00FFFFFF
  75. /* Invalid command status register's masks and shifts */
  76. #define CAM_CDM_ICL_STATUS_LAST_CID_SHIFT 4
  77. #define CAM_CDM_ICL_STATUS_LAST_CID_MASK 0X30
  78. #define CAM_CDM_ICL_STATUS_INV_CID_MASK 0x03
  79. /* Core_cfg register's masks and shifts */
  80. #define CAM_CDM_CORE_CFG_PRIORITY_MASK 0XF00000
  81. #define CAM_CDM_CORE_CFG_PRIORITY_SHIFT 20
  82. #define CAM_CDM_CORE_CFG_IMPLICIT_WAIT_EN_MASK 0x20000
  83. #define CAM_CDM_CORE_CFG_ARB_SEL_RR_MASK 0x10000
  84. #define CAM_CDM_CORE_CFG_AHB_STOP_ON_ERR_MASK 0x100
  85. #define CAM_CDM_CORE_CFG_AHB_BURST_EN_MASK 0x10
  86. #define CAM_CDM_CORE_CFG_AHB_BURST_LEN_MASK 0x0F
  87. /* Core enable register masks and shifts */
  88. #define CAM_CDM_CORE_EN_MASK 0x1
  89. #define CAM_CDM_CORE_PAUSE_MASK 0X2
  90. /* Curent BL command masks and shifts */
  91. #define CAM_CDM_CURRENT_BL_LEN 0xFFFFF
  92. #define CAM_CDM_CURRENT_BL_ARB 0x100000
  93. #define CAM_CDM_CURRENT_BL_FIFO 0xC00000
  94. #define CAM_CDM_CURRENT_BL_TAG 0xFF000000
  95. #define CAM_CDM_CURRENT_BL_ARB_SHIFT 0x14
  96. #define CAM_CDM_CURRENT_BL_FIFO_SHIFT 0x16
  97. #define CAM_CDM_CURRENT_BL_TAG_SHIFT 0x18
  98. /* IRQ bit-masks */
  99. #define CAM_CDM_IRQ_STATUS_RST_DONE_MASK 0x1
  100. #define CAM_CDM_IRQ_STATUS_INLINE_IRQ_MASK 0x2
  101. #define CAM_CDM_IRQ_STATUS_BL_DONE_MASK 0x4
  102. #define CAM_CDM_IRQ_STATUS_ERROR_INV_CMD_MASK 0x10000
  103. #define CAM_CDM_IRQ_STATUS_ERROR_OVER_FLOW_MASK 0x20000
  104. #define CAM_CDM_IRQ_STATUS_ERROR_AHB_BUS_MASK 0x40000
  105. #define CAM_CDM_IRQ_STATUS_USR_DATA_MASK 0xFF
  106. #define CAM_CDM_IRQ_STATUS_ERRORS \
  107. (CAM_CDM_IRQ_STATUS_ERROR_INV_CMD_MASK | \
  108. CAM_CDM_IRQ_STATUS_ERROR_OVER_FLOW_MASK | \
  109. CAM_CDM_IRQ_STATUS_ERROR_AHB_BUS_MASK)
  110. /* Structure to store hw version info */
  111. struct cam_version_reg {
  112. uint32_t hw_version;
  113. };
  114. /**
  115. * struct cam_cdm_irq_regs - CDM IRQ registers
  116. *
  117. * @irq_mask: register offset for irq_mask
  118. * @irq_clear: register offset for irq_clear
  119. * @irq_clear_cmd: register offset to initiate irq clear
  120. * @irq_set: register offset to set irq
  121. * @irq_set_cmd: register offset to issue set_irq from irq_set
  122. * @irq_status: register offset to look which irq is received
  123. */
  124. struct cam_cdm_irq_regs {
  125. uint32_t irq_mask;
  126. uint32_t irq_clear;
  127. uint32_t irq_clear_cmd;
  128. uint32_t irq_set;
  129. uint32_t irq_set_cmd;
  130. uint32_t irq_status;
  131. };
  132. /**
  133. * struct cam_cdm_bl_fifo_regs - BL_FIFO registers
  134. *
  135. * @bl_fifo_base: register offset to write bl_cmd base address
  136. * @bl_fifo_len: register offset to write bl_cmd length
  137. * @bl_fifo_store: register offset to commit the BL cmd
  138. * @bl_fifo_cfg: register offset to config BL_FIFO depth, etc.
  139. */
  140. struct cam_cdm_bl_fifo_regs {
  141. uint32_t bl_fifo_base;
  142. uint32_t bl_fifo_len;
  143. uint32_t bl_fifo_store;
  144. uint32_t bl_fifo_cfg;
  145. };
  146. /**
  147. * struct cam_cdm_bl_pending_req_reg_params - BL_FIFO pending registers
  148. *
  149. * @rb_offset: register offset pending bl request in BL_FIFO
  150. * @rb_mask: mask to get number of pending BLs in BL_FIFO
  151. * @rb_num_fifo: number of BL_FIFO's information in the register
  152. * @rb_next_fifo_shift: shift to get next fifo's pending BLs.
  153. */
  154. struct cam_cdm_bl_pending_req_reg_params {
  155. uint32_t rb_offset;
  156. uint32_t rb_mask;
  157. uint32_t rb_num_fifo;
  158. uint32_t rb_next_fifo_shift;
  159. };
  160. /**
  161. * struct cam_cdm_scratch_reg - scratch register
  162. *
  163. * @scratch_reg: offset of scratch register
  164. */
  165. struct cam_cdm_scratch_reg {
  166. uint32_t scratch_reg;
  167. };
  168. /* struct cam_cdm_perf_mon_regs - perf_mon registers */
  169. struct cam_cdm_perf_mon_regs {
  170. uint32_t perf_mon_ctrl;
  171. uint32_t perf_mon_0;
  172. uint32_t perf_mon_1;
  173. uint32_t perf_mon_2;
  174. };
  175. /**
  176. * struct cam_cdm_perf_mon_regs - perf mon counter's registers
  177. *
  178. * @count_cfg_0: register offset to configure perf measures
  179. * @always_count_val: register offset for always count value
  180. * @busy_count_val: register offset to get busy count
  181. * @stall_axi_count_val: register offset to get axi stall counts
  182. * @count_status: register offset to know if count status finished
  183. * for stall, busy and always.
  184. */
  185. struct cam_cdm_perf_regs {
  186. uint32_t count_cfg_0;
  187. uint32_t always_count_val;
  188. uint32_t busy_count_val;
  189. uint32_t stall_axi_count_val;
  190. uint32_t count_status;
  191. };
  192. /**
  193. * struct cam_cdm_icl_data_regs - CDM icl data registers
  194. *
  195. * @icl_last_data_0: register offset to log last known good command
  196. * @icl_last_data_1: register offset to log last known good command 1
  197. * @icl_last_data_2: register offset to log last known good command 2
  198. * @icl_inv_data: register offset to log CDM cmd that triggered
  199. * invalid command.
  200. */
  201. struct cam_cdm_icl_data_regs {
  202. uint32_t icl_last_data_0;
  203. uint32_t icl_last_data_1;
  204. uint32_t icl_last_data_2;
  205. uint32_t icl_inv_data;
  206. };
  207. /**
  208. * struct cam_cdm_icl_misc_regs - CDM icl misc registers
  209. *
  210. * @icl_inv_bl_addr: register offset to give address of bl_cmd that
  211. * gave invalid command
  212. * @icl_status: register offset for context that gave good BL
  213. * command and invalid command.
  214. */
  215. struct cam_cdm_icl_misc_regs {
  216. uint32_t icl_inv_bl_addr;
  217. uint32_t icl_status;
  218. };
  219. /**
  220. * struct cam_cdm_icl_regs - CDM icl registers
  221. *
  222. * @data_regs: structure with registers of all cdm good and invalid
  223. * BL command information.
  224. * @misc_regs: structure with registers for invalid command address
  225. * and context
  226. */
  227. struct cam_cdm_icl_regs {
  228. struct cam_cdm_icl_data_regs *data_regs;
  229. struct cam_cdm_icl_misc_regs *misc_regs;
  230. };
  231. /**
  232. * struct cam_cdm_comp_wait_status - BL_FIFO comp_event status register
  233. *
  234. * @comp_wait_status: register offset to give information on whether the
  235. * CDM is waiting for an event from another module
  236. */
  237. struct cam_cdm_comp_wait_status {
  238. uint32_t comp_wait_status;
  239. };
  240. /**
  241. * struct cam_cdm_common_reg_data - structure for register data
  242. *
  243. * @num_bl_fifo: number of FIFO are there in CDM
  244. * @num_bl_fifo_irq: number of FIFO irqs in CDM
  245. * @num_bl_pending_req_reg: number of pending_requests register in CDM
  246. * @num_scratch_reg: number of scratch registers in CDM
  247. */
  248. struct cam_cdm_common_reg_data {
  249. uint32_t num_bl_fifo;
  250. uint32_t num_bl_fifo_irq;
  251. uint32_t num_bl_pending_req_reg;
  252. uint32_t num_scratch_reg;
  253. };
  254. /**
  255. * struct cam_cdm_common_regs - common structure to get common registers
  256. * of CDM
  257. *
  258. * @cdm_hw_version: offset to read cdm_hw_version
  259. * @cam_version: offset to read the camera Titan architecture version
  260. * @rst_cmd: offset to reset the CDM
  261. * @cgc_cfg: offset to configure CDM CGC logic
  262. * @core_cfg: offset to configure CDM core with ARB_SEL, implicit
  263. * wait, etc.
  264. * @core_en: offset to pause/enable CDM
  265. * @fe_cfg: offset to configure CDM fetch engine
  266. * @irq_context_status offset to read back irq context status
  267. * @bl_fifo_rb: offset to set BL_FIFO read back
  268. * @bl_fifo_base_rb: offset to read back base address on offset set by
  269. * bl_fifo_rb
  270. * @bl_fifo_len_rb: offset to read back base len and tag on offset set by
  271. * bl_fifo_rb
  272. * @usr_data: offset to read user data from GEN_IRQ commands
  273. * @wait_status: offset to read status for last WAIT command
  274. * @last_ahb_addr: offset to read back last AHB address generated by CDM
  275. * @last_ahb_data: offset to read back last AHB data generated by CDM
  276. * @core_debug: offset to configure CDM debug bus and debug features
  277. * @last_ahb_err_addr: offset to read back last AHB Error address generated
  278. * by CDM
  279. * @last_ahb_err_data: offset to read back last AHB Error data generated
  280. * by CDM
  281. * @current_bl_base: offset to read back current command buffer BASE address
  282. * value out of BL_FIFO
  283. * @current_bl_len: offset to read back current command buffer len, TAG,
  284. * context ID ARB value out of BL_FIFO
  285. * @current_used_ahb_base: offset to read back current base address used by
  286. * CDM to access camera register
  287. * @debug_status: offset to read back current CDM status
  288. * @bus_misr_cfg0: offset to enable bus MISR and configure sampling mode
  289. * @bus_misr_cfg1: offset to select from one of the six MISR's for reading
  290. * signature value
  291. * @bus_misr_rd_val: offset to read MISR signature
  292. * @pending_req: registers to read pending request in FIFO
  293. * @comp_wait: registers to read comp_event CDM is waiting for
  294. * @perf_mon: registers to read perf_mon information
  295. * @scratch: registers to read scratch register value
  296. * @perf_reg: registers to read performance counters value
  297. * @icl_reg: registers to read information related to good
  298. * and invalid commands in FIFO
  299. * @spare: spare register
  300. * @priority_group_bit_offset offset of priority group bits
  301. *
  302. */
  303. struct cam_cdm_common_regs {
  304. uint32_t cdm_hw_version;
  305. const struct cam_version_reg *cam_version;
  306. uint32_t rst_cmd;
  307. uint32_t cgc_cfg;
  308. uint32_t core_cfg;
  309. uint32_t core_en;
  310. uint32_t fe_cfg;
  311. uint32_t irq_context_status;
  312. uint32_t bl_fifo_rb;
  313. uint32_t bl_fifo_base_rb;
  314. uint32_t bl_fifo_len_rb;
  315. uint32_t usr_data;
  316. uint32_t wait_status;
  317. uint32_t last_ahb_addr;
  318. uint32_t last_ahb_data;
  319. uint32_t core_debug;
  320. uint32_t last_ahb_err_addr;
  321. uint32_t last_ahb_err_data;
  322. uint32_t current_bl_base;
  323. uint32_t current_bl_len;
  324. uint32_t current_used_ahb_base;
  325. uint32_t debug_status;
  326. uint32_t bus_misr_cfg0;
  327. uint32_t bus_misr_cfg1;
  328. uint32_t bus_misr_rd_val;
  329. const struct cam_cdm_bl_pending_req_reg_params
  330. *pending_req[CAM_CDM_BL_FIFO_PENDING_REQ_REG_NUM];
  331. const struct cam_cdm_comp_wait_status
  332. *comp_wait[CAM_CDM_COMP_WAIT_STATUS_REG_NUM];
  333. const struct cam_cdm_perf_mon_regs
  334. *perf_mon[CAM_CDM_PERF_MON_REG_NUM];
  335. const struct cam_cdm_scratch_reg
  336. *scratch[CAM_CDM_SCRATCH_REG_NUM];
  337. const struct cam_cdm_perf_regs *perf_reg;
  338. const struct cam_cdm_icl_regs *icl_reg;
  339. uint32_t spare;
  340. uint32_t priority_group_bit_offset;
  341. };
  342. /**
  343. * struct cam_cdm_hw_reg_offset - BL_FIFO comp_event status register
  344. *
  345. * @cmn_reg: pointer to structure to get common registers of a CDM
  346. * @bl_fifo_reg: pointer to structure to get BL_FIFO registers of a CDM
  347. * @irq_reg: pointer to structure to get IRQ registers of a CDM
  348. * @reg_data: pointer to structure to reg_data related to CDM
  349. * registers
  350. */
  351. struct cam_cdm_hw_reg_offset {
  352. const struct cam_cdm_common_regs *cmn_reg;
  353. const struct cam_cdm_bl_fifo_regs *bl_fifo_reg[CAM_CDM_BL_FIFO_REG_NUM];
  354. const struct cam_cdm_irq_regs *irq_reg[CAM_CDM_BL_FIFO_IRQ_REG_NUM];
  355. const struct cam_cdm_common_reg_data *reg_data;
  356. };
  357. /* enum cam_cdm_hw_process_intf_cmd - interface commands.*/
  358. enum cam_cdm_hw_process_intf_cmd {
  359. CAM_CDM_HW_INTF_CMD_ACQUIRE,
  360. CAM_CDM_HW_INTF_CMD_RELEASE,
  361. CAM_CDM_HW_INTF_CMD_SUBMIT_BL,
  362. CAM_CDM_HW_INTF_CMD_RESET_HW,
  363. CAM_CDM_HW_INTF_CMD_FLUSH_HW,
  364. CAM_CDM_HW_INTF_CMD_HANDLE_ERROR,
  365. CAM_CDM_HW_INTF_CMD_HANG_DETECT,
  366. CAM_CDM_HW_INTF_DUMP_DBG_REGS,
  367. CAM_CDM_HW_INTF_CMD_INVALID,
  368. };
  369. /* enum cam_cdm_flags - Bit fields for CDM flags used */
  370. enum cam_cdm_flags {
  371. CAM_CDM_FLAG_SHARED_CDM,
  372. CAM_CDM_FLAG_PRIVATE_CDM,
  373. };
  374. /* enum cam_cdm_type - Enum for possible CAM CDM types */
  375. enum cam_cdm_type {
  376. CAM_VIRTUAL_CDM,
  377. CAM_HW_CDM,
  378. };
  379. /* enum cam_cdm_mem_base_index - Enum for possible CAM CDM types */
  380. enum cam_cdm_mem_base_index {
  381. CAM_HW_CDM_BASE_INDEX,
  382. CAM_HW_CDM_MAX_INDEX = CAM_SOC_MAX_BLOCK,
  383. };
  384. /* enum cam_cdm_bl_cb_type - Enum for possible CAM CDM cb request types */
  385. enum cam_cdm_bl_cb_type {
  386. CAM_HW_CDM_BL_CB_CLIENT = 1,
  387. CAM_HW_CDM_BL_CB_INTERNAL,
  388. };
  389. /* enum cam_cdm_arbitration - Enum type of arbitration */
  390. enum cam_cdm_arbitration {
  391. CAM_CDM_ARBITRATION_NONE,
  392. CAM_CDM_ARBITRATION_ROUND_ROBIN,
  393. CAM_CDM_ARBITRATION_PRIORITY_BASED,
  394. CAM_CDM_ARBITRATION_MAX,
  395. };
  396. enum cam_cdm_hw_version {
  397. CAM_CDM_VERSION = 0,
  398. CAM_CDM_VERSION_1_0 = 0x10000000,
  399. CAM_CDM_VERSION_1_1 = 0x10010000,
  400. CAM_CDM_VERSION_1_2 = 0x10020000,
  401. CAM_CDM_VERSION_2_0 = 0x20000000,
  402. CAM_CDM_VERSION_2_1 = 0x20010000,
  403. CAM_CDM_VERSION_MAX,
  404. };
  405. /* struct cam_cdm_client - struct for cdm clients data.*/
  406. struct cam_cdm_client {
  407. struct cam_cdm_acquire_data data;
  408. void __iomem *changebase_addr;
  409. uint32_t stream_on;
  410. uint32_t refcount;
  411. struct mutex lock;
  412. uint32_t handle;
  413. };
  414. /* struct cam_cdm_work_payload - struct for cdm work payload data.*/
  415. struct cam_cdm_work_payload {
  416. struct cam_hw_info *hw;
  417. uint32_t irq_status;
  418. uint32_t irq_data;
  419. int fifo_idx;
  420. ktime_t workq_scheduled_ts;
  421. struct work_struct work;
  422. };
  423. /* struct cam_cdm_bl_cb_request_entry - callback entry for work to process.*/
  424. struct cam_cdm_bl_cb_request_entry {
  425. uint8_t bl_tag;
  426. enum cam_cdm_bl_cb_type request_type;
  427. uint32_t client_hdl;
  428. void *userdata;
  429. uint32_t cookie;
  430. struct list_head entry;
  431. };
  432. /* struct cam_cdm_hw_intf_cmd_submit_bl - cdm interface submit command.*/
  433. struct cam_cdm_hw_intf_cmd_submit_bl {
  434. uint32_t handle;
  435. struct cam_cdm_bl_request *data;
  436. };
  437. /* struct cam_cdm_hw_mem - CDM hw memory struct */
  438. struct cam_cdm_hw_mem {
  439. int32_t handle;
  440. uint32_t vaddr;
  441. uintptr_t kmdvaddr;
  442. size_t size;
  443. };
  444. /* struct cam_cdm_bl_fifo - CDM hw memory struct */
  445. struct cam_cdm_bl_fifo {
  446. struct completion bl_complete;
  447. struct workqueue_struct *work_queue;
  448. struct list_head bl_request_list;
  449. struct mutex fifo_lock;
  450. uint8_t bl_tag;
  451. uint32_t bl_depth;
  452. uint8_t last_bl_tag_done;
  453. atomic_t work_record;
  454. };
  455. /**
  456. * struct cam_cdm - CDM hw device struct
  457. *
  458. * @index: index of CDM hardware
  459. * @name: cdm_name
  460. * @id: enum for possible CDM hardwares
  461. * @flags: enum to tell if CDM is private of shared
  462. * @reset_complete: completion event to make CDM wait for reset
  463. * @work_queue: workqueue to schedule work for virtual CDM
  464. * @bl_request_list: bl_request list for submitted commands in
  465. * virtual CDM
  466. * @version: CDM version with major, minor, incr and reserved
  467. * @hw_version: CDM version as read from the cdm_version register
  468. * @hw_family_version: version of hw family the CDM belongs to
  469. * @iommu_hdl: CDM iommu handle
  470. * @offsets: pointer to structure of CDM registers
  471. * @ops: CDM ops for generating cdm commands
  472. * @clients: CDM clients array currently active on CDM
  473. * @bl_fifo: structure with per fifo related attributes
  474. * @cdm_status: bitfield with bits assigned for different cdm status
  475. * @bl_tag: slot value at which the next bl cmd will be written
  476. * in case of virtual CDM
  477. * @gen_irq: memory region in which gen_irq command will be written
  478. * @cpas_handle: handle for cpas driver
  479. * @arbitration: type of arbitration to be used for the CDM
  480. */
  481. struct cam_cdm {
  482. uint32_t index;
  483. char name[128];
  484. enum cam_cdm_id id;
  485. enum cam_cdm_flags flags;
  486. struct completion reset_complete;
  487. struct workqueue_struct *work_queue;
  488. struct list_head bl_request_list;
  489. struct cam_hw_version version;
  490. uint32_t hw_version;
  491. uint32_t hw_family_version;
  492. struct cam_iommu_handle iommu_hdl;
  493. struct cam_cdm_hw_reg_offset *offsets;
  494. struct cam_cdm_utils_ops *ops;
  495. struct cam_cdm_client *clients[CAM_PER_CDM_MAX_REGISTERED_CLIENTS];
  496. struct cam_cdm_bl_fifo bl_fifo[CAM_CDM_BL_FIFO_MAX];
  497. unsigned long cdm_status;
  498. uint8_t bl_tag;
  499. struct cam_cdm_hw_mem gen_irq[CAM_CDM_BL_FIFO_MAX];
  500. uint32_t cpas_handle;
  501. enum cam_cdm_arbitration arbitration;
  502. };
  503. /* struct cam_cdm_private_dt_data - CDM hw custom dt data */
  504. struct cam_cdm_private_dt_data {
  505. bool dt_cdm_shared;
  506. bool config_fifo;
  507. bool is_single_ctx_cdm;
  508. uint8_t priority_group;
  509. uint32_t fifo_depth[CAM_CDM_BL_FIFO_MAX];
  510. uint32_t dt_num_supported_clients;
  511. uint32_t pid;
  512. uint32_t mid;
  513. const char *dt_cdm_client_name[CAM_PER_CDM_MAX_REGISTERED_CLIENTS];
  514. };
  515. /* struct cam_cdm_intf_devices - CDM mgr interface devices */
  516. struct cam_cdm_intf_devices {
  517. struct mutex lock;
  518. uint32_t refcount;
  519. struct cam_hw_intf *device;
  520. struct cam_cdm_private_dt_data *data;
  521. };
  522. /* struct cam_cdm_intf_mgr - CDM mgr interface device struct */
  523. struct cam_cdm_intf_mgr {
  524. bool probe_done;
  525. uint32_t cdm_count;
  526. uint32_t dt_supported_hw_cdm;
  527. int32_t refcount;
  528. struct cam_cdm_intf_devices nodes[CAM_CDM_INTF_MGR_MAX_SUPPORTED_CDM];
  529. };
  530. int cam_cdm_intf_register_hw_cdm(struct cam_hw_intf *hw,
  531. struct cam_cdm_private_dt_data *data, enum cam_cdm_type type,
  532. uint32_t *index);
  533. int cam_cdm_intf_deregister_hw_cdm(struct cam_hw_intf *hw,
  534. struct cam_cdm_private_dt_data *data, enum cam_cdm_type type,
  535. uint32_t index);
  536. #endif /* _CAM_CDM_H_ */