Tom Rini | 4549e78 | 2018-05-06 18:27:01 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2018, STMicroelectronics - All Rights Reserved |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <config.h> |
| 7 | #include <common.h> |
Patrick Delaunay | d1a4b09 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 8 | #include <init.h> |
Patrick Delaunay | 4fb4681 | 2020-05-25 12:19:49 +0200 | [diff] [blame] | 9 | #include <asm/io.h> |
Patrick Delaunay | d1a4b09 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 10 | #include <asm/arch/sys_proto.h> |
Patrick Delaunay | 4fb4681 | 2020-05-25 12:19:49 +0200 | [diff] [blame] | 11 | #include <linux/bitops.h> |
| 12 | #include <linux/delay.h> |
Patrick Delaunay | d1a4b09 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 13 | #include "../common/stpmic1.h" |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 14 | |
Patrick Delaunay | 2f23832 | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 15 | /* board early initialisation in board_f: need to use global variable */ |
| 16 | static u32 opp_voltage_mv __section(".data"); |
| 17 | |
| 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 | |
Patrick Delaunay | d1a4b09 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 24 | int board_early_init_f(void) |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 25 | { |
Patrick Delaunay | d1a4b09 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 26 | if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT)) |
Patrick Delaunay | 2f23832 | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 27 | stpmic1_init(opp_voltage_mv); |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 28 | |
Patrick Delaunay | d1a4b09 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 29 | return 0; |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 30 | } |
Patrick Delaunay | 4fb4681 | 2020-05-25 12:19:49 +0200 | [diff] [blame] | 31 | |
| 32 | #ifdef CONFIG_DEBUG_UART_BOARD_INIT |
| 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 |