This source file includes following definitions.
- cvmx_helper_board_get_mii_address
- __cvmx_helper_board_link_get
- __cvmx_helper_board_interface_probe
- __cvmx_helper_board_usb_get_clock_type
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #include <linux/bug.h>
35 #include <asm/octeon/octeon.h>
36 #include <asm/octeon/cvmx-bootinfo.h>
37
38 #include <asm/octeon/cvmx-config.h>
39
40 #include <asm/octeon/cvmx-helper.h>
41 #include <asm/octeon/cvmx-helper-util.h>
42 #include <asm/octeon/cvmx-helper-board.h>
43
44 #include <asm/octeon/cvmx-gmxx-defs.h>
45 #include <asm/octeon/cvmx-asxx-defs.h>
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 int cvmx_helper_board_get_mii_address(int ipd_port)
64 {
65 switch (cvmx_sysinfo_get()->board_type) {
66 case CVMX_BOARD_TYPE_SIM:
67
68 return -1;
69 case CVMX_BOARD_TYPE_EBT3000:
70 case CVMX_BOARD_TYPE_EBT5800:
71 case CVMX_BOARD_TYPE_THUNDER:
72 case CVMX_BOARD_TYPE_NICPRO2:
73
74 if ((ipd_port >= 16) && (ipd_port < 20))
75 return ipd_port - 16;
76 else
77 return -1;
78 case CVMX_BOARD_TYPE_KODAMA:
79 case CVMX_BOARD_TYPE_EBH3100:
80 case CVMX_BOARD_TYPE_HIKARI:
81 case CVMX_BOARD_TYPE_CN3010_EVB_HS5:
82 case CVMX_BOARD_TYPE_CN3005_EVB_HS5:
83 case CVMX_BOARD_TYPE_CN3020_EVB_HS5:
84
85
86
87
88 if (ipd_port == 0)
89 return 4;
90 else if (ipd_port == 1)
91 return 9;
92 else
93 return -1;
94 case CVMX_BOARD_TYPE_NAC38:
95
96 if ((ipd_port >= 0) && (ipd_port < 4))
97 return ipd_port;
98 else if ((ipd_port >= 16) && (ipd_port < 20))
99 return ipd_port - 16 + 4;
100 else
101 return -1;
102 case CVMX_BOARD_TYPE_EBH3000:
103
104 return -1;
105 case CVMX_BOARD_TYPE_EBH5200:
106 case CVMX_BOARD_TYPE_EBH5201:
107 case CVMX_BOARD_TYPE_EBT5200:
108
109 if ((ipd_port >= CVMX_HELPER_BOARD_MGMT_IPD_PORT) &&
110 (ipd_port < (CVMX_HELPER_BOARD_MGMT_IPD_PORT + 2)))
111 return ipd_port - CVMX_HELPER_BOARD_MGMT_IPD_PORT;
112
113
114
115
116 if ((ipd_port >= 0) && (ipd_port < 4))
117 return ipd_port + 2;
118 else
119 return -1;
120 case CVMX_BOARD_TYPE_EBH5600:
121 case CVMX_BOARD_TYPE_EBH5601:
122 case CVMX_BOARD_TYPE_EBH5610:
123
124 if (ipd_port == CVMX_HELPER_BOARD_MGMT_IPD_PORT)
125 return 0;
126
127
128
129
130 if ((ipd_port >= 0) && (ipd_port < 4))
131 return ipd_port + 1;
132 else
133 return -1;
134 case CVMX_BOARD_TYPE_CUST_NB5:
135 if (ipd_port == 2)
136 return 4;
137 else
138 return -1;
139 case CVMX_BOARD_TYPE_NIC_XLE_4G:
140
141 if ((ipd_port >= 16) && (ipd_port < 20))
142 return ipd_port - 16 + 1;
143 else
144 return -1;
145 case CVMX_BOARD_TYPE_NIC_XLE_10G:
146 case CVMX_BOARD_TYPE_NIC10E:
147 return -1;
148 case CVMX_BOARD_TYPE_NIC4E:
149 if (ipd_port >= 0 && ipd_port <= 3)
150 return (ipd_port + 0x1f) & 0x1f;
151 else
152 return -1;
153 case CVMX_BOARD_TYPE_NIC2E:
154 if (ipd_port >= 0 && ipd_port <= 1)
155 return ipd_port + 1;
156 else
157 return -1;
158 case CVMX_BOARD_TYPE_BBGW_REF:
159
160
161
162
163 return -1;
164
165 case CVMX_BOARD_TYPE_CUST_WSX16:
166 if (ipd_port >= 0 && ipd_port <= 3)
167 return ipd_port;
168 else if (ipd_port >= 16 && ipd_port <= 19)
169 return ipd_port - 16 + 4;
170 else
171 return -1;
172 case CVMX_BOARD_TYPE_UBNT_E100:
173 if (ipd_port >= 0 && ipd_port <= 2)
174 return 7 - ipd_port;
175 else
176 return -1;
177 case CVMX_BOARD_TYPE_KONTRON_S1901:
178 if (ipd_port == CVMX_HELPER_BOARD_MGMT_IPD_PORT)
179 return 1;
180 else
181 return -1;
182
183 }
184
185
186 cvmx_dprintf
187 ("cvmx_helper_board_get_mii_address: Unknown board type %d\n",
188 cvmx_sysinfo_get()->board_type);
189 return -1;
190 }
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210 cvmx_helper_link_info_t __cvmx_helper_board_link_get(int ipd_port)
211 {
212 cvmx_helper_link_info_t result;
213
214 WARN(!octeon_is_simulation(),
215 "Using deprecated link status - please update your DT");
216
217
218 result.u64 = 0;
219
220 if (octeon_is_simulation()) {
221
222 result.s.link_up = 1;
223 result.s.full_duplex = 1;
224 result.s.speed = 1000;
225 return result;
226 }
227
228 if (OCTEON_IS_MODEL(OCTEON_CN3XXX)
229 || OCTEON_IS_MODEL(OCTEON_CN58XX)
230 || OCTEON_IS_MODEL(OCTEON_CN50XX)) {
231
232
233
234
235
236
237
238 union cvmx_gmxx_rxx_rx_inbnd inband_status;
239 int interface = cvmx_helper_get_interface_num(ipd_port);
240 int index = cvmx_helper_get_interface_index_num(ipd_port);
241 inband_status.u64 =
242 cvmx_read_csr(CVMX_GMXX_RXX_RX_INBND(index, interface));
243
244 result.s.link_up = inband_status.s.status;
245 result.s.full_duplex = inband_status.s.duplex;
246 switch (inband_status.s.speed) {
247 case 0:
248 result.s.speed = 10;
249 break;
250 case 1:
251 result.s.speed = 100;
252 break;
253 case 2:
254 result.s.speed = 1000;
255 break;
256 case 3:
257 result.u64 = 0;
258 break;
259 }
260 } else {
261
262
263
264
265
266
267 result.u64 = 0;
268 }
269
270
271 if (!result.s.link_up)
272 result.u64 = 0;
273
274 return result;
275 }
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298 int __cvmx_helper_board_interface_probe(int interface, int supported_ports)
299 {
300 switch (cvmx_sysinfo_get()->board_type) {
301 case CVMX_BOARD_TYPE_CN3005_EVB_HS5:
302 if (interface == 0)
303 return 2;
304 break;
305 case CVMX_BOARD_TYPE_BBGW_REF:
306 if (interface == 0)
307 return 2;
308 break;
309 case CVMX_BOARD_TYPE_NIC_XLE_4G:
310 if (interface == 0)
311 return 0;
312 break;
313
314
315 case CVMX_BOARD_TYPE_EBH5600:
316 if (interface == 1)
317 return 0;
318 break;
319 }
320 return supported_ports;
321 }
322
323
324
325
326
327
328
329 enum cvmx_helper_board_usb_clock_types __cvmx_helper_board_usb_get_clock_type(void)
330 {
331 switch (cvmx_sysinfo_get()->board_type) {
332 case CVMX_BOARD_TYPE_BBGW_REF:
333 case CVMX_BOARD_TYPE_LANAI2_A:
334 case CVMX_BOARD_TYPE_LANAI2_U:
335 case CVMX_BOARD_TYPE_LANAI2_G:
336 case CVMX_BOARD_TYPE_NIC10E_66:
337 case CVMX_BOARD_TYPE_UBNT_E100:
338 return USB_CLOCK_TYPE_CRYSTAL_12;
339 case CVMX_BOARD_TYPE_NIC10E:
340 return USB_CLOCK_TYPE_REF_12;
341 default:
342 break;
343 }
344
345 if (OCTEON_IS_OCTEON2())
346 return USB_CLOCK_TYPE_CRYSTAL_12;
347 return USB_CLOCK_TYPE_REF_48;
348 }