1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Atheros AR71XX/AR724X/AR913X common definitions
4  *
5  * Copyright (C) 2018-2019 Rosy Song <rosysong@rosinson.com>
6  * Copyright (C) 2015-2016 Wills Wang <wills.wang@live.com>
7  * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
8  * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
9  */
10 
11 #ifndef __ASM_MACH_ATH79_H
12 #define __ASM_MACH_ATH79_H
13 
14 #include <asm/global_data.h>
15 #include <linux/types.h>
16 
17 DECLARE_GLOBAL_DATA_PTR;
18 
19 enum ath79_soc_type {
20 	ATH79_SOC_UNKNOWN,
21 	ATH79_SOC_AR7130,
22 	ATH79_SOC_AR7141,
23 	ATH79_SOC_AR7161,
24 	ATH79_SOC_AR7240,
25 	ATH79_SOC_AR7241,
26 	ATH79_SOC_AR7242,
27 	ATH79_SOC_AR9130,
28 	ATH79_SOC_AR9132,
29 	ATH79_SOC_AR9330,
30 	ATH79_SOC_AR9331,
31 	ATH79_SOC_AR9341,
32 	ATH79_SOC_AR9342,
33 	ATH79_SOC_AR9344,
34 	ATH79_SOC_QCA9533,
35 	ATH79_SOC_QCA9556,
36 	ATH79_SOC_QCA9558,
37 	ATH79_SOC_TP9343,
38 	ATH79_SOC_QCA9561,
39 };
40 
soc_is_ar71xx(void)41 static inline int soc_is_ar71xx(void)
42 {
43 	return gd->arch.soc == ATH79_SOC_AR7130 ||
44 		gd->arch.soc == ATH79_SOC_AR7141 ||
45 		gd->arch.soc == ATH79_SOC_AR7161;
46 }
47 
soc_is_ar724x(void)48 static inline int soc_is_ar724x(void)
49 {
50 	return gd->arch.soc == ATH79_SOC_AR7240 ||
51 		gd->arch.soc == ATH79_SOC_AR7241 ||
52 		gd->arch.soc == ATH79_SOC_AR7242;
53 }
54 
soc_is_ar7240(void)55 static inline int soc_is_ar7240(void)
56 {
57 	return gd->arch.soc == ATH79_SOC_AR7240;
58 }
59 
soc_is_ar7241(void)60 static inline int soc_is_ar7241(void)
61 {
62 	return gd->arch.soc == ATH79_SOC_AR7241;
63 }
64 
soc_is_ar7242(void)65 static inline int soc_is_ar7242(void)
66 {
67 	return gd->arch.soc == ATH79_SOC_AR7242;
68 }
69 
soc_is_ar913x(void)70 static inline int soc_is_ar913x(void)
71 {
72 	return gd->arch.soc == ATH79_SOC_AR9130 ||
73 		gd->arch.soc == ATH79_SOC_AR9132;
74 }
75 
soc_is_ar933x(void)76 static inline int soc_is_ar933x(void)
77 {
78 	return gd->arch.soc == ATH79_SOC_AR9330 ||
79 		gd->arch.soc == ATH79_SOC_AR9331;
80 }
81 
soc_is_ar9341(void)82 static inline int soc_is_ar9341(void)
83 {
84 	return gd->arch.soc == ATH79_SOC_AR9341;
85 }
86 
soc_is_ar9342(void)87 static inline int soc_is_ar9342(void)
88 {
89 	return gd->arch.soc == ATH79_SOC_AR9342;
90 }
91 
soc_is_ar9344(void)92 static inline int soc_is_ar9344(void)
93 {
94 	return gd->arch.soc == ATH79_SOC_AR9344;
95 }
96 
soc_is_ar934x(void)97 static inline int soc_is_ar934x(void)
98 {
99 	return soc_is_ar9341() ||
100 		soc_is_ar9342() ||
101 		soc_is_ar9344();
102 }
103 
soc_is_qca9533(void)104 static inline int soc_is_qca9533(void)
105 {
106 	return gd->arch.soc == ATH79_SOC_QCA9533;
107 }
108 
soc_is_qca953x(void)109 static inline int soc_is_qca953x(void)
110 {
111 	return soc_is_qca9533();
112 }
113 
soc_is_qca9556(void)114 static inline int soc_is_qca9556(void)
115 {
116 	return gd->arch.soc == ATH79_SOC_QCA9556;
117 }
118 
soc_is_qca9558(void)119 static inline int soc_is_qca9558(void)
120 {
121 	return gd->arch.soc == ATH79_SOC_QCA9558;
122 }
123 
soc_is_qca955x(void)124 static inline int soc_is_qca955x(void)
125 {
126 	return soc_is_qca9556() || soc_is_qca9558();
127 }
128 
soc_is_tp9343(void)129 static inline int soc_is_tp9343(void)
130 {
131 	return gd->arch.soc == ATH79_SOC_TP9343;
132 }
133 
soc_is_qca9561(void)134 static inline int soc_is_qca9561(void)
135 {
136 	return gd->arch.soc == ATH79_SOC_QCA9561;
137 }
138 
soc_is_qca956x(void)139 static inline int soc_is_qca956x(void)
140 {
141 	return soc_is_tp9343() || soc_is_qca9561();
142 }
143 
144 u32 ath79_get_bootstrap(void);
145 int ath79_eth_reset(void);
146 int ath79_usb_reset(void);
147 
148 void ar934x_pll_init(const u16 cpu_mhz, const u16 ddr_mhz, const u16 ahb_mhz);
149 void ar934x_ddr_init(const u16 cpu_mhz, const u16 ddr_mhz, const u16 ahb_mhz);
150 
151 void qca956x_pll_init(void);
152 void qca956x_ddr_init(void);
153 #endif /* __ASM_MACH_ATH79_H */
154