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> |
Marek Vasut | 5bfe0a1 | 2023-05-18 00:02:39 +0200 | [diff] [blame] | 7 | #include <power/pmic.h> |
| 8 | #include <power/stpmic1.h> |
Patrick Delaunay | f2f25c3 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 9 | #include <asm/arch/sys_proto.h> |
| 10 | #include "../common/stpmic1.h" |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 11 | |
Patrick Delaunay | 08c891a | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 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 | { |
Simon Glass | e91ac4c | 2021-07-10 21:14:24 -0600 | [diff] [blame] | 17 | if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER)) |
Patrick Delaunay | 08c891a | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 18 | opp_voltage_mv = voltage_mv; |
| 19 | } |
| 20 | |
Patrick Delaunay | f2f25c3 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 21 | int board_early_init_f(void) |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 22 | { |
Marek Vasut | 5bfe0a1 | 2023-05-18 00:02:39 +0200 | [diff] [blame] | 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 | } |
Patrick Delaunay | bff284f | 2019-07-30 19:16:20 +0200 | [diff] [blame] | 32 | |
Patrick Delaunay | f2f25c3 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 33 | return 0; |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 34 | } |
Patrick Delaunay | 79c0791 | 2020-05-25 12:19:49 +0200 | [diff] [blame] | 35 | |