Tom Rini | 8b0c8a1 | 2018-05-06 18:27:01 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2018, STMicroelectronics - All Rights Reserved |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <config.h> |
| 7 | #include <common.h> |
Marek Vasut | 5bfe0a1 | 2023-05-18 00:02:39 +0200 | [diff] [blame] | 8 | #include <power/pmic.h> |
| 9 | #include <power/stpmic1.h> |
Patrick Delaunay | f2f25c3 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 10 | #include <asm/arch/sys_proto.h> |
| 11 | #include "../common/stpmic1.h" |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 12 | |
Patrick Delaunay | 08c891a | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 13 | /* board early initialisation in board_f: need to use global variable */ |
| 14 | static u32 opp_voltage_mv __section(".data"); |
| 15 | |
| 16 | void board_vddcore_init(u32 voltage_mv) |
| 17 | { |
Simon Glass | e91ac4c | 2021-07-10 21:14:24 -0600 | [diff] [blame] | 18 | if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER)) |
Patrick Delaunay | 08c891a | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 19 | opp_voltage_mv = voltage_mv; |
| 20 | } |
| 21 | |
Patrick Delaunay | f2f25c3 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 22 | int board_early_init_f(void) |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 23 | { |
Marek Vasut | 5bfe0a1 | 2023-05-18 00:02:39 +0200 | [diff] [blame] | 24 | 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 Delaunay | bff284f | 2019-07-30 19:16:20 +0200 | [diff] [blame] | 33 | |
Patrick Delaunay | f2f25c3 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 34 | return 0; |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 35 | } |
Patrick Delaunay | 79c0791 | 2020-05-25 12:19:49 +0200 | [diff] [blame] | 36 | |