blob: 6d0c6c9d5622fbe7890add97b200e4e6ced76d02 [file] [log] [blame]
Gabor Juhosd4a67d92011-01-04 21:28:14 +01001/*
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
14#ifndef __ASM_MACH_ATH79_H
15#define __ASM_MACH_ATH79_H
16
17#include <linux/types.h>
18#include <linux/io.h>
19
20enum ath79_soc_type {
21 ATH79_SOC_UNKNOWN,
22 ATH79_SOC_AR7130,
23 ATH79_SOC_AR7141,
24 ATH79_SOC_AR7161,
25 ATH79_SOC_AR7240,
26 ATH79_SOC_AR7241,
27 ATH79_SOC_AR7242,
28 ATH79_SOC_AR9130,
Gabor Juhos6d1c8fd2011-06-23 18:13:14 +020029 ATH79_SOC_AR9132,
30 ATH79_SOC_AR9330,
31 ATH79_SOC_AR9331,
Gabor Juhosd4a67d92011-01-04 21:28:14 +010032};
33
34extern enum ath79_soc_type ath79_soc;
Gabor Juhosbe5f3622011-11-18 00:17:46 +000035extern unsigned int ath79_soc_rev;
Gabor Juhosd4a67d92011-01-04 21:28:14 +010036
37static 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
44static inline int soc_is_ar724x(void)
45{
46 return (ath79_soc == ATH79_SOC_AR7240 ||
47 ath79_soc == ATH79_SOC_AR7241 ||
48 ath79_soc == ATH79_SOC_AR7242);
49}
50
51static inline int soc_is_ar7240(void)
52{
53 return (ath79_soc == ATH79_SOC_AR7240);
54}
55
56static inline int soc_is_ar7241(void)
57{
58 return (ath79_soc == ATH79_SOC_AR7241);
59}
60
61static inline int soc_is_ar7242(void)
62{
63 return (ath79_soc == ATH79_SOC_AR7242);
64}
65
66static inline int soc_is_ar913x(void)
67{
68 return (ath79_soc == ATH79_SOC_AR9130 ||
69 ath79_soc == ATH79_SOC_AR9132);
70}
71
Gabor Juhos04225e12011-06-20 21:26:04 +020072static inline int soc_is_ar933x(void)
73{
74 return (ath79_soc == ATH79_SOC_AR9330 ||
75 ath79_soc == ATH79_SOC_AR9331);
76}
77
Gabor Juhosd4a67d92011-01-04 21:28:14 +010078extern void __iomem *ath79_ddr_base;
79extern void __iomem *ath79_pll_base;
80extern void __iomem *ath79_reset_base;
81
82static inline void ath79_pll_wr(unsigned reg, u32 val)
83{
84 __raw_writel(val, ath79_pll_base + reg);
85}
86
87static inline u32 ath79_pll_rr(unsigned reg)
88{
89 return __raw_readl(ath79_pll_base + reg);
90}
91
92static inline void ath79_reset_wr(unsigned reg, u32 val)
93{
94 __raw_writel(val, ath79_reset_base + reg);
95}
96
97static inline u32 ath79_reset_rr(unsigned reg)
98{
99 return __raw_readl(ath79_reset_base + reg);
100}
101
102void ath79_device_reset_set(u32 mask);
103void ath79_device_reset_clear(u32 mask);
104
105#endif /* __ASM_MACH_ATH79_H */