bsec: move bsec_mode_is_closed_device() service to platform
authorLionel Debieve <lionel.debieve@st.com>
Mon, 16 Sep 2019 10:17:09 +0000 (12:17 +0200)
committerLionel Debieve <lionel.debieve@st.com>
Fri, 20 Sep 2019 21:21:10 +0000 (23:21 +0200)
This BSEC service is a platform specific service. Implementation
moved to the platform part.

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Change-Id: I1f70ed48a446860498ed111acce01187568538c9

drivers/st/bsec/bsec.c
include/drivers/st/bsec.h
plat/st/common/include/stm32mp_common.h
plat/st/stm32mp1/stm32mp1_private.c

index b3c15ee8bab354fd0c86c435c4a9499de07699ac..01c369edcd7eefe64219c0f9af5bcf9b732cefe9 100644 (file)
@@ -840,22 +840,6 @@ static uint32_t bsec_power_safmem(bool power)
        return BSEC_OK;
 }
 
-/*
- * bsec_mode_is_closed_device: read OTP secure sub-mode.
- * return: false if open_device and true of closed_device.
- */
-bool bsec_mode_is_closed_device(void)
-{
-       uint32_t value;
-
-       if ((bsec_shadow_register(DATA0_OTP) != BSEC_OK) ||
-           (bsec_read_otp(&value, DATA0_OTP) != BSEC_OK)) {
-               return true;
-       }
-
-       return (value & DATA0_OTP_SECURED) == DATA0_OTP_SECURED;
-}
-
 /*
  * bsec_shadow_read_otp: Load OTP from SAFMEM and provide its value
  * otp_value: read value.
@@ -894,7 +878,7 @@ uint32_t bsec_check_nsec_access_rights(uint32_t otp)
 
        if (otp >= STM32MP1_UPPER_OTP_START) {
                /* Check if BSEC is in OTP-SECURED closed_device state. */
-               if (bsec_mode_is_closed_device()) {
+               if (stm32mp_is_closed_device()) {
                        if (!non_secure_can_access(otp)) {
                                return BSEC_ERROR;
                        }
index 2171550b3c6a09cf3050dd541ae702338a288a43..d833e7ab2720486db829c44574b64916711e2896 100644 (file)
@@ -199,7 +199,6 @@ bool bsec_read_sp_lock(uint32_t otp);
 bool bsec_wr_lock(uint32_t otp);
 uint32_t bsec_otp_lock(uint32_t service, uint32_t value);
 
-bool bsec_mode_is_closed_device(void);
 uint32_t bsec_shadow_read_otp(uint32_t *otp_value, uint32_t word);
 uint32_t bsec_check_nsec_access_rights(uint32_t otp);
 
index e20308ee2f5726ceb43e54e17d888d39cbe06564..59657fdc2c539a547ffaf43f8070344ac9f0b20e 100644 (file)
@@ -19,6 +19,7 @@ void stm32mp_save_boot_ctx_address(uintptr_t address);
 uintptr_t stm32mp_get_boot_ctx_address(void);
 
 bool stm32mp_is_single_core(void);
+bool stm32mp_is_closed_device(void);
 
 /* Return the base address of the DDR controller */
 uintptr_t stm32mp_ddrctrl_base(void);
index 38ebcef64c0d1a6b16ca470c320115bab79ff969..e2dcd2af730cf37412aaaab6e53d6c807e9923ae 100644 (file)
@@ -278,6 +278,19 @@ bool stm32mp_is_single_core(void)
        return ret;
 }
 
+/* Return true when device is in closed state */
+bool stm32mp_is_closed_device(void)
+{
+       uint32_t value;
+
+       if ((bsec_shadow_register(DATA0_OTP) != BSEC_OK) ||
+           (bsec_read_otp(&value, DATA0_OTP) != BSEC_OK)) {
+               return true;
+       }
+
+       return (value & DATA0_OTP_SECURED) == DATA0_OTP_SECURED;
+}
+
 uint32_t stm32_iwdg_get_instance(uintptr_t base)
 {
        switch (base) {