blob: 89076c322726c50566858967b0ea4ea7dfb3452c [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/arch/regs-gpio.h>
Ben Dooks498e03b2007-07-22 16:08:48 +010017#include <asm/plat-s3c/regs-serial.h>
Ben Dooks498e03b2007-07-22 16:08:48 +010018
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#define S3C2410_UART1_OFF (0x4000)
20#define SHIFT_2440TXF (14-9)
21
Ben Dooks498e03b2007-07-22 16:08:48 +010022 .macro addruart, rx
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 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
Ben Dooks3ec20522007-07-22 16:12:04 +010027#if CONFIG_DEBUG_S3C_UART != 0
28 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C_UART)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#endif
Ben Dooks498e03b2007-07-22 16:08:48 +010030 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Ben Dookscbc4dbf2007-07-22 16:10:23 +010032 .macro fifo_full_s3c24xx rd, rx
Ben Dooks68d9ab32006-06-24 21:21:27 +010033 @ check for arm920 vs arm926. currently assume all arm926
34 @ devices have an 64 byte FIFO identical to the s3c2440
35 mrc p15, 0, \rd, c0, c0
36 and \rd, \rd, #0xff0
37 teq \rd, #0x260
38 beq 1004f
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 mrc p15, 0, \rd, c1, c0
40 tst \rd, #1
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +000041 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART)
43 bic \rd, \rd, #0xff000
44 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
45 and \rd, \rd, #0x00ff0000
46 teq \rd, #0x00440000 @ is it 2440?
Ben Dooks68d9ab32006-06-24 21:21:27 +0100471004:
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
49 moveq \rd, \rd, lsr #SHIFT_2440TXF
50 tst \rd, #S3C2410_UFSTAT_TXFULL
Ben Dooks498e03b2007-07-22 16:08:48 +010051 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Ben Dookscbc4dbf2007-07-22 16:10:23 +010053 .macro fifo_full_s3c2410 rd, rx
54 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
55 tst \rd, #S3C2410_UFSTAT_TXFULL
56 .endm
57
58/* fifo level reading */
59
60 .macro fifo_level_s3c24xx rd, rx
Ben Dooks1197b4c2007-07-22 16:15:44 +010061 @ check for arm920 vs arm926. currently assume all arm926
62 @ devices have an 64 byte FIFO identical to the s3c2440
63 mrc p15, 0, \rd, c0, c0
64 and \rd, \rd, #0xff0
65 teq \rd, #0x260
66 beq 10000f
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 mrc p15, 0, \rd, c1, c0
68 tst \rd, #1
Lucas Correia Villa Real0367a8d2006-01-26 15:20:50 +000069 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART)
71 bic \rd, \rd, #0xff000
72 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
73 and \rd, \rd, #0x00ff0000
74 teq \rd, #0x00440000 @ is it 2440?
75
Ben Dooks1197b4c2007-07-22 16:15:44 +01007610000:
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
78 andne \rd, \rd, #S3C2410_UFSTAT_TXMASK
79 andeq \rd, \rd, #S3C2440_UFSTAT_TXMASK
Ben Dooks498e03b2007-07-22 16:08:48 +010080 .endm
Ben Dookscbc4dbf2007-07-22 16:10:23 +010081
82 .macro fifo_level_s3c2410 rd, rx
83 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
84 and \rd, \rd, #S3C2410_UFSTAT_TXMASK
85 .endm
86
87/* Select the correct implementation depending on the configuration. The
88 * S3C2440 will get selected by default, as these are the most widely
89 * used variants of these
90*/
91
92#if defined(CONFIG_CPU_LLSERIAL_S3C2410_ONLY)
93#define fifo_full fifo_full_s3c2410
94#define fifo_level fifo_level_s3c2410
Ben Dookscbc4dbf2007-07-22 16:10:23 +010095#elif !defined(CONFIG_CPU_LLSERIAL_S3C2440_ONLY)
96#define fifo_full fifo_full_s3c24xx
97#define fifo_level fifo_level_s3c24xx
Ben Dookscbc4dbf2007-07-22 16:10:23 +010098#endif
99
100/* include the reset of the code which will do the work */
101
102#include <asm/plat-s3c/debug-macro.S>