aboutsummaryrefslogtreecommitdiff
path: root/plat/st/stm32mp1/stm32mp1_context.c
diff options
context:
space:
mode:
authorYann Gautier <yann.gautier@st.com>2018-07-20 11:36:05 +0200
committerYann Gautier <yann.gautier@st.com>2018-07-24 17:14:22 +0200
commite58a53fb72117a6c0dd28dcb4034e83e5e321893 (patch)
treecfe2d2369d95a04fdff14e64933ff797818f5038 /plat/st/stm32mp1/stm32mp1_context.c
parent6a339a49522db3ebb7eb44dec5772941b68372b6 (diff)
downloadtrusted-firmware-a-e58a53fb72117a6c0dd28dcb4034e83e5e321893.tar.gz
stm32mp1: save boot information in backup registers
This will be used by BL33 to get boot device and instance. Signed-off-by: Yann Gautier <yann.gautier@st.com> Signed-off-by: Mathieu Belou <mathieu.belou@st.com> Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Diffstat (limited to 'plat/st/stm32mp1/stm32mp1_context.c')
-rw-r--r--plat/st/stm32mp1/stm32mp1_context.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/plat/st/stm32mp1/stm32mp1_context.c b/plat/st/stm32mp1/stm32mp1_context.c
new file mode 100644
index 0000000000..245fd17d75
--- /dev/null
+++ b/plat/st/stm32mp1/stm32mp1_context.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <dt-bindings/clock/stm32mp1-clks.h>
+#include <errno.h>
+#include <mmio.h>
+#include <platform_def.h>
+#include <stm32mp1_clk.h>
+#include <stm32mp1_context.h>
+
+#define TAMP_BOOT_ITF_BACKUP_REG_ID U(20)
+#define TAMP_BOOT_ITF_MASK U(0x0000FF00)
+#define TAMP_BOOT_ITF_SHIFT 8
+
+int stm32_save_boot_interface(uint32_t interface, uint32_t instance)
+{
+ uint32_t tamp_clk_off = 0;
+ uint32_t bkpr_itf_idx = tamp_bkpr(TAMP_BOOT_ITF_BACKUP_REG_ID);
+
+ if (!stm32mp1_clk_is_enabled(RTCAPB)) {
+ tamp_clk_off = 1;
+ if (stm32mp1_clk_enable(RTCAPB) != 0) {
+ return -EINVAL;
+ }
+ }
+
+ mmio_clrsetbits_32(bkpr_itf_idx,
+ TAMP_BOOT_ITF_MASK,
+ ((interface << 4) | (instance & 0xFU)) <<
+ TAMP_BOOT_ITF_SHIFT);
+
+ if (tamp_clk_off != 0U) {
+ if (stm32mp1_clk_disable(RTCAPB) != 0) {
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}