blob: d63dffd97e87f4a74b5e449e1f3fe9124fb11a50 [file] [log] [blame]
Tom Rini8b0c8a12018-05-06 18:27:01 -04001// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +01002/*
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +01004 */
5
6#include <config.h>
Marek Vasut5bfe0a12023-05-18 00:02:39 +02007#include <power/pmic.h>
8#include <power/stpmic1.h>
Patrick Delaunayf2f25c32020-05-25 12:19:46 +02009#include <asm/arch/sys_proto.h>
10#include "../common/stpmic1.h"
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010011
Patrick Delaunay08c891a2020-05-25 12:19:47 +020012/* board early initialisation in board_f: need to use global variable */
13static u32 opp_voltage_mv __section(".data");
14
15void board_vddcore_init(u32 voltage_mv)
16{
Simon Glasse91ac4c2021-07-10 21:14:24 -060017 if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER))
Patrick Delaunay08c891a2020-05-25 12:19:47 +020018 opp_voltage_mv = voltage_mv;
19}
20
Patrick Delaunayf2f25c32020-05-25 12:19:46 +020021int board_early_init_f(void)
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010022{
Marek Vasut5bfe0a12023-05-18 00:02:39 +020023 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 }
Patrick Delaunaybff284f2019-07-30 19:16:20 +020032
Patrick Delaunayf2f25c32020-05-25 12:19:46 +020033 return 0;
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010034}
Patrick Delaunay79c07912020-05-25 12:19:49 +020035