SPDX: Convert all of our single license tags to Linux Kernel style
[platform/kernel/u-boot.git] / drivers / usb / common / fsl-errata.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Freescale USB Controller
4  *
5  * Copyright 2013 Freescale Semiconductor, Inc.
6  */
7
8 #include <common.h>
9 #include <fsl_errata.h>
10 #include<fsl_usb.h>
11 #if defined(CONFIG_FSL_LSCH2) || defined(CONFIG_FSL_LSCH3) || \
12         defined(CONFIG_ARM)
13 #include <asm/arch/clock.h>
14 #endif
15
16 /* USB Erratum Checking code */
17 #if defined(CONFIG_PPC) || defined(CONFIG_ARM)
18 bool has_dual_phy(void)
19 {
20         u32 svr = get_svr();
21         u32 soc = SVR_SOC_VER(svr);
22
23         switch (soc) {
24 #ifdef CONFIG_PPC
25         case SVR_T1023:
26         case SVR_T1024:
27         case SVR_T1013:
28         case SVR_T1014:
29                 return IS_SVR_REV(svr, 1, 0);
30         case SVR_T1040:
31         case SVR_T1042:
32         case SVR_T1020:
33         case SVR_T1022:
34         case SVR_T2080:
35         case SVR_T2081:
36                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
37         case SVR_T4240:
38         case SVR_T4160:
39         case SVR_T4080:
40                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
41 #endif
42         }
43
44         return false;
45 }
46
47 bool has_erratum_a006261(void)
48 {
49         u32 svr = get_svr();
50         u32 soc = SVR_SOC_VER(svr);
51
52         switch (soc) {
53 #ifdef CONFIG_PPC
54         case SVR_P1010:
55                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
56         case SVR_P2041:
57         case SVR_P2040:
58                 return IS_SVR_REV(svr, 1, 0) ||
59                         IS_SVR_REV(svr, 1, 1) ||
60                         IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1);
61         case SVR_P3041:
62                 return IS_SVR_REV(svr, 1, 0) ||
63                         IS_SVR_REV(svr, 1, 1) ||
64                         IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1);
65         case SVR_P5010:
66         case SVR_P5020:
67         case SVR_P5021:
68                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
69         case SVR_T4240:
70                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
71         case SVR_P5040:
72                 return IS_SVR_REV(svr, 1, 0) ||
73                         IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1);
74 #endif
75         }
76
77         return false;
78 }
79
80 bool has_erratum_a007075(void)
81 {
82         u32 svr = get_svr();
83         u32 soc = SVR_SOC_VER(svr);
84
85         switch (soc) {
86 #ifdef CONFIG_PPC
87         case SVR_B4860:
88         case SVR_B4420:
89                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
90         case SVR_P1010:
91                 return IS_SVR_REV(svr, 1, 0);
92         case SVR_P4080:
93                 return IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 3, 0);
94 #endif
95         }
96         return false;
97 }
98
99 bool has_erratum_a007798(void)
100 {
101 #ifdef CONFIG_PPC
102         return SVR_SOC_VER(get_svr()) == SVR_T4240 &&
103                 IS_SVR_REV(get_svr(), 2, 0);
104 #endif
105         return false;
106 }
107
108 bool has_erratum_a007792(void)
109 {
110         u32 svr = get_svr();
111         u32 soc = SVR_SOC_VER(svr);
112
113         switch (soc) {
114 #ifdef CONFIG_PPC
115         case SVR_T4240:
116         case SVR_T4160:
117         case SVR_T4080:
118                 return IS_SVR_REV(svr, 2, 0);
119         case SVR_T1024:
120         case SVR_T1023:
121                 return IS_SVR_REV(svr, 1, 0);
122         case SVR_T1040:
123         case SVR_T1042:
124         case SVR_T1020:
125         case SVR_T1022:
126         case SVR_T2080:
127         case SVR_T2081:
128                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
129 #endif
130         }
131         return false;
132 }
133
134 bool has_erratum_a005697(void)
135 {
136         u32 svr = get_svr();
137         u32 soc = SVR_SOC_VER(svr);
138
139         switch (soc) {
140 #ifdef CONFIG_PPC
141         case SVR_9131:
142         case SVR_9132:
143                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
144 #endif
145 #ifdef ONFIG_ARM64
146         case SVR_LS1012A:
147                 return IS_SVR_REV(svr, 1, 0);
148 #endif
149         }
150         return false;
151 }
152
153 bool has_erratum_a004477(void)
154 {
155         u32 svr = get_svr();
156         u32 soc = SVR_SOC_VER(svr);
157
158         switch (soc) {
159 #ifdef CONFIG_PPC
160         case SVR_P1010:
161                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
162         case SVR_P1022:
163         case SVR_9131:
164         case SVR_9132:
165                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
166         case SVR_P2020:
167                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0) ||
168                         IS_SVR_REV(svr, 2, 1);
169         case SVR_B4860:
170         case SVR_B4420:
171                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
172         case SVR_P4080:
173                 return IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 3, 0);
174 #endif
175         }
176
177         return false;
178 }
179
180 bool has_erratum_a008751(void)
181 {
182         u32 svr = get_svr();
183         u32 soc = SVR_SOC_VER(svr);
184
185         switch (soc) {
186 #ifdef CONFIG_ARM64
187         case SVR_LS2080A:
188         case SVR_LS2085A:
189                 return IS_SVR_REV(svr, 1, 0);
190 #endif
191         }
192         return false;
193 }
194
195 bool has_erratum_a010151(void)
196 {
197         u32 svr = get_svr();
198         u32 soc = SVR_SOC_VER(svr);
199
200 #ifdef CONFIG_ARM64
201         if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1043A)))
202                 return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
203 #endif
204
205         switch (soc) {
206 #ifdef CONFIG_ARM64
207         case SVR_LS2080A:
208         case SVR_LS2085A:
209                         /* fallthrough */
210         case SVR_LS2088A:
211                         /* fallthrough */
212         case SVR_LS2081A:
213         case SVR_LS1046A:
214         case SVR_LS1012A:
215                 return IS_SVR_REV(svr, 1, 0);
216 #endif
217 #ifdef CONFIG_ARCH_LS1021A
218         case SOC_VER_LS1020:
219         case SOC_VER_LS1021:
220         case SOC_VER_LS1022:
221         case SOC_VER_SLS1020:
222                 return IS_SVR_REV(svr, 2, 0);
223 #endif
224         }
225         return false;
226 }
227
228 #endif