home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / include / asm-arm / arch-s3c2410 / uncompress.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-08-11  |  3.9 KB  |  173 lines

  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.  *  22-Feb-2005 BJD  Added watchdog to uncompress
  19.  *  04-Apr-2005 LCVR Added support to S3C2400 (no cpuid at GSTATUS1)
  20. */
  21.  
  22. #ifndef __ASM_ARCH_UNCOMPRESS_H
  23. #define __ASM_ARCH_UNCOMPRESS_H
  24.  
  25.  
  26. /* defines for UART registers */
  27. #include "asm/arch/regs-serial.h"
  28. #include "asm/arch/regs-gpio.h"
  29. #include "asm/arch/regs-watchdog.h"
  30.  
  31. #include <asm/arch/map.h>
  32.  
  33. /* working in physical space... */
  34. #undef S3C2410_GPIOREG
  35. #undef S3C2410_WDOGREG
  36.  
  37. #define S3C2410_GPIOREG(x) ((S3C24XX_PA_GPIO + (x)))
  38. #define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
  39.  
  40. /* how many bytes we allow into the FIFO at a time in FIFO mode */
  41. #define FIFO_MAX     (14)
  42.  
  43. #define uart_base S3C24XX_PA_UART + (0x4000*CONFIG_S3C2410_LOWLEVEL_UART_PORT)
  44.  
  45. static __inline__ void
  46. uart_wr(unsigned int reg, unsigned int val)
  47. {
  48.     volatile unsigned int *ptr;
  49.  
  50.     ptr = (volatile unsigned int *)(reg + uart_base);
  51.     *ptr = val;
  52. }
  53.  
  54. static __inline__ unsigned int
  55. uart_rd(unsigned int reg)
  56. {
  57.     volatile unsigned int *ptr;
  58.  
  59.     ptr = (volatile unsigned int *)(reg + uart_base);
  60.     return *ptr;
  61. }
  62.  
  63.  
  64. /* we can deal with the case the UARTs are being run
  65.  * in FIFO mode, so that we don't hold up our execution
  66.  * waiting for tx to happen...
  67. */
  68.  
  69. static void putc(int ch)
  70. {
  71.     int cpuid = S3C2410_GSTATUS1_2410;
  72.  
  73. #ifndef CONFIG_CPU_S3C2400
  74.     cpuid = *((volatile unsigned int *)S3C2410_GSTATUS1);
  75.     cpuid &= S3C2410_GSTATUS1_IDMASK;
  76. #endif
  77.  
  78.     if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
  79.         int level;
  80.  
  81.         while (1) {
  82.             level = uart_rd(S3C2410_UFSTAT);
  83.  
  84.             if (cpuid == S3C2410_GSTATUS1_2440) {
  85.                 level &= S3C2440_UFSTAT_TXMASK;
  86.                 level >>= S3C2440_UFSTAT_TXSHIFT;
  87.             } else {
  88.                 level &= S3C2410_UFSTAT_TXMASK;
  89.                 level >>= S3C2410_UFSTAT_TXSHIFT;
  90.             }
  91.  
  92.             if (level < FIFO_MAX)
  93.                 break;
  94.         }
  95.  
  96.     } else {
  97.         /* not using fifos */
  98.  
  99.         while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
  100.             barrier();
  101.     }
  102.  
  103.     /* write byte to transmission register */
  104.     uart_wr(S3C2410_UTXH, ch);
  105. }
  106.  
  107. static inline void flush(void)
  108. {
  109. }
  110.  
  111. #define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
  112.  
  113. /* CONFIG_S3C2410_BOOT_WATCHDOG
  114.  *
  115.  * Simple boot-time watchdog setup, to reboot the system if there is
  116.  * any problem with the boot process
  117. */
  118.  
  119. #ifdef CONFIG_S3C2410_BOOT_WATCHDOG
  120.  
  121. #define WDOG_COUNT (0xff00)
  122.  
  123. static inline void arch_decomp_wdog(void)
  124. {
  125.     __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
  126. }
  127.  
  128. static void arch_decomp_wdog_start(void)
  129. {
  130.     __raw_writel(WDOG_COUNT, S3C2410_WTDAT);
  131.     __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
  132.     __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
  133. }
  134.  
  135. #else
  136. #define arch_decomp_wdog_start()
  137. #define arch_decomp_wdog()
  138. #endif
  139.  
  140. #ifdef CONFIG_S3C2410_BOOT_ERROR_RESET
  141.  
  142. static void arch_decomp_error(const char *x)
  143. {
  144.     putstr("\n\n");
  145.     putstr(x);
  146.     putstr("\n\n -- System resetting\n");
  147.  
  148.     __raw_writel(0x4000, S3C2410_WTDAT);
  149.     __raw_writel(0x4000, S3C2410_WTCNT);
  150.     __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
  151.  
  152.     while(1);
  153. }
  154.  
  155. #define arch_error arch_decomp_error
  156. #endif
  157.  
  158. static void error(char *err);
  159.  
  160. static void
  161. arch_decomp_setup(void)
  162. {
  163.     /* we may need to setup the uart(s) here if we are not running
  164.      * on an BAST... the BAST will have left the uarts configured
  165.      * after calling linux.
  166.      */
  167.  
  168.     arch_decomp_wdog_start();
  169. }
  170.  
  171.  
  172. #endif /* __ASM_ARCH_UNCOMPRESS_H */
  173.