ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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 */
17
18 #ifndef __ASM_ARCH_UNCOMPRESS_H
19 #define __ASM_ARCH_UNCOMPRESS_H
20
21 /* defines for UART registers */
22 #include "asm/arch/regs-serial.h"
23
24 #include <asm/arch/map.h>
25
26 /* how many bytes we allow into the FIFO at a time in FIFO mode */
27 #define FIFO_MAX         (14)
28
29 #if 1
30 #define uart_base S3C2410_PA_UART
31 #else
32 static unsigned int uart_base = S3C2410_PA_UART;
33 #endif
34
35 static __inline__ void
36 uart_wr(unsigned int reg, unsigned int val)
37 {
38         volatile unsigned int *ptr;
39
40         ptr = (volatile unsigned int *)(reg + uart_base);
41         *ptr = val;
42 }
43
44 static __inline__ unsigned int
45 uart_rd(unsigned int reg)
46 {
47         volatile unsigned int *ptr;
48
49         ptr = (volatile unsigned int *)(reg + uart_base);
50         return *ptr;
51 }
52
53
54 /* currently we do not need the watchdog... */
55 #define arch_decomp_wdog()
56
57
58 static void error(char *err);
59
60 static void
61 arch_decomp_setup(void)
62 {
63         /* we may need to setup the uart(s) here if we are not running
64          * on an BAST... the BAST will have left the uarts configured
65          * after calling linux.
66          */
67 }
68
69 /* we can deal with the case the UARTs are being run
70  * in FIFO mode, so that we don't hold up our execution
71  * waiting for tx to happen...
72 */
73
74 static void
75 putc(char ch)
76 {
77         if (ch == '\n')
78                 putc('\r');    /* expand newline to \r\n */
79
80         if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
81                 int level;
82
83                 while (1) {
84                         level = uart_rd(S3C2410_UFSTAT);
85                         level &= S3C2410_UFSTAT_TXMASK;
86                         level >>= S3C2410_UFSTAT_TXSHIFT;
87
88                         if (level < FIFO_MAX)
89                                 break;
90                 }
91
92         } else {
93                 /* not using fifos */
94
95                 while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXFE) != S3C2410_UTRSTAT_TXFE);
96         }
97
98         /* write byte to transmission register */
99         uart_wr(S3C2410_UTXH, ch);
100 }
101
102 static void
103 puts(const char *ptr)
104 {
105         for (; *ptr != '\0'; ptr++) {
106                 putc(*ptr);
107         }
108 }
109
110 #endif /* __ASM_ARCH_UNCOMPRESS_H */