1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Copyright (C) STMicroelectronics SA 2017 - All Rights Reserved 4 * Author: Gerald Baeza <gerald.baeza@st.com> for STMicroelectronics. 5 */ 6 7#ifdef CONFIG_STM32F4_DEBUG_UART 8#define STM32_USART_SR_OFF 0x00 9#define STM32_USART_TDR_OFF 0x04 10#endif 11 12#ifdef CONFIG_STM32F7_DEBUG_UART 13#define STM32_USART_SR_OFF 0x1C 14#define STM32_USART_TDR_OFF 0x28 15#endif 16 17#define STM32_USART_TC (1 << 6) /* Tx complete */ 18#define STM32_USART_TXE (1 << 7) /* Tx data reg empty */ 19 20.macro addruart, rp, rv, tmp 21 ldr \rp, =CONFIG_DEBUG_UART_PHYS @ physical base 22 ldr \rv, =CONFIG_DEBUG_UART_VIRT @ virt base 23.endm 24 25.macro senduart,rd,rx 26 strb \rd, [\rx, #STM32_USART_TDR_OFF] 27.endm 28 29.macro waituart,rd,rx 301001: ldr \rd, [\rx, #(STM32_USART_SR_OFF)] @ Read Status Register 31 tst \rd, #STM32_USART_TXE @ TXE = 1 = tx empty 32 beq 1001b 33.endm 34 35.macro busyuart,rd,rx 361001: ldr \rd, [\rx, #(STM32_USART_SR_OFF)] @ Read Status Register 37 tst \rd, #STM32_USART_TC @ TC = 1 = tx complete 38 beq 1001b 39.endm 40