uncompress.h 3.9 KB

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