uncompress.h 3.6 KB

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