1 /* linux/arch/arm/mach-s5p64x0/include/mach/uncompress.h
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
6 * S5P64X0 - uncompress code
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.
13 #ifndef __ASM_ARCH_UNCOMPRESS_H
14 #define __ASM_ARCH_UNCOMPRESS_H
19 * cannot use commonly <plat/uncompress.h>
20 * because uart base of S5P6440 and S5P6450 is different
23 typedef unsigned int upf_t
; /* cannot include linux/serial_core.h */
27 unsigned int fifo_mask
;
28 unsigned int fifo_max
;
30 /* forward declerations */
32 static void arch_detect_cpu(void);
34 /* defines for UART registers */
36 #include <plat/regs-serial.h>
37 #include <plat/regs-watchdog.h>
39 /* working in physical space... */
40 #undef S3C2410_WDOGREG
41 #define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
43 /* how many bytes we allow into the FIFO at a time in FIFO mode */
46 unsigned long uart_base
;
48 static __inline__
void get_uart_base(void)
52 chipid
= *(const volatile unsigned int __force
*) 0xE0100118;
54 uart_base
= S3C_UART_OFFSET
* CONFIG_S3C_LOWLEVEL_UART_PORT
;
56 if ((chipid
& 0xff000) == 0x50000)
57 uart_base
+= 0xEC800000;
59 uart_base
+= 0xEC000000;
62 static __inline__
void uart_wr(unsigned int reg
, unsigned int val
)
64 volatile unsigned int *ptr
;
67 ptr
= (volatile unsigned int *)(reg
+ uart_base
);
71 static __inline__
unsigned int uart_rd(unsigned int reg
)
73 volatile unsigned int *ptr
;
76 ptr
= (volatile unsigned int *)(reg
+ uart_base
);
81 * we can deal with the case the UARTs are being run
82 * in FIFO mode, so that we don't hold up our execution
83 * waiting for tx to happen...
86 static void putc(int ch
)
88 if (uart_rd(S3C2410_UFCON
) & S3C2410_UFCON_FIFOMODE
) {
92 level
= uart_rd(S3C2410_UFSTAT
);
100 /* not using fifos */
102 while ((uart_rd(S3C2410_UTRSTAT
) & S3C2410_UTRSTAT_TXE
) != S3C2410_UTRSTAT_TXE
)
106 /* write byte to transmission register */
107 uart_wr(S3C2410_UTXH
, ch
);
110 static inline void flush(void)
114 #define __raw_writel(d, ad) \
116 *((volatile unsigned int __force *)(ad)) = (d); \
120 * CONFIG_S3C_BOOT_WATCHDOG
122 * Simple boot-time watchdog setup, to reboot the system if there is
123 * any problem with the boot process
126 #ifdef CONFIG_S3C_BOOT_WATCHDOG
128 #define WDOG_COUNT (0xff00)
130 static inline void arch_decomp_wdog(void)
132 __raw_writel(WDOG_COUNT
, S3C2410_WTCNT
);
135 static void arch_decomp_wdog_start(void)
137 __raw_writel(WDOG_COUNT
, S3C2410_WTDAT
);
138 __raw_writel(WDOG_COUNT
, S3C2410_WTCNT
);
139 __raw_writel(S3C2410_WTCON_ENABLE
| S3C2410_WTCON_DIV128
| S3C2410_WTCON_RSTEN
| S3C2410_WTCON_PRESCALE(0x80), S3C2410_WTCON
);
143 #define arch_decomp_wdog_start()
144 #define arch_decomp_wdog()
147 #ifdef CONFIG_S3C_BOOT_ERROR_RESET
149 static void arch_decomp_error(const char *x
)
153 putstr("\n\n -- System resetting\n");
155 __raw_writel(0x4000, S3C2410_WTDAT
);
156 __raw_writel(0x4000, S3C2410_WTCNT
);
157 __raw_writel(S3C2410_WTCON_ENABLE
| S3C2410_WTCON_DIV128
| S3C2410_WTCON_RSTEN
| S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON
);
162 #define arch_error arch_decomp_error
165 #ifdef CONFIG_S3C_BOOT_UART_FORCE_FIFO
166 static inline void arch_enable_uart_fifo(void)
168 u32 fifocon
= uart_rd(S3C2410_UFCON
);
170 if (!(fifocon
& S3C2410_UFCON_FIFOMODE
)) {
171 fifocon
|= S3C2410_UFCON_RESETBOTH
;
172 uart_wr(S3C2410_UFCON
, fifocon
);
174 /* wait for fifo reset to complete */
176 fifocon
= uart_rd(S3C2410_UFCON
);
177 if (!(fifocon
& S3C2410_UFCON_RESETBOTH
))
183 #define arch_enable_uart_fifo() do { } while(0)
186 static void arch_decomp_setup(void)
189 * we may need to setup the uart(s) here if we are not running
190 * on an BAST... the BAST will have left the uarts configured
191 * after calling linux.
195 arch_decomp_wdog_start();
198 * Enable the UART FIFOs if they where not enabled and our
199 * configuration says we should turn them on.
202 arch_enable_uart_fifo();
207 static void arch_detect_cpu(void)
209 /* we do not need to do any cpu detection here at the moment. */
212 #endif /* __ASM_ARCH_UNCOMPRESS_H */