uncompress.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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) ((S3C2410_PA_GPIO + (x)))
  33. #define S3C2410_WDOGREG(x) ((S3C2410_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 S3C2410_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
  56. putc(char ch)
  57. {
  58. int cpuid = S3C2410_GSTATUS1_2410;
  59. #ifndef CONFIG_CPU_S3C2400
  60. cpuid = *((volatile unsigned int *)S3C2410_GSTATUS1);
  61. cpuid &= S3C2410_GSTATUS1_IDMASK;
  62. #endif
  63. if (ch == '\n')
  64. putc('\r'); /* expand newline to \r\n */
  65. if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
  66. int level;
  67. while (1) {
  68. level = uart_rd(S3C2410_UFSTAT);
  69. if (cpuid == S3C2410_GSTATUS1_2440) {
  70. level &= S3C2440_UFSTAT_TXMASK;
  71. level >>= S3C2440_UFSTAT_TXSHIFT;
  72. } else {
  73. level &= S3C2410_UFSTAT_TXMASK;
  74. level >>= S3C2410_UFSTAT_TXSHIFT;
  75. }
  76. if (level < FIFO_MAX)
  77. break;
  78. }
  79. } else {
  80. /* not using fifos */
  81. while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE);
  82. }
  83. /* write byte to transmission register */
  84. uart_wr(S3C2410_UTXH, ch);
  85. }
  86. static void
  87. putstr(const char *ptr)
  88. {
  89. for (; *ptr != '\0'; ptr++) {
  90. putc(*ptr);
  91. }
  92. }
  93. /* CONFIG_S3C2410_BOOT_WATCHDOG
  94. *
  95. * Simple boot-time watchdog setup, to reboot the system if there is
  96. * any problem with the boot process
  97. */
  98. #ifdef CONFIG_S3C2410_BOOT_WATCHDOG
  99. #define WDOG_COUNT (0xff00)
  100. #define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
  101. static inline void arch_decomp_wdog(void)
  102. {
  103. __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
  104. }
  105. static void arch_decomp_wdog_start(void)
  106. {
  107. __raw_writel(WDOG_COUNT, S3C2410_WTDAT);
  108. __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
  109. __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
  110. }
  111. #else
  112. #define arch_decomp_wdog_start()
  113. #define arch_decomp_wdog()
  114. #endif
  115. static void error(char *err);
  116. static void
  117. arch_decomp_setup(void)
  118. {
  119. /* we may need to setup the uart(s) here if we are not running
  120. * on an BAST... the BAST will have left the uarts configured
  121. * after calling linux.
  122. */
  123. arch_decomp_wdog_start();
  124. }
  125. #endif /* __ASM_ARCH_UNCOMPRESS_H */