vserver 1.9.5.x5
[linux-2.6.git] / include / asm-arm / arch-s3c2410 / uncompress.h
1 /* linux/include/asm-arm/arch-s3c2410/uncompress.h
2  *
3  * (c) 2003 Simtec Electronics
4  *    Ben Dooks <ben@simtec.co.uk>
5  *
6  * S3C2410 - uncompress code
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  *
12  * Changelog:
13  *  22-May-2003 BJD  Created
14  *  08-Sep-2003 BJD  Moved to linux v2.6
15  *  12-Mar-2004 BJD  Updated header protection
16  *  12-Oct-2004 BJD  Take account of debug uart configuration
17  *  15-Nov-2004 BJD  Fixed uart configuration
18 */
19
20 #ifndef __ASM_ARCH_UNCOMPRESS_H
21 #define __ASM_ARCH_UNCOMPRESS_H
22
23 #include <linux/config.h>
24
25 /* defines for UART registers */
26 #include "asm/arch/regs-serial.h"
27 #include "asm/arch/regs-gpio.h"
28
29 #include <asm/arch/map.h>
30
31 /* working in physical space... */
32 #undef S3C2410_GPIOREG
33 #define S3C2410_GPIOREG(x) ((S3C2410_PA_GPIO + (x)))
34
35 /* how many bytes we allow into the FIFO at a time in FIFO mode */
36 #define FIFO_MAX         (14)
37
38 #define uart_base S3C2410_PA_UART + (0x4000*CONFIG_S3C2410_LOWLEVEL_UART_PORT)
39
40 static __inline__ void
41 uart_wr(unsigned int reg, unsigned int val)
42 {
43         volatile unsigned int *ptr;
44
45         ptr = (volatile unsigned int *)(reg + uart_base);
46         *ptr = val;
47 }
48
49 static __inline__ unsigned int
50 uart_rd(unsigned int reg)
51 {
52         volatile unsigned int *ptr;
53
54         ptr = (volatile unsigned int *)(reg + uart_base);
55         return *ptr;
56 }
57
58
59 /* currently we do not need the watchdog... */
60 #define arch_decomp_wdog()
61
62
63 static void error(char *err);
64
65 static void
66 arch_decomp_setup(void)
67 {
68         /* we may need to setup the uart(s) here if we are not running
69          * on an BAST... the BAST will have left the uarts configured
70          * after calling linux.
71          */
72 }
73
74 /* we can deal with the case the UARTs are being run
75  * in FIFO mode, so that we don't hold up our execution
76  * waiting for tx to happen...
77 */
78
79 static void
80 putc(char ch)
81 {
82         int cpuid = *((volatile unsigned int *)S3C2410_GSTATUS1);
83
84         cpuid &= S3C2410_GSTATUS1_IDMASK;
85
86         if (ch == '\n')
87                 putc('\r');    /* expand newline to \r\n */
88
89         if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
90                 int level;
91
92                 while (1) {
93                         level = uart_rd(S3C2410_UFSTAT);
94
95                         if (cpuid == S3C2410_GSTATUS1_2440) {
96                                 level &= S3C2440_UFSTAT_TXMASK;
97                                 level >>= S3C2440_UFSTAT_TXSHIFT;
98                         } else {
99                                 level &= S3C2410_UFSTAT_TXMASK;
100                                 level >>= S3C2410_UFSTAT_TXSHIFT;
101                         }
102
103                         if (level < FIFO_MAX)
104                                 break;
105                 }
106
107         } else {
108                 /* not using fifos */
109
110                 while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE);
111         }
112
113         /* write byte to transmission register */
114         uart_wr(S3C2410_UTXH, ch);
115 }
116
117 static void
118 putstr(const char *ptr)
119 {
120         for (; *ptr != '\0'; ptr++) {
121                 putc(*ptr);
122         }
123 }
124
125 #endif /* __ASM_ARCH_UNCOMPRESS_H */