debug_uart.c 754 B

1234567891011121314151617181920212223242526272829
  1. // SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
  2. /*
  3. * Copyright (C) 2022, STMicroelectronics - All Rights Reserved
  4. */
  5. #include <config.h>
  6. #include <debug_uart.h>
  7. #include <asm/io.h>
  8. #include <asm/arch/stm32.h>
  9. #include <linux/bitops.h>
  10. #define RCC_MP_APB1ENSETR (STM32_RCC_BASE + 0x0A00)
  11. #define RCC_MP_AHB4ENSETR (STM32_RCC_BASE + 0x0A28)
  12. #define GPIOG_BASE 0x50008000
  13. void board_debug_uart_init(void)
  14. {
  15. if (CONFIG_DEBUG_UART_BASE == STM32_UART4_BASE) {
  16. /* UART4 clock enable */
  17. setbits_le32(RCC_MP_APB1ENSETR, BIT(16));
  18. /* GPIOG clock enable */
  19. writel(BIT(6), RCC_MP_AHB4ENSETR);
  20. /* GPIO configuration for ST boards: Uart4 TX = G11 */
  21. writel(0xffbfffff, GPIOG_BASE + 0x00);
  22. writel(0x00006000, GPIOG_BASE + 0x24);
  23. }
  24. }