uncompress.h 3.4 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 void putc_ns9360(char c, void __iomem *base)
  20. {
  21. static int t = 0x10000;
  22. do {
  23. if (t)
  24. --t;
  25. if (__raw_readl(base + 8) & (1 << 3)) {
  26. __raw_writeb(c, base + 16);
  27. t = 0x10000;
  28. break;
  29. }
  30. } while (t);
  31. }
  32. static void putc_a9m9750dev(char c, void __iomem *base)
  33. {
  34. static int t = 0x10000;
  35. do {
  36. if (t)
  37. --t;
  38. if (__raw_readb(base + 5) & (1 << 5)) {
  39. __raw_writeb(c, base);
  40. t = 0x10000;
  41. break;
  42. }
  43. } while (t);
  44. }
  45. static void putc_ns921x(char c, void __iomem *base)
  46. {
  47. static int t = 0x10000;
  48. do {
  49. if (t)
  50. --t;
  51. if (!(__raw_readl(base) & (1 << 11))) {
  52. __raw_writeb(c, base + 0x0028);
  53. t = 0x10000;
  54. break;
  55. }
  56. } while (t);
  57. }
  58. #define MSCS __REG(0xA0900184)
  59. #define NS9360_UARTA __REG(0x90200040)
  60. #define NS9360_UARTB __REG(0x90200000)
  61. #define NS9360_UARTC __REG(0x90300000)
  62. #define NS9360_UARTD __REG(0x90300040)
  63. #define NS9360_UART_ENABLED(base) \
  64. (__raw_readl(NS9360_UARTA) & (1 << 31))
  65. #define A9M9750DEV_UARTA __REG(0x40000000)
  66. #define NS921XSYS_CLOCK __REG(0xa090017c)
  67. #define NS921X_UARTA __REG(0x90010000)
  68. #define NS921X_UARTB __REG(0x90018000)
  69. #define NS921X_UARTC __REG(0x90020000)
  70. #define NS921X_UARTD __REG(0x90028000)
  71. #define NS921X_UART_ENABLED(base) \
  72. (__raw_readl((base) + 0x1000) & (1 << 29))
  73. static void autodetect(void (**putc)(char, void __iomem *), void __iomem **base)
  74. {
  75. if (((__raw_readl(MSCS) >> 16) & 0xfe) == 0x00) {
  76. /* ns9360 or ns9750 */
  77. if (NS9360_UART_ENABLED(NS9360_UARTA)) {
  78. *putc = putc_ns9360;
  79. *base = NS9360_UARTA;
  80. return;
  81. } else if (NS9360_UART_ENABLED(NS9360_UARTB)) {
  82. *putc = putc_ns9360;
  83. *base = NS9360_UARTB;
  84. return;
  85. } else if (NS9360_UART_ENABLED(NS9360_UARTC)) {
  86. *putc = putc_ns9360;
  87. *base = NS9360_UARTC;
  88. return;
  89. } else if (NS9360_UART_ENABLED(NS9360_UARTD)) {
  90. *putc = putc_ns9360;
  91. *base = NS9360_UARTD;
  92. return;
  93. } else if (__raw_readl(__REG(0xa09001f4)) == 0xfffff001) {
  94. *putc = putc_a9m9750dev;
  95. *base = A9M9750DEV_UARTA;
  96. return;
  97. }
  98. } else if (((__raw_readl(MSCS) >> 16) & 0xfe) == 0x02) {
  99. /* ns921x */
  100. u32 clock = __raw_readl(NS921XSYS_CLOCK);
  101. if ((clock & (1 << 1)) &&
  102. NS921X_UART_ENABLED(NS921X_UARTA)) {
  103. *putc = putc_ns921x;
  104. *base = NS921X_UARTA;
  105. return;
  106. } else if ((clock & (1 << 2)) &&
  107. NS921X_UART_ENABLED(NS921X_UARTB)) {
  108. *putc = putc_ns921x;
  109. *base = NS921X_UARTB;
  110. return;
  111. } else if ((clock & (1 << 3)) &&
  112. NS921X_UART_ENABLED(NS921X_UARTC)) {
  113. *putc = putc_ns921x;
  114. *base = NS921X_UARTC;
  115. return;
  116. } else if ((clock & (1 << 4)) &&
  117. NS921X_UART_ENABLED(NS921X_UARTD)) {
  118. *putc = putc_ns921x;
  119. *base = NS921X_UARTD;
  120. return;
  121. }
  122. }
  123. *putc = putc_dummy;
  124. }
  125. void (*myputc)(char, void __iomem *);
  126. void __iomem *base;
  127. static void putc(char c)
  128. {
  129. myputc(c, base);
  130. }
  131. static void arch_decomp_setup(void)
  132. {
  133. autodetect(&myputc, &base);
  134. }
  135. #define arch_decomp_wdog()
  136. static void flush(void)
  137. {
  138. /* nothing */
  139. }
  140. #endif /* ifndef __ASM_ARCH_UNCOMPRESS_H */