diff options
author | Ruchika Gupta <ruchika.gupta@freescale.com> | 2014-06-23 08:12:33 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-06-25 09:38:39 -0400 |
commit | 17157c90a8abf9323ee2a3daac7ad9f696642dda (patch) | |
tree | 669b3f012c1dbd8e7aac0114f61c169d5801587c | |
parent | eb1139cd437afadc63f58159c111e3f166bddb51 (diff) |
crypto: caam - Configuration for platforms with virtualization enabled in CAAM
For platforms with virtualization enabled
1. The job ring registers can be written to only is the job ring has been
started i.e STARTR bit in JRSTART register is 1
2. For DECO's under direct software control, with virtualization enabled
PL, BMT, ICID and SDID values need to be provided. These are provided by
selecting a Job ring in start mode whose parameters would be used for the
DECO access programming.
Signed-off-by: Ruchika Gupta <ruchika.gupta@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/caam/ctrl.c | 39 | ||||
-rw-r--r-- | drivers/crypto/caam/intern.h | 1 | ||||
-rw-r--r-- | drivers/crypto/caam/regs.h | 18 |
3 files changed, 56 insertions, 2 deletions
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 066a4d4b62bf..1d8e003d2582 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c | |||
@@ -88,6 +88,14 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, | |||
88 | 88 | ||
89 | /* Set the bit to request direct access to DECO0 */ | 89 | /* Set the bit to request direct access to DECO0 */ |
90 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; | 90 | topregs = (struct caam_full __iomem *)ctrlpriv->ctrl; |
91 | |||
92 | if (ctrlpriv->virt_en == 1) | ||
93 | setbits32(&topregs->ctrl.deco_rsr, DECORSR_JR0); | ||
94 | |||
95 | while (!(rd_reg32(&topregs->ctrl.deco_rsr) & DECORSR_VALID) && | ||
96 | --timeout) | ||
97 | cpu_relax(); | ||
98 | |||
91 | setbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); | 99 | setbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); |
92 | 100 | ||
93 | while (!(rd_reg32(&topregs->ctrl.deco_rq) & DECORR_DEN0) && | 101 | while (!(rd_reg32(&topregs->ctrl.deco_rq) & DECORR_DEN0) && |
@@ -130,6 +138,9 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, | |||
130 | *status = rd_reg32(&topregs->deco.op_status_hi) & | 138 | *status = rd_reg32(&topregs->deco.op_status_hi) & |
131 | DECO_OP_STATUS_HI_ERR_MASK; | 139 | DECO_OP_STATUS_HI_ERR_MASK; |
132 | 140 | ||
141 | if (ctrlpriv->virt_en == 1) | ||
142 | clrbits32(&topregs->ctrl.deco_rsr, DECORSR_JR0); | ||
143 | |||
133 | /* Mark the DECO as free */ | 144 | /* Mark the DECO as free */ |
134 | clrbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); | 145 | clrbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE); |
135 | 146 | ||
@@ -378,6 +389,7 @@ static int caam_probe(struct platform_device *pdev) | |||
378 | #ifdef CONFIG_DEBUG_FS | 389 | #ifdef CONFIG_DEBUG_FS |
379 | struct caam_perfmon *perfmon; | 390 | struct caam_perfmon *perfmon; |
380 | #endif | 391 | #endif |
392 | u32 scfgr, comp_params; | ||
381 | u32 cha_vid_ls; | 393 | u32 cha_vid_ls; |
382 | 394 | ||
383 | ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(struct caam_drv_private), | 395 | ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(struct caam_drv_private), |
@@ -412,6 +424,33 @@ static int caam_probe(struct platform_device *pdev) | |||
412 | setbits32(&topregs->ctrl.mcr, MCFGR_WDENABLE | | 424 | setbits32(&topregs->ctrl.mcr, MCFGR_WDENABLE | |
413 | (sizeof(dma_addr_t) == sizeof(u64) ? MCFGR_LONG_PTR : 0)); | 425 | (sizeof(dma_addr_t) == sizeof(u64) ? MCFGR_LONG_PTR : 0)); |
414 | 426 | ||
427 | /* | ||
428 | * Read the Compile Time paramters and SCFGR to determine | ||
429 | * if Virtualization is enabled for this platform | ||
430 | */ | ||
431 | comp_params = rd_reg32(&topregs->ctrl.perfmon.comp_parms_ms); | ||
432 | scfgr = rd_reg32(&topregs->ctrl.scfgr); | ||
433 | |||
434 | ctrlpriv->virt_en = 0; | ||
435 | if (comp_params & CTPR_MS_VIRT_EN_INCL) { | ||
436 | /* VIRT_EN_INCL = 1 & VIRT_EN_POR = 1 or | ||
437 | * VIRT_EN_INCL = 1 & VIRT_EN_POR = 0 & SCFGR_VIRT_EN = 1 | ||
438 | */ | ||
439 | if ((comp_params & CTPR_MS_VIRT_EN_POR) || | ||
440 | (!(comp_params & CTPR_MS_VIRT_EN_POR) && | ||
441 | (scfgr & SCFGR_VIRT_EN))) | ||
442 | ctrlpriv->virt_en = 1; | ||
443 | } else { | ||
444 | /* VIRT_EN_INCL = 0 && VIRT_EN_POR_VALUE = 1 */ | ||
445 | if (comp_params & CTPR_MS_VIRT_EN_POR) | ||
446 | ctrlpriv->virt_en = 1; | ||
447 | } | ||
448 | |||
449 | if (ctrlpriv->virt_en == 1) | ||
450 | setbits32(&topregs->ctrl.jrstart, JRSTART_JR0_START | | ||
451 | JRSTART_JR1_START | JRSTART_JR2_START | | ||
452 | JRSTART_JR3_START); | ||
453 | |||
415 | if (sizeof(dma_addr_t) == sizeof(u64)) | 454 | if (sizeof(dma_addr_t) == sizeof(u64)) |
416 | if (of_device_is_compatible(nprop, "fsl,sec-v5.0")) | 455 | if (of_device_is_compatible(nprop, "fsl,sec-v5.0")) |
417 | dma_set_mask(dev, DMA_BIT_MASK(40)); | 456 | dma_set_mask(dev, DMA_BIT_MASK(40)); |
diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 6d85fcc5bd0a..97363db4e56e 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h | |||
@@ -82,6 +82,7 @@ struct caam_drv_private { | |||
82 | u8 total_jobrs; /* Total Job Rings in device */ | 82 | u8 total_jobrs; /* Total Job Rings in device */ |
83 | u8 qi_present; /* Nonzero if QI present in device */ | 83 | u8 qi_present; /* Nonzero if QI present in device */ |
84 | int secvio_irq; /* Security violation interrupt number */ | 84 | int secvio_irq; /* Security violation interrupt number */ |
85 | int virt_en; /* Virtualization enabled in CAAM */ | ||
85 | 86 | ||
86 | #define RNG4_MAX_HANDLES 2 | 87 | #define RNG4_MAX_HANDLES 2 |
87 | /* RNG4 block */ | 88 | /* RNG4 block */ |
diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index 7bb898d2e699..69e3562dc7d1 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h | |||
@@ -176,6 +176,8 @@ struct caam_perfmon { | |||
176 | u32 cha_rev_ls; /* CRNR - CHA Rev No. Least significant half*/ | 176 | u32 cha_rev_ls; /* CRNR - CHA Rev No. Least significant half*/ |
177 | #define CTPR_MS_QI_SHIFT 25 | 177 | #define CTPR_MS_QI_SHIFT 25 |
178 | #define CTPR_MS_QI_MASK (0x1ull << CTPR_MS_QI_SHIFT) | 178 | #define CTPR_MS_QI_MASK (0x1ull << CTPR_MS_QI_SHIFT) |
179 | #define CTPR_MS_VIRT_EN_INCL 0x00000001 | ||
180 | #define CTPR_MS_VIRT_EN_POR 0x00000002 | ||
179 | u32 comp_parms_ms; /* CTPR - Compile Parameters Register */ | 181 | u32 comp_parms_ms; /* CTPR - Compile Parameters Register */ |
180 | u32 comp_parms_ls; /* CTPR - Compile Parameters Register */ | 182 | u32 comp_parms_ls; /* CTPR - Compile Parameters Register */ |
181 | u64 rsvd1[2]; | 183 | u64 rsvd1[2]; |
@@ -309,9 +311,12 @@ struct caam_ctrl { | |||
309 | /* Bus Access Configuration Section 010-11f */ | 311 | /* Bus Access Configuration Section 010-11f */ |
310 | /* Read/Writable */ | 312 | /* Read/Writable */ |
311 | struct masterid jr_mid[4]; /* JRxLIODNR - JobR LIODN setup */ | 313 | struct masterid jr_mid[4]; /* JRxLIODNR - JobR LIODN setup */ |
312 | u32 rsvd3[12]; | 314 | u32 rsvd3[11]; |
315 | u32 jrstart; /* JRSTART - Job Ring Start Register */ | ||
313 | struct masterid rtic_mid[4]; /* RTICxLIODNR - RTIC LIODN setup */ | 316 | struct masterid rtic_mid[4]; /* RTICxLIODNR - RTIC LIODN setup */ |
314 | u32 rsvd4[7]; | 317 | u32 rsvd4[5]; |
318 | u32 deco_rsr; /* DECORSR - Deco Request Source */ | ||
319 | u32 rsvd11; | ||
315 | u32 deco_rq; /* DECORR - DECO Request */ | 320 | u32 deco_rq; /* DECORR - DECO Request */ |
316 | struct partid deco_mid[5]; /* DECOxLIODNR - 1 per DECO */ | 321 | struct partid deco_mid[5]; /* DECOxLIODNR - 1 per DECO */ |
317 | u32 rsvd5[22]; | 322 | u32 rsvd5[22]; |
@@ -352,7 +357,10 @@ struct caam_ctrl { | |||
352 | #define MCFGR_DMA_RESET 0x10000000 | 357 | #define MCFGR_DMA_RESET 0x10000000 |
353 | #define MCFGR_LONG_PTR 0x00010000 /* Use >32-bit desc addressing */ | 358 | #define MCFGR_LONG_PTR 0x00010000 /* Use >32-bit desc addressing */ |
354 | #define SCFGR_RDBENABLE 0x00000400 | 359 | #define SCFGR_RDBENABLE 0x00000400 |
360 | #define SCFGR_VIRT_EN 0x00008000 | ||
355 | #define DECORR_RQD0ENABLE 0x00000001 /* Enable DECO0 for direct access */ | 361 | #define DECORR_RQD0ENABLE 0x00000001 /* Enable DECO0 for direct access */ |
362 | #define DECORSR_JR0 0x00000001 /* JR to supply TZ, SDID, ICID */ | ||
363 | #define DECORSR_VALID 0x80000000 | ||
356 | #define DECORR_DEN0 0x00010000 /* DECO0 available for access*/ | 364 | #define DECORR_DEN0 0x00010000 /* DECO0 available for access*/ |
357 | 365 | ||
358 | /* AXI read cache control */ | 366 | /* AXI read cache control */ |
@@ -370,6 +378,12 @@ struct caam_ctrl { | |||
370 | #define MCFGR_AXIPRI 0x00000008 /* Assert AXI priority sideband */ | 378 | #define MCFGR_AXIPRI 0x00000008 /* Assert AXI priority sideband */ |
371 | #define MCFGR_BURST_64 0x00000001 /* Max burst size */ | 379 | #define MCFGR_BURST_64 0x00000001 /* Max burst size */ |
372 | 380 | ||
381 | /* JRSTART register offsets */ | ||
382 | #define JRSTART_JR0_START 0x00000001 /* Start Job ring 0 */ | ||
383 | #define JRSTART_JR1_START 0x00000002 /* Start Job ring 1 */ | ||
384 | #define JRSTART_JR2_START 0x00000004 /* Start Job ring 2 */ | ||
385 | #define JRSTART_JR3_START 0x00000008 /* Start Job ring 3 */ | ||
386 | |||
373 | /* | 387 | /* |
374 | * caam_job_ring - direct job ring setup | 388 | * caam_job_ring - direct job ring setup |
375 | * 1-4 possible per instantiation, base + 1000/2000/3000/4000 | 389 | * 1-4 possible per instantiation, base + 1000/2000/3000/4000 |