uncompress.h 3.9 KB

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