1d4a67d9dSGabor Juhos /* 2d4a67d9dSGabor Juhos * Atheros AR71XX/AR724X/AR913X common definitions 3d4a67d9dSGabor Juhos * 4d4a67d9dSGabor Juhos * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> 5d4a67d9dSGabor Juhos * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> 6d4a67d9dSGabor Juhos * 7d4a67d9dSGabor Juhos * Parts of this file are based on Atheros' 2.6.15 BSP 8d4a67d9dSGabor Juhos * 9d4a67d9dSGabor Juhos * This program is free software; you can redistribute it and/or modify it 10d4a67d9dSGabor Juhos * under the terms of the GNU General Public License version 2 as published 11d4a67d9dSGabor Juhos * by the Free Software Foundation. 12d4a67d9dSGabor Juhos */ 13d4a67d9dSGabor Juhos 14d4a67d9dSGabor Juhos #ifndef __ASM_MACH_ATH79_H 15d4a67d9dSGabor Juhos #define __ASM_MACH_ATH79_H 16d4a67d9dSGabor Juhos 17d4a67d9dSGabor Juhos #include <linux/types.h> 18d4a67d9dSGabor Juhos #include <linux/io.h> 19d4a67d9dSGabor Juhos 20d4a67d9dSGabor Juhos enum ath79_soc_type { 21d4a67d9dSGabor Juhos ATH79_SOC_UNKNOWN, 22d4a67d9dSGabor Juhos ATH79_SOC_AR7130, 23d4a67d9dSGabor Juhos ATH79_SOC_AR7141, 24d4a67d9dSGabor Juhos ATH79_SOC_AR7161, 25d4a67d9dSGabor Juhos ATH79_SOC_AR7240, 26d4a67d9dSGabor Juhos ATH79_SOC_AR7241, 27d4a67d9dSGabor Juhos ATH79_SOC_AR7242, 28d4a67d9dSGabor Juhos ATH79_SOC_AR9130, 296d1c8fdeSGabor Juhos ATH79_SOC_AR9132, 306d1c8fdeSGabor Juhos ATH79_SOC_AR9330, 316d1c8fdeSGabor Juhos ATH79_SOC_AR9331, 32d8411466SGabor Juhos ATH79_SOC_AR9341, 33d8411466SGabor Juhos ATH79_SOC_AR9342, 34d8411466SGabor Juhos ATH79_SOC_AR9344, 352e6c91e3SGabor Juhos ATH79_SOC_QCA9556, 362e6c91e3SGabor Juhos ATH79_SOC_QCA9558, 37d4a67d9dSGabor Juhos }; 38d4a67d9dSGabor Juhos 39d4a67d9dSGabor Juhos extern enum ath79_soc_type ath79_soc; 40be5f3623SGabor Juhos extern unsigned int ath79_soc_rev; 41d4a67d9dSGabor Juhos 42d4a67d9dSGabor Juhos static inline int soc_is_ar71xx(void) 43d4a67d9dSGabor Juhos { 44d4a67d9dSGabor Juhos return (ath79_soc == ATH79_SOC_AR7130 || 45d4a67d9dSGabor Juhos ath79_soc == ATH79_SOC_AR7141 || 46d4a67d9dSGabor Juhos ath79_soc == ATH79_SOC_AR7161); 47d4a67d9dSGabor Juhos } 48d4a67d9dSGabor Juhos 49d4a67d9dSGabor Juhos static inline int soc_is_ar724x(void) 50d4a67d9dSGabor Juhos { 51d4a67d9dSGabor Juhos return (ath79_soc == ATH79_SOC_AR7240 || 52d4a67d9dSGabor Juhos ath79_soc == ATH79_SOC_AR7241 || 53d4a67d9dSGabor Juhos ath79_soc == ATH79_SOC_AR7242); 54d4a67d9dSGabor Juhos } 55d4a67d9dSGabor Juhos 56d4a67d9dSGabor Juhos static inline int soc_is_ar7240(void) 57d4a67d9dSGabor Juhos { 58d4a67d9dSGabor Juhos return (ath79_soc == ATH79_SOC_AR7240); 59d4a67d9dSGabor Juhos } 60d4a67d9dSGabor Juhos 61d4a67d9dSGabor Juhos static inline int soc_is_ar7241(void) 62d4a67d9dSGabor Juhos { 63d4a67d9dSGabor Juhos return (ath79_soc == ATH79_SOC_AR7241); 64d4a67d9dSGabor Juhos } 65d4a67d9dSGabor Juhos 66d4a67d9dSGabor Juhos static inline int soc_is_ar7242(void) 67d4a67d9dSGabor Juhos { 68d4a67d9dSGabor Juhos return (ath79_soc == ATH79_SOC_AR7242); 69d4a67d9dSGabor Juhos } 70d4a67d9dSGabor Juhos 71d4a67d9dSGabor Juhos static inline int soc_is_ar913x(void) 72d4a67d9dSGabor Juhos { 73d4a67d9dSGabor Juhos return (ath79_soc == ATH79_SOC_AR9130 || 74d4a67d9dSGabor Juhos ath79_soc == ATH79_SOC_AR9132); 75d4a67d9dSGabor Juhos } 76d4a67d9dSGabor Juhos 7704225e1dSGabor Juhos static inline int soc_is_ar933x(void) 7804225e1dSGabor Juhos { 7904225e1dSGabor Juhos return (ath79_soc == ATH79_SOC_AR9330 || 8004225e1dSGabor Juhos ath79_soc == ATH79_SOC_AR9331); 8104225e1dSGabor Juhos } 8204225e1dSGabor Juhos 83d8411466SGabor Juhos static inline int soc_is_ar9341(void) 84d8411466SGabor Juhos { 85d8411466SGabor Juhos return (ath79_soc == ATH79_SOC_AR9341); 86d8411466SGabor Juhos } 87d8411466SGabor Juhos 88d8411466SGabor Juhos static inline int soc_is_ar9342(void) 89d8411466SGabor Juhos { 90d8411466SGabor Juhos return (ath79_soc == ATH79_SOC_AR9342); 91d8411466SGabor Juhos } 92d8411466SGabor Juhos 93d8411466SGabor Juhos static inline int soc_is_ar9344(void) 94d8411466SGabor Juhos { 95d8411466SGabor Juhos return (ath79_soc == ATH79_SOC_AR9344); 96d8411466SGabor Juhos } 97d8411466SGabor Juhos 98d8411466SGabor Juhos static inline int soc_is_ar934x(void) 99d8411466SGabor Juhos { 100d8411466SGabor Juhos return soc_is_ar9341() || soc_is_ar9342() || soc_is_ar9344(); 101d8411466SGabor Juhos } 102d8411466SGabor Juhos 1032e6c91e3SGabor Juhos static inline int soc_is_qca9556(void) 1042e6c91e3SGabor Juhos { 1052e6c91e3SGabor Juhos return ath79_soc == ATH79_SOC_QCA9556; 1062e6c91e3SGabor Juhos } 1072e6c91e3SGabor Juhos 1082e6c91e3SGabor Juhos static inline int soc_is_qca9558(void) 1092e6c91e3SGabor Juhos { 1102e6c91e3SGabor Juhos return ath79_soc == ATH79_SOC_QCA9558; 1112e6c91e3SGabor Juhos } 1122e6c91e3SGabor Juhos 1132e6c91e3SGabor Juhos static inline int soc_is_qca955x(void) 1142e6c91e3SGabor Juhos { 1152e6c91e3SGabor Juhos return soc_is_qca9556() || soc_is_qca9558(); 1162e6c91e3SGabor Juhos } 1172e6c91e3SGabor Juhos 118*24b0e3e8SAlban Bedel void ath79_ddr_set_pci_windows(void); 119*24b0e3e8SAlban Bedel 120d4a67d9dSGabor Juhos extern void __iomem *ath79_pll_base; 121d4a67d9dSGabor Juhos extern void __iomem *ath79_reset_base; 122d4a67d9dSGabor Juhos 123d4a67d9dSGabor Juhos static inline void ath79_pll_wr(unsigned reg, u32 val) 124d4a67d9dSGabor Juhos { 125d4a67d9dSGabor Juhos __raw_writel(val, ath79_pll_base + reg); 126d4a67d9dSGabor Juhos } 127d4a67d9dSGabor Juhos 128d4a67d9dSGabor Juhos static inline u32 ath79_pll_rr(unsigned reg) 129d4a67d9dSGabor Juhos { 130d4a67d9dSGabor Juhos return __raw_readl(ath79_pll_base + reg); 131d4a67d9dSGabor Juhos } 132d4a67d9dSGabor Juhos 133d4a67d9dSGabor Juhos static inline void ath79_reset_wr(unsigned reg, u32 val) 134d4a67d9dSGabor Juhos { 135d4a67d9dSGabor Juhos __raw_writel(val, ath79_reset_base + reg); 136d4a67d9dSGabor Juhos } 137d4a67d9dSGabor Juhos 138d4a67d9dSGabor Juhos static inline u32 ath79_reset_rr(unsigned reg) 139d4a67d9dSGabor Juhos { 140d4a67d9dSGabor Juhos return __raw_readl(ath79_reset_base + reg); 141d4a67d9dSGabor Juhos } 142d4a67d9dSGabor Juhos 143d4a67d9dSGabor Juhos void ath79_device_reset_set(u32 mask); 144d4a67d9dSGabor Juhos void ath79_device_reset_clear(u32 mask); 145d4a67d9dSGabor Juhos 146d4a67d9dSGabor Juhos #endif /* __ASM_MACH_ATH79_H */ 147