blob: 47e8827e956498759a777071b872477b42c4c37e [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 Juhosd8411462012-03-14 10:45:21 +010032 ATH79_SOC_AR9341,
33 ATH79_SOC_AR9342,
34 ATH79_SOC_AR9344,
Matthias Schifferaf2d1b52018-07-20 13:58:19 +020035 ATH79_SOC_QCA9533,
Gabor Juhos2e6c91e2013-02-15 13:38:16 +000036 ATH79_SOC_QCA9556,
37 ATH79_SOC_QCA9558,
Matthias Schifferaf2d1b52018-07-20 13:58:19 +020038 ATH79_SOC_TP9343,
39 ATH79_SOC_QCA956X,
Gabor Juhosd4a67d92011-01-04 21:28:14 +010040};
41
42extern enum ath79_soc_type ath79_soc;
Gabor Juhosbe5f3622011-11-18 00:17:46 +000043extern unsigned int ath79_soc_rev;
Gabor Juhosd4a67d92011-01-04 21:28:14 +010044
45static inline int soc_is_ar71xx(void)
46{
47 return (ath79_soc == ATH79_SOC_AR7130 ||
48 ath79_soc == ATH79_SOC_AR7141 ||
49 ath79_soc == ATH79_SOC_AR7161);
50}
51
52static inline int soc_is_ar724x(void)
53{
54 return (ath79_soc == ATH79_SOC_AR7240 ||
55 ath79_soc == ATH79_SOC_AR7241 ||
56 ath79_soc == ATH79_SOC_AR7242);
57}
58
59static inline int soc_is_ar7240(void)
60{
61 return (ath79_soc == ATH79_SOC_AR7240);
62}
63
64static inline int soc_is_ar7241(void)
65{
66 return (ath79_soc == ATH79_SOC_AR7241);
67}
68
69static inline int soc_is_ar7242(void)
70{
71 return (ath79_soc == ATH79_SOC_AR7242);
72}
73
74static inline int soc_is_ar913x(void)
75{
76 return (ath79_soc == ATH79_SOC_AR9130 ||
77 ath79_soc == ATH79_SOC_AR9132);
78}
79
Gabor Juhos04225e12011-06-20 21:26:04 +020080static inline int soc_is_ar933x(void)
81{
82 return (ath79_soc == ATH79_SOC_AR9330 ||
83 ath79_soc == ATH79_SOC_AR9331);
84}
85
Gabor Juhosd8411462012-03-14 10:45:21 +010086static inline int soc_is_ar9341(void)
87{
88 return (ath79_soc == ATH79_SOC_AR9341);
89}
90
91static inline int soc_is_ar9342(void)
92{
93 return (ath79_soc == ATH79_SOC_AR9342);
94}
95
96static inline int soc_is_ar9344(void)
97{
98 return (ath79_soc == ATH79_SOC_AR9344);
99}
100
101static inline int soc_is_ar934x(void)
102{
103 return soc_is_ar9341() || soc_is_ar9342() || soc_is_ar9344();
104}
105
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200106static inline int soc_is_qca9533(void)
107{
108 return ath79_soc == ATH79_SOC_QCA9533;
109}
110
111static inline int soc_is_qca953x(void)
112{
113 return soc_is_qca9533();
114}
115
Gabor Juhos2e6c91e2013-02-15 13:38:16 +0000116static inline int soc_is_qca9556(void)
117{
118 return ath79_soc == ATH79_SOC_QCA9556;
119}
120
121static inline int soc_is_qca9558(void)
122{
123 return ath79_soc == ATH79_SOC_QCA9558;
124}
125
126static inline int soc_is_qca955x(void)
127{
128 return soc_is_qca9556() || soc_is_qca9558();
129}
130
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200131static inline int soc_is_tp9343(void)
132{
133 return ath79_soc == ATH79_SOC_TP9343;
134}
135
136static inline int soc_is_qca9561(void)
137{
138 return ath79_soc == ATH79_SOC_QCA956X;
139}
140
141static inline int soc_is_qca9563(void)
142{
143 return ath79_soc == ATH79_SOC_QCA956X;
144}
145
146static inline int soc_is_qca956x(void)
147{
148 return soc_is_qca9561() || soc_is_qca9563();
149}
150
Alban Bedelc166fe72015-11-17 20:34:55 +0100151void ath79_ddr_wb_flush(unsigned int reg);
Alban Bedel24b0e3e2015-04-19 14:30:03 +0200152void ath79_ddr_set_pci_windows(void);
153
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100154extern void __iomem *ath79_pll_base;
155extern void __iomem *ath79_reset_base;
156
157static inline void ath79_pll_wr(unsigned reg, u32 val)
158{
159 __raw_writel(val, ath79_pll_base + reg);
160}
161
162static inline u32 ath79_pll_rr(unsigned reg)
163{
164 return __raw_readl(ath79_pll_base + reg);
165}
166
167static inline void ath79_reset_wr(unsigned reg, u32 val)
168{
169 __raw_writel(val, ath79_reset_base + reg);
Felix Fietkauf8a7bfe2018-07-20 13:58:22 +0200170 (void) __raw_readl(ath79_reset_base + reg); /* flush */
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100171}
172
173static inline u32 ath79_reset_rr(unsigned reg)
174{
175 return __raw_readl(ath79_reset_base + reg);
176}
177
178void ath79_device_reset_set(u32 mask);
179void ath79_device_reset_clear(u32 mask);
180
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100181#endif /* __ASM_MACH_ATH79_H */