uncompress.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. #include <plat/regs-watchdog.h>
  25. /* working in physical space... */
  26. #undef S3C2410_WDOGREG
  27. #define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
  28. /* how many bytes we allow into the FIFO at a time in FIFO mode */
  29. #define FIFO_MAX (14)
  30. static __inline__ void
  31. uart_wr(unsigned int reg, unsigned int val)
  32. {
  33. volatile unsigned int *ptr;
  34. ptr = (volatile unsigned int *)(reg + uart_base);
  35. *ptr = val;
  36. }
  37. static __inline__ unsigned int
  38. uart_rd(unsigned int reg)
  39. {
  40. volatile unsigned int *ptr;
  41. ptr = (volatile unsigned int *)(reg + uart_base);
  42. return *ptr;
  43. }
  44. /* we can deal with the case the UARTs are being run
  45. * in FIFO mode, so that we don't hold up our execution
  46. * waiting for tx to happen...
  47. */
  48. static void putc(int ch)
  49. {
  50. if (!config_enabled(CONFIG_DEBUG_LL))
  51. return;
  52. if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
  53. int level;
  54. while (1) {
  55. level = uart_rd(S3C2410_UFSTAT);
  56. level &= fifo_mask;
  57. if (level < fifo_max)
  58. break;
  59. }
  60. } else {
  61. /* not using fifos */
  62. while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
  63. barrier();
  64. }
  65. /* write byte to transmission register */
  66. uart_wr(S3C2410_UTXH, ch);
  67. }
  68. static inline void flush(void)
  69. {
  70. }
  71. #define __raw_writel(d, ad) \
  72. do { \
  73. *((volatile unsigned int __force *)(ad)) = (d); \
  74. } while (0)
  75. #ifdef CONFIG_S3C_BOOT_ERROR_RESET
  76. static void arch_decomp_error(const char *x)
  77. {
  78. putstr("\n\n");
  79. putstr(x);
  80. putstr("\n\n -- System resetting\n");
  81. __raw_writel(0x4000, S3C2410_WTDAT);
  82. __raw_writel(0x4000, S3C2410_WTCNT);
  83. __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
  84. while(1);
  85. }
  86. #define arch_error arch_decomp_error
  87. #endif
  88. #ifdef CONFIG_S3C_BOOT_UART_FORCE_FIFO
  89. static inline void arch_enable_uart_fifo(void)
  90. {
  91. u32 fifocon;
  92. if (!config_enabled(CONFIG_DEBUG_LL))
  93. return;
  94. fifocon = uart_rd(S3C2410_UFCON);
  95. if (!(fifocon & S3C2410_UFCON_FIFOMODE)) {
  96. fifocon |= S3C2410_UFCON_RESETBOTH;
  97. uart_wr(S3C2410_UFCON, fifocon);
  98. /* wait for fifo reset to complete */
  99. while (1) {
  100. fifocon = uart_rd(S3C2410_UFCON);
  101. if (!(fifocon & S3C2410_UFCON_RESETBOTH))
  102. break;
  103. }
  104. }
  105. }
  106. #else
  107. #define arch_enable_uart_fifo() do { } while(0)
  108. #endif
  109. static void
  110. arch_decomp_setup(void)
  111. {
  112. /* we may need to setup the uart(s) here if we are not running
  113. * on an BAST... the BAST will have left the uarts configured
  114. * after calling linux.
  115. */
  116. arch_detect_cpu();
  117. /* Enable the UART FIFOs if they where not enabled and our
  118. * configuration says we should turn them on.
  119. */
  120. arch_enable_uart_fifo();
  121. }
  122. #endif /* __ASM_PLAT_UNCOMPRESS_H */