aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/talitos.c
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/talitos.c
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/talitos.c')
-rw-r--r--drivers/crypto/talitos.c37
1 files changed, 22 insertions, 15 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);