]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: stm32mp: add defines for BSEC_LOCK status in stm32key command
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Thu, 15 Sep 2022 16:11:38 +0000 (18:11 +0200)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Fri, 23 Sep 2022 12:28:25 +0000 (14:28 +0200)
Add defines for value used in stm32key for BSEC permanent lock status
and error.

This patch is a preliminary step to support more lock status in BSEC
driver.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
arch/arm/mach-stm32mp/cmd_stm32key.c

index 68f28922d1e7a9005feb1cf505dbbaa0bf6c0e33..1899d91ecb53b3fb640b33e4dbf703ccf395ec0b 100644 (file)
@@ -19,6 +19,9 @@
 #define STM32_OTP_HASH_KEY_START       24
 #define STM32_OTP_HASH_KEY_SIZE                8
 
+#define BSEC_LOCK_ERROR                        (-1)
+#define BSEC_LOCK_PERM                 BIT(0)
+
 static int get_misc_dev(struct udevice **dev)
 {
        int ret;
@@ -60,14 +63,14 @@ static int read_hash_otp(bool print, bool *locked, bool *closed)
                        val = ~0x0;
                ret = misc_read(dev, STM32_BSEC_LOCK(word), &lock, 4);
                if (ret != 4)
-                       lock = -1;
+                       lock = BSEC_LOCK_ERROR;
                if (print)
-                       printf("OTP HASH %i: %x lock : %d\n", word, val, lock);
+                       printf("OTP HASH %i: %x lock : %x\n", word, val, lock);
                if (val == ~0x0)
                        nb_invalid++;
                else if (val == 0x0)
                        nb_zero++;
-               if (lock == 1)
+               if (lock & BSEC_LOCK_PERM)
                        nb_lock++;
        }
 
@@ -77,13 +80,13 @@ static int read_hash_otp(bool print, bool *locked, bool *closed)
                val = 0x0;
        ret = misc_read(dev, STM32_BSEC_LOCK(word), &lock, 4);
        if (ret != 4)
-               lock = -1;
+               lock = BSEC_LOCK_ERROR;
 
        status = (val & STM32_OTP_CLOSE_MASK) == STM32_OTP_CLOSE_MASK;
        if (closed)
                *closed = status;
        if (print)
-               printf("OTP %d: closed status: %d lock : %d\n", word, status, lock);
+               printf("OTP %d: closed status: %d lock : %x\n", word, status, lock);
 
        status = (nb_lock == STM32_OTP_HASH_KEY_SIZE);
        if (locked)
@@ -128,7 +131,7 @@ static int fuse_hash_value(u32 addr, bool print)
                        return ret;
                }
                /* on success, lock the OTP for HASH key */
-               val = 1;
+               val = BSEC_LOCK_PERM;
                ret = misc_write(dev, STM32_BSEC_LOCK(word), &val, 4);
                if (ret != 4) {
                        log_err("Lock OTP %i failed\n", word);