Merge branch 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linux-2.6
[linux-2.6] / include / asm-arm / arch-s3c2410 / debug-macro.S
1 /* 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.
13 */
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
25                 ldreq   \rx, = S3C24XX_PA_UART
26                 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
33                 strb    \rd, [\rx, # S3C2410_UTXH ]
34                 .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...
41 1003:
42                 @ 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
48                 mrc     p15, 0, \rd, c1, c0
49                 tst     \rd, #1
50                 addeq   \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
51                 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?
56 1004:
57                 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
63 1001:
64                 @ busy waiting for non fifo
65                 ldr     \rd, [ \rx, # S3C2410_UTRSTAT ]
66                 tst     \rd, #S3C2410_UTRSTAT_TXFE
67                 beq     1001b
68
69 1002:           @ 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...
78 1003:
79                 mrc     p15, 0, \rd, c1, c0
80                 tst     \rd, #1
81                 addeq   \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
82                 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
95 1001:
96                 @ idle waiting for non fifo
97                 ldr     \rd, [ \rx, # S3C2410_UTRSTAT ]
98                 tst     \rd, #S3C2410_UTRSTAT_TXFE
99                 beq     1001b
100
101 1002:           @ exit busyuart
102                 .endm