uncompress.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * arch/arm/mach-ns9xxx/include/mach/uncompress.h
  3. *
  4. * Copyright (C) 2006 by Digi International Inc.
  5. * All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. */
  11. #ifndef __ASM_ARCH_UNCOMPRESS_H
  12. #define __ASM_ARCH_UNCOMPRESS_H
  13. #include <linux/io.h>
  14. #define __REG(x) ((void __iomem __force *)(x))
  15. static void putc_dummy(char c, void __iomem *base)
  16. {
  17. /* nothing */
  18. }
  19. static int timeout;
  20. static void putc_ns9360(char c, void __iomem *base)
  21. {
  22. do {
  23. if (timeout)
  24. --timeout;
  25. if (__raw_readl(base + 8) & (1 << 3)) {
  26. __raw_writeb(c, base + 16);
  27. timeout = 0x10000;
  28. break;
  29. }
  30. } while (timeout);
  31. }
  32. static void putc_a9m9750dev(char c, void __iomem *base)
  33. {
  34. do {
  35. if (timeout)
  36. --timeout;
  37. if (__raw_readb(base + 5) & (1 << 5)) {
  38. __raw_writeb(c, base);
  39. timeout = 0x10000;
  40. break;
  41. }
  42. } while (timeout);
  43. }
  44. static void putc_ns921x(char c, void __iomem *base)
  45. {
  46. do {
  47. if (timeout)
  48. --timeout;
  49. if (!(__raw_readl(base) & (1 << 11))) {
  50. __raw_writeb(c, base + 0x0028);
  51. timeout = 0x10000;
  52. break;
  53. }
  54. } while (timeout);
  55. }
  56. #define MSCS __REG(0xA0900184)
  57. #define NS9360_UARTA __REG(0x90200040)
  58. #define NS9360_UARTB __REG(0x90200000)
  59. #define NS9360_UARTC __REG(0x90300000)
  60. #define NS9360_UARTD __REG(0x90300040)
  61. #define NS9360_UART_ENABLED(base) \
  62. (__raw_readl(NS9360_UARTA) & (1 << 31))
  63. #define A9M9750DEV_UARTA __REG(0x40000000)
  64. #define NS921XSYS_CLOCK __REG(0xa090017c)
  65. #define NS921X_UARTA __REG(0x90010000)
  66. #define NS921X_UARTB __REG(0x90018000)
  67. #define NS921X_UARTC __REG(0x90020000)
  68. #define NS921X_UARTD __REG(0x90028000)
  69. #define NS921X_UART_ENABLED(base) \
  70. (__raw_readl((base) + 0x1000) & (1 << 29))
  71. static void autodetect(void (**putc)(char, void __iomem *), void __iomem **base)
  72. {
  73. timeout = 0x10000;
  74. if (((__raw_readl(MSCS) >> 16) & 0xfe) == 0x00) {
  75. /* ns9360 or ns9750 */
  76. if (NS9360_UART_ENABLED(NS9360_UARTA)) {
  77. *putc = putc_ns9360;
  78. *base = NS9360_UARTA;
  79. return;
  80. } else if (NS9360_UART_ENABLED(NS9360_UARTB)) {
  81. *putc = putc_ns9360;
  82. *base = NS9360_UARTB;
  83. return;
  84. } else if (NS9360_UART_ENABLED(NS9360_UARTC)) {
  85. *putc = putc_ns9360;
  86. *base = NS9360_UARTC;
  87. return;
  88. } else if (NS9360_UART_ENABLED(NS9360_UARTD)) {
  89. *putc = putc_ns9360;
  90. *base = NS9360_UARTD;
  91. return;
  92. } else if (__raw_readl(__REG(0xa09001f4)) == 0xfffff001) {
  93. *putc = putc_a9m9750dev;
  94. *base = A9M9750DEV_UARTA;
  95. return;
  96. }
  97. } else if (((__raw_readl(MSCS) >> 16) & 0xfe) == 0x02) {
  98. /* ns921x */
  99. u32 clock = __raw_readl(NS921XSYS_CLOCK);
  100. if ((clock & (1 << 1)) &&
  101. NS921X_UART_ENABLED(NS921X_UARTA)) {
  102. *putc = putc_ns921x;
  103. *base = NS921X_UARTA;
  104. return;
  105. } else if ((clock & (1 << 2)) &&
  106. NS921X_UART_ENABLED(NS921X_UARTB)) {
  107. *putc = putc_ns921x;
  108. *base = NS921X_UARTB;
  109. return;
  110. } else if ((clock & (1 << 3)) &&
  111. NS921X_UART_ENABLED(NS921X_UARTC)) {
  112. *putc = putc_ns921x;
  113. *base = NS921X_UARTC;
  114. return;
  115. } else if ((clock & (1 << 4)) &&
  116. NS921X_UART_ENABLED(NS921X_UARTD)) {
  117. *putc = putc_ns921x;
  118. *base = NS921X_UARTD;
  119. return;
  120. }
  121. }
  122. *putc = putc_dummy;
  123. }
  124. void (*myputc)(char, void __iomem *);
  125. void __iomem *base;
  126. static void putc(char c)
  127. {
  128. myputc(c, base);
  129. }
  130. static void arch_decomp_setup(void)
  131. {
  132. autodetect(&myputc, &base);
  133. }
  134. #define arch_decomp_wdog()
  135. static void flush(void)
  136. {
  137. /* nothing */
  138. }
  139. #endif /* ifndef __ASM_ARCH_UNCOMPRESS_H */