ath79.h 3.4 KB

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