[ARM] S3C64XX: Add system boot-time support
[linux-2.6/mini2440.git] / arch / arm / plat-s3c / include / plat / uncompress.h
blobeeef32c4312dc343ea4d3b35c286f455dc764566
1 /* linux/include/asm-arm/plat-s3c/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 */
19 /* uart setup */
21 static unsigned int fifo_mask;
22 static unsigned int fifo_max;
24 /* forward declerations */
26 static void arch_detect_cpu(void);
28 /* defines for UART registers */
30 #include <plat/regs-serial.h>
31 #include <plat/regs-watchdog.h>
33 /* working in physical space... */
34 #undef S3C2410_WDOGREG
35 #define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
37 /* how many bytes we allow into the FIFO at a time in FIFO mode */
38 #define FIFO_MAX (14)
40 #define uart_base S3C_PA_UART + (S3C_UART_OFFSET * CONFIG_S3C_LOWLEVEL_UART_PORT)
42 static __inline__ void
43 uart_wr(unsigned int reg, unsigned int val)
45 volatile unsigned int *ptr;
47 ptr = (volatile unsigned int *)(reg + uart_base);
48 *ptr = val;
51 static __inline__ unsigned int
52 uart_rd(unsigned int reg)
54 volatile unsigned int *ptr;
56 ptr = (volatile unsigned int *)(reg + uart_base);
57 return *ptr;
60 /* we can deal with the case the UARTs are being run
61 * in FIFO mode, so that we don't hold up our execution
62 * waiting for tx to happen...
65 static void putc(int ch)
67 if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
68 int level;
70 while (1) {
71 level = uart_rd(S3C2410_UFSTAT);
72 level &= fifo_mask;
74 if (level < fifo_max)
75 break;
78 } else {
79 /* not using fifos */
81 while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
82 barrier();
85 /* write byte to transmission register */
86 uart_wr(S3C2410_UTXH, ch);
89 static inline void flush(void)
93 #define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
95 /* CONFIG_S3C_BOOT_WATCHDOG
97 * Simple boot-time watchdog setup, to reboot the system if there is
98 * any problem with the boot process
101 #ifdef CONFIG_S3C_BOOT_WATCHDOG
103 #define WDOG_COUNT (0xff00)
105 static inline void arch_decomp_wdog(void)
107 __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
110 static void arch_decomp_wdog_start(void)
112 __raw_writel(WDOG_COUNT, S3C2410_WTDAT);
113 __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
114 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x80), S3C2410_WTCON);
117 #else
118 #define arch_decomp_wdog_start()
119 #define arch_decomp_wdog()
120 #endif
122 #ifdef CONFIG_S3C_BOOT_ERROR_RESET
124 static void arch_decomp_error(const char *x)
126 putstr("\n\n");
127 putstr(x);
128 putstr("\n\n -- System resetting\n");
130 __raw_writel(0x4000, S3C2410_WTDAT);
131 __raw_writel(0x4000, S3C2410_WTCNT);
132 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
134 while(1);
137 #define arch_error arch_decomp_error
138 #endif
140 static void error(char *err);
142 static void
143 arch_decomp_setup(void)
145 /* we may need to setup the uart(s) here if we are not running
146 * on an BAST... the BAST will have left the uarts configured
147 * after calling linux.
150 arch_detect_cpu();
151 arch_decomp_wdog_start();
155 #endif /* __ASM_PLAT_UNCOMPRESS_H */