4 * Support for ATMEL SHA1/SHA256 HW acceleration.
6 * Copyright (c) 2012 Eukréa Electromatique - ATMEL
7 * Author: Nicolas Royer <nicolas@eukrea.com>
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 published
11 * by the Free Software Foundation.
13 * Some ideas are from omap-sham.c drivers.
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/slab.h>
20 #include <linux/err.h>
21 #include <linux/clk.h>
23 #include <linux/hw_random.h>
24 #include <linux/platform_device.h>
26 #include <linux/device.h>
27 #include <linux/init.h>
28 #include <linux/errno.h>
29 #include <linux/interrupt.h>
30 #include <linux/irq.h>
31 #include <linux/scatterlist.h>
32 #include <linux/dma-mapping.h>
33 #include <linux/of_device.h>
34 #include <linux/delay.h>
35 #include <linux/crypto.h>
36 #include <linux/cryptohash.h>
37 #include <crypto/scatterwalk.h>
38 #include <crypto/algapi.h>
39 #include <crypto/sha.h>
40 #include <crypto/hash.h>
41 #include <crypto/internal/hash.h>
42 #include <linux/platform_data/crypto-atmel.h>
43 #include "atmel-sha-regs.h"
46 #define SHA_FLAGS_BUSY BIT(0)
47 #define SHA_FLAGS_FINAL BIT(1)
48 #define SHA_FLAGS_DMA_ACTIVE BIT(2)
49 #define SHA_FLAGS_OUTPUT_READY BIT(3)
50 #define SHA_FLAGS_INIT BIT(4)
51 #define SHA_FLAGS_CPU BIT(5)
52 #define SHA_FLAGS_DMA_READY BIT(6)
54 #define SHA_FLAGS_FINUP BIT(16)
55 #define SHA_FLAGS_SG BIT(17)
56 #define SHA_FLAGS_SHA1 BIT(18)
57 #define SHA_FLAGS_SHA224 BIT(19)
58 #define SHA_FLAGS_SHA256 BIT(20)
59 #define SHA_FLAGS_SHA384 BIT(21)
60 #define SHA_FLAGS_SHA512 BIT(22)
61 #define SHA_FLAGS_ERROR BIT(23)
62 #define SHA_FLAGS_PAD BIT(24)
64 #define SHA_OP_UPDATE 1
65 #define SHA_OP_FINAL 2
67 #define SHA_BUFFER_LEN PAGE_SIZE
69 #define ATMEL_SHA_DMA_THRESHOLD 56
71 struct atmel_sha_caps {
80 struct atmel_sha_reqctx {
81 struct atmel_sha_dev *dd;
85 u8 digest[SHA512_DIGEST_SIZE] __aligned(sizeof(u32));
92 struct scatterlist *sg;
93 unsigned int offset; /* offset in current sg */
94 unsigned int total; /* total request */
98 u8 buffer[0] __aligned(sizeof(u32));
101 struct atmel_sha_ctx {
102 struct atmel_sha_dev *dd;
107 struct crypto_shash *fallback;
111 #define ATMEL_SHA_QUEUE_LENGTH 50
113 struct atmel_sha_dma {
114 struct dma_chan *chan;
115 struct dma_slave_config dma_conf;
118 struct atmel_sha_dev {
119 struct list_head list;
120 unsigned long phys_base;
124 void __iomem *io_base;
128 struct tasklet_struct done_task;
131 struct crypto_queue queue;
132 struct ahash_request *req;
134 struct atmel_sha_dma dma_lch_in;
136 struct atmel_sha_caps caps;
141 struct atmel_sha_drv {
142 struct list_head dev_list;
146 static struct atmel_sha_drv atmel_sha = {
147 .dev_list = LIST_HEAD_INIT(atmel_sha.dev_list),
148 .lock = __SPIN_LOCK_UNLOCKED(atmel_sha.lock),
151 static inline u32 atmel_sha_read(struct atmel_sha_dev *dd, u32 offset)
153 return readl_relaxed(dd->io_base + offset);
156 static inline void atmel_sha_write(struct atmel_sha_dev *dd,
157 u32 offset, u32 value)
159 writel_relaxed(value, dd->io_base + offset);
162 static size_t atmel_sha_append_sg(struct atmel_sha_reqctx *ctx)
166 while ((ctx->bufcnt < ctx->buflen) && ctx->total) {
167 count = min(ctx->sg->length - ctx->offset, ctx->total);
168 count = min(count, ctx->buflen - ctx->bufcnt);
173 scatterwalk_map_and_copy(ctx->buffer + ctx->bufcnt, ctx->sg,
174 ctx->offset, count, 0);
176 ctx->bufcnt += count;
177 ctx->offset += count;
180 if (ctx->offset == ctx->sg->length) {
181 ctx->sg = sg_next(ctx->sg);
193 * The purpose of this padding is to ensure that the padded message is a
194 * multiple of 512 bits (SHA1/SHA224/SHA256) or 1024 bits (SHA384/SHA512).
195 * The bit "1" is appended at the end of the message followed by
196 * "padlen-1" zero bits. Then a 64 bits block (SHA1/SHA224/SHA256) or
197 * 128 bits block (SHA384/SHA512) equals to the message length in bits
200 * For SHA1/SHA224/SHA256, padlen is calculated as followed:
201 * - if message length < 56 bytes then padlen = 56 - message length
202 * - else padlen = 64 + 56 - message length
204 * For SHA384/SHA512, padlen is calculated as followed:
205 * - if message length < 112 bytes then padlen = 112 - message length
206 * - else padlen = 128 + 112 - message length
208 static void atmel_sha_fill_padding(struct atmel_sha_reqctx *ctx, int length)
210 unsigned int index, padlen;
214 size[0] = ctx->digcnt[0];
215 size[1] = ctx->digcnt[1];
217 size[0] += ctx->bufcnt;
218 if (size[0] < ctx->bufcnt)
222 if (size[0] < length)
225 bits[1] = cpu_to_be64(size[0] << 3);
226 bits[0] = cpu_to_be64(size[1] << 3 | size[0] >> 61);
228 if (ctx->flags & (SHA_FLAGS_SHA384 | SHA_FLAGS_SHA512)) {
229 index = ctx->bufcnt & 0x7f;
230 padlen = (index < 112) ? (112 - index) : ((128+112) - index);
231 *(ctx->buffer + ctx->bufcnt) = 0x80;
232 memset(ctx->buffer + ctx->bufcnt + 1, 0, padlen-1);
233 memcpy(ctx->buffer + ctx->bufcnt + padlen, bits, 16);
234 ctx->bufcnt += padlen + 16;
235 ctx->flags |= SHA_FLAGS_PAD;
237 index = ctx->bufcnt & 0x3f;
238 padlen = (index < 56) ? (56 - index) : ((64+56) - index);
239 *(ctx->buffer + ctx->bufcnt) = 0x80;
240 memset(ctx->buffer + ctx->bufcnt + 1, 0, padlen-1);
241 memcpy(ctx->buffer + ctx->bufcnt + padlen, &bits[1], 8);
242 ctx->bufcnt += padlen + 8;
243 ctx->flags |= SHA_FLAGS_PAD;
247 static int atmel_sha_init(struct ahash_request *req)
249 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
250 struct atmel_sha_ctx *tctx = crypto_ahash_ctx(tfm);
251 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
252 struct atmel_sha_dev *dd = NULL;
253 struct atmel_sha_dev *tmp;
255 spin_lock_bh(&atmel_sha.lock);
257 list_for_each_entry(tmp, &atmel_sha.dev_list, list) {
266 spin_unlock_bh(&atmel_sha.lock);
272 dev_dbg(dd->dev, "init: digest size: %d\n",
273 crypto_ahash_digestsize(tfm));
275 switch (crypto_ahash_digestsize(tfm)) {
276 case SHA1_DIGEST_SIZE:
277 ctx->flags |= SHA_FLAGS_SHA1;
278 ctx->block_size = SHA1_BLOCK_SIZE;
280 case SHA224_DIGEST_SIZE:
281 ctx->flags |= SHA_FLAGS_SHA224;
282 ctx->block_size = SHA224_BLOCK_SIZE;
284 case SHA256_DIGEST_SIZE:
285 ctx->flags |= SHA_FLAGS_SHA256;
286 ctx->block_size = SHA256_BLOCK_SIZE;
288 case SHA384_DIGEST_SIZE:
289 ctx->flags |= SHA_FLAGS_SHA384;
290 ctx->block_size = SHA384_BLOCK_SIZE;
292 case SHA512_DIGEST_SIZE:
293 ctx->flags |= SHA_FLAGS_SHA512;
294 ctx->block_size = SHA512_BLOCK_SIZE;
304 ctx->buflen = SHA_BUFFER_LEN;
309 static void atmel_sha_write_ctrl(struct atmel_sha_dev *dd, int dma)
311 struct atmel_sha_reqctx *ctx = ahash_request_ctx(dd->req);
312 u32 valcr = 0, valmr = SHA_MR_MODE_AUTO;
315 if (!dd->caps.has_dma)
316 atmel_sha_write(dd, SHA_IER, SHA_INT_TXBUFE);
317 valmr = SHA_MR_MODE_PDC;
318 if (dd->caps.has_dualbuff)
319 valmr |= SHA_MR_DUALBUFF;
321 atmel_sha_write(dd, SHA_IER, SHA_INT_DATARDY);
324 if (ctx->flags & SHA_FLAGS_SHA1)
325 valmr |= SHA_MR_ALGO_SHA1;
326 else if (ctx->flags & SHA_FLAGS_SHA224)
327 valmr |= SHA_MR_ALGO_SHA224;
328 else if (ctx->flags & SHA_FLAGS_SHA256)
329 valmr |= SHA_MR_ALGO_SHA256;
330 else if (ctx->flags & SHA_FLAGS_SHA384)
331 valmr |= SHA_MR_ALGO_SHA384;
332 else if (ctx->flags & SHA_FLAGS_SHA512)
333 valmr |= SHA_MR_ALGO_SHA512;
335 /* Setting CR_FIRST only for the first iteration */
336 if (!(ctx->digcnt[0] || ctx->digcnt[1]))
337 valcr = SHA_CR_FIRST;
339 atmel_sha_write(dd, SHA_CR, valcr);
340 atmel_sha_write(dd, SHA_MR, valmr);
343 static int atmel_sha_xmit_cpu(struct atmel_sha_dev *dd, const u8 *buf,
344 size_t length, int final)
346 struct atmel_sha_reqctx *ctx = ahash_request_ctx(dd->req);
348 const u32 *buffer = (const u32 *)buf;
350 dev_dbg(dd->dev, "xmit_cpu: digcnt: 0x%llx 0x%llx, length: %d, final: %d\n",
351 ctx->digcnt[1], ctx->digcnt[0], length, final);
353 atmel_sha_write_ctrl(dd, 0);
355 /* should be non-zero before next lines to disable clocks later */
356 ctx->digcnt[0] += length;
357 if (ctx->digcnt[0] < length)
361 dd->flags |= SHA_FLAGS_FINAL; /* catch last interrupt */
363 len32 = DIV_ROUND_UP(length, sizeof(u32));
365 dd->flags |= SHA_FLAGS_CPU;
367 for (count = 0; count < len32; count++)
368 atmel_sha_write(dd, SHA_REG_DIN(count), buffer[count]);
373 static int atmel_sha_xmit_pdc(struct atmel_sha_dev *dd, dma_addr_t dma_addr1,
374 size_t length1, dma_addr_t dma_addr2, size_t length2, int final)
376 struct atmel_sha_reqctx *ctx = ahash_request_ctx(dd->req);
379 dev_dbg(dd->dev, "xmit_pdc: digcnt: 0x%llx 0x%llx, length: %d, final: %d\n",
380 ctx->digcnt[1], ctx->digcnt[0], length1, final);
382 len32 = DIV_ROUND_UP(length1, sizeof(u32));
383 atmel_sha_write(dd, SHA_PTCR, SHA_PTCR_TXTDIS);
384 atmel_sha_write(dd, SHA_TPR, dma_addr1);
385 atmel_sha_write(dd, SHA_TCR, len32);
387 len32 = DIV_ROUND_UP(length2, sizeof(u32));
388 atmel_sha_write(dd, SHA_TNPR, dma_addr2);
389 atmel_sha_write(dd, SHA_TNCR, len32);
391 atmel_sha_write_ctrl(dd, 1);
393 /* should be non-zero before next lines to disable clocks later */
394 ctx->digcnt[0] += length1;
395 if (ctx->digcnt[0] < length1)
399 dd->flags |= SHA_FLAGS_FINAL; /* catch last interrupt */
401 dd->flags |= SHA_FLAGS_DMA_ACTIVE;
403 /* Start DMA transfer */
404 atmel_sha_write(dd, SHA_PTCR, SHA_PTCR_TXTEN);
409 static void atmel_sha_dma_callback(void *data)
411 struct atmel_sha_dev *dd = data;
413 /* dma_lch_in - completed - wait DATRDY */
414 atmel_sha_write(dd, SHA_IER, SHA_INT_DATARDY);
417 static int atmel_sha_xmit_dma(struct atmel_sha_dev *dd, dma_addr_t dma_addr1,
418 size_t length1, dma_addr_t dma_addr2, size_t length2, int final)
420 struct atmel_sha_reqctx *ctx = ahash_request_ctx(dd->req);
421 struct dma_async_tx_descriptor *in_desc;
422 struct scatterlist sg[2];
424 dev_dbg(dd->dev, "xmit_dma: digcnt: 0x%llx 0x%llx, length: %d, final: %d\n",
425 ctx->digcnt[1], ctx->digcnt[0], length1, final);
427 if (ctx->flags & (SHA_FLAGS_SHA1 | SHA_FLAGS_SHA224 |
429 dd->dma_lch_in.dma_conf.src_maxburst = 16;
430 dd->dma_lch_in.dma_conf.dst_maxburst = 16;
432 dd->dma_lch_in.dma_conf.src_maxburst = 32;
433 dd->dma_lch_in.dma_conf.dst_maxburst = 32;
436 dmaengine_slave_config(dd->dma_lch_in.chan, &dd->dma_lch_in.dma_conf);
439 sg_init_table(sg, 2);
440 sg_dma_address(&sg[0]) = dma_addr1;
441 sg_dma_len(&sg[0]) = length1;
442 sg_dma_address(&sg[1]) = dma_addr2;
443 sg_dma_len(&sg[1]) = length2;
444 in_desc = dmaengine_prep_slave_sg(dd->dma_lch_in.chan, sg, 2,
445 DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
447 sg_init_table(sg, 1);
448 sg_dma_address(&sg[0]) = dma_addr1;
449 sg_dma_len(&sg[0]) = length1;
450 in_desc = dmaengine_prep_slave_sg(dd->dma_lch_in.chan, sg, 1,
451 DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
456 in_desc->callback = atmel_sha_dma_callback;
457 in_desc->callback_param = dd;
459 atmel_sha_write_ctrl(dd, 1);
461 /* should be non-zero before next lines to disable clocks later */
462 ctx->digcnt[0] += length1;
463 if (ctx->digcnt[0] < length1)
467 dd->flags |= SHA_FLAGS_FINAL; /* catch last interrupt */
469 dd->flags |= SHA_FLAGS_DMA_ACTIVE;
471 /* Start DMA transfer */
472 dmaengine_submit(in_desc);
473 dma_async_issue_pending(dd->dma_lch_in.chan);
478 static int atmel_sha_xmit_start(struct atmel_sha_dev *dd, dma_addr_t dma_addr1,
479 size_t length1, dma_addr_t dma_addr2, size_t length2, int final)
481 if (dd->caps.has_dma)
482 return atmel_sha_xmit_dma(dd, dma_addr1, length1,
483 dma_addr2, length2, final);
485 return atmel_sha_xmit_pdc(dd, dma_addr1, length1,
486 dma_addr2, length2, final);
489 static int atmel_sha_update_cpu(struct atmel_sha_dev *dd)
491 struct atmel_sha_reqctx *ctx = ahash_request_ctx(dd->req);
494 atmel_sha_append_sg(ctx);
495 atmel_sha_fill_padding(ctx, 0);
496 bufcnt = ctx->bufcnt;
499 return atmel_sha_xmit_cpu(dd, ctx->buffer, bufcnt, 1);
502 static int atmel_sha_xmit_dma_map(struct atmel_sha_dev *dd,
503 struct atmel_sha_reqctx *ctx,
504 size_t length, int final)
506 ctx->dma_addr = dma_map_single(dd->dev, ctx->buffer,
507 ctx->buflen + ctx->block_size, DMA_TO_DEVICE);
508 if (dma_mapping_error(dd->dev, ctx->dma_addr)) {
509 dev_err(dd->dev, "dma %u bytes error\n", ctx->buflen +
514 ctx->flags &= ~SHA_FLAGS_SG;
516 /* next call does not fail... so no unmap in the case of error */
517 return atmel_sha_xmit_start(dd, ctx->dma_addr, length, 0, 0, final);
520 static int atmel_sha_update_dma_slow(struct atmel_sha_dev *dd)
522 struct atmel_sha_reqctx *ctx = ahash_request_ctx(dd->req);
526 atmel_sha_append_sg(ctx);
528 final = (ctx->flags & SHA_FLAGS_FINUP) && !ctx->total;
530 dev_dbg(dd->dev, "slow: bufcnt: %u, digcnt: 0x%llx 0x%llx, final: %d\n",
531 ctx->bufcnt, ctx->digcnt[1], ctx->digcnt[0], final);
534 atmel_sha_fill_padding(ctx, 0);
536 if (final || (ctx->bufcnt == ctx->buflen && ctx->total)) {
539 return atmel_sha_xmit_dma_map(dd, ctx, count, final);
545 static int atmel_sha_update_dma_start(struct atmel_sha_dev *dd)
547 struct atmel_sha_reqctx *ctx = ahash_request_ctx(dd->req);
548 unsigned int length, final, tail;
549 struct scatterlist *sg;
555 if (ctx->bufcnt || ctx->offset)
556 return atmel_sha_update_dma_slow(dd);
558 dev_dbg(dd->dev, "fast: digcnt: 0x%llx 0x%llx, bufcnt: %u, total: %u\n",
559 ctx->digcnt[1], ctx->digcnt[0], ctx->bufcnt, ctx->total);
563 if (!IS_ALIGNED(sg->offset, sizeof(u32)))
564 return atmel_sha_update_dma_slow(dd);
566 if (!sg_is_last(sg) && !IS_ALIGNED(sg->length, ctx->block_size))
567 /* size is not ctx->block_size aligned */
568 return atmel_sha_update_dma_slow(dd);
570 length = min(ctx->total, sg->length);
572 if (sg_is_last(sg)) {
573 if (!(ctx->flags & SHA_FLAGS_FINUP)) {
574 /* not last sg must be ctx->block_size aligned */
575 tail = length & (ctx->block_size - 1);
580 ctx->total -= length;
581 ctx->offset = length; /* offset where to start slow */
583 final = (ctx->flags & SHA_FLAGS_FINUP) && !ctx->total;
587 tail = length & (ctx->block_size - 1);
590 ctx->offset = length; /* offset where to start slow */
593 atmel_sha_append_sg(ctx);
595 atmel_sha_fill_padding(ctx, length);
597 ctx->dma_addr = dma_map_single(dd->dev, ctx->buffer,
598 ctx->buflen + ctx->block_size, DMA_TO_DEVICE);
599 if (dma_mapping_error(dd->dev, ctx->dma_addr)) {
600 dev_err(dd->dev, "dma %u bytes error\n",
601 ctx->buflen + ctx->block_size);
606 ctx->flags &= ~SHA_FLAGS_SG;
609 return atmel_sha_xmit_start(dd, ctx->dma_addr, count, 0,
613 if (!dma_map_sg(dd->dev, ctx->sg, 1,
615 dev_err(dd->dev, "dma_map_sg error\n");
619 ctx->flags |= SHA_FLAGS_SG;
623 return atmel_sha_xmit_start(dd, sg_dma_address(ctx->sg),
624 length, ctx->dma_addr, count, final);
628 if (!dma_map_sg(dd->dev, ctx->sg, 1, DMA_TO_DEVICE)) {
629 dev_err(dd->dev, "dma_map_sg error\n");
633 ctx->flags |= SHA_FLAGS_SG;
635 /* next call does not fail... so no unmap in the case of error */
636 return atmel_sha_xmit_start(dd, sg_dma_address(ctx->sg), length, 0,
640 static int atmel_sha_update_dma_stop(struct atmel_sha_dev *dd)
642 struct atmel_sha_reqctx *ctx = ahash_request_ctx(dd->req);
644 if (ctx->flags & SHA_FLAGS_SG) {
645 dma_unmap_sg(dd->dev, ctx->sg, 1, DMA_TO_DEVICE);
646 if (ctx->sg->length == ctx->offset) {
647 ctx->sg = sg_next(ctx->sg);
651 if (ctx->flags & SHA_FLAGS_PAD) {
652 dma_unmap_single(dd->dev, ctx->dma_addr,
653 ctx->buflen + ctx->block_size, DMA_TO_DEVICE);
656 dma_unmap_single(dd->dev, ctx->dma_addr, ctx->buflen +
657 ctx->block_size, DMA_TO_DEVICE);
663 static int atmel_sha_update_req(struct atmel_sha_dev *dd)
665 struct ahash_request *req = dd->req;
666 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
669 dev_dbg(dd->dev, "update_req: total: %u, digcnt: 0x%llx 0x%llx\n",
670 ctx->total, ctx->digcnt[1], ctx->digcnt[0]);
672 if (ctx->flags & SHA_FLAGS_CPU)
673 err = atmel_sha_update_cpu(dd);
675 err = atmel_sha_update_dma_start(dd);
677 /* wait for dma completion before can take more data */
678 dev_dbg(dd->dev, "update: err: %d, digcnt: 0x%llx 0%llx\n",
679 err, ctx->digcnt[1], ctx->digcnt[0]);
684 static int atmel_sha_final_req(struct atmel_sha_dev *dd)
686 struct ahash_request *req = dd->req;
687 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
691 if (ctx->bufcnt >= ATMEL_SHA_DMA_THRESHOLD) {
692 atmel_sha_fill_padding(ctx, 0);
695 err = atmel_sha_xmit_dma_map(dd, ctx, count, 1);
697 /* faster to handle last block with cpu */
699 atmel_sha_fill_padding(ctx, 0);
702 err = atmel_sha_xmit_cpu(dd, ctx->buffer, count, 1);
705 dev_dbg(dd->dev, "final_req: err: %d\n", err);
710 static void atmel_sha_copy_hash(struct ahash_request *req)
712 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
713 u32 *hash = (u32 *)ctx->digest;
716 if (ctx->flags & SHA_FLAGS_SHA1)
717 for (i = 0; i < SHA1_DIGEST_SIZE / sizeof(u32); i++)
718 hash[i] = atmel_sha_read(ctx->dd, SHA_REG_DIGEST(i));
719 else if (ctx->flags & SHA_FLAGS_SHA224)
720 for (i = 0; i < SHA224_DIGEST_SIZE / sizeof(u32); i++)
721 hash[i] = atmel_sha_read(ctx->dd, SHA_REG_DIGEST(i));
722 else if (ctx->flags & SHA_FLAGS_SHA256)
723 for (i = 0; i < SHA256_DIGEST_SIZE / sizeof(u32); i++)
724 hash[i] = atmel_sha_read(ctx->dd, SHA_REG_DIGEST(i));
725 else if (ctx->flags & SHA_FLAGS_SHA384)
726 for (i = 0; i < SHA384_DIGEST_SIZE / sizeof(u32); i++)
727 hash[i] = atmel_sha_read(ctx->dd, SHA_REG_DIGEST(i));
729 for (i = 0; i < SHA512_DIGEST_SIZE / sizeof(u32); i++)
730 hash[i] = atmel_sha_read(ctx->dd, SHA_REG_DIGEST(i));
733 static void atmel_sha_copy_ready_hash(struct ahash_request *req)
735 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
740 if (ctx->flags & SHA_FLAGS_SHA1)
741 memcpy(req->result, ctx->digest, SHA1_DIGEST_SIZE);
742 else if (ctx->flags & SHA_FLAGS_SHA224)
743 memcpy(req->result, ctx->digest, SHA224_DIGEST_SIZE);
744 else if (ctx->flags & SHA_FLAGS_SHA256)
745 memcpy(req->result, ctx->digest, SHA256_DIGEST_SIZE);
746 else if (ctx->flags & SHA_FLAGS_SHA384)
747 memcpy(req->result, ctx->digest, SHA384_DIGEST_SIZE);
749 memcpy(req->result, ctx->digest, SHA512_DIGEST_SIZE);
752 static int atmel_sha_finish(struct ahash_request *req)
754 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
755 struct atmel_sha_dev *dd = ctx->dd;
758 if (ctx->digcnt[0] || ctx->digcnt[1])
759 atmel_sha_copy_ready_hash(req);
761 dev_dbg(dd->dev, "digcnt: 0x%llx 0x%llx, bufcnt: %d\n", ctx->digcnt[1],
762 ctx->digcnt[0], ctx->bufcnt);
767 static void atmel_sha_finish_req(struct ahash_request *req, int err)
769 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
770 struct atmel_sha_dev *dd = ctx->dd;
773 atmel_sha_copy_hash(req);
774 if (SHA_FLAGS_FINAL & dd->flags)
775 err = atmel_sha_finish(req);
777 ctx->flags |= SHA_FLAGS_ERROR;
780 /* atomic operation is not needed here */
781 dd->flags &= ~(SHA_FLAGS_BUSY | SHA_FLAGS_FINAL | SHA_FLAGS_CPU |
782 SHA_FLAGS_DMA_READY | SHA_FLAGS_OUTPUT_READY);
784 clk_disable_unprepare(dd->iclk);
786 if (req->base.complete)
787 req->base.complete(&req->base, err);
789 /* handle new request */
790 tasklet_schedule(&dd->done_task);
793 static int atmel_sha_hw_init(struct atmel_sha_dev *dd)
795 clk_prepare_enable(dd->iclk);
797 if (!(SHA_FLAGS_INIT & dd->flags)) {
798 atmel_sha_write(dd, SHA_CR, SHA_CR_SWRST);
799 dd->flags |= SHA_FLAGS_INIT;
806 static inline unsigned int atmel_sha_get_version(struct atmel_sha_dev *dd)
808 return atmel_sha_read(dd, SHA_HW_VERSION) & 0x00000fff;
811 static void atmel_sha_hw_version_init(struct atmel_sha_dev *dd)
813 atmel_sha_hw_init(dd);
815 dd->hw_version = atmel_sha_get_version(dd);
818 "version: 0x%x\n", dd->hw_version);
820 clk_disable_unprepare(dd->iclk);
823 static int atmel_sha_handle_queue(struct atmel_sha_dev *dd,
824 struct ahash_request *req)
826 struct crypto_async_request *async_req, *backlog;
827 struct atmel_sha_reqctx *ctx;
829 int err = 0, ret = 0;
831 spin_lock_irqsave(&dd->lock, flags);
833 ret = ahash_enqueue_request(&dd->queue, req);
835 if (SHA_FLAGS_BUSY & dd->flags) {
836 spin_unlock_irqrestore(&dd->lock, flags);
840 backlog = crypto_get_backlog(&dd->queue);
841 async_req = crypto_dequeue_request(&dd->queue);
843 dd->flags |= SHA_FLAGS_BUSY;
845 spin_unlock_irqrestore(&dd->lock, flags);
851 backlog->complete(backlog, -EINPROGRESS);
853 req = ahash_request_cast(async_req);
855 ctx = ahash_request_ctx(req);
857 dev_dbg(dd->dev, "handling new req, op: %lu, nbytes: %d\n",
858 ctx->op, req->nbytes);
860 err = atmel_sha_hw_init(dd);
865 if (ctx->op == SHA_OP_UPDATE) {
866 err = atmel_sha_update_req(dd);
867 if (err != -EINPROGRESS && (ctx->flags & SHA_FLAGS_FINUP))
868 /* no final() after finup() */
869 err = atmel_sha_final_req(dd);
870 } else if (ctx->op == SHA_OP_FINAL) {
871 err = atmel_sha_final_req(dd);
875 if (err != -EINPROGRESS)
876 /* done_task will not finish it, so do it here */
877 atmel_sha_finish_req(req, err);
879 dev_dbg(dd->dev, "exit, err: %d\n", err);
884 static int atmel_sha_enqueue(struct ahash_request *req, unsigned int op)
886 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
887 struct atmel_sha_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
888 struct atmel_sha_dev *dd = tctx->dd;
892 return atmel_sha_handle_queue(dd, req);
895 static int atmel_sha_update(struct ahash_request *req)
897 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
902 ctx->total = req->nbytes;
906 if (ctx->flags & SHA_FLAGS_FINUP) {
907 if (ctx->bufcnt + ctx->total < ATMEL_SHA_DMA_THRESHOLD)
908 /* faster to use CPU for short transfers */
909 ctx->flags |= SHA_FLAGS_CPU;
910 } else if (ctx->bufcnt + ctx->total < ctx->buflen) {
911 atmel_sha_append_sg(ctx);
914 return atmel_sha_enqueue(req, SHA_OP_UPDATE);
917 static int atmel_sha_final(struct ahash_request *req)
919 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
920 struct atmel_sha_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
921 struct atmel_sha_dev *dd = tctx->dd;
925 ctx->flags |= SHA_FLAGS_FINUP;
927 if (ctx->flags & SHA_FLAGS_ERROR)
928 return 0; /* uncompleted hash is not needed */
931 return atmel_sha_enqueue(req, SHA_OP_FINAL);
932 } else if (!(ctx->flags & SHA_FLAGS_PAD)) { /* add padding */
933 err = atmel_sha_hw_init(dd);
937 dd->flags |= SHA_FLAGS_BUSY;
938 err = atmel_sha_final_req(dd);
940 /* copy ready hash (+ finalize hmac) */
941 return atmel_sha_finish(req);
945 if (err != -EINPROGRESS)
946 /* done_task will not finish it, so do it here */
947 atmel_sha_finish_req(req, err);
952 static int atmel_sha_finup(struct ahash_request *req)
954 struct atmel_sha_reqctx *ctx = ahash_request_ctx(req);
957 ctx->flags |= SHA_FLAGS_FINUP;
959 err1 = atmel_sha_update(req);
960 if (err1 == -EINPROGRESS ||
961 (err1 == -EBUSY && (ahash_request_flags(req) &
962 CRYPTO_TFM_REQ_MAY_BACKLOG)))
966 * final() has to be always called to cleanup resources
967 * even if udpate() failed, except EINPROGRESS
969 err2 = atmel_sha_final(req);
974 static int atmel_sha_digest(struct ahash_request *req)
976 return atmel_sha_init(req) ?: atmel_sha_finup(req);
979 static int atmel_sha_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base)
981 struct atmel_sha_ctx *tctx = crypto_tfm_ctx(tfm);
982 const char *alg_name = crypto_tfm_alg_name(tfm);
984 /* Allocate a fallback and abort if it failed. */
985 tctx->fallback = crypto_alloc_shash(alg_name, 0,
986 CRYPTO_ALG_NEED_FALLBACK);
987 if (IS_ERR(tctx->fallback)) {
988 pr_err("atmel-sha: fallback driver '%s' could not be loaded.\n",
990 return PTR_ERR(tctx->fallback);
992 crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
993 sizeof(struct atmel_sha_reqctx) +
994 SHA_BUFFER_LEN + SHA512_BLOCK_SIZE);
999 static int atmel_sha_cra_init(struct crypto_tfm *tfm)
1001 return atmel_sha_cra_init_alg(tfm, NULL);
1004 static void atmel_sha_cra_exit(struct crypto_tfm *tfm)
1006 struct atmel_sha_ctx *tctx = crypto_tfm_ctx(tfm);
1008 crypto_free_shash(tctx->fallback);
1009 tctx->fallback = NULL;
1012 static struct ahash_alg sha_1_256_algs[] = {
1014 .init = atmel_sha_init,
1015 .update = atmel_sha_update,
1016 .final = atmel_sha_final,
1017 .finup = atmel_sha_finup,
1018 .digest = atmel_sha_digest,
1020 .digestsize = SHA1_DIGEST_SIZE,
1023 .cra_driver_name = "atmel-sha1",
1024 .cra_priority = 100,
1025 .cra_flags = CRYPTO_ALG_ASYNC |
1026 CRYPTO_ALG_NEED_FALLBACK,
1027 .cra_blocksize = SHA1_BLOCK_SIZE,
1028 .cra_ctxsize = sizeof(struct atmel_sha_ctx),
1030 .cra_module = THIS_MODULE,
1031 .cra_init = atmel_sha_cra_init,
1032 .cra_exit = atmel_sha_cra_exit,
1037 .init = atmel_sha_init,
1038 .update = atmel_sha_update,
1039 .final = atmel_sha_final,
1040 .finup = atmel_sha_finup,
1041 .digest = atmel_sha_digest,
1043 .digestsize = SHA256_DIGEST_SIZE,
1045 .cra_name = "sha256",
1046 .cra_driver_name = "atmel-sha256",
1047 .cra_priority = 100,
1048 .cra_flags = CRYPTO_ALG_ASYNC |
1049 CRYPTO_ALG_NEED_FALLBACK,
1050 .cra_blocksize = SHA256_BLOCK_SIZE,
1051 .cra_ctxsize = sizeof(struct atmel_sha_ctx),
1053 .cra_module = THIS_MODULE,
1054 .cra_init = atmel_sha_cra_init,
1055 .cra_exit = atmel_sha_cra_exit,
1061 static struct ahash_alg sha_224_alg = {
1062 .init = atmel_sha_init,
1063 .update = atmel_sha_update,
1064 .final = atmel_sha_final,
1065 .finup = atmel_sha_finup,
1066 .digest = atmel_sha_digest,
1068 .digestsize = SHA224_DIGEST_SIZE,
1070 .cra_name = "sha224",
1071 .cra_driver_name = "atmel-sha224",
1072 .cra_priority = 100,
1073 .cra_flags = CRYPTO_ALG_ASYNC |
1074 CRYPTO_ALG_NEED_FALLBACK,
1075 .cra_blocksize = SHA224_BLOCK_SIZE,
1076 .cra_ctxsize = sizeof(struct atmel_sha_ctx),
1078 .cra_module = THIS_MODULE,
1079 .cra_init = atmel_sha_cra_init,
1080 .cra_exit = atmel_sha_cra_exit,
1085 static struct ahash_alg sha_384_512_algs[] = {
1087 .init = atmel_sha_init,
1088 .update = atmel_sha_update,
1089 .final = atmel_sha_final,
1090 .finup = atmel_sha_finup,
1091 .digest = atmel_sha_digest,
1093 .digestsize = SHA384_DIGEST_SIZE,
1095 .cra_name = "sha384",
1096 .cra_driver_name = "atmel-sha384",
1097 .cra_priority = 100,
1098 .cra_flags = CRYPTO_ALG_ASYNC |
1099 CRYPTO_ALG_NEED_FALLBACK,
1100 .cra_blocksize = SHA384_BLOCK_SIZE,
1101 .cra_ctxsize = sizeof(struct atmel_sha_ctx),
1102 .cra_alignmask = 0x3,
1103 .cra_module = THIS_MODULE,
1104 .cra_init = atmel_sha_cra_init,
1105 .cra_exit = atmel_sha_cra_exit,
1110 .init = atmel_sha_init,
1111 .update = atmel_sha_update,
1112 .final = atmel_sha_final,
1113 .finup = atmel_sha_finup,
1114 .digest = atmel_sha_digest,
1116 .digestsize = SHA512_DIGEST_SIZE,
1118 .cra_name = "sha512",
1119 .cra_driver_name = "atmel-sha512",
1120 .cra_priority = 100,
1121 .cra_flags = CRYPTO_ALG_ASYNC |
1122 CRYPTO_ALG_NEED_FALLBACK,
1123 .cra_blocksize = SHA512_BLOCK_SIZE,
1124 .cra_ctxsize = sizeof(struct atmel_sha_ctx),
1125 .cra_alignmask = 0x3,
1126 .cra_module = THIS_MODULE,
1127 .cra_init = atmel_sha_cra_init,
1128 .cra_exit = atmel_sha_cra_exit,
1134 static void atmel_sha_done_task(unsigned long data)
1136 struct atmel_sha_dev *dd = (struct atmel_sha_dev *)data;
1139 if (!(SHA_FLAGS_BUSY & dd->flags)) {
1140 atmel_sha_handle_queue(dd, NULL);
1144 if (SHA_FLAGS_CPU & dd->flags) {
1145 if (SHA_FLAGS_OUTPUT_READY & dd->flags) {
1146 dd->flags &= ~SHA_FLAGS_OUTPUT_READY;
1149 } else if (SHA_FLAGS_DMA_READY & dd->flags) {
1150 if (SHA_FLAGS_DMA_ACTIVE & dd->flags) {
1151 dd->flags &= ~SHA_FLAGS_DMA_ACTIVE;
1152 atmel_sha_update_dma_stop(dd);
1158 if (SHA_FLAGS_OUTPUT_READY & dd->flags) {
1159 /* hash or semi-hash ready */
1160 dd->flags &= ~(SHA_FLAGS_DMA_READY |
1161 SHA_FLAGS_OUTPUT_READY);
1162 err = atmel_sha_update_dma_start(dd);
1163 if (err != -EINPROGRESS)
1170 /* finish curent request */
1171 atmel_sha_finish_req(dd->req, err);
1174 static irqreturn_t atmel_sha_irq(int irq, void *dev_id)
1176 struct atmel_sha_dev *sha_dd = dev_id;
1179 reg = atmel_sha_read(sha_dd, SHA_ISR);
1180 if (reg & atmel_sha_read(sha_dd, SHA_IMR)) {
1181 atmel_sha_write(sha_dd, SHA_IDR, reg);
1182 if (SHA_FLAGS_BUSY & sha_dd->flags) {
1183 sha_dd->flags |= SHA_FLAGS_OUTPUT_READY;
1184 if (!(SHA_FLAGS_CPU & sha_dd->flags))
1185 sha_dd->flags |= SHA_FLAGS_DMA_READY;
1186 tasklet_schedule(&sha_dd->done_task);
1188 dev_warn(sha_dd->dev, "SHA interrupt when no active requests.\n");
1196 static void atmel_sha_unregister_algs(struct atmel_sha_dev *dd)
1200 for (i = 0; i < ARRAY_SIZE(sha_1_256_algs); i++)
1201 crypto_unregister_ahash(&sha_1_256_algs[i]);
1203 if (dd->caps.has_sha224)
1204 crypto_unregister_ahash(&sha_224_alg);
1206 if (dd->caps.has_sha_384_512) {
1207 for (i = 0; i < ARRAY_SIZE(sha_384_512_algs); i++)
1208 crypto_unregister_ahash(&sha_384_512_algs[i]);
1212 static int atmel_sha_register_algs(struct atmel_sha_dev *dd)
1216 for (i = 0; i < ARRAY_SIZE(sha_1_256_algs); i++) {
1217 err = crypto_register_ahash(&sha_1_256_algs[i]);
1219 goto err_sha_1_256_algs;
1222 if (dd->caps.has_sha224) {
1223 err = crypto_register_ahash(&sha_224_alg);
1225 goto err_sha_224_algs;
1228 if (dd->caps.has_sha_384_512) {
1229 for (i = 0; i < ARRAY_SIZE(sha_384_512_algs); i++) {
1230 err = crypto_register_ahash(&sha_384_512_algs[i]);
1232 goto err_sha_384_512_algs;
1238 err_sha_384_512_algs:
1239 for (j = 0; j < i; j++)
1240 crypto_unregister_ahash(&sha_384_512_algs[j]);
1241 crypto_unregister_ahash(&sha_224_alg);
1243 i = ARRAY_SIZE(sha_1_256_algs);
1245 for (j = 0; j < i; j++)
1246 crypto_unregister_ahash(&sha_1_256_algs[j]);
1251 static bool atmel_sha_filter(struct dma_chan *chan, void *slave)
1253 struct at_dma_slave *sl = slave;
1255 if (sl && sl->dma_dev == chan->device->dev) {
1263 static int atmel_sha_dma_init(struct atmel_sha_dev *dd,
1264 struct crypto_platform_data *pdata)
1267 dma_cap_mask_t mask_in;
1269 /* Try to grab DMA channel */
1270 dma_cap_zero(mask_in);
1271 dma_cap_set(DMA_SLAVE, mask_in);
1273 dd->dma_lch_in.chan = dma_request_slave_channel_compat(mask_in,
1274 atmel_sha_filter, &pdata->dma_slave->rxdata, dd->dev, "tx");
1275 if (!dd->dma_lch_in.chan) {
1276 dev_warn(dd->dev, "no DMA channel available\n");
1280 dd->dma_lch_in.dma_conf.direction = DMA_MEM_TO_DEV;
1281 dd->dma_lch_in.dma_conf.dst_addr = dd->phys_base +
1283 dd->dma_lch_in.dma_conf.src_maxburst = 1;
1284 dd->dma_lch_in.dma_conf.src_addr_width =
1285 DMA_SLAVE_BUSWIDTH_4_BYTES;
1286 dd->dma_lch_in.dma_conf.dst_maxburst = 1;
1287 dd->dma_lch_in.dma_conf.dst_addr_width =
1288 DMA_SLAVE_BUSWIDTH_4_BYTES;
1289 dd->dma_lch_in.dma_conf.device_fc = false;
1294 static void atmel_sha_dma_cleanup(struct atmel_sha_dev *dd)
1296 dma_release_channel(dd->dma_lch_in.chan);
1299 static void atmel_sha_get_cap(struct atmel_sha_dev *dd)
1302 dd->caps.has_dma = 0;
1303 dd->caps.has_dualbuff = 0;
1304 dd->caps.has_sha224 = 0;
1305 dd->caps.has_sha_384_512 = 0;
1307 /* keep only major version number */
1308 switch (dd->hw_version & 0xff0) {
1310 dd->caps.has_dma = 1;
1311 dd->caps.has_dualbuff = 1;
1312 dd->caps.has_sha224 = 1;
1313 dd->caps.has_sha_384_512 = 1;
1316 dd->caps.has_dma = 1;
1317 dd->caps.has_dualbuff = 1;
1318 dd->caps.has_sha224 = 1;
1324 "Unmanaged sha version, set minimum capabilities\n");
1329 #if defined(CONFIG_OF)
1330 static const struct of_device_id atmel_sha_dt_ids[] = {
1331 { .compatible = "atmel,at91sam9g46-sha" },
1335 MODULE_DEVICE_TABLE(of, atmel_sha_dt_ids);
1337 static struct crypto_platform_data *atmel_sha_of_init(struct platform_device *pdev)
1339 struct device_node *np = pdev->dev.of_node;
1340 struct crypto_platform_data *pdata;
1343 dev_err(&pdev->dev, "device node not found\n");
1344 return ERR_PTR(-EINVAL);
1347 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
1349 dev_err(&pdev->dev, "could not allocate memory for pdata\n");
1350 return ERR_PTR(-ENOMEM);
1353 pdata->dma_slave = devm_kzalloc(&pdev->dev,
1354 sizeof(*(pdata->dma_slave)),
1356 if (!pdata->dma_slave) {
1357 dev_err(&pdev->dev, "could not allocate memory for dma_slave\n");
1358 devm_kfree(&pdev->dev, pdata);
1359 return ERR_PTR(-ENOMEM);
1364 #else /* CONFIG_OF */
1365 static inline struct crypto_platform_data *atmel_sha_of_init(struct platform_device *dev)
1367 return ERR_PTR(-EINVAL);
1371 static int atmel_sha_probe(struct platform_device *pdev)
1373 struct atmel_sha_dev *sha_dd;
1374 struct crypto_platform_data *pdata;
1375 struct device *dev = &pdev->dev;
1376 struct resource *sha_res;
1377 unsigned long sha_phys_size;
1380 sha_dd = kzalloc(sizeof(struct atmel_sha_dev), GFP_KERNEL);
1381 if (sha_dd == NULL) {
1382 dev_err(dev, "unable to alloc data struct.\n");
1389 platform_set_drvdata(pdev, sha_dd);
1391 INIT_LIST_HEAD(&sha_dd->list);
1393 tasklet_init(&sha_dd->done_task, atmel_sha_done_task,
1394 (unsigned long)sha_dd);
1396 crypto_init_queue(&sha_dd->queue, ATMEL_SHA_QUEUE_LENGTH);
1400 /* Get the base address */
1401 sha_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1403 dev_err(dev, "no MEM resource info\n");
1407 sha_dd->phys_base = sha_res->start;
1408 sha_phys_size = resource_size(sha_res);
1411 sha_dd->irq = platform_get_irq(pdev, 0);
1412 if (sha_dd->irq < 0) {
1413 dev_err(dev, "no IRQ resource info\n");
1418 err = request_irq(sha_dd->irq, atmel_sha_irq, IRQF_SHARED, "atmel-sha",
1421 dev_err(dev, "unable to request sha irq.\n");
1425 /* Initializing the clock */
1426 sha_dd->iclk = clk_get(&pdev->dev, "sha_clk");
1427 if (IS_ERR(sha_dd->iclk)) {
1428 dev_err(dev, "clock intialization failed.\n");
1429 err = PTR_ERR(sha_dd->iclk);
1433 sha_dd->io_base = ioremap(sha_dd->phys_base, sha_phys_size);
1434 if (!sha_dd->io_base) {
1435 dev_err(dev, "can't ioremap\n");
1440 atmel_sha_hw_version_init(sha_dd);
1442 atmel_sha_get_cap(sha_dd);
1444 if (sha_dd->caps.has_dma) {
1445 pdata = pdev->dev.platform_data;
1447 pdata = atmel_sha_of_init(pdev);
1448 if (IS_ERR(pdata)) {
1449 dev_err(&pdev->dev, "platform data not available\n");
1450 err = PTR_ERR(pdata);
1454 if (!pdata->dma_slave) {
1458 err = atmel_sha_dma_init(sha_dd, pdata);
1462 dev_info(dev, "using %s for DMA transfers\n",
1463 dma_chan_name(sha_dd->dma_lch_in.chan));
1466 spin_lock(&atmel_sha.lock);
1467 list_add_tail(&sha_dd->list, &atmel_sha.dev_list);
1468 spin_unlock(&atmel_sha.lock);
1470 err = atmel_sha_register_algs(sha_dd);
1474 dev_info(dev, "Atmel SHA1/SHA256%s%s\n",
1475 sha_dd->caps.has_sha224 ? "/SHA224" : "",
1476 sha_dd->caps.has_sha_384_512 ? "/SHA384/SHA512" : "");
1481 spin_lock(&atmel_sha.lock);
1482 list_del(&sha_dd->list);
1483 spin_unlock(&atmel_sha.lock);
1484 if (sha_dd->caps.has_dma)
1485 atmel_sha_dma_cleanup(sha_dd);
1488 iounmap(sha_dd->io_base);
1490 clk_put(sha_dd->iclk);
1492 free_irq(sha_dd->irq, sha_dd);
1494 tasklet_kill(&sha_dd->done_task);
1498 dev_err(dev, "initialization failed.\n");
1503 static int atmel_sha_remove(struct platform_device *pdev)
1505 static struct atmel_sha_dev *sha_dd;
1507 sha_dd = platform_get_drvdata(pdev);
1510 spin_lock(&atmel_sha.lock);
1511 list_del(&sha_dd->list);
1512 spin_unlock(&atmel_sha.lock);
1514 atmel_sha_unregister_algs(sha_dd);
1516 tasklet_kill(&sha_dd->done_task);
1518 if (sha_dd->caps.has_dma)
1519 atmel_sha_dma_cleanup(sha_dd);
1521 iounmap(sha_dd->io_base);
1523 clk_put(sha_dd->iclk);
1525 if (sha_dd->irq >= 0)
1526 free_irq(sha_dd->irq, sha_dd);
1534 static struct platform_driver atmel_sha_driver = {
1535 .probe = atmel_sha_probe,
1536 .remove = atmel_sha_remove,
1538 .name = "atmel_sha",
1539 .owner = THIS_MODULE,
1540 .of_match_table = of_match_ptr(atmel_sha_dt_ids),
1544 module_platform_driver(atmel_sha_driver);
1546 MODULE_DESCRIPTION("Atmel SHA (1/256/224/384/512) hw acceleration support.");
1547 MODULE_LICENSE("GPL v2");
1548 MODULE_AUTHOR("Nicolas Royer - Eukréa Electromatique");