aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/caam/regs.h
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-08-20 13:23:59 -0700
committerHerbert Xu <herbert@gondor.apana.org.au>2019-08-30 18:05:30 +1000
commita1cf573ee95d5a15bdd1d33310d179d92b229dd1 (patch)
tree96a1ac431cc4109999c499f574b10684b39a7714 /drivers/crypto/caam/regs.h
parentcrypto: caam - don't hardcode inpentry size (diff)
downloadlinux-dev-a1cf573ee95d5a15bdd1d33310d179d92b229dd1.tar.xz
linux-dev-a1cf573ee95d5a15bdd1d33310d179d92b229dd1.zip
crypto: caam - select DMA address size at runtime
i.MX8 mScale SoC still use 32-bit addresses in its CAAM implmentation, so we can't rely on sizeof(dma_addr_t) to detemine CAAM pointer size. Convert the code to query CTPR and MCFGR for that during driver probing. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Chris Spencer <christopher.spencer@sea.co.uk> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Chris Healy <cphealy@gmail.com> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Horia Geantă <horia.geanta@nxp.com> Cc: Aymen Sghaier <aymen.sghaier@nxp.com> Cc: Leonard Crestez <leonard.crestez@nxp.com> Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--drivers/crypto/caam/regs.h40
1 files changed, 30 insertions, 10 deletions
diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h
index 6dbb269a3e7e..05127b70527d 100644
--- a/drivers/crypto/caam/regs.h
+++ b/drivers/crypto/caam/regs.h
@@ -191,7 +191,8 @@ static inline u64 caam_dma64_to_cpu(u64 value)
static inline u64 cpu_to_caam_dma(u64 value)
{
- if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
+ if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
+ caam_ptr_sz == sizeof(u64))
return cpu_to_caam_dma64(value);
else
return cpu_to_caam32(value);
@@ -199,7 +200,8 @@ static inline u64 cpu_to_caam_dma(u64 value)
static inline u64 caam_dma_to_cpu(u64 value)
{
- if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
+ if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
+ caam_ptr_sz == sizeof(u64))
return caam_dma64_to_cpu(value);
else
return caam32_to_cpu(value);
@@ -213,13 +215,24 @@ static inline u64 caam_dma_to_cpu(u64 value)
static inline void jr_outentry_get(void *outring, int hw_idx, dma_addr_t *desc,
u32 *jrstatus)
{
- struct {
- dma_addr_t desc;/* Pointer to completed descriptor */
- u32 jrstatus; /* Status for completed descriptor */
- } __packed *outentry = outring;
- *desc = outentry[hw_idx].desc;
- *jrstatus = outentry[hw_idx].jrstatus;
+ if (caam_ptr_sz == sizeof(u32)) {
+ struct {
+ u32 desc;
+ u32 jrstatus;
+ } __packed *outentry = outring;
+
+ *desc = outentry[hw_idx].desc;
+ *jrstatus = outentry[hw_idx].jrstatus;
+ } else {
+ struct {
+ dma_addr_t desc;/* Pointer to completed descriptor */
+ u32 jrstatus; /* Status for completed descriptor */
+ } __packed *outentry = outring;
+
+ *desc = outentry[hw_idx].desc;
+ *jrstatus = outentry[hw_idx].jrstatus;
+ }
}
#define SIZEOF_JR_OUTENTRY (caam_ptr_sz + sizeof(u32))
@@ -246,9 +259,15 @@ static inline u32 jr_outentry_jrstatus(void *outring, int hw_idx)
static inline void jr_inpentry_set(void *inpring, int hw_idx, dma_addr_t val)
{
- dma_addr_t *inpentry = inpring;
+ if (caam_ptr_sz == sizeof(u32)) {
+ u32 *inpentry = inpring;
- inpentry[hw_idx] = val;
+ inpentry[hw_idx] = val;
+ } else {
+ dma_addr_t *inpentry = inpring;
+
+ inpentry[hw_idx] = val;
+ }
}
#define SIZEOF_JR_INPENTRY caam_ptr_sz
@@ -380,6 +399,7 @@ struct caam_perfmon {
u32 cha_rev_ls; /* CRNR - CHA Rev No. Least significant half*/
#define CTPR_MS_QI_SHIFT 25
#define CTPR_MS_QI_MASK (0x1ull << CTPR_MS_QI_SHIFT)
+#define CTPR_MS_PS BIT(17)
#define CTPR_MS_DPAA2 BIT(13)
#define CTPR_MS_VIRT_EN_INCL 0x00000001
#define CTPR_MS_VIRT_EN_POR 0x00000002