ath79.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Atheros AR71XX/AR724X/AR913X common definitions
  3. *
  4. * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6. *
  7. * Parts of this file are based on Atheros' 2.6.15 BSP
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published
  11. * by the Free Software Foundation.
  12. */
  13. #ifndef __ASM_MACH_ATH79_H
  14. #define __ASM_MACH_ATH79_H
  15. #include <linux/types.h>
  16. #include <linux/io.h>
  17. enum ath79_soc_type {
  18. ATH79_SOC_UNKNOWN,
  19. ATH79_SOC_AR7130,
  20. ATH79_SOC_AR7141,
  21. ATH79_SOC_AR7161,
  22. ATH79_SOC_AR7240,
  23. ATH79_SOC_AR7241,
  24. ATH79_SOC_AR7242,
  25. ATH79_SOC_AR9130,
  26. ATH79_SOC_AR9132,
  27. ATH79_SOC_AR9330,
  28. ATH79_SOC_AR9331,
  29. ATH79_SOC_AR9341,
  30. ATH79_SOC_AR9342,
  31. ATH79_SOC_AR9344,
  32. ATH79_SOC_QCA9533,
  33. ATH79_SOC_QCA9556,
  34. ATH79_SOC_QCA9558,
  35. ATH79_SOC_TP9343,
  36. ATH79_SOC_QCA956X,
  37. };
  38. extern enum ath79_soc_type ath79_soc;
  39. extern unsigned int ath79_soc_rev;
  40. static inline int soc_is_ar71xx(void)
  41. {
  42. return (ath79_soc == ATH79_SOC_AR7130 ||
  43. ath79_soc == ATH79_SOC_AR7141 ||
  44. ath79_soc == ATH79_SOC_AR7161);
  45. }
  46. static inline int soc_is_ar724x(void)
  47. {
  48. return (ath79_soc == ATH79_SOC_AR7240 ||
  49. ath79_soc == ATH79_SOC_AR7241 ||
  50. ath79_soc == ATH79_SOC_AR7242);
  51. }
  52. static inline int soc_is_ar7240(void)
  53. {
  54. return (ath79_soc == ATH79_SOC_AR7240);
  55. }
  56. static inline int soc_is_ar7241(void)
  57. {
  58. return (ath79_soc == ATH79_SOC_AR7241);
  59. }
  60. static inline int soc_is_ar7242(void)
  61. {
  62. return (ath79_soc == ATH79_SOC_AR7242);
  63. }
  64. static inline int soc_is_ar913x(void)
  65. {
  66. return (ath79_soc == ATH79_SOC_AR9130 ||
  67. ath79_soc == ATH79_SOC_AR9132);
  68. }
  69. static inline int soc_is_ar933x(void)
  70. {
  71. return (ath79_soc == ATH79_SOC_AR9330 ||
  72. ath79_soc == ATH79_SOC_AR9331);
  73. }
  74. static inline int soc_is_ar9341(void)
  75. {
  76. return (ath79_soc == ATH79_SOC_AR9341);
  77. }
  78. static inline int soc_is_ar9342(void)
  79. {
  80. return (ath79_soc == ATH79_SOC_AR9342);
  81. }
  82. static inline int soc_is_ar9344(void)
  83. {
  84. return (ath79_soc == ATH79_SOC_AR9344);
  85. }
  86. static inline int soc_is_ar934x(void)
  87. {
  88. return soc_is_ar9341() || soc_is_ar9342() || soc_is_ar9344();
  89. }
  90. static inline int soc_is_qca9533(void)
  91. {
  92. return ath79_soc == ATH79_SOC_QCA9533;
  93. }
  94. static inline int soc_is_qca953x(void)
  95. {
  96. return soc_is_qca9533();
  97. }
  98. static inline int soc_is_qca9556(void)
  99. {
  100. return ath79_soc == ATH79_SOC_QCA9556;
  101. }
  102. static inline int soc_is_qca9558(void)
  103. {
  104. return ath79_soc == ATH79_SOC_QCA9558;
  105. }
  106. static inline int soc_is_qca955x(void)
  107. {
  108. return soc_is_qca9556() || soc_is_qca9558();
  109. }
  110. static inline int soc_is_tp9343(void)
  111. {
  112. return ath79_soc == ATH79_SOC_TP9343;
  113. }
  114. static inline int soc_is_qca9561(void)
  115. {
  116. return ath79_soc == ATH79_SOC_QCA956X;
  117. }
  118. static inline int soc_is_qca9563(void)
  119. {
  120. return ath79_soc == ATH79_SOC_QCA956X;
  121. }
  122. static inline int soc_is_qca956x(void)
  123. {
  124. return soc_is_qca9561() || soc_is_qca9563();
  125. }
  126. void ath79_ddr_wb_flush(unsigned int reg);
  127. void ath79_ddr_set_pci_windows(void);
  128. extern void __iomem *ath79_pll_base;
  129. extern void __iomem *ath79_reset_base;
  130. static inline void ath79_pll_wr(unsigned reg, u32 val)
  131. {
  132. __raw_writel(val, ath79_pll_base + reg);
  133. }
  134. static inline u32 ath79_pll_rr(unsigned reg)
  135. {
  136. return __raw_readl(ath79_pll_base + reg);
  137. }
  138. static inline void ath79_reset_wr(unsigned reg, u32 val)
  139. {
  140. __raw_writel(val, ath79_reset_base + reg);
  141. (void) __raw_readl(ath79_reset_base + reg); /* flush */
  142. }
  143. static inline u32 ath79_reset_rr(unsigned reg)
  144. {
  145. return __raw_readl(ath79_reset_base + reg);
  146. }
  147. void ath79_device_reset_set(u32 mask);
  148. void ath79_device_reset_clear(u32 mask);
  149. void ath79_cpu_irq_init(unsigned irq_wb_chan2, unsigned irq_wb_chan3);
  150. void ath79_misc_irq_init(void __iomem *regs, int irq,
  151. int irq_base, bool is_ar71xx);
  152. #endif /* __ASM_MACH_ATH79_H */