aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/bfin_crc.c
diff options
context:
space:
mode:
authorSonic Zhang <sonic.zhang@analog.com>2014-04-10 02:30:56 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-04-16 08:40:15 -0400
commit52e6e543f2d8c8320b6e9c53110bd1c5768d6b43 (patch)
treee4038b1c3921fef6670b0808a79834fc0b2cd646 /drivers/crypto/bfin_crc.c
parent2d9cab5194c89a0d20fb8dce09e9d3a7c85e8f37 (diff)
crypto: bfin_crc - access crc registers by readl and writel functions
Move architecture independant crc header file out of the blackfin folder. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Reviewed-by: Marek Vasut <marex@denx.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/bfin_crc.c')
-rw-r--r--drivers/crypto/bfin_crc.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/crypto/bfin_crc.c b/drivers/crypto/bfin_crc.c
index c9ff298e6d26..cea3e8c1fdf9 100644
--- a/drivers/crypto/bfin_crc.c
+++ b/drivers/crypto/bfin_crc.c
@@ -30,9 +30,11 @@
30#include <crypto/internal/hash.h> 30#include <crypto/internal/hash.h>
31 31
32#include <asm/blackfin.h> 32#include <asm/blackfin.h>
33#include <asm/bfin_crc.h>
34#include <asm/dma.h> 33#include <asm/dma.h>
35#include <asm/portmux.h> 34#include <asm/portmux.h>
35#include <asm/io.h>
36
37#include "bfin_crc.h"
36 38
37#define CRC_CCRYPTO_QUEUE_LENGTH 5 39#define CRC_CCRYPTO_QUEUE_LENGTH 5
38 40
@@ -54,7 +56,7 @@ struct bfin_crypto_crc {
54 int irq; 56 int irq;
55 int dma_ch; 57 int dma_ch;
56 u32 poly; 58 u32 poly;
57 volatile struct crc_register *regs; 59 struct crc_register *regs;
58 60
59 struct ahash_request *req; /* current request in operation */ 61 struct ahash_request *req; /* current request in operation */
60 struct dma_desc_array *sg_cpu; /* virt addr of sg dma descriptors */ 62 struct dma_desc_array *sg_cpu; /* virt addr of sg dma descriptors */
@@ -132,13 +134,13 @@ static struct scatterlist *sg_get(struct scatterlist *sg_list, unsigned int nent
132 134
133static int bfin_crypto_crc_init_hw(struct bfin_crypto_crc *crc, u32 key) 135static int bfin_crypto_crc_init_hw(struct bfin_crypto_crc *crc, u32 key)
134{ 136{
135 crc->regs->datacntrld = 0; 137 writel(0, &crc->regs->datacntrld);
136 crc->regs->control = MODE_CALC_CRC << OPMODE_OFFSET; 138 writel(MODE_CALC_CRC << OPMODE_OFFSET, &crc->regs->control);
137 crc->regs->curresult = key; 139 writel(key, &crc->regs->curresult);
138 140
139 /* setup CRC interrupts */ 141 /* setup CRC interrupts */
140 crc->regs->status = CMPERRI | DCNTEXPI; 142 writel(CMPERRI | DCNTEXPI, &crc->regs->status);
141 crc->regs->intrenset = CMPERRI | DCNTEXPI; 143 writel(CMPERRI | DCNTEXPI, &crc->regs->intrenset);
142 144
143 return 0; 145 return 0;
144} 146}
@@ -303,6 +305,7 @@ static int bfin_crypto_crc_handle_queue(struct bfin_crypto_crc *crc,
303 int nsg, i, j; 305 int nsg, i, j;
304 unsigned int nextlen; 306 unsigned int nextlen;
305 unsigned long flags; 307 unsigned long flags;
308 u32 reg;
306 309
307 spin_lock_irqsave(&crc->lock, flags); 310 spin_lock_irqsave(&crc->lock, flags);
308 if (req) 311 if (req)
@@ -402,13 +405,14 @@ finish_update:
402 ctx->sg_buflen += CHKSUM_DIGEST_SIZE; 405 ctx->sg_buflen += CHKSUM_DIGEST_SIZE;
403 406
404 /* set CRC data count before start DMA */ 407 /* set CRC data count before start DMA */
405 crc->regs->datacnt = ctx->sg_buflen >> 2; 408 writel(ctx->sg_buflen >> 2, &crc->regs->datacnt);
406 409
407 /* setup and enable CRC DMA */ 410 /* setup and enable CRC DMA */
408 bfin_crypto_crc_config_dma(crc); 411 bfin_crypto_crc_config_dma(crc);
409 412
410 /* finally kick off CRC operation */ 413 /* finally kick off CRC operation */
411 crc->regs->control |= BLKEN; 414 reg = readl(&crc->regs->control);
415 writel(reg | BLKEN, &crc->regs->control);
412 416
413 return -EINPROGRESS; 417 return -EINPROGRESS;
414} 418}
@@ -529,14 +533,17 @@ static void bfin_crypto_crc_done_task(unsigned long data)
529static irqreturn_t bfin_crypto_crc_handler(int irq, void *dev_id) 533static irqreturn_t bfin_crypto_crc_handler(int irq, void *dev_id)
530{ 534{
531 struct bfin_crypto_crc *crc = dev_id; 535 struct bfin_crypto_crc *crc = dev_id;
536 u32 reg;
532 537
533 if (crc->regs->status & DCNTEXP) { 538 if (readl(&crc->regs->status) & DCNTEXP) {
534 crc->regs->status = DCNTEXP; 539 writel(DCNTEXP, &crc->regs->status);
535 540
536 /* prepare results */ 541 /* prepare results */
537 put_unaligned_le32(crc->regs->result, crc->req->result); 542 put_unaligned_le32(readl(&crc->regs->result),
543 crc->req->result);
538 544
539 crc->regs->control &= ~BLKEN; 545 reg = readl(&crc->regs->control);
546 writel(reg & ~BLKEN, &crc->regs->control);
540 crc->busy = 0; 547 crc->busy = 0;
541 548
542 if (crc->req->base.complete) 549 if (crc->req->base.complete)
@@ -560,7 +567,7 @@ static int bfin_crypto_crc_suspend(struct platform_device *pdev, pm_message_t st
560 struct bfin_crypto_crc *crc = platform_get_drvdata(pdev); 567 struct bfin_crypto_crc *crc = platform_get_drvdata(pdev);
561 int i = 100000; 568 int i = 100000;
562 569
563 while ((crc->regs->control & BLKEN) && --i) 570 while ((readl(&crc->regs->control) & BLKEN) && --i)
564 cpu_relax(); 571 cpu_relax();
565 572
566 if (i == 0) 573 if (i == 0)
@@ -648,10 +655,11 @@ static int bfin_crypto_crc_probe(struct platform_device *pdev)
648 */ 655 */
649 crc->sg_mid_buf = (u8 *)(crc->sg_cpu + ((CRC_MAX_DMA_DESC + 1) << 1)); 656 crc->sg_mid_buf = (u8 *)(crc->sg_cpu + ((CRC_MAX_DMA_DESC + 1) << 1));
650 657
651 crc->regs->control = 0; 658 writel(0, &crc->regs->control);
652 crc->regs->poly = crc->poly = (u32)pdev->dev.platform_data; 659 crc->poly = (u32)pdev->dev.platform_data;
660 writel(crc->poly, &crc->regs->poly);
653 661
654 while (!(crc->regs->status & LUTDONE) && (--timeout) > 0) 662 while (!(readl(&crc->regs->status) & LUTDONE) && (--timeout) > 0)
655 cpu_relax(); 663 cpu_relax();
656 664
657 if (timeout == 0) 665 if (timeout == 0)