/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Debugging macro include header3*4* Copyright (C) 1994-1999 Russell King5* Moved from linux/arch/arm/kernel/debug.S by Ben Dooks6*/78#include <linux/serial_reg.h>910/* External port on Zoom2/3 */11#define ZOOM_UART_BASE 0x1000000012#define ZOOM_UART_VIRT 0xfa4000001314#define OMAP_PORT_SHIFT 215#define ZOOM_PORT_SHIFT 11617#define UART_OFFSET(addr) ((addr) & 0x00ffffff)1819.pushsection .data20.align 221omap_uart_phys: .word 022omap_uart_virt: .word 023omap_uart_lsr: .word 024.popsection2526.macro addruart, rp, rv, tmp2728/* Use omap_uart_phys/virt if already configured */2910: adr \rp, 99f @ get effective addr of 99f30ldr \rv, [\rp] @ get absolute addr of 99f31sub \rv, \rv, \rp @ offset between the two32ldr \rp, [\rp, #4] @ abs addr of omap_uart_phys33sub \tmp, \rp, \rv @ make it effective34ldr \rp, [\tmp, #0] @ omap_uart_phys35ldr \rv, [\tmp, #4] @ omap_uart_virt36cmp \rp, #0 @ is port configured?37cmpne \rv, #038bne 100f @ already configured3940/* Configure the UART offset from the phys/virt base */41#ifdef CONFIG_DEBUG_ZOOM_UART42ldr \rp, =ZOOM_UART_BASE43str \rp, [\tmp, #0] @ omap_uart_phys44ldr \rp, =ZOOM_UART_VIRT45str \rp, [\tmp, #4] @ omap_uart_virt46mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)47str \rp, [\tmp, #8] @ omap_uart_lsr48#endif49b 10b5051.align5299: .word .53.word omap_uart_phys54.ltorg5556100: /* Pass the UART_LSR reg address */57ldr \tmp, [\tmp, #8] @ omap_uart_lsr58add \rp, \rp, \tmp59add \rv, \rv, \tmp60.endm6162.macro senduart,rd,rx63orr \rd, \rd, \rx, lsl #24 @ preserve LSR reg offset64bic \rx, \rx, #0xff @ get base (THR) reg address65strb \rd, [\rx] @ send lower byte of rd66orr \rx, \rx, \rd, lsr #24 @ restore original rx (LSR)67bic \rd, \rd, #(0xff << 24) @ restore original rd68.endm6970.macro busyuart,rd,rx711001: ldrb \rd, [\rx] @ rx contains UART_LSR address72and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)73teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)74bne 1001b75.endm7677.macro waituartcts,rd,rx78.endm7980.macro waituarttxrdy,rd,rx81.endm828384