uncompress.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* arch/arm/plat-samsung/include/plat/uncompress.h
  2. *
  3. * Copyright 2003, 2007 Simtec Electronics
  4. * http://armlinux.simtec.co.uk/
  5. * Ben Dooks <ben@simtec.co.uk>
  6. *
  7. * S3C - uncompress code
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef __ASM_PLAT_UNCOMPRESS_H
  14. #define __ASM_PLAT_UNCOMPRESS_H
  15. typedef unsigned int upf_t; /* cannot include linux/serial_core.h */
  16. /* uart setup */
  17. unsigned int fifo_mask;
  18. unsigned int fifo_max;
  19. volatile u8 *uart_base;
  20. /* forward declerations */
  21. static void arch_detect_cpu(void);
  22. /* defines for UART registers */
  23. #include <plat/regs-serial.h>
  24. /* working in physical space... */
  25. #define S3C_WDOGREG(x) ((S3C_PA_WDT + (x)))
  26. #define S3C2410_WTCON S3C_WDOGREG(0x00)
  27. #define S3C2410_WTDAT S3C_WDOGREG(0x04)
  28. #define S3C2410_WTCNT S3C_WDOGREG(0x08)
  29. #define S3C2410_WTCON_RSTEN (1 << 0)
  30. #define S3C2410_WTCON_ENABLE (1 << 5)
  31. #define S3C2410_WTCON_DIV128 (3 << 3)
  32. #define S3C2410_WTCON_PRESCALE(x) ((x) << 8)
  33. /* how many bytes we allow into the FIFO at a time in FIFO mode */
  34. #define FIFO_MAX (14)
  35. static __inline__ void
  36. uart_wr(unsigned int reg, unsigned int val)
  37. {
  38. volatile unsigned int *ptr;
  39. ptr = (volatile unsigned int *)(reg + uart_base);
  40. *ptr = val;
  41. }
  42. static __inline__ unsigned int
  43. uart_rd(unsigned int reg)
  44. {
  45. volatile unsigned int *ptr;
  46. ptr = (volatile unsigned int *)(reg + uart_base);
  47. return *ptr;
  48. }
  49. /* we can deal with the case the UARTs are being run
  50. * in FIFO mode, so that we don't hold up our execution
  51. * waiting for tx to happen...
  52. */
  53. static void putc(int ch)
  54. {
  55. if (!config_enabled(CONFIG_DEBUG_LL))
  56. return;
  57. if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
  58. int level;
  59. while (1) {
  60. level = uart_rd(S3C2410_UFSTAT);
  61. level &= fifo_mask;
  62. if (level < fifo_max)
  63. break;
  64. }
  65. } else {
  66. /* not using fifos */
  67. while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
  68. barrier();
  69. }
  70. /* write byte to transmission register */
  71. uart_wr(S3C2410_UTXH, ch);
  72. }
  73. static inline void flush(void)
  74. {
  75. }
  76. #define __raw_writel(d, ad) \
  77. do { \
  78. *((volatile unsigned int __force *)(ad)) = (d); \
  79. } while (0)
  80. #ifdef CONFIG_S3C_BOOT_ERROR_RESET
  81. static void arch_decomp_error(const char *x)
  82. {
  83. putstr("\n\n");
  84. putstr(x);
  85. putstr("\n\n -- System resetting\n");
  86. __raw_writel(0x4000, S3C2410_WTDAT);
  87. __raw_writel(0x4000, S3C2410_WTCNT);
  88. __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
  89. while(1);
  90. }
  91. #define arch_error arch_decomp_error
  92. #endif
  93. #ifdef CONFIG_S3C_BOOT_UART_FORCE_FIFO
  94. static inline void arch_enable_uart_fifo(void)
  95. {
  96. u32 fifocon;
  97. if (!config_enabled(CONFIG_DEBUG_LL))
  98. return;
  99. fifocon = uart_rd(S3C2410_UFCON);
  100. if (!(fifocon & S3C2410_UFCON_FIFOMODE)) {
  101. fifocon |= S3C2410_UFCON_RESETBOTH;
  102. uart_wr(S3C2410_UFCON, fifocon);
  103. /* wait for fifo reset to complete */
  104. while (1) {
  105. fifocon = uart_rd(S3C2410_UFCON);
  106. if (!(fifocon & S3C2410_UFCON_RESETBOTH))
  107. break;
  108. }
  109. }
  110. }
  111. #else
  112. #define arch_enable_uart_fifo() do { } while(0)
  113. #endif
  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_detect_cpu();
  122. /* Enable the UART FIFOs if they where not enabled and our
  123. * configuration says we should turn them on.
  124. */
  125. arch_enable_uart_fifo();
  126. }
  127. #endif /* __ASM_PLAT_UNCOMPRESS_H */