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