Prepare v2024.10
[platform/kernel/u-boot.git] / board / st / stm32mp1 / spl.c
1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2 /*
3  * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
4  */
5
6 #include <config.h>
7 #include <power/pmic.h>
8 #include <power/stpmic1.h>
9 #include <asm/arch/sys_proto.h>
10 #include "../common/stpmic1.h"
11
12 /* board early initialisation in board_f: need to use global variable */
13 static u32 opp_voltage_mv __section(".data");
14
15 void board_vddcore_init(u32 voltage_mv)
16 {
17         if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER))
18                 opp_voltage_mv = voltage_mv;
19 }
20
21 int board_early_init_f(void)
22 {
23         if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER)) {
24                 struct udevice *dev = stpmic1_init(opp_voltage_mv);
25
26                 /* Keep vdd on during the reset cycle */
27                 pmic_clrsetbits(dev,
28                                 STPMIC1_BUCKS_MRST_CR,
29                                 STPMIC1_MRST_BUCK(STPMIC1_BUCK3),
30                                 STPMIC1_MRST_BUCK(STPMIC1_BUCK3));
31         }
32
33         return 0;
34 }
35