1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2 /*
3  * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
4  * Copyright (C) 2020 Engicam S.r.l.
5  * Copyright (C) 2020 Amarula Solutions(India)
6  */
7 
8 #include <common.h>
9 #include <asm/io.h>
10 
11 /* board early initialisation in board_f: need to use global variable */
12 static u32 opp_voltage_mv __section(".data");
13 
board_vddcore_init(u32 voltage_mv)14 void board_vddcore_init(u32 voltage_mv)
15 {
16 	if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT))
17 		opp_voltage_mv = voltage_mv;
18 }
19 
board_early_init_f(void)20 int board_early_init_f(void)
21 {
22 	return 0;
23 }
24 
25 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
board_debug_uart_init(void)26 void board_debug_uart_init(void)
27 {
28 #if (CONFIG_DEBUG_UART_BASE == STM32_UART4_BASE)
29 
30 #define RCC_MP_APB1ENSETR (STM32_RCC_BASE + 0x0A00)
31 #define RCC_MP_AHB4ENSETR (STM32_RCC_BASE + 0x0A28)
32 
33 	/* UART4 clock enable */
34 	setbits_le32(RCC_MP_APB1ENSETR, BIT(16));
35 
36 #define GPIOG_BASE 0x50008000
37 	/* GPIOG clock enable */
38 	writel(BIT(6), RCC_MP_AHB4ENSETR);
39 	/* GPIO configuration for ST boards: Uart4 TX = G11 */
40 	writel(0xffbfffff, GPIOG_BASE + 0x00);
41 	writel(0x00006000, GPIOG_BASE + 0x24);
42 #else
43 
44 #error("CONFIG_DEBUG_UART_BASE: not supported value")
45 
46 #endif
47 }
48 #endif
49