uncompress.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* linux/include/asm-arm/plat-s3c/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. static unsigned int fifo_mask;
  18. static unsigned int fifo_max;
  19. /* forward declerations */
  20. static void arch_detect_cpu(void);
  21. /* defines for UART registers */
  22. #include <asm/plat-s3c/regs-serial.h>
  23. #include <asm/plat-s3c/regs-watchdog.h>
  24. /* working in physical space... */
  25. #undef S3C2410_WDOGREG
  26. #define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
  27. /* how many bytes we allow into the FIFO at a time in FIFO mode */
  28. #define FIFO_MAX (14)
  29. #define uart_base S3C24XX_PA_UART + (0x4000*CONFIG_S3C_LOWLEVEL_UART_PORT)
  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 (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
  51. int level;
  52. while (1) {
  53. level = uart_rd(S3C2410_UFSTAT);
  54. level &= fifo_mask;
  55. if (level < fifo_max)
  56. break;
  57. }
  58. } else {
  59. /* not using fifos */
  60. while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
  61. barrier();
  62. }
  63. /* write byte to transmission register */
  64. uart_wr(S3C2410_UTXH, ch);
  65. }
  66. static inline void flush(void)
  67. {
  68. }
  69. #define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
  70. /* CONFIG_S3C_BOOT_WATCHDOG
  71. *
  72. * Simple boot-time watchdog setup, to reboot the system if there is
  73. * any problem with the boot process
  74. */
  75. #ifdef CONFIG_S3C_BOOT_WATCHDOG
  76. #define WDOG_COUNT (0xff00)
  77. static inline void arch_decomp_wdog(void)
  78. {
  79. __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
  80. }
  81. static void arch_decomp_wdog_start(void)
  82. {
  83. __raw_writel(WDOG_COUNT, S3C2410_WTDAT);
  84. __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
  85. __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x80), S3C2410_WTCON);
  86. }
  87. #else
  88. #define arch_decomp_wdog_start()
  89. #define arch_decomp_wdog()
  90. #endif
  91. #ifdef CONFIG_S3C_BOOT_ERROR_RESET
  92. static void arch_decomp_error(const char *x)
  93. {
  94. putstr("\n\n");
  95. putstr(x);
  96. putstr("\n\n -- System resetting\n");
  97. __raw_writel(0x4000, S3C2410_WTDAT);
  98. __raw_writel(0x4000, S3C2410_WTCNT);
  99. __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
  100. while(1);
  101. }
  102. #define arch_error arch_decomp_error
  103. #endif
  104. static void error(char *err);
  105. static void
  106. arch_decomp_setup(void)
  107. {
  108. /* we may need to setup the uart(s) here if we are not running
  109. * on an BAST... the BAST will have left the uarts configured
  110. * after calling linux.
  111. */
  112. arch_detect_cpu();
  113. arch_decomp_wdog_start();
  114. }
  115. #endif /* __ASM_PLAT_UNCOMPRESS_H */