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 <hwconfig.h>
10#include <fsl_errata.h>
11#include<fsl_usb.h>
12#if defined(CONFIG_FSL_LSCH2) || defined(CONFIG_FSL_LSCH3) || \
13	defined(CONFIG_ARM)
14#include <asm/arch/clock.h>
15#endif
16
17/* USB Erratum Checking code */
18#if defined(CONFIG_PPC) || defined(CONFIG_ARM)
19bool has_dual_phy(void)
20{
21	u32 svr = get_svr();
22	u32 soc = SVR_SOC_VER(svr);
23
24	switch (soc) {
25#ifdef CONFIG_PPC
26	case SVR_T1023:
27	case SVR_T1024:
28	case SVR_T1013:
29	case SVR_T1014:
30		return IS_SVR_REV(svr, 1, 0);
31	case SVR_T1040:
32	case SVR_T1042:
33	case SVR_T1020:
34	case SVR_T1022:
35	case SVR_T2080:
36	case SVR_T2081:
37		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
38	case SVR_T4240:
39	case SVR_T4160:
40	case SVR_T4080:
41		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
42#endif
43	}
44
45	return false;
46}
47
48bool has_erratum_a005275(void)
49{
50	u32 svr = get_svr();
51	u32 soc = SVR_SOC_VER(svr);
52
53	if (hwconfig("no_erratum_a005275"))
54		return false;
55
56	switch (soc) {
57#ifdef CONFIG_PPC
58	case SVR_P3041:
59	case SVR_P2041:
60	case SVR_P2040:
61		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
62	case SVR_P5010:
63	case SVR_P5020:
64	case SVR_P5021:
65		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
66	case SVR_P5040:
67	case SVR_P1010:
68		return IS_SVR_REV(svr, 1, 0);
69#endif
70	}
71
72	return false;
73}
74
75bool has_erratum_a006261(void)
76{
77	u32 svr = get_svr();
78	u32 soc = SVR_SOC_VER(svr);
79
80	switch (soc) {
81#ifdef CONFIG_PPC
82	case SVR_P1010:
83		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
84	case SVR_P2041:
85	case SVR_P2040:
86		return IS_SVR_REV(svr, 1, 0) ||
87			IS_SVR_REV(svr, 1, 1) ||
88			IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1);
89	case SVR_P3041:
90		return IS_SVR_REV(svr, 1, 0) ||
91			IS_SVR_REV(svr, 1, 1) ||
92			IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1);
93	case SVR_P5010:
94	case SVR_P5020:
95	case SVR_P5021:
96		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
97	case SVR_T4240:
98		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
99	case SVR_P5040:
100		return IS_SVR_REV(svr, 1, 0) ||
101			IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1);
102#endif
103	}
104
105	return false;
106}
107
108bool has_erratum_a007075(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_B4860:
116	case SVR_B4420:
117		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
118	case SVR_P1010:
119		return IS_SVR_REV(svr, 1, 0);
120	case SVR_P4080:
121		return IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 3, 0);
122#endif
123	}
124	return false;
125}
126
127bool has_erratum_a007798(void)
128{
129#ifdef CONFIG_PPC
130	return SVR_SOC_VER(get_svr()) == SVR_T4240 &&
131		IS_SVR_REV(get_svr(), 2, 0);
132#endif
133	return false;
134}
135
136bool has_erratum_a007792(void)
137{
138	u32 svr = get_svr();
139	u32 soc = SVR_SOC_VER(svr);
140
141	switch (soc) {
142#ifdef CONFIG_PPC
143	case SVR_T4240:
144	case SVR_T4160:
145	case SVR_T4080:
146		return IS_SVR_REV(svr, 2, 0);
147	case SVR_T1024:
148	case SVR_T1023:
149		return IS_SVR_REV(svr, 1, 0);
150	case SVR_T1040:
151	case SVR_T1042:
152	case SVR_T1020:
153	case SVR_T1022:
154	case SVR_T2080:
155	case SVR_T2081:
156		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
157#endif
158	}
159	return false;
160}
161
162bool has_erratum_a005697(void)
163{
164	u32 svr = get_svr();
165	u32 soc = SVR_SOC_VER(svr);
166
167	switch (soc) {
168#ifdef CONFIG_PPC
169	case SVR_9131:
170	case SVR_9132:
171		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
172#endif
173#ifdef ONFIG_ARM64
174	case SVR_LS1012A:
175		return IS_SVR_REV(svr, 1, 0);
176#endif
177	}
178	return false;
179}
180
181bool has_erratum_a004477(void)
182{
183	u32 svr = get_svr();
184	u32 soc = SVR_SOC_VER(svr);
185
186	switch (soc) {
187#ifdef CONFIG_PPC
188	case SVR_P1010:
189		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
190	case SVR_P1022:
191	case SVR_9131:
192	case SVR_9132:
193		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
194	case SVR_P2020:
195		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0) ||
196			IS_SVR_REV(svr, 2, 1);
197	case SVR_B4860:
198	case SVR_B4420:
199		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0);
200	case SVR_P4080:
201		return IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 3, 0);
202#endif
203	}
204
205	return false;
206}
207
208bool has_erratum_a008751(void)
209{
210	u32 svr = get_svr();
211	u32 soc = SVR_SOC_VER(svr);
212
213	switch (soc) {
214#ifdef CONFIG_ARM64
215	case SVR_LS2080A:
216	case SVR_LS2085A:
217		return IS_SVR_REV(svr, 1, 0);
218#endif
219	}
220	return false;
221}
222
223bool has_erratum_a010151(void)
224{
225	u32 svr = get_svr();
226	u32 soc = SVR_SOC_VER(svr);
227
228#ifdef CONFIG_ARM64
229	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1043A)))
230		return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1);
231#endif
232
233	switch (soc) {
234#ifdef CONFIG_ARM64
235	case SVR_LS2080A:
236	case SVR_LS2085A:
237			/* fallthrough */
238	case SVR_LS2088A:
239			/* fallthrough */
240	case SVR_LS2081A:
241	case SVR_LS1046A:
242	case SVR_LS1012A:
243		return IS_SVR_REV(svr, 1, 0);
244#endif
245#ifdef CONFIG_ARCH_LS1021A
246	case SOC_VER_LS1020:
247	case SOC_VER_LS1021:
248	case SOC_VER_LS1022:
249	case SOC_VER_SLS1020:
250		return IS_SVR_REV(svr, 2, 0);
251#endif
252	}
253	return false;
254}
255
256#endif
257