uncompress.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* linux/arch/arm/mach-s5p64x0/include/mach/uncompress.h
  2. *
  3. * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * S5P64X0 - 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. #include <mach/map.h>
  15. /*
  16. * cannot use commonly <plat/uncompress.h>
  17. * because uart base of S5P6440 and S5P6450 is different
  18. */
  19. typedef unsigned int upf_t; /* cannot include linux/serial_core.h */
  20. /* uart setup */
  21. unsigned int fifo_mask;
  22. unsigned int fifo_max;
  23. /* forward declerations */
  24. static void arch_detect_cpu(void);
  25. /* defines for UART registers */
  26. #include <plat/regs-serial.h>
  27. #include <plat/regs-watchdog.h>
  28. /* working in physical space... */
  29. #undef S3C2410_WDOGREG
  30. #define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
  31. /* how many bytes we allow into the FIFO at a time in FIFO mode */
  32. #define FIFO_MAX (14)
  33. unsigned long uart_base;
  34. static __inline__ void get_uart_base(void)
  35. {
  36. unsigned int chipid;
  37. chipid = *(const volatile unsigned int __force *) 0xE0100118;
  38. uart_base = S3C_UART_OFFSET * CONFIG_S3C_LOWLEVEL_UART_PORT;
  39. if ((chipid & 0xff000) == 0x50000)
  40. uart_base += 0xEC800000;
  41. else
  42. uart_base += 0xEC000000;
  43. }
  44. static __inline__ void uart_wr(unsigned int reg, unsigned int val)
  45. {
  46. volatile unsigned int *ptr;
  47. get_uart_base();
  48. ptr = (volatile unsigned int *)(reg + uart_base);
  49. *ptr = val;
  50. }
  51. static __inline__ unsigned int uart_rd(unsigned int reg)
  52. {
  53. volatile unsigned int *ptr;
  54. get_uart_base();
  55. ptr = (volatile unsigned int *)(reg + uart_base);
  56. return *ptr;
  57. }
  58. /*
  59. * we can deal with the case the UARTs are being run
  60. * in FIFO mode, so that we don't hold up our execution
  61. * waiting for tx to happen...
  62. */
  63. static void putc(int ch)
  64. {
  65. if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
  66. int level;
  67. while (1) {
  68. level = uart_rd(S3C2410_UFSTAT);
  69. level &= fifo_mask;
  70. if (level < fifo_max)
  71. break;
  72. }
  73. } else {
  74. /* not using fifos */
  75. while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
  76. barrier();
  77. }
  78. /* write byte to transmission register */
  79. uart_wr(S3C2410_UTXH, ch);
  80. }
  81. static inline void flush(void)
  82. {
  83. }
  84. #define __raw_writel(d, ad) \
  85. do { \
  86. *((volatile unsigned int __force *)(ad)) = (d); \
  87. } while (0)
  88. #ifdef CONFIG_S3C_BOOT_ERROR_RESET
  89. static void arch_decomp_error(const char *x)
  90. {
  91. putstr("\n\n");
  92. putstr(x);
  93. putstr("\n\n -- System resetting\n");
  94. __raw_writel(0x4000, S3C2410_WTDAT);
  95. __raw_writel(0x4000, S3C2410_WTCNT);
  96. __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
  97. while(1);
  98. }
  99. #define arch_error arch_decomp_error
  100. #endif
  101. #ifdef CONFIG_S3C_BOOT_UART_FORCE_FIFO
  102. static inline void arch_enable_uart_fifo(void)
  103. {
  104. u32 fifocon = uart_rd(S3C2410_UFCON);
  105. if (!(fifocon & S3C2410_UFCON_FIFOMODE)) {
  106. fifocon |= S3C2410_UFCON_RESETBOTH;
  107. uart_wr(S3C2410_UFCON, fifocon);
  108. /* wait for fifo reset to complete */
  109. while (1) {
  110. fifocon = uart_rd(S3C2410_UFCON);
  111. if (!(fifocon & S3C2410_UFCON_RESETBOTH))
  112. break;
  113. }
  114. }
  115. }
  116. #else
  117. #define arch_enable_uart_fifo() do { } while(0)
  118. #endif
  119. static void arch_decomp_setup(void)
  120. {
  121. /*
  122. * we may need to setup the uart(s) here if we are not running
  123. * on an BAST... the BAST will have left the uarts configured
  124. * after calling linux.
  125. */
  126. arch_detect_cpu();
  127. /*
  128. * Enable the UART FIFOs if they where not enabled and our
  129. * configuration says we should turn them on.
  130. */
  131. arch_enable_uart_fifo();
  132. }
  133. static void arch_detect_cpu(void)
  134. {
  135. /* we do not need to do any cpu detection here at the moment. */
  136. }
  137. #endif /* __ASM_ARCH_UNCOMPRESS_H */