From 1c37d0c1d378769249c797de5b13d73cf6f17a53 Mon Sep 17 00:00:00 2001 From: Nicolas Le Bayon Date: Thu, 26 Nov 2020 09:57:09 +0100 Subject: [PATCH] feat(stm32mp1): update CFG0 OTP for STM32MP13 This field is now declared on the 10 LSB bits on STM32MP13. Several possible values are specified in the Reference Manual, and indicate an open or closed device. Other values lead to a system panic. Change-Id: I697124a21db66a56e7e223d601aa7cf44bb183c4 Signed-off-by: Nicolas Le Bayon --- plat/st/stm32mp1/stm32mp1_def.h | 10 ++++++++++ plat/st/stm32mp1/stm32mp1_private.c | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/plat/st/stm32mp1/stm32mp1_def.h b/plat/st/stm32mp1/stm32mp1_def.h index dd4559ffd..6fde3b5ba 100644 --- a/plat/st/stm32mp1/stm32mp1_def.h +++ b/plat/st/stm32mp1/stm32mp1_def.h @@ -431,7 +431,17 @@ enum ddr_type { /* OTP mask */ /* CFG0 */ +#if STM32MP13 +#define CFG0_OTP_MODE_MASK GENMASK_32(9, 0) +#define CFG0_OTP_MODE_SHIFT 0 +#define CFG0_OPEN_DEVICE 0x17U +#define CFG0_CLOSED_DEVICE 0x3FU +#define CFG0_CLOSED_DEVICE_NO_BOUNDARY_SCAN 0x17FU +#define CFG0_CLOSED_DEVICE_NO_JTAG 0x3FFU +#endif +#if STM32MP15 #define CFG0_CLOSED_DEVICE BIT(6) +#endif /* PART NUMBER */ #if STM32MP13 diff --git a/plat/st/stm32mp1/stm32mp1_private.c b/plat/st/stm32mp1/stm32mp1_private.c index 738cd8cc4..a9b9f4c5a 100644 --- a/plat/st/stm32mp1/stm32mp1_private.c +++ b/plat/st/stm32mp1/stm32mp1_private.c @@ -549,7 +549,23 @@ bool stm32mp_is_closed_device(void) return true; } +#if STM32MP13 + value = (value & CFG0_OTP_MODE_MASK) >> CFG0_OTP_MODE_SHIFT; + + switch (value) { + case CFG0_OPEN_DEVICE: + return false; + case CFG0_CLOSED_DEVICE: + case CFG0_CLOSED_DEVICE_NO_BOUNDARY_SCAN: + case CFG0_CLOSED_DEVICE_NO_JTAG: + return true; + default: + panic(); + } +#endif +#if STM32MP15 return (value & CFG0_CLOSED_DEVICE) == CFG0_CLOSED_DEVICE; +#endif } /* Return true when device supports secure boot */