summaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorKim Phillips <kim.phillips@freescale.com>2011-11-21 03:13:27 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2011-11-21 03:21:50 -0500
commitad42d5fc85383278663ecb58a24f6547ad0ba735 (patch)
treeacad5589157f94ceb2df9ef97cc2deb635fe0bbd /drivers/crypto
parent5b859b6ebb18b37244d44b5300bf765694b7303c (diff)
crypto: talitos - prepare driver for channel remap support
Add a reg member to the channel struct and use it to access channels. Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/talitos.c37
-rw-r--r--drivers/crypto/talitos.h31
2 files changed, 38 insertions, 30 deletions
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index c372a18ed22e..7f82e91e461c 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -99,6 +99,8 @@ struct talitos_request {
99 99
100/* per-channel fifo management */ 100/* per-channel fifo management */
101struct talitos_channel { 101struct talitos_channel {
102 void __iomem *reg;
103
102 /* request fifo */ 104 /* request fifo */
103 struct talitos_request *fifo; 105 struct talitos_request *fifo;
104 106
@@ -197,9 +199,9 @@ static int reset_channel(struct device *dev, int ch)
197 struct talitos_private *priv = dev_get_drvdata(dev); 199 struct talitos_private *priv = dev_get_drvdata(dev);
198 unsigned int timeout = TALITOS_TIMEOUT; 200 unsigned int timeout = TALITOS_TIMEOUT;
199 201
200 setbits32(priv->reg + TALITOS_CCCR(ch), TALITOS_CCCR_RESET); 202 setbits32(priv->chan[ch].reg + TALITOS_CCCR, TALITOS_CCCR_RESET);
201 203
202 while ((in_be32(priv->reg + TALITOS_CCCR(ch)) & TALITOS_CCCR_RESET) 204 while ((in_be32(priv->chan[ch].reg + TALITOS_CCCR) & TALITOS_CCCR_RESET)
203 && --timeout) 205 && --timeout)
204 cpu_relax(); 206 cpu_relax();
205 207
@@ -209,12 +211,12 @@ static int reset_channel(struct device *dev, int ch)
209 } 211 }
210 212
211 /* set 36-bit addressing, done writeback enable and done IRQ enable */ 213 /* set 36-bit addressing, done writeback enable and done IRQ enable */
212 setbits32(priv->reg + TALITOS_CCCR_LO(ch), TALITOS_CCCR_LO_EAE | 214 setbits32(priv->chan[ch].reg + TALITOS_CCCR_LO, TALITOS_CCCR_LO_EAE |
213 TALITOS_CCCR_LO_CDWE | TALITOS_CCCR_LO_CDIE); 215 TALITOS_CCCR_LO_CDWE | TALITOS_CCCR_LO_CDIE);
214 216
215 /* and ICCR writeback, if available */ 217 /* and ICCR writeback, if available */
216 if (priv->features & TALITOS_FTR_HW_AUTH_CHECK) 218 if (priv->features & TALITOS_FTR_HW_AUTH_CHECK)
217 setbits32(priv->reg + TALITOS_CCCR_LO(ch), 219 setbits32(priv->chan[ch].reg + TALITOS_CCCR_LO,
218 TALITOS_CCCR_LO_IWSE); 220 TALITOS_CCCR_LO_IWSE);
219 221
220 return 0; 222 return 0;
@@ -328,8 +330,9 @@ static int talitos_submit(struct device *dev, int ch, struct talitos_desc *desc,
328 330
329 /* GO! */ 331 /* GO! */
330 wmb(); 332 wmb();
331 out_be32(priv->reg + TALITOS_FF(ch), upper_32_bits(request->dma_desc)); 333 out_be32(priv->chan[ch].reg + TALITOS_FF,
332 out_be32(priv->reg + TALITOS_FF_LO(ch), 334 upper_32_bits(request->dma_desc));
335 out_be32(priv->chan[ch].reg + TALITOS_FF_LO,
333 lower_32_bits(request->dma_desc)); 336 lower_32_bits(request->dma_desc));
334 337
335 spin_unlock_irqrestore(&priv->chan[ch].head_lock, flags); 338 spin_unlock_irqrestore(&priv->chan[ch].head_lock, flags);
@@ -423,7 +426,7 @@ static u32 current_desc_hdr(struct device *dev, int ch)
423 int tail = priv->chan[ch].tail; 426 int tail = priv->chan[ch].tail;
424 dma_addr_t cur_desc; 427 dma_addr_t cur_desc;
425 428
426 cur_desc = in_be32(priv->reg + TALITOS_CDPR_LO(ch)); 429 cur_desc = in_be32(priv->chan[ch].reg + TALITOS_CDPR_LO);
427 430
428 while (priv->chan[ch].fifo[tail].dma_desc != cur_desc) { 431 while (priv->chan[ch].fifo[tail].dma_desc != cur_desc) {
429 tail = (tail + 1) & (priv->fifo_len - 1); 432 tail = (tail + 1) & (priv->fifo_len - 1);
@@ -445,7 +448,7 @@ static void report_eu_error(struct device *dev, int ch, u32 desc_hdr)
445 int i; 448 int i;
446 449
447 if (!desc_hdr) 450 if (!desc_hdr)
448 desc_hdr = in_be32(priv->reg + TALITOS_DESCBUF(ch)); 451 desc_hdr = in_be32(priv->chan[ch].reg + TALITOS_DESCBUF);
449 452
450 switch (desc_hdr & DESC_HDR_SEL0_MASK) { 453 switch (desc_hdr & DESC_HDR_SEL0_MASK) {
451 case DESC_HDR_SEL0_AFEU: 454 case DESC_HDR_SEL0_AFEU:
@@ -507,8 +510,8 @@ static void report_eu_error(struct device *dev, int ch, u32 desc_hdr)
507 510
508 for (i = 0; i < 8; i++) 511 for (i = 0; i < 8; i++)
509 dev_err(dev, "DESCBUF 0x%08x_%08x\n", 512 dev_err(dev, "DESCBUF 0x%08x_%08x\n",
510 in_be32(priv->reg + TALITOS_DESCBUF(ch) + 8*i), 513 in_be32(priv->chan[ch].reg + TALITOS_DESCBUF + 8*i),
511 in_be32(priv->reg + TALITOS_DESCBUF_LO(ch) + 8*i)); 514 in_be32(priv->chan[ch].reg + TALITOS_DESCBUF_LO + 8*i));
512} 515}
513 516
514/* 517/*
@@ -529,8 +532,8 @@ static void talitos_error(unsigned long data, u32 isr, u32 isr_lo)
529 532
530 error = -EINVAL; 533 error = -EINVAL;
531 534
532 v = in_be32(priv->reg + TALITOS_CCPSR(ch)); 535 v = in_be32(priv->chan[ch].reg + TALITOS_CCPSR);
533 v_lo = in_be32(priv->reg + TALITOS_CCPSR_LO(ch)); 536 v_lo = in_be32(priv->chan[ch].reg + TALITOS_CCPSR_LO);
534 537
535 if (v_lo & TALITOS_CCPSR_LO_DOF) { 538 if (v_lo & TALITOS_CCPSR_LO_DOF) {
536 dev_err(dev, "double fetch fifo overflow error\n"); 539 dev_err(dev, "double fetch fifo overflow error\n");
@@ -568,10 +571,10 @@ static void talitos_error(unsigned long data, u32 isr, u32 isr_lo)
568 if (reset_ch) { 571 if (reset_ch) {
569 reset_channel(dev, ch); 572 reset_channel(dev, ch);
570 } else { 573 } else {
571 setbits32(priv->reg + TALITOS_CCCR(ch), 574 setbits32(priv->chan[ch].reg + TALITOS_CCCR,
572 TALITOS_CCCR_CONT); 575 TALITOS_CCCR_CONT);
573 setbits32(priv->reg + TALITOS_CCCR_LO(ch), 0); 576 setbits32(priv->chan[ch].reg + TALITOS_CCCR_LO, 0);
574 while ((in_be32(priv->reg + TALITOS_CCCR(ch)) & 577 while ((in_be32(priv->chan[ch].reg + TALITOS_CCCR) &
575 TALITOS_CCCR_CONT) && --timeout) 578 TALITOS_CCCR_CONT) && --timeout)
576 cpu_relax(); 579 cpu_relax();
577 if (timeout == 0) { 580 if (timeout == 0) {
@@ -2710,6 +2713,10 @@ static int talitos_probe(struct platform_device *ofdev)
2710 goto err_out; 2713 goto err_out;
2711 } 2714 }
2712 2715
2716 for (i = 0; i < priv->num_channels; i++)
2717 priv->chan[i].reg = priv->reg + TALITOS_CH_BASE_OFFSET +
2718 TALITOS_CH_STRIDE * (i + 1);
2719
2713 for (i = 0; i < priv->num_channels; i++) { 2720 for (i = 0; i < priv->num_channels; i++) {
2714 spin_lock_init(&priv->chan[i].head_lock); 2721 spin_lock_init(&priv->chan[i].head_lock);
2715 spin_lock_init(&priv->chan[i].tail_lock); 2722 spin_lock_init(&priv->chan[i].tail_lock);
diff --git a/drivers/crypto/talitos.h b/drivers/crypto/talitos.h
index 0b746aca4587..3ed319da853c 100644
--- a/drivers/crypto/talitos.h
+++ b/drivers/crypto/talitos.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Freescale SEC (talitos) device register and descriptor header defines 2 * Freescale SEC (talitos) device register and descriptor header defines
3 * 3 *
4 * Copyright (c) 2006-2010 Freescale Semiconductor, Inc. 4 * Copyright (c) 2006-2011 Freescale Semiconductor, Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
@@ -49,13 +49,14 @@
49#define TALITOS_ICR_LO 0x101C 49#define TALITOS_ICR_LO 0x101C
50 50
51/* channel register address stride */ 51/* channel register address stride */
52#define TALITOS_CH_BASE_OFFSET 0x1000 /* default channel map base */
52#define TALITOS_CH_STRIDE 0x100 53#define TALITOS_CH_STRIDE 0x100
53 54
54/* channel configuration register */ 55/* channel configuration register */
55#define TALITOS_CCCR(ch) (ch * TALITOS_CH_STRIDE + 0x1108) 56#define TALITOS_CCCR 0x8
56#define TALITOS_CCCR_CONT 0x2 /* channel continue */ 57#define TALITOS_CCCR_CONT 0x2 /* channel continue */
57#define TALITOS_CCCR_RESET 0x1 /* channel reset */ 58#define TALITOS_CCCR_RESET 0x1 /* channel reset */
58#define TALITOS_CCCR_LO(ch) (ch * TALITOS_CH_STRIDE + 0x110c) 59#define TALITOS_CCCR_LO 0xc
59#define TALITOS_CCCR_LO_IWSE 0x80 /* chan. ICCR writeback enab. */ 60#define TALITOS_CCCR_LO_IWSE 0x80 /* chan. ICCR writeback enab. */
60#define TALITOS_CCCR_LO_EAE 0x20 /* extended address enable */ 61#define TALITOS_CCCR_LO_EAE 0x20 /* extended address enable */
61#define TALITOS_CCCR_LO_CDWE 0x10 /* chan. done writeback enab. */ 62#define TALITOS_CCCR_LO_CDWE 0x10 /* chan. done writeback enab. */
@@ -63,8 +64,8 @@
63#define TALITOS_CCCR_LO_CDIE 0x2 /* channel done IRQ enable */ 64#define TALITOS_CCCR_LO_CDIE 0x2 /* channel done IRQ enable */
64 65
65/* CCPSR: channel pointer status register */ 66/* CCPSR: channel pointer status register */
66#define TALITOS_CCPSR(ch) (ch * TALITOS_CH_STRIDE + 0x1110) 67#define TALITOS_CCPSR 0x10
67#define TALITOS_CCPSR_LO(ch) (ch * TALITOS_CH_STRIDE + 0x1114) 68#define TALITOS_CCPSR_LO 0x14
68#define TALITOS_CCPSR_LO_DOF 0x8000 /* double FF write oflow error */ 69#define TALITOS_CCPSR_LO_DOF 0x8000 /* double FF write oflow error */
69#define TALITOS_CCPSR_LO_SOF 0x4000 /* single FF write oflow error */ 70#define TALITOS_CCPSR_LO_SOF 0x4000 /* single FF write oflow error */
70#define TALITOS_CCPSR_LO_MDTE 0x2000 /* master data transfer error */ 71#define TALITOS_CCPSR_LO_MDTE 0x2000 /* master data transfer error */
@@ -79,24 +80,24 @@
79#define TALITOS_CCPSR_LO_SRL 0x0010 /* scatter return/length error */ 80#define TALITOS_CCPSR_LO_SRL 0x0010 /* scatter return/length error */
80 81
81/* channel fetch fifo register */ 82/* channel fetch fifo register */
82#define TALITOS_FF(ch) (ch * TALITOS_CH_STRIDE + 0x1148) 83#define TALITOS_FF 0x48
83#define TALITOS_FF_LO(ch) (ch * TALITOS_CH_STRIDE + 0x114c) 84#define TALITOS_FF_LO 0x4c
84 85
85/* current descriptor pointer register */ 86/* current descriptor pointer register */
86#define TALITOS_CDPR(ch) (ch * TALITOS_CH_STRIDE + 0x1140) 87#define TALITOS_CDPR 0x40
87#define TALITOS_CDPR_LO(ch) (ch * TALITOS_CH_STRIDE + 0x1144) 88#define TALITOS_CDPR_LO 0x44
88 89
89/* descriptor buffer register */ 90/* descriptor buffer register */
90#define TALITOS_DESCBUF(ch) (ch * TALITOS_CH_STRIDE + 0x1180) 91#define TALITOS_DESCBUF 0x80
91#define TALITOS_DESCBUF_LO(ch) (ch * TALITOS_CH_STRIDE + 0x1184) 92#define TALITOS_DESCBUF_LO 0x84
92 93
93/* gather link table */ 94/* gather link table */
94#define TALITOS_GATHER(ch) (ch * TALITOS_CH_STRIDE + 0x11c0) 95#define TALITOS_GATHER 0xc0
95#define TALITOS_GATHER_LO(ch) (ch * TALITOS_CH_STRIDE + 0x11c4) 96#define TALITOS_GATHER_LO 0xc4
96 97
97/* scatter link table */ 98/* scatter link table */
98#define TALITOS_SCATTER(ch) (ch * TALITOS_CH_STRIDE + 0x11e0) 99#define TALITOS_SCATTER 0xe0
99#define TALITOS_SCATTER_LO(ch) (ch * TALITOS_CH_STRIDE + 0x11e4) 100#define TALITOS_SCATTER_LO 0xe4
100 101
101/* execution unit interrupt status registers */ 102/* execution unit interrupt status registers */
102#define TALITOS_DEUISR 0x2030 /* DES unit */ 103#define TALITOS_DEUISR 0x2030 /* DES unit */