blob: 8b4a529f759a28bd3a00302686c4e95d5d488349 [file] [log] [blame]
Tom Rini4549e782018-05-06 18:27:01 -04001// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
Patrick Delaunayf8598d92018-03-12 10:46:18 +01002/*
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
Patrick Delaunayf8598d92018-03-12 10:46:18 +01004 */
5
6#include <config.h>
7#include <common.h>
Marek Vasutb3d97f82023-05-18 00:02:39 +02008#include <power/pmic.h>
9#include <power/stpmic1.h>
Patrick Delaunayd1a4b092020-05-25 12:19:46 +020010#include <asm/arch/sys_proto.h>
11#include "../common/stpmic1.h"
Patrick Delaunayf8598d92018-03-12 10:46:18 +010012
Patrick Delaunay2f238322020-05-25 12:19:47 +020013/* board early initialisation in board_f: need to use global variable */
14static u32 opp_voltage_mv __section(".data");
15
16void board_vddcore_init(u32 voltage_mv)
17{
Simon Glass933b2f02021-07-10 21:14:24 -060018 if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER))
Patrick Delaunay2f238322020-05-25 12:19:47 +020019 opp_voltage_mv = voltage_mv;
20}
21
Patrick Delaunayd1a4b092020-05-25 12:19:46 +020022int board_early_init_f(void)
Patrick Delaunayf8598d92018-03-12 10:46:18 +010023{
Marek Vasutb3d97f82023-05-18 00:02:39 +020024 if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER)) {
25 struct udevice *dev = stpmic1_init(opp_voltage_mv);
26
27 /* Keep vdd on during the reset cycle */
28 pmic_clrsetbits(dev,
29 STPMIC1_BUCKS_MRST_CR,
30 STPMIC1_MRST_BUCK(STPMIC1_BUCK3),
31 STPMIC1_MRST_BUCK(STPMIC1_BUCK3));
32 }
Patrick Delaunayf8598d92018-03-12 10:46:18 +010033
Patrick Delaunayd1a4b092020-05-25 12:19:46 +020034 return 0;
Patrick Delaunayf8598d92018-03-12 10:46:18 +010035}
Patrick Delaunay4fb46812020-05-25 12:19:49 +020036