linux_dsm_epyc7002/arch/arm/include/debug/stm32.S
Gerald Baeza d88bb418b7 ARM: stm32: debug: add low-level debug support
This adds low-level debug support on USART1 for STM32F4
and STM32F7.
Compiled via 'CONFIG_DEBUG_LL' and 'CONFIG_EARLY_PRINTK'.
Enabled via 'earlyprintk' in bootargs.

Signed-off-by: Gerald Baeza <gerald.baeza@st.com>
Signed-off-by: Bich Hemon <bich.hemon@st.com>
Acked-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
2018-11-12 10:20:41 -08:00

42 lines
1.1 KiB
ArmAsm

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) STMicroelectronics SA 2017 - All Rights Reserved
* Author: Gerald Baeza <gerald.baeza@st.com> for STMicroelectronics.
*/
#define STM32_UART_BASE 0x40011000 /* USART1 */
#ifdef CONFIG_STM32F4_DEBUG_UART
#define STM32_USART_SR_OFF 0x00
#define STM32_USART_TDR_OFF 0x04
#endif
#ifdef CONFIG_STM32F7_DEBUG_UART
#define STM32_USART_SR_OFF 0x1C
#define STM32_USART_TDR_OFF 0x28
#endif
#define STM32_USART_TC (1 << 6) /* Tx complete */
#define STM32_USART_TXE (1 << 7) /* Tx data reg empty */
.macro addruart, rp, rv, tmp
ldr \rp, =STM32_UART_BASE @ physical base
ldr \rv, =STM32_UART_BASE @ virt base /* NoMMU */
.endm
.macro senduart,rd,rx
strb \rd, [\rx, #STM32_USART_TDR_OFF]
.endm
.macro waituart,rd,rx
1001: ldr \rd, [\rx, #(STM32_USART_SR_OFF)] @ Read Status Register
tst \rd, #STM32_USART_TXE @ TXE = 1 = tx empty
beq 1001b
.endm
.macro busyuart,rd,rx
1001: ldr \rd, [\rx, #(STM32_USART_SR_OFF)] @ Read Status Register
tst \rd, #STM32_USART_TC @ TC = 1 = tx complete
beq 1001b
.endm