blob: b7d15d125458ad3fff6bd79e62df67821d9ac761 [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.
13 *
14 * Modifications:
15 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
16*/
17
18#include <asm/arch/map.h>
19#include <asm/arch/regs-serial.h>
20#include <asm/arch/regs-gpio.h>
21
22#define S3C2410_UART1_OFF (0x4000)
23#define SHIFT_2440TXF (14-9)
24
25 .macro addruart, rx
26 mrc p15, 0, \rx, c1, c0
27 tst \rx, #1
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +000028 ldreq \rx, = S3C24XX_PA_UART
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 ldrne \rx, = S3C24XX_VA_UART
30#if CONFIG_DEBUG_S3C2410_UART != 0
31 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C2410_UART)
32#endif
33 .endm
34
35 .macro senduart,rd,rx
Ben Dooks68d9ab32006-06-24 21:21:27 +010036 strb \rd, [\rx, # S3C2410_UTXH ]
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 .endm
38
39 .macro busyuart, rd, rx
40 ldr \rd, [ \rx, # S3C2410_UFCON ]
41 tst \rd, #S3C2410_UFCON_FIFOMODE @ fifo enabled?
42 beq 1001f @
43 @ FIFO enabled...
441003:
Ben Dooks68d9ab32006-06-24 21:21:27 +010045 @ check for arm920 vs arm926. currently assume all arm926
46 @ devices have an 64 byte FIFO identical to the s3c2440
47 mrc p15, 0, \rd, c0, c0
48 and \rd, \rd, #0xff0
49 teq \rd, #0x260
50 beq 1004f
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 mrc p15, 0, \rd, c1, c0
52 tst \rd, #1
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +000053 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART)
55 bic \rd, \rd, #0xff000
56 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
57 and \rd, \rd, #0x00ff0000
58 teq \rd, #0x00440000 @ is it 2440?
Ben Dooks68d9ab32006-06-24 21:21:27 +0100591004:
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
61 moveq \rd, \rd, lsr #SHIFT_2440TXF
62 tst \rd, #S3C2410_UFSTAT_TXFULL
63 bne 1003b
64 b 1002f
65
661001:
67 @ busy waiting for non fifo
68 ldr \rd, [ \rx, # S3C2410_UTRSTAT ]
69 tst \rd, #S3C2410_UTRSTAT_TXFE
70 beq 1001b
71
721002: @ exit busyuart
73 .endm
74
75 .macro waituart,rd,rx
76
77 ldr \rd, [ \rx, # S3C2410_UFCON ]
78 tst \rd, #S3C2410_UFCON_FIFOMODE @ fifo enabled?
79 beq 1001f @
80 @ FIFO enabled...
811003:
82 mrc p15, 0, \rd, c1, c0
83 tst \rd, #1
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +000084 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART)
86 bic \rd, \rd, #0xff000
87 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
88 and \rd, \rd, #0x00ff0000
89 teq \rd, #0x00440000 @ is it 2440?
90
91 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
92 andne \rd, \rd, #S3C2410_UFSTAT_TXMASK
93 andeq \rd, \rd, #S3C2440_UFSTAT_TXMASK
94 teq \rd, #0
95 bne 1003b
96 b 1002f
97
981001:
99 @ idle waiting for non fifo
100 ldr \rd, [ \rx, # S3C2410_UTRSTAT ]
101 tst \rd, #S3C2410_UTRSTAT_TXFE
102 beq 1001b
103
1041002: @ exit busyuart
105 .endm