Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Debugging macro include header
0004  *
0005  *  Copyright (C) 1994-1999 Russell King
0006  *  Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
0007 */
0008 
0009 #include <linux/serial_reg.h>
0010 
0011 /* External port on Zoom2/3 */
0012 #define ZOOM_UART_BASE      0x10000000
0013 #define ZOOM_UART_VIRT      0xfa400000
0014 
0015 #define OMAP_PORT_SHIFT     2
0016 #define ZOOM_PORT_SHIFT     1
0017 
0018 #define UART_OFFSET(addr)   ((addr) & 0x00ffffff)
0019 
0020         .pushsection .data
0021         .align  2
0022 omap_uart_phys: .word   0
0023 omap_uart_virt: .word   0
0024 omap_uart_lsr:  .word   0
0025         .popsection
0026 
0027         .macro  addruart, rp, rv, tmp
0028 
0029         /* Use omap_uart_phys/virt if already configured */
0030 10:     adr \rp, 99f        @ get effective addr of 99f
0031         ldr \rv, [\rp]      @ get absolute addr of 99f
0032         sub \rv, \rv, \rp       @ offset between the two
0033         ldr \rp, [\rp, #4]      @ abs addr of omap_uart_phys
0034         sub \tmp, \rp, \rv      @ make it effective
0035         ldr \rp, [\tmp, #0]     @ omap_uart_phys
0036         ldr \rv, [\tmp, #4]     @ omap_uart_virt
0037         cmp \rp, #0         @ is port configured?
0038         cmpne   \rv, #0
0039         bne 100f            @ already configured
0040 
0041         /* Configure the UART offset from the phys/virt base */
0042 #ifdef CONFIG_DEBUG_ZOOM_UART
0043         ldr \rp, =ZOOM_UART_BASE
0044         str \rp, [\tmp, #0]     @ omap_uart_phys
0045         ldr \rp, =ZOOM_UART_VIRT
0046         str \rp, [\tmp, #4]     @ omap_uart_virt
0047         mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
0048         str \rp, [\tmp, #8]     @ omap_uart_lsr
0049 #endif
0050         b   10b
0051 
0052         .align
0053 99:     .word   .
0054         .word   omap_uart_phys
0055         .ltorg
0056 
0057 100:        /* Pass the UART_LSR reg address */
0058         ldr \tmp, [\tmp, #8]    @ omap_uart_lsr
0059         add \rp, \rp, \tmp
0060         add \rv, \rv, \tmp
0061         .endm
0062 
0063         .macro  senduart,rd,rx
0064         orr \rd, \rd, \rx, lsl #24  @ preserve LSR reg offset
0065         bic \rx, \rx, #0xff     @ get base (THR) reg address
0066         strb    \rd, [\rx]      @ send lower byte of rd
0067         orr \rx, \rx, \rd, lsr #24  @ restore original rx (LSR)
0068         bic \rd, \rd, #(0xff << 24) @ restore original rd
0069         .endm
0070 
0071         .macro  busyuart,rd,rx
0072 1001:       ldrb    \rd, [\rx]      @ rx contains UART_LSR address
0073         and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
0074         teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
0075         bne 1001b
0076         .endm
0077 
0078         .macro  waituartcts,rd,rx
0079         .endm
0080 
0081         .macro  waituarttxrdy,rd,rx
0082         .endm