cam_cdm.h 18 KB

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