blob: 93064860e0e57bc106d5db72af34fd446fcf668c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* linux/include/asm-arm/arch-s3c2410/debug-macro.S
2 *
3 * Debugging macro include header
4 *
5 * Copyright (C) 1994-1999 Russell King
6 * Copyright (C) 2005 Simtec Electronics
7 *
8 * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013*/
14
15#include <asm/arch/map.h>
16#include <asm/arch/regs-serial.h>
17#include <asm/arch/regs-gpio.h>
18
19#define S3C2410_UART1_OFF (0x4000)
20#define SHIFT_2440TXF (14-9)
21
22 .macro addruart, rx
23 mrc p15, 0, \rx, c1, c0
24 tst \rx, #1
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +000025 ldreq \rx, = S3C24XX_PA_UART
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 ldrne \rx, = S3C24XX_VA_UART
27#if CONFIG_DEBUG_S3C2410_UART != 0
28 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C2410_UART)
29#endif
30 .endm
31
32 .macro senduart,rd,rx
Ben Dooks68d9ab32006-06-24 21:21:27 +010033 strb \rd, [\rx, # S3C2410_UTXH ]
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 .endm
35
36 .macro busyuart, rd, rx
37 ldr \rd, [ \rx, # S3C2410_UFCON ]
38 tst \rd, #S3C2410_UFCON_FIFOMODE @ fifo enabled?
39 beq 1001f @
40 @ FIFO enabled...
411003:
Ben Dooks68d9ab32006-06-24 21:21:27 +010042 @ check for arm920 vs arm926. currently assume all arm926
43 @ devices have an 64 byte FIFO identical to the s3c2440
44 mrc p15, 0, \rd, c0, c0
45 and \rd, \rd, #0xff0
46 teq \rd, #0x260
47 beq 1004f
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 mrc p15, 0, \rd, c1, c0
49 tst \rd, #1
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +000050 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART)
52 bic \rd, \rd, #0xff000
53 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
54 and \rd, \rd, #0x00ff0000
55 teq \rd, #0x00440000 @ is it 2440?
Ben Dooks68d9ab32006-06-24 21:21:27 +0100561004:
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
58 moveq \rd, \rd, lsr #SHIFT_2440TXF
59 tst \rd, #S3C2410_UFSTAT_TXFULL
60 bne 1003b
61 b 1002f
62
631001:
64 @ busy waiting for non fifo
65 ldr \rd, [ \rx, # S3C2410_UTRSTAT ]
66 tst \rd, #S3C2410_UTRSTAT_TXFE
67 beq 1001b
68
691002: @ exit busyuart
70 .endm
71
72 .macro waituart,rd,rx
73
74 ldr \rd, [ \rx, # S3C2410_UFCON ]
75 tst \rd, #S3C2410_UFCON_FIFOMODE @ fifo enabled?
76 beq 1001f @
77 @ FIFO enabled...
781003:
79 mrc p15, 0, \rd, c1, c0
80 tst \rd, #1
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +000081 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART)
83 bic \rd, \rd, #0xff000
84 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
85 and \rd, \rd, #0x00ff0000
86 teq \rd, #0x00440000 @ is it 2440?
87
88 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
89 andne \rd, \rd, #S3C2410_UFSTAT_TXMASK
90 andeq \rd, \rd, #S3C2440_UFSTAT_TXMASK
91 teq \rd, #0
92 bne 1003b
93 b 1002f
94
951001:
96 @ idle waiting for non fifo
97 ldr \rd, [ \rx, # S3C2410_UTRSTAT ]
98 tst \rd, #S3C2410_UTRSTAT_TXFE
99 beq 1001b
100
1011002: @ exit busyuart
102 .endm