blob: 373ac4fa4a479f02e3ecf94f33bc546c19bfee1c [file] [log] [blame]
Gary R Hookea0375a2016-03-01 13:49:25 -06001/*
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>
Gary R Hookfba88552016-07-26 19:09:20 -05007 * Author: Gary R Hook <gary.hook@amd.com>
Gary R Hookea0375a2016-03-01 13:49:25 -06008 *
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
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/pci.h>
17#include <linux/kthread.h>
18#include <linux/interrupt.h>
19#include <linux/ccp.h>
20
21#include "ccp-dev.h"
22
Gary R Hook58a690b2016-07-26 19:09:50 -050023static u32 ccp_alloc_ksb(struct ccp_cmd_queue *cmd_q, unsigned int count)
24{
25 int start;
26 struct ccp_device *ccp = cmd_q->ccp;
27
28 for (;;) {
29 mutex_lock(&ccp->sb_mutex);
30
31 start = (u32)bitmap_find_next_zero_area(ccp->sb,
32 ccp->sb_count,
33 ccp->sb_start,
34 count, 0);
35 if (start <= ccp->sb_count) {
36 bitmap_set(ccp->sb, start, count);
37
38 mutex_unlock(&ccp->sb_mutex);
39 break;
40 }
41
42 ccp->sb_avail = 0;
43
44 mutex_unlock(&ccp->sb_mutex);
45
46 /* Wait for KSB entries to become available */
47 if (wait_event_interruptible(ccp->sb_queue, ccp->sb_avail))
48 return 0;
49 }
50
51 return KSB_START + start;
52}
53
54static void ccp_free_ksb(struct ccp_cmd_queue *cmd_q, unsigned int start,
55 unsigned int count)
56{
57 struct ccp_device *ccp = cmd_q->ccp;
58
59 if (!start)
60 return;
61
62 mutex_lock(&ccp->sb_mutex);
63
64 bitmap_clear(ccp->sb, start - KSB_START, count);
65
66 ccp->sb_avail = 1;
67
68 mutex_unlock(&ccp->sb_mutex);
69
70 wake_up_interruptible_all(&ccp->sb_queue);
71}
72
Gary R Hookea0375a2016-03-01 13:49:25 -060073static int ccp_do_cmd(struct ccp_op *op, u32 *cr, unsigned int cr_count)
74{
75 struct ccp_cmd_queue *cmd_q = op->cmd_q;
76 struct ccp_device *ccp = cmd_q->ccp;
77 void __iomem *cr_addr;
78 u32 cr0, cmd;
79 unsigned int i;
80 int ret = 0;
81
82 /* We could read a status register to see how many free slots
83 * are actually available, but reading that register resets it
84 * and you could lose some error information.
85 */
86 cmd_q->free_slots--;
87
88 cr0 = (cmd_q->id << REQ0_CMD_Q_SHIFT)
89 | (op->jobid << REQ0_JOBID_SHIFT)
90 | REQ0_WAIT_FOR_WRITE;
91
92 if (op->soc)
93 cr0 |= REQ0_STOP_ON_COMPLETE
94 | REQ0_INT_ON_COMPLETE;
95
96 if (op->ioc || !cmd_q->free_slots)
97 cr0 |= REQ0_INT_ON_COMPLETE;
98
99 /* Start at CMD_REQ1 */
100 cr_addr = ccp->io_regs + CMD_REQ0 + CMD_REQ_INCR;
101
102 mutex_lock(&ccp->req_mutex);
103
104 /* Write CMD_REQ1 through CMD_REQx first */
105 for (i = 0; i < cr_count; i++, cr_addr += CMD_REQ_INCR)
106 iowrite32(*(cr + i), cr_addr);
107
108 /* Tell the CCP to start */
109 wmb();
110 iowrite32(cr0, ccp->io_regs + CMD_REQ0);
111
112 mutex_unlock(&ccp->req_mutex);
113
114 if (cr0 & REQ0_INT_ON_COMPLETE) {
115 /* Wait for the job to complete */
116 ret = wait_event_interruptible(cmd_q->int_queue,
117 cmd_q->int_rcvd);
118 if (ret || cmd_q->cmd_error) {
119 /* On error delete all related jobs from the queue */
120 cmd = (cmd_q->id << DEL_Q_ID_SHIFT)
121 | op->jobid;
122
123 iowrite32(cmd, ccp->io_regs + DEL_CMD_Q_JOB);
124
125 if (!ret)
126 ret = -EIO;
127 } else if (op->soc) {
128 /* Delete just head job from the queue on SoC */
129 cmd = DEL_Q_ACTIVE
130 | (cmd_q->id << DEL_Q_ID_SHIFT)
131 | op->jobid;
132
133 iowrite32(cmd, ccp->io_regs + DEL_CMD_Q_JOB);
134 }
135
136 cmd_q->free_slots = CMD_Q_DEPTH(cmd_q->q_status);
137
138 cmd_q->int_rcvd = 0;
139 }
140
141 return ret;
142}
143
144static int ccp_perform_aes(struct ccp_op *op)
145{
146 u32 cr[6];
147
148 /* Fill out the register contents for REQ1 through REQ6 */
149 cr[0] = (CCP_ENGINE_AES << REQ1_ENGINE_SHIFT)
150 | (op->u.aes.type << REQ1_AES_TYPE_SHIFT)
151 | (op->u.aes.mode << REQ1_AES_MODE_SHIFT)
152 | (op->u.aes.action << REQ1_AES_ACTION_SHIFT)
Gary R Hook956ee212016-07-26 19:09:40 -0500153 | (op->sb_key << REQ1_KEY_KSB_SHIFT);
Gary R Hookea0375a2016-03-01 13:49:25 -0600154 cr[1] = op->src.u.dma.length - 1;
155 cr[2] = ccp_addr_lo(&op->src.u.dma);
Gary R Hook956ee212016-07-26 19:09:40 -0500156 cr[3] = (op->sb_ctx << REQ4_KSB_SHIFT)
Gary R Hookea0375a2016-03-01 13:49:25 -0600157 | (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
158 | ccp_addr_hi(&op->src.u.dma);
159 cr[4] = ccp_addr_lo(&op->dst.u.dma);
160 cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
161 | ccp_addr_hi(&op->dst.u.dma);
162
163 if (op->u.aes.mode == CCP_AES_MODE_CFB)
164 cr[0] |= ((0x7f) << REQ1_AES_CFB_SIZE_SHIFT);
165
166 if (op->eom)
167 cr[0] |= REQ1_EOM;
168
169 if (op->init)
170 cr[0] |= REQ1_INIT;
171
172 return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
173}
174
175static int ccp_perform_xts_aes(struct ccp_op *op)
176{
177 u32 cr[6];
178
179 /* Fill out the register contents for REQ1 through REQ6 */
180 cr[0] = (CCP_ENGINE_XTS_AES_128 << REQ1_ENGINE_SHIFT)
181 | (op->u.xts.action << REQ1_AES_ACTION_SHIFT)
182 | (op->u.xts.unit_size << REQ1_XTS_AES_SIZE_SHIFT)
Gary R Hook956ee212016-07-26 19:09:40 -0500183 | (op->sb_key << REQ1_KEY_KSB_SHIFT);
Gary R Hookea0375a2016-03-01 13:49:25 -0600184 cr[1] = op->src.u.dma.length - 1;
185 cr[2] = ccp_addr_lo(&op->src.u.dma);
Gary R Hook956ee212016-07-26 19:09:40 -0500186 cr[3] = (op->sb_ctx << REQ4_KSB_SHIFT)
Gary R Hookea0375a2016-03-01 13:49:25 -0600187 | (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
188 | ccp_addr_hi(&op->src.u.dma);
189 cr[4] = ccp_addr_lo(&op->dst.u.dma);
190 cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
191 | ccp_addr_hi(&op->dst.u.dma);
192
193 if (op->eom)
194 cr[0] |= REQ1_EOM;
195
196 if (op->init)
197 cr[0] |= REQ1_INIT;
198
199 return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
200}
201
202static int ccp_perform_sha(struct ccp_op *op)
203{
204 u32 cr[6];
205
206 /* Fill out the register contents for REQ1 through REQ6 */
207 cr[0] = (CCP_ENGINE_SHA << REQ1_ENGINE_SHIFT)
208 | (op->u.sha.type << REQ1_SHA_TYPE_SHIFT)
209 | REQ1_INIT;
210 cr[1] = op->src.u.dma.length - 1;
211 cr[2] = ccp_addr_lo(&op->src.u.dma);
Gary R Hook956ee212016-07-26 19:09:40 -0500212 cr[3] = (op->sb_ctx << REQ4_KSB_SHIFT)
Gary R Hookea0375a2016-03-01 13:49:25 -0600213 | (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
214 | ccp_addr_hi(&op->src.u.dma);
215
216 if (op->eom) {
217 cr[0] |= REQ1_EOM;
218 cr[4] = lower_32_bits(op->u.sha.msg_bits);
219 cr[5] = upper_32_bits(op->u.sha.msg_bits);
220 } else {
221 cr[4] = 0;
222 cr[5] = 0;
223 }
224
225 return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
226}
227
228static int ccp_perform_rsa(struct ccp_op *op)
229{
230 u32 cr[6];
231
232 /* Fill out the register contents for REQ1 through REQ6 */
233 cr[0] = (CCP_ENGINE_RSA << REQ1_ENGINE_SHIFT)
234 | (op->u.rsa.mod_size << REQ1_RSA_MOD_SIZE_SHIFT)
Gary R Hook956ee212016-07-26 19:09:40 -0500235 | (op->sb_key << REQ1_KEY_KSB_SHIFT)
Gary R Hookea0375a2016-03-01 13:49:25 -0600236 | REQ1_EOM;
237 cr[1] = op->u.rsa.input_len - 1;
238 cr[2] = ccp_addr_lo(&op->src.u.dma);
Gary R Hook956ee212016-07-26 19:09:40 -0500239 cr[3] = (op->sb_ctx << REQ4_KSB_SHIFT)
Gary R Hookea0375a2016-03-01 13:49:25 -0600240 | (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
241 | ccp_addr_hi(&op->src.u.dma);
242 cr[4] = ccp_addr_lo(&op->dst.u.dma);
243 cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
244 | ccp_addr_hi(&op->dst.u.dma);
245
246 return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
247}
248
249static int ccp_perform_passthru(struct ccp_op *op)
250{
251 u32 cr[6];
252
253 /* Fill out the register contents for REQ1 through REQ6 */
254 cr[0] = (CCP_ENGINE_PASSTHRU << REQ1_ENGINE_SHIFT)
255 | (op->u.passthru.bit_mod << REQ1_PT_BW_SHIFT)
256 | (op->u.passthru.byte_swap << REQ1_PT_BS_SHIFT);
257
258 if (op->src.type == CCP_MEMTYPE_SYSTEM)
259 cr[1] = op->src.u.dma.length - 1;
260 else
261 cr[1] = op->dst.u.dma.length - 1;
262
263 if (op->src.type == CCP_MEMTYPE_SYSTEM) {
264 cr[2] = ccp_addr_lo(&op->src.u.dma);
265 cr[3] = (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
266 | ccp_addr_hi(&op->src.u.dma);
267
268 if (op->u.passthru.bit_mod != CCP_PASSTHRU_BITWISE_NOOP)
Gary R Hook956ee212016-07-26 19:09:40 -0500269 cr[3] |= (op->sb_key << REQ4_KSB_SHIFT);
Gary R Hookea0375a2016-03-01 13:49:25 -0600270 } else {
Gary R Hook956ee212016-07-26 19:09:40 -0500271 cr[2] = op->src.u.sb * CCP_SB_BYTES;
272 cr[3] = (CCP_MEMTYPE_SB << REQ4_MEMTYPE_SHIFT);
Gary R Hookea0375a2016-03-01 13:49:25 -0600273 }
274
275 if (op->dst.type == CCP_MEMTYPE_SYSTEM) {
276 cr[4] = ccp_addr_lo(&op->dst.u.dma);
277 cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
278 | ccp_addr_hi(&op->dst.u.dma);
279 } else {
Gary R Hook956ee212016-07-26 19:09:40 -0500280 cr[4] = op->dst.u.sb * CCP_SB_BYTES;
281 cr[5] = (CCP_MEMTYPE_SB << REQ6_MEMTYPE_SHIFT);
Gary R Hookea0375a2016-03-01 13:49:25 -0600282 }
283
284 if (op->eom)
285 cr[0] |= REQ1_EOM;
286
287 return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
288}
289
290static int ccp_perform_ecc(struct ccp_op *op)
291{
292 u32 cr[6];
293
294 /* Fill out the register contents for REQ1 through REQ6 */
295 cr[0] = REQ1_ECC_AFFINE_CONVERT
296 | (CCP_ENGINE_ECC << REQ1_ENGINE_SHIFT)
297 | (op->u.ecc.function << REQ1_ECC_FUNCTION_SHIFT)
298 | REQ1_EOM;
299 cr[1] = op->src.u.dma.length - 1;
300 cr[2] = ccp_addr_lo(&op->src.u.dma);
301 cr[3] = (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
302 | ccp_addr_hi(&op->src.u.dma);
303 cr[4] = ccp_addr_lo(&op->dst.u.dma);
304 cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
305 | ccp_addr_hi(&op->dst.u.dma);
306
307 return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
308}
309
Gary R Hookea0375a2016-03-01 13:49:25 -0600310static int ccp_init(struct ccp_device *ccp)
311{
312 struct device *dev = ccp->dev;
313 struct ccp_cmd_queue *cmd_q;
314 struct dma_pool *dma_pool;
315 char dma_pool_name[MAX_DMAPOOL_NAME_LEN];
316 unsigned int qmr, qim, i;
317 int ret;
318
319 /* Find available queues */
320 qim = 0;
321 qmr = ioread32(ccp->io_regs + Q_MASK_REG);
322 for (i = 0; i < MAX_HW_QUEUES; i++) {
323 if (!(qmr & (1 << i)))
324 continue;
325
326 /* Allocate a dma pool for this queue */
327 snprintf(dma_pool_name, sizeof(dma_pool_name), "%s_q%d",
328 ccp->name, i);
329 dma_pool = dma_pool_create(dma_pool_name, dev,
330 CCP_DMAPOOL_MAX_SIZE,
331 CCP_DMAPOOL_ALIGN, 0);
332 if (!dma_pool) {
333 dev_err(dev, "unable to allocate dma pool\n");
334 ret = -ENOMEM;
335 goto e_pool;
336 }
337
338 cmd_q = &ccp->cmd_q[ccp->cmd_q_count];
339 ccp->cmd_q_count++;
340
341 cmd_q->ccp = ccp;
342 cmd_q->id = i;
343 cmd_q->dma_pool = dma_pool;
344
345 /* Reserve 2 KSB regions for the queue */
Gary R Hook956ee212016-07-26 19:09:40 -0500346 cmd_q->sb_key = KSB_START + ccp->sb_start++;
347 cmd_q->sb_ctx = KSB_START + ccp->sb_start++;
348 ccp->sb_count -= 2;
Gary R Hookea0375a2016-03-01 13:49:25 -0600349
350 /* Preset some register values and masks that are queue
351 * number dependent
352 */
353 cmd_q->reg_status = ccp->io_regs + CMD_Q_STATUS_BASE +
354 (CMD_Q_STATUS_INCR * i);
355 cmd_q->reg_int_status = ccp->io_regs + CMD_Q_INT_STATUS_BASE +
356 (CMD_Q_STATUS_INCR * i);
357 cmd_q->int_ok = 1 << (i * 2);
358 cmd_q->int_err = 1 << ((i * 2) + 1);
359
360 cmd_q->free_slots = CMD_Q_DEPTH(ioread32(cmd_q->reg_status));
361
362 init_waitqueue_head(&cmd_q->int_queue);
363
364 /* Build queue interrupt mask (two interrupts per queue) */
365 qim |= cmd_q->int_ok | cmd_q->int_err;
366
367#ifdef CONFIG_ARM64
368 /* For arm64 set the recommended queue cache settings */
369 iowrite32(ccp->axcache, ccp->io_regs + CMD_Q_CACHE_BASE +
370 (CMD_Q_CACHE_INC * i));
371#endif
372
373 dev_dbg(dev, "queue #%u available\n", i);
374 }
375 if (ccp->cmd_q_count == 0) {
376 dev_notice(dev, "no command queues available\n");
377 ret = -EIO;
378 goto e_pool;
379 }
380 dev_notice(dev, "%u command queues available\n", ccp->cmd_q_count);
381
382 /* Disable and clear interrupts until ready */
383 iowrite32(0x00, ccp->io_regs + IRQ_MASK_REG);
384 for (i = 0; i < ccp->cmd_q_count; i++) {
385 cmd_q = &ccp->cmd_q[i];
386
387 ioread32(cmd_q->reg_int_status);
388 ioread32(cmd_q->reg_status);
389 }
390 iowrite32(qim, ccp->io_regs + IRQ_STATUS_REG);
391
392 /* Request an irq */
393 ret = ccp->get_irq(ccp);
394 if (ret) {
395 dev_err(dev, "unable to allocate an IRQ\n");
396 goto e_pool;
397 }
398
399 /* Initialize the queues used to wait for KSB space and suspend */
Gary R Hook956ee212016-07-26 19:09:40 -0500400 init_waitqueue_head(&ccp->sb_queue);
Gary R Hookea0375a2016-03-01 13:49:25 -0600401 init_waitqueue_head(&ccp->suspend_queue);
402
403 /* Create a kthread for each queue */
404 for (i = 0; i < ccp->cmd_q_count; i++) {
405 struct task_struct *kthread;
406
407 cmd_q = &ccp->cmd_q[i];
408
409 kthread = kthread_create(ccp_cmd_queue_thread, cmd_q,
410 "%s-q%u", ccp->name, cmd_q->id);
411 if (IS_ERR(kthread)) {
412 dev_err(dev, "error creating queue thread (%ld)\n",
413 PTR_ERR(kthread));
414 ret = PTR_ERR(kthread);
415 goto e_kthread;
416 }
417
418 cmd_q->kthread = kthread;
419 wake_up_process(kthread);
420 }
421
422 /* Register the RNG */
423 ccp->hwrng.name = ccp->rngname;
424 ccp->hwrng.read = ccp_trng_read;
425 ret = hwrng_register(&ccp->hwrng);
426 if (ret) {
427 dev_err(dev, "error registering hwrng (%d)\n", ret);
428 goto e_kthread;
429 }
430
Gary R Hook58ea8ab2016-04-18 09:21:44 -0500431 /* Register the DMA engine support */
432 ret = ccp_dmaengine_register(ccp);
433 if (ret)
434 goto e_hwrng;
435
Gary R Hookea0375a2016-03-01 13:49:25 -0600436 ccp_add_device(ccp);
437
438 /* Enable interrupts */
439 iowrite32(qim, ccp->io_regs + IRQ_MASK_REG);
440
441 return 0;
442
Gary R Hook58ea8ab2016-04-18 09:21:44 -0500443e_hwrng:
444 hwrng_unregister(&ccp->hwrng);
445
Gary R Hookea0375a2016-03-01 13:49:25 -0600446e_kthread:
447 for (i = 0; i < ccp->cmd_q_count; i++)
448 if (ccp->cmd_q[i].kthread)
449 kthread_stop(ccp->cmd_q[i].kthread);
450
451 ccp->free_irq(ccp);
452
453e_pool:
454 for (i = 0; i < ccp->cmd_q_count; i++)
455 dma_pool_destroy(ccp->cmd_q[i].dma_pool);
456
457 return ret;
458}
459
460static void ccp_destroy(struct ccp_device *ccp)
461{
462 struct ccp_cmd_queue *cmd_q;
463 struct ccp_cmd *cmd;
464 unsigned int qim, i;
465
466 /* Remove this device from the list of available units first */
467 ccp_del_device(ccp);
468
Gary R Hookea0375a2016-03-01 13:49:25 -0600469 /* Build queue interrupt mask (two interrupt masks per queue) */
470 qim = 0;
471 for (i = 0; i < ccp->cmd_q_count; i++) {
472 cmd_q = &ccp->cmd_q[i];
473 qim |= cmd_q->int_ok | cmd_q->int_err;
474 }
475
476 /* Disable and clear interrupts */
477 iowrite32(0x00, ccp->io_regs + IRQ_MASK_REG);
478 for (i = 0; i < ccp->cmd_q_count; i++) {
479 cmd_q = &ccp->cmd_q[i];
480
481 ioread32(cmd_q->reg_int_status);
482 ioread32(cmd_q->reg_status);
483 }
484 iowrite32(qim, ccp->io_regs + IRQ_STATUS_REG);
485
Gary R Hook8256e682016-07-26 19:10:02 -0500486 /* Unregister the DMA engine */
487 ccp_dmaengine_unregister(ccp);
488
489 /* Unregister the RNG */
490 hwrng_unregister(&ccp->hwrng);
491
492 /* Stop the queue kthreads */
493 for (i = 0; i < ccp->cmd_q_count; i++)
494 if (ccp->cmd_q[i].kthread)
495 kthread_stop(ccp->cmd_q[i].kthread);
496
Gary R Hookea0375a2016-03-01 13:49:25 -0600497 ccp->free_irq(ccp);
498
499 for (i = 0; i < ccp->cmd_q_count; i++)
500 dma_pool_destroy(ccp->cmd_q[i].dma_pool);
501
502 /* Flush the cmd and backlog queue */
503 while (!list_empty(&ccp->cmd)) {
504 /* Invoke the callback directly with an error code */
505 cmd = list_first_entry(&ccp->cmd, struct ccp_cmd, entry);
506 list_del(&cmd->entry);
507 cmd->callback(cmd->data, -ENODEV);
508 }
509 while (!list_empty(&ccp->backlog)) {
510 /* Invoke the callback directly with an error code */
511 cmd = list_first_entry(&ccp->backlog, struct ccp_cmd, entry);
512 list_del(&cmd->entry);
513 cmd->callback(cmd->data, -ENODEV);
514 }
515}
516
517static irqreturn_t ccp_irq_handler(int irq, void *data)
518{
519 struct device *dev = data;
520 struct ccp_device *ccp = dev_get_drvdata(dev);
521 struct ccp_cmd_queue *cmd_q;
522 u32 q_int, status;
523 unsigned int i;
524
525 status = ioread32(ccp->io_regs + IRQ_STATUS_REG);
526
527 for (i = 0; i < ccp->cmd_q_count; i++) {
528 cmd_q = &ccp->cmd_q[i];
529
530 q_int = status & (cmd_q->int_ok | cmd_q->int_err);
531 if (q_int) {
532 cmd_q->int_status = status;
533 cmd_q->q_status = ioread32(cmd_q->reg_status);
534 cmd_q->q_int_status = ioread32(cmd_q->reg_int_status);
535
536 /* On error, only save the first error value */
537 if ((q_int & cmd_q->int_err) && !cmd_q->cmd_error)
538 cmd_q->cmd_error = CMD_Q_ERROR(cmd_q->q_status);
539
540 cmd_q->int_rcvd = 1;
541
542 /* Acknowledge the interrupt and wake the kthread */
543 iowrite32(q_int, ccp->io_regs + IRQ_STATUS_REG);
544 wake_up_interruptible(&cmd_q->int_queue);
545 }
546 }
547
548 return IRQ_HANDLED;
549}
550
Julia Lawallbc197b2a2016-05-01 13:52:55 +0200551static const struct ccp_actions ccp3_actions = {
Gary R Hooka43eb982016-07-26 19:09:31 -0500552 .aes = ccp_perform_aes,
553 .xts_aes = ccp_perform_xts_aes,
554 .sha = ccp_perform_sha,
555 .rsa = ccp_perform_rsa,
556 .passthru = ccp_perform_passthru,
557 .ecc = ccp_perform_ecc,
Gary R Hook58a690b2016-07-26 19:09:50 -0500558 .sballoc = ccp_alloc_ksb,
559 .sbfree = ccp_free_ksb,
Gary R Hookea0375a2016-03-01 13:49:25 -0600560 .init = ccp_init,
561 .destroy = ccp_destroy,
562 .irqhandler = ccp_irq_handler,
563};
564
565struct ccp_vdata ccpv3 = {
566 .version = CCP_VERSION(3, 0),
567 .perform = &ccp3_actions,
Gary R Hookfba88552016-07-26 19:09:20 -0500568 .bar = 2,
569 .offset = 0x20000,
Gary R Hookea0375a2016-03-01 13:49:25 -0600570};