1 /* arch/arm/plat-samsung/include/plat/uncompress.h
3 * Copyright 2003, 2007 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
7 * S3C - uncompress code
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #ifndef __ASM_PLAT_UNCOMPRESS_H
15 #define __ASM_PLAT_UNCOMPRESS_H
17 typedef unsigned int upf_t; /* cannot include linux/serial_core.h */
21 unsigned int fifo_mask;
22 unsigned int fifo_max;
24 volatile u8 *uart_base;
26 /* forward declerations */
28 static void arch_detect_cpu(void);
30 /* defines for UART registers */
32 #include <plat/regs-serial.h>
34 /* working in physical space... */
35 #define S3C_WDOGREG(x) ((S3C_PA_WDT + (x)))
37 #define S3C2410_WTCON S3C_WDOGREG(0x00)
38 #define S3C2410_WTDAT S3C_WDOGREG(0x04)
39 #define S3C2410_WTCNT S3C_WDOGREG(0x08)
41 #define S3C2410_WTCON_RSTEN (1 << 0)
42 #define S3C2410_WTCON_ENABLE (1 << 5)
44 #define S3C2410_WTCON_DIV128 (3 << 3)
46 #define S3C2410_WTCON_PRESCALE(x) ((x) << 8)
48 /* how many bytes we allow into the FIFO at a time in FIFO mode */
51 static __inline__ void
52 uart_wr(unsigned int reg, unsigned int val)
54 volatile unsigned int *ptr;
56 ptr = (volatile unsigned int *)(reg + uart_base);
60 static __inline__ unsigned int
61 uart_rd(unsigned int reg)
63 volatile unsigned int *ptr;
65 ptr = (volatile unsigned int *)(reg + uart_base);
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...
74 static void putc(int ch)
76 if (!config_enabled(CONFIG_DEBUG_LL))
79 if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
83 level = uart_rd(S3C2410_UFSTAT);
93 while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
97 /* write byte to transmission register */
98 uart_wr(S3C2410_UTXH, ch);
101 static inline void flush(void)
105 #define __raw_writel(d, ad) \
107 *((volatile unsigned int __force *)(ad)) = (d); \
110 #ifdef CONFIG_S3C_BOOT_ERROR_RESET
112 static void arch_decomp_error(const char *x)
116 putstr("\n\n -- System resetting\n");
118 __raw_writel(0x4000, S3C2410_WTDAT);
119 __raw_writel(0x4000, S3C2410_WTCNT);
120 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
125 #define arch_error arch_decomp_error
128 #ifdef CONFIG_S3C_BOOT_UART_FORCE_FIFO
129 static inline void arch_enable_uart_fifo(void)
133 if (!config_enabled(CONFIG_DEBUG_LL))
136 fifocon = uart_rd(S3C2410_UFCON);
138 if (!(fifocon & S3C2410_UFCON_FIFOMODE)) {
139 fifocon |= S3C2410_UFCON_RESETBOTH;
140 uart_wr(S3C2410_UFCON, fifocon);
142 /* wait for fifo reset to complete */
144 fifocon = uart_rd(S3C2410_UFCON);
145 if (!(fifocon & S3C2410_UFCON_RESETBOTH))
149 uart_wr(S3C2410_UFCON, S3C2410_UFCON_FIFOMODE);
153 #define arch_enable_uart_fifo() do { } while(0)
158 arch_decomp_setup(void)
160 /* we may need to setup the uart(s) here if we are not running
161 * on an BAST... the BAST will have left the uarts configured
162 * after calling linux.
167 /* Enable the UART FIFOs if they where not enabled and our
168 * configuration says we should turn them on.
171 arch_enable_uart_fifo();
175 #endif /* __ASM_PLAT_UNCOMPRESS_H */