Yann Gautier | 4193466 | 2018-07-20 11:36:05 +0200 | [diff] [blame] | 1 | /* |
Yann Gautier | a2e2a30 | 2019-02-14 11:13:39 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. |
Yann Gautier | 4193466 | 2018-07-20 11:36:05 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Yann Gautier | 4193466 | 2018-07-20 11:36:05 +0200 | [diff] [blame] | 7 | #include <errno.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
Yann Gautier | 4193466 | 2018-07-20 11:36:05 +0200 | [diff] [blame] | 9 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | |
| 11 | #include <drivers/st/stm32mp1_clk.h> |
| 12 | #include <dt-bindings/clock/stm32mp1-clks.h> |
| 13 | #include <lib/mmio.h> |
| 14 | |
Yann Gautier | 4193466 | 2018-07-20 11:36:05 +0200 | [diff] [blame] | 15 | #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 | |
| 21 | int stm32_save_boot_interface(uint32_t interface, uint32_t instance) |
| 22 | { |
Yann Gautier | 4193466 | 2018-07-20 11:36:05 +0200 | [diff] [blame] | 23 | uint32_t bkpr_itf_idx = tamp_bkpr(TAMP_BOOT_ITF_BACKUP_REG_ID); |
| 24 | |
Yann Gautier | e4a3c35 | 2019-02-14 10:53:33 +0100 | [diff] [blame] | 25 | stm32mp_clk_enable(RTCAPB); |
Yann Gautier | 4193466 | 2018-07-20 11:36:05 +0200 | [diff] [blame] | 26 | |
| 27 | mmio_clrsetbits_32(bkpr_itf_idx, |
| 28 | TAMP_BOOT_ITF_MASK, |
| 29 | ((interface << 4) | (instance & 0xFU)) << |
| 30 | TAMP_BOOT_ITF_SHIFT); |
| 31 | |
Yann Gautier | e4a3c35 | 2019-02-14 10:53:33 +0100 | [diff] [blame] | 32 | stm32mp_clk_disable(RTCAPB); |
Yann Gautier | 4193466 | 2018-07-20 11:36:05 +0200 | [diff] [blame] | 33 | |
| 34 | return 0; |
| 35 | } |