blob: cf8a91eb4125a1a6716668b5d7d2b7c49fc6b5a0 [file] [log] [blame]
Yann Gautier41934662018-07-20 11:36:05 +02001/*
Yann Gautiera2e2a302019-02-14 11:13:39 +01002 * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
Yann Gautier41934662018-07-20 11:36:05 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Yann Gautier41934662018-07-20 11:36:05 +02007#include <errno.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Yann Gautier41934662018-07-20 11:36:05 +02009#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010
11#include <drivers/st/stm32mp1_clk.h>
12#include <dt-bindings/clock/stm32mp1-clks.h>
13#include <lib/mmio.h>
14
Yann Gautier41934662018-07-20 11:36:05 +020015#include <stm32mp1_context.h>
16
17#define TAMP_BOOT_ITF_BACKUP_REG_ID U(20)
18#define TAMP_BOOT_ITF_MASK U(0x0000FF00)
19#define TAMP_BOOT_ITF_SHIFT 8
20
21int stm32_save_boot_interface(uint32_t interface, uint32_t instance)
22{
Yann Gautier41934662018-07-20 11:36:05 +020023 uint32_t bkpr_itf_idx = tamp_bkpr(TAMP_BOOT_ITF_BACKUP_REG_ID);
24
Yann Gautiere4a3c352019-02-14 10:53:33 +010025 stm32mp_clk_enable(RTCAPB);
Yann Gautier41934662018-07-20 11:36:05 +020026
27 mmio_clrsetbits_32(bkpr_itf_idx,
28 TAMP_BOOT_ITF_MASK,
29 ((interface << 4) | (instance & 0xFU)) <<
30 TAMP_BOOT_ITF_SHIFT);
31
Yann Gautiere4a3c352019-02-14 10:53:33 +010032 stm32mp_clk_disable(RTCAPB);
Yann Gautier41934662018-07-20 11:36:05 +020033
34 return 0;
35}