ccp-dev.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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 ALL_INTERRUPTS (INT_COMPLETION| \
  94. INT_ERROR| \
  95. INT_QUEUE_STOPPED)
  96. #define LSB_REGION_WIDTH 5
  97. #define MAX_LSB_CNT 8
  98. #define LSB_SIZE 16
  99. #define LSB_ITEM_SIZE 32
  100. #define PLSB_MAP_SIZE (LSB_SIZE)
  101. #define SLSB_MAP_SIZE (MAX_LSB_CNT * LSB_SIZE)
  102. #define LSB_ENTRY_NUMBER(LSB_ADDR) (LSB_ADDR / LSB_ITEM_SIZE)
  103. /* ------------------------ CCP Version 3 Specifics ------------------------ */
  104. #define REQ0_WAIT_FOR_WRITE 0x00000004
  105. #define REQ0_INT_ON_COMPLETE 0x00000002
  106. #define REQ0_STOP_ON_COMPLETE 0x00000001
  107. #define REQ0_CMD_Q_SHIFT 9
  108. #define REQ0_JOBID_SHIFT 3
  109. /****** REQ1 Related Values ******/
  110. #define REQ1_PROTECT_SHIFT 27
  111. #define REQ1_ENGINE_SHIFT 23
  112. #define REQ1_KEY_KSB_SHIFT 2
  113. #define REQ1_EOM 0x00000002
  114. #define REQ1_INIT 0x00000001
  115. /* AES Related Values */
  116. #define REQ1_AES_TYPE_SHIFT 21
  117. #define REQ1_AES_MODE_SHIFT 18
  118. #define REQ1_AES_ACTION_SHIFT 17
  119. #define REQ1_AES_CFB_SIZE_SHIFT 10
  120. /* XTS-AES Related Values */
  121. #define REQ1_XTS_AES_SIZE_SHIFT 10
  122. /* SHA Related Values */
  123. #define REQ1_SHA_TYPE_SHIFT 21
  124. /* RSA Related Values */
  125. #define REQ1_RSA_MOD_SIZE_SHIFT 10
  126. /* Pass-Through Related Values */
  127. #define REQ1_PT_BW_SHIFT 12
  128. #define REQ1_PT_BS_SHIFT 10
  129. /* ECC Related Values */
  130. #define REQ1_ECC_AFFINE_CONVERT 0x00200000
  131. #define REQ1_ECC_FUNCTION_SHIFT 18
  132. /****** REQ4 Related Values ******/
  133. #define REQ4_KSB_SHIFT 18
  134. #define REQ4_MEMTYPE_SHIFT 16
  135. /****** REQ6 Related Values ******/
  136. #define REQ6_MEMTYPE_SHIFT 16
  137. /****** Key Storage Block ******/
  138. #define KSB_START 77
  139. #define KSB_END 127
  140. #define KSB_COUNT (KSB_END - KSB_START + 1)
  141. #define CCP_SB_BITS 256
  142. #define CCP_JOBID_MASK 0x0000003f
  143. /* ------------------------ General CCP Defines ------------------------ */
  144. #define CCP_DMAPOOL_MAX_SIZE 64
  145. #define CCP_DMAPOOL_ALIGN BIT(5)
  146. #define CCP_REVERSE_BUF_SIZE 64
  147. #define CCP_AES_KEY_SB_COUNT 1
  148. #define CCP_AES_CTX_SB_COUNT 1
  149. #define CCP_XTS_AES_KEY_SB_COUNT 1
  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 pending;
  187. struct list_head active;
  188. struct list_head complete;
  189. struct tasklet_struct cleanup_tasklet;
  190. enum dma_status status;
  191. struct dma_chan dma_chan;
  192. };
  193. struct ccp_cmd_queue {
  194. struct ccp_device *ccp;
  195. /* Queue identifier */
  196. u32 id;
  197. /* Queue dma pool */
  198. struct dma_pool *dma_pool;
  199. /* Queue base address (not neccessarily aligned)*/
  200. struct ccp5_desc *qbase;
  201. /* Aligned queue start address (per requirement) */
  202. struct mutex q_mutex ____cacheline_aligned;
  203. unsigned int qidx;
  204. /* Version 5 has different requirements for queue memory */
  205. unsigned int qsize;
  206. dma_addr_t qbase_dma;
  207. dma_addr_t qdma_tail;
  208. /* Per-queue reserved storage block(s) */
  209. u32 sb_key;
  210. u32 sb_ctx;
  211. /* Bitmap of LSBs that can be accessed by this queue */
  212. DECLARE_BITMAP(lsbmask, MAX_LSB_CNT);
  213. /* Private LSB that is assigned to this queue, or -1 if none.
  214. * Bitmap for my private LSB, unused otherwise
  215. */
  216. int lsb;
  217. DECLARE_BITMAP(lsbmap, PLSB_MAP_SIZE);
  218. /* Queue processing thread */
  219. struct task_struct *kthread;
  220. unsigned int active;
  221. unsigned int suspended;
  222. /* Number of free command slots available */
  223. unsigned int free_slots;
  224. /* Interrupt masks */
  225. u32 int_ok;
  226. u32 int_err;
  227. /* Register addresses for queue */
  228. void __iomem *reg_control;
  229. void __iomem *reg_tail_lo;
  230. void __iomem *reg_head_lo;
  231. void __iomem *reg_int_enable;
  232. void __iomem *reg_interrupt_status;
  233. void __iomem *reg_status;
  234. void __iomem *reg_int_status;
  235. void __iomem *reg_dma_status;
  236. void __iomem *reg_dma_read_status;
  237. void __iomem *reg_dma_write_status;
  238. u32 qcontrol; /* Cached control register */
  239. /* Status values from job */
  240. u32 int_status;
  241. u32 q_status;
  242. u32 q_int_status;
  243. u32 cmd_error;
  244. /* Interrupt wait queue */
  245. wait_queue_head_t int_queue;
  246. unsigned int int_rcvd;
  247. } ____cacheline_aligned;
  248. struct ccp_device {
  249. struct list_head entry;
  250. struct ccp_vdata *vdata;
  251. unsigned int ord;
  252. char name[MAX_CCP_NAME_LEN];
  253. char rngname[MAX_CCP_NAME_LEN];
  254. struct device *dev;
  255. /* Bus specific device information
  256. */
  257. void *dev_specific;
  258. int (*get_irq)(struct ccp_device *ccp);
  259. void (*free_irq)(struct ccp_device *ccp);
  260. unsigned int irq;
  261. /* I/O area used for device communication. The register mapping
  262. * starts at an offset into the mapped bar.
  263. * The CMD_REQx registers and the Delete_Cmd_Queue_Job register
  264. * need to be protected while a command queue thread is accessing
  265. * them.
  266. */
  267. struct mutex req_mutex ____cacheline_aligned;
  268. void __iomem *io_map;
  269. void __iomem *io_regs;
  270. /* Master lists that all cmds are queued on. Because there can be
  271. * more than one CCP command queue that can process a cmd a separate
  272. * backlog list is neeeded so that the backlog completion call
  273. * completes before the cmd is available for execution.
  274. */
  275. spinlock_t cmd_lock ____cacheline_aligned;
  276. unsigned int cmd_count;
  277. struct list_head cmd;
  278. struct list_head backlog;
  279. /* The command queues. These represent the queues available on the
  280. * CCP that are available for processing cmds
  281. */
  282. struct ccp_cmd_queue cmd_q[MAX_HW_QUEUES];
  283. unsigned int cmd_q_count;
  284. /* Support for the CCP True RNG
  285. */
  286. struct hwrng hwrng;
  287. unsigned int hwrng_retries;
  288. /* Support for the CCP DMA capabilities
  289. */
  290. struct dma_device dma_dev;
  291. struct ccp_dma_chan *ccp_dma_chan;
  292. struct kmem_cache *dma_cmd_cache;
  293. struct kmem_cache *dma_desc_cache;
  294. /* A counter used to generate job-ids for cmds submitted to the CCP
  295. */
  296. atomic_t current_id ____cacheline_aligned;
  297. /* The v3 CCP uses key storage blocks (SB) to maintain context for
  298. * certain operations. To prevent multiple cmds from using the same
  299. * SB range a command queue reserves an SB range for the duration of
  300. * the cmd. Each queue, will however, reserve 2 SB blocks for
  301. * operations that only require single SB entries (eg. AES context/iv
  302. * and key) in order to avoid allocation contention. This will reserve
  303. * at most 10 SB entries, leaving 40 SB entries available for dynamic
  304. * allocation.
  305. *
  306. * The v5 CCP Local Storage Block (LSB) is broken up into 8
  307. * memrory ranges, each of which can be enabled for access by one
  308. * or more queues. Device initialization takes this into account,
  309. * and attempts to assign one region for exclusive use by each
  310. * available queue; the rest are then aggregated as "public" use.
  311. * If there are fewer regions than queues, all regions are shared
  312. * amongst all queues.
  313. */
  314. struct mutex sb_mutex ____cacheline_aligned;
  315. DECLARE_BITMAP(sb, KSB_COUNT);
  316. wait_queue_head_t sb_queue;
  317. unsigned int sb_avail;
  318. unsigned int sb_count;
  319. u32 sb_start;
  320. /* Bitmap of shared LSBs, if any */
  321. DECLARE_BITMAP(lsbmap, SLSB_MAP_SIZE);
  322. /* Suspend support */
  323. unsigned int suspending;
  324. wait_queue_head_t suspend_queue;
  325. /* DMA caching attribute support */
  326. unsigned int axcache;
  327. };
  328. enum ccp_memtype {
  329. CCP_MEMTYPE_SYSTEM = 0,
  330. CCP_MEMTYPE_SB,
  331. CCP_MEMTYPE_LOCAL,
  332. CCP_MEMTYPE__LAST,
  333. };
  334. #define CCP_MEMTYPE_LSB CCP_MEMTYPE_KSB
  335. struct ccp_dma_info {
  336. dma_addr_t address;
  337. unsigned int offset;
  338. unsigned int length;
  339. enum dma_data_direction dir;
  340. };
  341. struct ccp_dm_workarea {
  342. struct device *dev;
  343. struct dma_pool *dma_pool;
  344. unsigned int length;
  345. u8 *address;
  346. struct ccp_dma_info dma;
  347. };
  348. struct ccp_sg_workarea {
  349. struct scatterlist *sg;
  350. int nents;
  351. struct scatterlist *dma_sg;
  352. struct device *dma_dev;
  353. unsigned int dma_count;
  354. enum dma_data_direction dma_dir;
  355. unsigned int sg_used;
  356. u64 bytes_left;
  357. };
  358. struct ccp_data {
  359. struct ccp_sg_workarea sg_wa;
  360. struct ccp_dm_workarea dm_wa;
  361. };
  362. struct ccp_mem {
  363. enum ccp_memtype type;
  364. union {
  365. struct ccp_dma_info dma;
  366. u32 sb;
  367. } u;
  368. };
  369. struct ccp_aes_op {
  370. enum ccp_aes_type type;
  371. enum ccp_aes_mode mode;
  372. enum ccp_aes_action action;
  373. };
  374. struct ccp_xts_aes_op {
  375. enum ccp_aes_action action;
  376. enum ccp_xts_aes_unit_size unit_size;
  377. };
  378. struct ccp_sha_op {
  379. enum ccp_sha_type type;
  380. u64 msg_bits;
  381. };
  382. struct ccp_rsa_op {
  383. u32 mod_size;
  384. u32 input_len;
  385. };
  386. struct ccp_passthru_op {
  387. enum ccp_passthru_bitwise bit_mod;
  388. enum ccp_passthru_byteswap byte_swap;
  389. };
  390. struct ccp_ecc_op {
  391. enum ccp_ecc_function function;
  392. };
  393. struct ccp_op {
  394. struct ccp_cmd_queue *cmd_q;
  395. u32 jobid;
  396. u32 ioc;
  397. u32 soc;
  398. u32 sb_key;
  399. u32 sb_ctx;
  400. u32 init;
  401. u32 eom;
  402. struct ccp_mem src;
  403. struct ccp_mem dst;
  404. struct ccp_mem exp;
  405. union {
  406. struct ccp_aes_op aes;
  407. struct ccp_xts_aes_op xts;
  408. struct ccp_sha_op sha;
  409. struct ccp_rsa_op rsa;
  410. struct ccp_passthru_op passthru;
  411. struct ccp_ecc_op ecc;
  412. } u;
  413. };
  414. static inline u32 ccp_addr_lo(struct ccp_dma_info *info)
  415. {
  416. return lower_32_bits(info->address + info->offset);
  417. }
  418. static inline u32 ccp_addr_hi(struct ccp_dma_info *info)
  419. {
  420. return upper_32_bits(info->address + info->offset) & 0x0000ffff;
  421. }
  422. /**
  423. * descriptor for version 5 CPP commands
  424. * 8 32-bit words:
  425. * word 0: function; engine; control bits
  426. * word 1: length of source data
  427. * word 2: low 32 bits of source pointer
  428. * word 3: upper 16 bits of source pointer; source memory type
  429. * word 4: low 32 bits of destination pointer
  430. * word 5: upper 16 bits of destination pointer; destination memory type
  431. * word 6: low 32 bits of key pointer
  432. * word 7: upper 16 bits of key pointer; key memory type
  433. */
  434. struct dword0 {
  435. unsigned int soc:1;
  436. unsigned int ioc:1;
  437. unsigned int rsvd1:1;
  438. unsigned int init:1;
  439. unsigned int eom:1; /* AES/SHA only */
  440. unsigned int function:15;
  441. unsigned int engine:4;
  442. unsigned int prot:1;
  443. unsigned int rsvd2:7;
  444. };
  445. struct dword3 {
  446. unsigned int src_hi:16;
  447. unsigned int src_mem:2;
  448. unsigned int lsb_cxt_id:8;
  449. unsigned int rsvd1:5;
  450. unsigned int fixed:1;
  451. };
  452. union dword4 {
  453. __le32 dst_lo; /* NON-SHA */
  454. __le32 sha_len_lo; /* SHA */
  455. };
  456. union dword5 {
  457. struct {
  458. unsigned int dst_hi:16;
  459. unsigned int dst_mem:2;
  460. unsigned int rsvd1:13;
  461. unsigned int fixed:1;
  462. } fields;
  463. __le32 sha_len_hi;
  464. };
  465. struct dword7 {
  466. unsigned int key_hi:16;
  467. unsigned int key_mem:2;
  468. unsigned int rsvd1:14;
  469. };
  470. struct ccp5_desc {
  471. struct dword0 dw0;
  472. __le32 length;
  473. __le32 src_lo;
  474. struct dword3 dw3;
  475. union dword4 dw4;
  476. union dword5 dw5;
  477. __le32 key_lo;
  478. struct dword7 dw7;
  479. };
  480. int ccp_pci_init(void);
  481. void ccp_pci_exit(void);
  482. int ccp_platform_init(void);
  483. void ccp_platform_exit(void);
  484. void ccp_add_device(struct ccp_device *ccp);
  485. void ccp_del_device(struct ccp_device *ccp);
  486. extern void ccp_log_error(struct ccp_device *, int);
  487. struct ccp_device *ccp_alloc_struct(struct device *dev);
  488. bool ccp_queues_suspended(struct ccp_device *ccp);
  489. int ccp_cmd_queue_thread(void *data);
  490. int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait);
  491. int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd);
  492. int ccp_register_rng(struct ccp_device *ccp);
  493. void ccp_unregister_rng(struct ccp_device *ccp);
  494. int ccp_dmaengine_register(struct ccp_device *ccp);
  495. void ccp_dmaengine_unregister(struct ccp_device *ccp);
  496. /* Structure for computation functions that are device-specific */
  497. struct ccp_actions {
  498. int (*aes)(struct ccp_op *);
  499. int (*xts_aes)(struct ccp_op *);
  500. int (*sha)(struct ccp_op *);
  501. int (*rsa)(struct ccp_op *);
  502. int (*passthru)(struct ccp_op *);
  503. int (*ecc)(struct ccp_op *);
  504. u32 (*sballoc)(struct ccp_cmd_queue *, unsigned int);
  505. void (*sbfree)(struct ccp_cmd_queue *, unsigned int,
  506. unsigned int);
  507. unsigned int (*get_free_slots)(struct ccp_cmd_queue *);
  508. int (*init)(struct ccp_device *);
  509. void (*destroy)(struct ccp_device *);
  510. irqreturn_t (*irqhandler)(int, void *);
  511. };
  512. /* Structure to hold CCP version-specific values */
  513. struct ccp_vdata {
  514. const unsigned int version;
  515. void (*setup)(struct ccp_device *);
  516. const struct ccp_actions *perform;
  517. const unsigned int bar;
  518. const unsigned int offset;
  519. };
  520. extern const struct ccp_vdata ccpv3;
  521. extern const struct ccp_vdata ccpv5a;
  522. extern const struct ccp_vdata ccpv5b;
  523. #endif