ath79.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. };
  33. extern enum ath79_soc_type ath79_soc;
  34. extern unsigned int ath79_soc_rev;
  35. static inline int soc_is_ar71xx(void)
  36. {
  37. return (ath79_soc == ATH79_SOC_AR7130 ||
  38. ath79_soc == ATH79_SOC_AR7141 ||
  39. ath79_soc == ATH79_SOC_AR7161);
  40. }
  41. static inline int soc_is_ar724x(void)
  42. {
  43. return (ath79_soc == ATH79_SOC_AR7240 ||
  44. ath79_soc == ATH79_SOC_AR7241 ||
  45. ath79_soc == ATH79_SOC_AR7242);
  46. }
  47. static inline int soc_is_ar7240(void)
  48. {
  49. return (ath79_soc == ATH79_SOC_AR7240);
  50. }
  51. static inline int soc_is_ar7241(void)
  52. {
  53. return (ath79_soc == ATH79_SOC_AR7241);
  54. }
  55. static inline int soc_is_ar7242(void)
  56. {
  57. return (ath79_soc == ATH79_SOC_AR7242);
  58. }
  59. static inline int soc_is_ar913x(void)
  60. {
  61. return (ath79_soc == ATH79_SOC_AR9130 ||
  62. ath79_soc == ATH79_SOC_AR9132);
  63. }
  64. static inline int soc_is_ar933x(void)
  65. {
  66. return (ath79_soc == ATH79_SOC_AR9330 ||
  67. ath79_soc == ATH79_SOC_AR9331);
  68. }
  69. static inline int soc_is_ar9341(void)
  70. {
  71. return (ath79_soc == ATH79_SOC_AR9341);
  72. }
  73. static inline int soc_is_ar9342(void)
  74. {
  75. return (ath79_soc == ATH79_SOC_AR9342);
  76. }
  77. static inline int soc_is_ar9344(void)
  78. {
  79. return (ath79_soc == ATH79_SOC_AR9344);
  80. }
  81. static inline int soc_is_ar934x(void)
  82. {
  83. return soc_is_ar9341() || soc_is_ar9342() || soc_is_ar9344();
  84. }
  85. extern void __iomem *ath79_ddr_base;
  86. extern void __iomem *ath79_pll_base;
  87. extern void __iomem *ath79_reset_base;
  88. static inline void ath79_pll_wr(unsigned reg, u32 val)
  89. {
  90. __raw_writel(val, ath79_pll_base + reg);
  91. }
  92. static inline u32 ath79_pll_rr(unsigned reg)
  93. {
  94. return __raw_readl(ath79_pll_base + reg);
  95. }
  96. static inline void ath79_reset_wr(unsigned reg, u32 val)
  97. {
  98. __raw_writel(val, ath79_reset_base + reg);
  99. }
  100. static inline u32 ath79_reset_rr(unsigned reg)
  101. {
  102. return __raw_readl(ath79_reset_base + reg);
  103. }
  104. void ath79_device_reset_set(u32 mask);
  105. void ath79_device_reset_clear(u32 mask);
  106. #endif /* __ASM_MACH_ATH79_H */