crypto: ccree - add HW engine config check
authorGilad Ben-Yossef <gilad@benyossef.com>
Mon, 17 Jun 2019 08:46:30 +0000 (11:46 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 27 Jun 2019 06:28:00 +0000 (14:28 +0800)
Add check to verify the stated device tree HW configuration
matches the HW.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccree/cc_driver.c
drivers/crypto/ccree/cc_driver.h
drivers/crypto/ccree/cc_host_regs.h

index 667bc73d7a00b671c5a1bcfbc15c7fcfaf819644..980aa04b655b67f5b0eda536421c5298a32a5d1e 100644 (file)
@@ -408,6 +408,24 @@ static int init_cc_resources(struct platform_device *plat_dev)
                }
                sig_cidr = val;
 
+               /* Check HW engine configuration */
+               val = cc_ioread(new_drvdata, CC_REG(HOST_REMOVE_INPUT_PINS));
+               switch (val) {
+               case CC_PINS_FULL:
+                       /* This is fine */
+                       break;
+               case CC_PINS_SLIM:
+                       if (new_drvdata->std_bodies & CC_STD_NIST) {
+                               dev_warn(dev, "703 mode forced due to HW configuration.\n");
+                               new_drvdata->std_bodies = CC_STD_OSCCA;
+                       }
+                       break;
+               default:
+                       dev_err(dev, "Unsupported engines configration.\n");
+                       rc = -EINVAL;
+                       goto post_clk_err;
+               }
+
                /* Check security disable state */
                val = cc_ioread(new_drvdata, CC_REG(SECURITY_DISABLED));
                val &= CC_SECURITY_DISABLED_MASK;
index 579eecae4825a7fcb47f5bfbd835272777b1143f..7cd99380bf1ff9abe175f374f9ad77062cfc1f2b 100644 (file)
@@ -53,6 +53,9 @@ enum cc_std_body {
 
 #define CC_COHERENT_CACHE_PARAMS 0xEEE
 
+#define CC_PINS_FULL   0x0
+#define CC_PINS_SLIM   0x9F
+
 /* Maximum DMA mask supported by IP */
 #define DMA_BIT_MASK_LEN 48
 
index ad1acb105f2d1c551b8eca81a23c9a3ea841c6d8..efe3e1d8b87b8622754b46658e92c4627967bae7 100644 (file)
 #define CC_HOST_POWER_DOWN_EN_REG_OFFSET       0xA78UL
 #define CC_HOST_POWER_DOWN_EN_VALUE_BIT_SHIFT  0x0UL
 #define CC_HOST_POWER_DOWN_EN_VALUE_BIT_SIZE   0x1UL
+#define CC_HOST_REMOVE_INPUT_PINS_REG_OFFSET   0x0A7CUL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_AES_ENGINE_BIT_SHIFT  0x0UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_AES_ENGINE_BIT_SIZE   0x1UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_AES_MAC_ENGINE_BIT_SHIFT      0x1UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_AES_MAC_ENGINE_BIT_SIZE       0x1UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_GHASH_ENGINE_BIT_SHIFT        0x2UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_GHASH_ENGINE_BIT_SIZE 0x1UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_DES_ENGINE_BIT_SHIFT  0x3UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_DES_ENGINE_BIT_SIZE   0x1UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_HASH_ENGINE_BIT_SHIFT 0x4UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_HASH_ENGINE_BIT_SIZE  0x1UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_SM3_ENGINE_BIT_SHIFT  0x5UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_SM3_ENGINE_BIT_SIZE   0x1UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_SM4_ENGINE_BIT_SHIFT  0x6UL
+#define CC_HOST_REMOVE_INPUT_PINS_REMOVE_SM4_ENGINE_BIT_SIZE   0x1UL
+#define CC_HOST_REMOVE_INPUT_PINS_OTP_DISCONNECTED_BIT_SHIFT   0x7UL
+#define CC_HOST_REMOVE_INPUT_PINS_OTP_DISCONNECTED_BIT_SIZE    0x1UL
 // --------------------------------------
 // BLOCK: ID_REGISTERS
 // --------------------------------------