uncompress.h 3.7 KB

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