ccp-dev.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * AMD Cryptographic Coprocessor (CCP) driver
  3. *
  4. * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
  5. *
  6. * Author: Tom Lendacky <thomas.lendacky@amd.com>
  7. * Author: Gary R Hook <gary.hook@amd.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef __CCP_DEV_H__
  14. #define __CCP_DEV_H__
  15. #include <linux/device.h>
  16. #include <linux/pci.h>
  17. #include <linux/spinlock.h>
  18. #include <linux/mutex.h>
  19. #include <linux/list.h>
  20. #include <linux/wait.h>
  21. #include <linux/dmapool.h>
  22. #include <linux/hw_random.h>
  23. #include <linux/bitops.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/irqreturn.h>
  26. #include <linux/dmaengine.h>
  27. #define MAX_CCP_NAME_LEN 16
  28. #define MAX_DMAPOOL_NAME_LEN 32
  29. #define MAX_HW_QUEUES 5
  30. #define MAX_CMD_QLEN 100
  31. #define TRNG_RETRIES 10
  32. #define CACHE_NONE 0x00
  33. #define CACHE_WB_NO_ALLOC 0xb7
  34. /****** Register Mappings ******/
  35. #define Q_MASK_REG 0x000
  36. #define TRNG_OUT_REG 0x00c
  37. #define IRQ_MASK_REG 0x040
  38. #define IRQ_STATUS_REG 0x200
  39. #define DEL_CMD_Q_JOB 0x124
  40. #define DEL_Q_ACTIVE 0x00000200
  41. #define DEL_Q_ID_SHIFT 6
  42. #define CMD_REQ0 0x180
  43. #define CMD_REQ_INCR 0x04
  44. #define CMD_Q_STATUS_BASE 0x210
  45. #define CMD_Q_INT_STATUS_BASE 0x214
  46. #define CMD_Q_STATUS_INCR 0x20
  47. #define CMD_Q_CACHE_BASE 0x228
  48. #define CMD_Q_CACHE_INC 0x20
  49. #define CMD_Q_ERROR(__qs) ((__qs) & 0x0000003f)
  50. #define CMD_Q_DEPTH(__qs) (((__qs) >> 12) & 0x0000000f)
  51. /* ------------------------ CCP Version 5 Specifics ------------------------ */
  52. #define CMD5_QUEUE_MASK_OFFSET 0x00
  53. #define CMD5_QUEUE_PRIO_OFFSET 0x04
  54. #define CMD5_REQID_CONFIG_OFFSET 0x08
  55. #define CMD5_CMD_TIMEOUT_OFFSET 0x10
  56. #define LSB_PUBLIC_MASK_LO_OFFSET 0x18
  57. #define LSB_PUBLIC_MASK_HI_OFFSET 0x1C
  58. #define LSB_PRIVATE_MASK_LO_OFFSET 0x20
  59. #define LSB_PRIVATE_MASK_HI_OFFSET 0x24
  60. #define CMD5_Q_CONTROL_BASE 0x0000
  61. #define CMD5_Q_TAIL_LO_BASE 0x0004
  62. #define CMD5_Q_HEAD_LO_BASE 0x0008
  63. #define CMD5_Q_INT_ENABLE_BASE 0x000C
  64. #define CMD5_Q_INTERRUPT_STATUS_BASE 0x0010
  65. #define CMD5_Q_STATUS_BASE 0x0100
  66. #define CMD5_Q_INT_STATUS_BASE 0x0104
  67. #define CMD5_Q_DMA_STATUS_BASE 0x0108
  68. #define CMD5_Q_DMA_READ_STATUS_BASE 0x010C
  69. #define CMD5_Q_DMA_WRITE_STATUS_BASE 0x0110
  70. #define CMD5_Q_ABORT_BASE 0x0114
  71. #define CMD5_Q_AX_CACHE_BASE 0x0118
  72. #define CMD5_CONFIG_0_OFFSET 0x6000
  73. #define CMD5_TRNG_CTL_OFFSET 0x6008
  74. #define CMD5_AES_MASK_OFFSET 0x6010
  75. #define CMD5_CLK_GATE_CTL_OFFSET 0x603C
  76. /* Address offset between two virtual queue registers */
  77. #define CMD5_Q_STATUS_INCR 0x1000
  78. /* Bit masks */
  79. #define CMD5_Q_RUN 0x1
  80. #define CMD5_Q_HALT 0x2
  81. #define CMD5_Q_MEM_LOCATION 0x4
  82. #define CMD5_Q_SIZE 0x1F
  83. #define CMD5_Q_SHIFT 3
  84. #define COMMANDS_PER_QUEUE 16
  85. #define QUEUE_SIZE_VAL ((ffs(COMMANDS_PER_QUEUE) - 2) & \
  86. CMD5_Q_SIZE)
  87. #define Q_PTR_MASK (2 << (QUEUE_SIZE_VAL + 5) - 1)
  88. #define Q_DESC_SIZE sizeof(struct ccp5_desc)
  89. #define Q_SIZE(n) (COMMANDS_PER_QUEUE*(n))
  90. #define INT_COMPLETION 0x1
  91. #define INT_ERROR 0x2
  92. #define INT_QUEUE_STOPPED 0x4
  93. #define INT_EMPTY_QUEUE 0x8
  94. #define SUPPORTED_INTERRUPTS (INT_COMPLETION | INT_ERROR)
  95. #define LSB_REGION_WIDTH 5
  96. #define MAX_LSB_CNT 8
  97. #define LSB_SIZE 16
  98. #define LSB_ITEM_SIZE 32
  99. #define PLSB_MAP_SIZE (LSB_SIZE)
  100. #define SLSB_MAP_SIZE (MAX_LSB_CNT * LSB_SIZE)
  101. #define LSB_ENTRY_NUMBER(LSB_ADDR) (LSB_ADDR / LSB_ITEM_SIZE)
  102. /* ------------------------ CCP Version 3 Specifics ------------------------ */
  103. #define REQ0_WAIT_FOR_WRITE 0x00000004
  104. #define REQ0_INT_ON_COMPLETE 0x00000002
  105. #define REQ0_STOP_ON_COMPLETE 0x00000001
  106. #define REQ0_CMD_Q_SHIFT 9
  107. #define REQ0_JOBID_SHIFT 3
  108. /****** REQ1 Related Values ******/
  109. #define REQ1_PROTECT_SHIFT 27
  110. #define REQ1_ENGINE_SHIFT 23
  111. #define REQ1_KEY_KSB_SHIFT 2
  112. #define REQ1_EOM 0x00000002
  113. #define REQ1_INIT 0x00000001
  114. /* AES Related Values */
  115. #define REQ1_AES_TYPE_SHIFT 21
  116. #define REQ1_AES_MODE_SHIFT 18
  117. #define REQ1_AES_ACTION_SHIFT 17
  118. #define REQ1_AES_CFB_SIZE_SHIFT 10
  119. /* XTS-AES Related Values */
  120. #define REQ1_XTS_AES_SIZE_SHIFT 10
  121. /* SHA Related Values */
  122. #define REQ1_SHA_TYPE_SHIFT 21
  123. /* RSA Related Values */
  124. #define REQ1_RSA_MOD_SIZE_SHIFT 10
  125. /* Pass-Through Related Values */
  126. #define REQ1_PT_BW_SHIFT 12
  127. #define REQ1_PT_BS_SHIFT 10
  128. /* ECC Related Values */
  129. #define REQ1_ECC_AFFINE_CONVERT 0x00200000
  130. #define REQ1_ECC_FUNCTION_SHIFT 18
  131. /****** REQ4 Related Values ******/
  132. #define REQ4_KSB_SHIFT 18
  133. #define REQ4_MEMTYPE_SHIFT 16
  134. /****** REQ6 Related Values ******/
  135. #define REQ6_MEMTYPE_SHIFT 16
  136. /****** Key Storage Block ******/
  137. #define KSB_START 77
  138. #define KSB_END 127
  139. #define KSB_COUNT (KSB_END - KSB_START + 1)
  140. #define CCP_SB_BITS 256
  141. #define CCP_JOBID_MASK 0x0000003f
  142. /* ------------------------ General CCP Defines ------------------------ */
  143. #define CCP_DMAPOOL_MAX_SIZE 64
  144. #define CCP_DMAPOOL_ALIGN BIT(5)
  145. #define CCP_REVERSE_BUF_SIZE 64
  146. #define CCP_AES_KEY_SB_COUNT 1
  147. #define CCP_AES_CTX_SB_COUNT 1
  148. #define CCP_XTS_AES_KEY_SB_COUNT 1
  149. #define CCP5_XTS_AES_KEY_SB_COUNT 2
  150. #define CCP_XTS_AES_CTX_SB_COUNT 1
  151. #define CCP_SHA_SB_COUNT 1
  152. #define CCP_RSA_MAX_WIDTH 4096
  153. #define CCP_PASSTHRU_BLOCKSIZE 256
  154. #define CCP_PASSTHRU_MASKSIZE 32
  155. #define CCP_PASSTHRU_SB_COUNT 1
  156. #define CCP_ECC_MODULUS_BYTES 48 /* 384-bits */
  157. #define CCP_ECC_MAX_OPERANDS 6
  158. #define CCP_ECC_MAX_OUTPUTS 3
  159. #define CCP_ECC_SRC_BUF_SIZE 448
  160. #define CCP_ECC_DST_BUF_SIZE 192
  161. #define CCP_ECC_OPERAND_SIZE 64
  162. #define CCP_ECC_OUTPUT_SIZE 64
  163. #define CCP_ECC_RESULT_OFFSET 60
  164. #define CCP_ECC_RESULT_SUCCESS 0x0001
  165. #define CCP_SB_BYTES 32
  166. struct ccp_op;
  167. struct ccp_device;
  168. struct ccp_cmd;
  169. struct ccp_fns;
  170. struct ccp_dma_cmd {
  171. struct list_head entry;
  172. struct ccp_cmd ccp_cmd;
  173. };
  174. struct ccp_dma_desc {
  175. struct list_head entry;
  176. struct ccp_device *ccp;
  177. struct list_head pending;
  178. struct list_head active;
  179. enum dma_status status;
  180. struct dma_async_tx_descriptor tx_desc;
  181. size_t len;
  182. };
  183. struct ccp_dma_chan {
  184. struct ccp_device *ccp;
  185. spinlock_t lock;
  186. struct list_head created;
  187. struct list_head pending;
  188. struct list_head active;
  189. struct list_head complete;
  190. struct tasklet_struct cleanup_tasklet;
  191. enum dma_status status;
  192. struct dma_chan dma_chan;
  193. };
  194. struct ccp_cmd_queue {
  195. struct ccp_device *ccp;
  196. /* Queue identifier */
  197. u32 id;
  198. /* Queue dma pool */
  199. struct dma_pool *dma_pool;
  200. /* Queue base address (not neccessarily aligned)*/
  201. struct ccp5_desc *qbase;
  202. /* Aligned queue start address (per requirement) */
  203. struct mutex q_mutex ____cacheline_aligned;
  204. unsigned int qidx;
  205. /* Version 5 has different requirements for queue memory */
  206. unsigned int qsize;
  207. dma_addr_t qbase_dma;
  208. dma_addr_t qdma_tail;
  209. /* Per-queue reserved storage block(s) */
  210. u32 sb_key;
  211. u32 sb_ctx;
  212. /* Bitmap of LSBs that can be accessed by this queue */
  213. DECLARE_BITMAP(lsbmask, MAX_LSB_CNT);
  214. /* Private LSB that is assigned to this queue, or -1 if none.
  215. * Bitmap for my private LSB, unused otherwise
  216. */
  217. unsigned int lsb;
  218. DECLARE_BITMAP(lsbmap, PLSB_MAP_SIZE);
  219. /* Queue processing thread */
  220. struct task_struct *kthread;
  221. unsigned int active;
  222. unsigned int suspended;
  223. /* Number of free command slots available */
  224. unsigned int free_slots;
  225. /* Interrupt masks */
  226. u32 int_ok;
  227. u32 int_err;
  228. /* Register addresses for queue */
  229. void __iomem *reg_control;
  230. void __iomem *reg_tail_lo;
  231. void __iomem *reg_head_lo;
  232. void __iomem *reg_int_enable;
  233. void __iomem *reg_interrupt_status;
  234. void __iomem *reg_status;
  235. void __iomem *reg_int_status;
  236. void __iomem *reg_dma_status;
  237. void __iomem *reg_dma_read_status;
  238. void __iomem *reg_dma_write_status;
  239. u32 qcontrol; /* Cached control register */
  240. /* Status values from job */
  241. u32 int_status;
  242. u32 q_status;
  243. u32 q_int_status;
  244. u32 cmd_error;
  245. /* Interrupt wait queue */
  246. wait_queue_head_t int_queue;
  247. unsigned int int_rcvd;
  248. } ____cacheline_aligned;
  249. struct ccp_device {
  250. struct list_head entry;
  251. struct ccp_vdata *vdata;
  252. unsigned int ord;
  253. char name[MAX_CCP_NAME_LEN];
  254. char rngname[MAX_CCP_NAME_LEN];
  255. struct device *dev;
  256. /* Bus specific device information
  257. */
  258. void *dev_specific;
  259. int (*get_irq)(struct ccp_device *ccp);
  260. void (*free_irq)(struct ccp_device *ccp);
  261. unsigned int qim;
  262. unsigned int irq;
  263. bool use_tasklet;
  264. struct tasklet_struct irq_tasklet;
  265. /* I/O area used for device communication. The register mapping
  266. * starts at an offset into the mapped bar.
  267. * The CMD_REQx registers and the Delete_Cmd_Queue_Job register
  268. * need to be protected while a command queue thread is accessing
  269. * them.
  270. */
  271. struct mutex req_mutex ____cacheline_aligned;
  272. void __iomem *io_map;
  273. void __iomem *io_regs;
  274. /* Master lists that all cmds are queued on. Because there can be
  275. * more than one CCP command queue that can process a cmd a separate
  276. * backlog list is neeeded so that the backlog completion call
  277. * completes before the cmd is available for execution.
  278. */
  279. spinlock_t cmd_lock ____cacheline_aligned;
  280. unsigned int cmd_count;
  281. struct list_head cmd;
  282. struct list_head backlog;
  283. /* The command queues. These represent the queues available on the
  284. * CCP that are available for processing cmds
  285. */
  286. struct ccp_cmd_queue cmd_q[MAX_HW_QUEUES];
  287. unsigned int cmd_q_count;
  288. /* Support for the CCP True RNG
  289. */
  290. struct hwrng hwrng;
  291. unsigned int hwrng_retries;
  292. /* Support for the CCP DMA capabilities
  293. */
  294. struct dma_device dma_dev;
  295. struct ccp_dma_chan *ccp_dma_chan;
  296. struct kmem_cache *dma_cmd_cache;
  297. struct kmem_cache *dma_desc_cache;
  298. /* A counter used to generate job-ids for cmds submitted to the CCP
  299. */
  300. atomic_t current_id ____cacheline_aligned;
  301. /* The v3 CCP uses key storage blocks (SB) to maintain context for
  302. * certain operations. To prevent multiple cmds from using the same
  303. * SB range a command queue reserves an SB range for the duration of
  304. * the cmd. Each queue, will however, reserve 2 SB blocks for
  305. * operations that only require single SB entries (eg. AES context/iv
  306. * and key) in order to avoid allocation contention. This will reserve
  307. * at most 10 SB entries, leaving 40 SB entries available for dynamic
  308. * allocation.
  309. *
  310. * The v5 CCP Local Storage Block (LSB) is broken up into 8
  311. * memrory ranges, each of which can be enabled for access by one
  312. * or more queues. Device initialization takes this into account,
  313. * and attempts to assign one region for exclusive use by each
  314. * available queue; the rest are then aggregated as "public" use.
  315. * If there are fewer regions than queues, all regions are shared
  316. * amongst all queues.
  317. */
  318. struct mutex sb_mutex ____cacheline_aligned;
  319. DECLARE_BITMAP(sb, KSB_COUNT);
  320. wait_queue_head_t sb_queue;
  321. unsigned int sb_avail;
  322. unsigned int sb_count;
  323. u32 sb_start;
  324. /* Bitmap of shared LSBs, if any */
  325. DECLARE_BITMAP(lsbmap, SLSB_MAP_SIZE);
  326. /* Suspend support */
  327. unsigned int suspending;
  328. wait_queue_head_t suspend_queue;
  329. /* DMA caching attribute support */
  330. unsigned int axcache;
  331. };
  332. enum ccp_memtype {
  333. CCP_MEMTYPE_SYSTEM = 0,
  334. CCP_MEMTYPE_SB,
  335. CCP_MEMTYPE_LOCAL,
  336. CCP_MEMTYPE__LAST,
  337. };
  338. #define CCP_MEMTYPE_LSB CCP_MEMTYPE_KSB
  339. struct ccp_dma_info {
  340. dma_addr_t address;
  341. unsigned int offset;
  342. unsigned int length;
  343. enum dma_data_direction dir;
  344. };
  345. struct ccp_dm_workarea {
  346. struct device *dev;
  347. struct dma_pool *dma_pool;
  348. unsigned int length;
  349. u8 *address;
  350. struct ccp_dma_info dma;
  351. };
  352. struct ccp_sg_workarea {
  353. struct scatterlist *sg;
  354. int nents;
  355. struct scatterlist *dma_sg;
  356. struct device *dma_dev;
  357. unsigned int dma_count;
  358. enum dma_data_direction dma_dir;
  359. unsigned int sg_used;
  360. u64 bytes_left;
  361. };
  362. struct ccp_data {
  363. struct ccp_sg_workarea sg_wa;
  364. struct ccp_dm_workarea dm_wa;
  365. };
  366. struct ccp_mem {
  367. enum ccp_memtype type;
  368. union {
  369. struct ccp_dma_info dma;
  370. u32 sb;
  371. } u;
  372. };
  373. struct ccp_aes_op {
  374. enum ccp_aes_type type;
  375. enum ccp_aes_mode mode;
  376. enum ccp_aes_action action;
  377. unsigned int size;
  378. };
  379. struct ccp_xts_aes_op {
  380. enum ccp_aes_type type;
  381. enum ccp_aes_action action;
  382. enum ccp_xts_aes_unit_size unit_size;
  383. };
  384. struct ccp_sha_op {
  385. enum ccp_sha_type type;
  386. u64 msg_bits;
  387. };
  388. struct ccp_rsa_op {
  389. u32 mod_size;
  390. u32 input_len;
  391. };
  392. struct ccp_passthru_op {
  393. enum ccp_passthru_bitwise bit_mod;
  394. enum ccp_passthru_byteswap byte_swap;
  395. };
  396. struct ccp_ecc_op {
  397. enum ccp_ecc_function function;
  398. };
  399. struct ccp_op {
  400. struct ccp_cmd_queue *cmd_q;
  401. u32 jobid;
  402. u32 ioc;
  403. u32 soc;
  404. u32 sb_key;
  405. u32 sb_ctx;
  406. u32 init;
  407. u32 eom;
  408. struct ccp_mem src;
  409. struct ccp_mem dst;
  410. struct ccp_mem exp;
  411. union {
  412. struct ccp_aes_op aes;
  413. struct ccp_xts_aes_op xts;
  414. struct ccp_sha_op sha;
  415. struct ccp_rsa_op rsa;
  416. struct ccp_passthru_op passthru;
  417. struct ccp_ecc_op ecc;
  418. } u;
  419. struct ccp_mem key;
  420. };
  421. static inline u32 ccp_addr_lo(struct ccp_dma_info *info)
  422. {
  423. return lower_32_bits(info->address + info->offset);
  424. }
  425. static inline u32 ccp_addr_hi(struct ccp_dma_info *info)
  426. {
  427. return upper_32_bits(info->address + info->offset) & 0x0000ffff;
  428. }
  429. /**
  430. * descriptor for version 5 CPP commands
  431. * 8 32-bit words:
  432. * word 0: function; engine; control bits
  433. * word 1: length of source data
  434. * word 2: low 32 bits of source pointer
  435. * word 3: upper 16 bits of source pointer; source memory type
  436. * word 4: low 32 bits of destination pointer
  437. * word 5: upper 16 bits of destination pointer; destination memory type
  438. * word 6: low 32 bits of key pointer
  439. * word 7: upper 16 bits of key pointer; key memory type
  440. */
  441. struct dword0 {
  442. __le32 soc:1;
  443. __le32 ioc:1;
  444. __le32 rsvd1:1;
  445. __le32 init:1;
  446. __le32 eom:1; /* AES/SHA only */
  447. __le32 function:15;
  448. __le32 engine:4;
  449. __le32 prot:1;
  450. __le32 rsvd2:7;
  451. };
  452. struct dword3 {
  453. __le32 src_hi:16;
  454. __le32 src_mem:2;
  455. __le32 lsb_cxt_id:8;
  456. __le32 rsvd1:5;
  457. __le32 fixed:1;
  458. };
  459. union dword4 {
  460. __le32 dst_lo; /* NON-SHA */
  461. __le32 sha_len_lo; /* SHA */
  462. };
  463. union dword5 {
  464. struct {
  465. __le32 dst_hi:16;
  466. __le32 dst_mem:2;
  467. __le32 rsvd1:13;
  468. __le32 fixed:1;
  469. } fields;
  470. __le32 sha_len_hi;
  471. };
  472. struct dword7 {
  473. __le32 key_hi:16;
  474. __le32 key_mem:2;
  475. __le32 rsvd1:14;
  476. };
  477. struct ccp5_desc {
  478. struct dword0 dw0;
  479. __le32 length;
  480. __le32 src_lo;
  481. struct dword3 dw3;
  482. union dword4 dw4;
  483. union dword5 dw5;
  484. __le32 key_lo;
  485. struct dword7 dw7;
  486. };
  487. int ccp_pci_init(void);
  488. void ccp_pci_exit(void);
  489. int ccp_platform_init(void);
  490. void ccp_platform_exit(void);
  491. void ccp_add_device(struct ccp_device *ccp);
  492. void ccp_del_device(struct ccp_device *ccp);
  493. extern void ccp_log_error(struct ccp_device *, int);
  494. struct ccp_device *ccp_alloc_struct(struct device *dev);
  495. bool ccp_queues_suspended(struct ccp_device *ccp);
  496. int ccp_cmd_queue_thread(void *data);
  497. int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait);
  498. int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd);
  499. int ccp_register_rng(struct ccp_device *ccp);
  500. void ccp_unregister_rng(struct ccp_device *ccp);
  501. int ccp_dmaengine_register(struct ccp_device *ccp);
  502. void ccp_dmaengine_unregister(struct ccp_device *ccp);
  503. /* Structure for computation functions that are device-specific */
  504. struct ccp_actions {
  505. int (*aes)(struct ccp_op *);
  506. int (*xts_aes)(struct ccp_op *);
  507. int (*sha)(struct ccp_op *);
  508. int (*rsa)(struct ccp_op *);
  509. int (*passthru)(struct ccp_op *);
  510. int (*ecc)(struct ccp_op *);
  511. u32 (*sballoc)(struct ccp_cmd_queue *, unsigned int);
  512. void (*sbfree)(struct ccp_cmd_queue *, unsigned int,
  513. unsigned int);
  514. unsigned int (*get_free_slots)(struct ccp_cmd_queue *);
  515. int (*init)(struct ccp_device *);
  516. void (*destroy)(struct ccp_device *);
  517. irqreturn_t (*irqhandler)(int, void *);
  518. };
  519. /* Structure to hold CCP version-specific values */
  520. struct ccp_vdata {
  521. const unsigned int version;
  522. void (*setup)(struct ccp_device *);
  523. const struct ccp_actions *perform;
  524. const unsigned int bar;
  525. const unsigned int offset;
  526. };
  527. extern const struct ccp_vdata ccpv3;
  528. extern const struct ccp_vdata ccpv5a;
  529. extern const struct ccp_vdata ccpv5b;
  530. #endif