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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75#include "tulip.h"
76#include <linux/delay.h>
77
78
79void pnic2_timer(unsigned long data)
80{
81 struct net_device *dev = (struct net_device *)data;
82 struct tulip_private *tp = netdev_priv(dev);
83 void __iomem *ioaddr = tp->base_addr;
84 int next_tick = 60*HZ;
85
86 if (tulip_debug > 3)
87 dev_info(&dev->dev, "PNIC2 negotiation status %08x\n",
88 ioread32(ioaddr + CSR12));
89
90 if (next_tick) {
91 mod_timer(&tp->timer, RUN_AT(next_tick));
92 }
93}
94
95
96void pnic2_start_nway(struct net_device *dev)
97{
98 struct tulip_private *tp = netdev_priv(dev);
99 void __iomem *ioaddr = tp->base_addr;
100 int csr14;
101 int csr12;
102
103
104
105
106
107
108 csr14 = (ioread32(ioaddr + CSR14) & 0xfff0ee39);
109
110
111 if (tp->sym_advertise & 0x0100) csr14 |= 0x00020000;
112
113
114 if (tp->sym_advertise & 0x0080) csr14 |= 0x00010000;
115
116
117 if (tp->sym_advertise & 0x0020) csr14 |= 0x00000040;
118
119
120
121
122 csr14 |= 0x00001184;
123
124 if (tulip_debug > 1)
125 netdev_dbg(dev, "Restarting PNIC2 autonegotiation, csr14=%08x\n",
126 csr14);
127
128
129 dev->if_port = 0;
130 tp->nway = tp->mediasense = 1;
131 tp->nwayset = tp->lpar = 0;
132
133
134
135 tp->csr6 = ioread32(ioaddr + CSR6);
136 if (tulip_debug > 1)
137 netdev_dbg(dev, "On Entry to Nway, csr6=%08x\n", tp->csr6);
138
139
140
141
142 tp->csr6 = tp->csr6 & 0xfe3bd1fd;
143
144
145
146 if (tp->sym_advertise & 0x0040) tp->csr6 |= 0x00000200;
147
148
149
150
151
152 tp->csr6 |= 0x01000000;
153 iowrite32(csr14, ioaddr + CSR14);
154 iowrite32(tp->csr6, ioaddr + CSR6);
155 udelay(100);
156
157
158
159
160
161
162
163 csr12 = (ioread32(ioaddr + CSR12) & 0xffff8fff);
164 csr12 |= 0x1000;
165 iowrite32(csr12, ioaddr + CSR12);
166}
167
168
169
170void pnic2_lnk_change(struct net_device *dev, int csr5)
171{
172 struct tulip_private *tp = netdev_priv(dev);
173 void __iomem *ioaddr = tp->base_addr;
174 int csr14;
175
176
177 int csr12 = ioread32(ioaddr + CSR12);
178
179 if (tulip_debug > 1)
180 dev_info(&dev->dev,
181 "PNIC2 link status interrupt %08x, CSR5 %x, %08x\n",
182 csr12, csr5, ioread32(ioaddr + CSR14));
183
184
185
186
187 if (tp->nway && !tp->nwayset) {
188
189
190
191 if ((csr12 & 0x7000) == 0x5000) {
192
193
194
195
196
197
198
199
200
201
202
203
204 int negotiated = ((csr12 >> 16) & 0x01E0) & tp->sym_advertise;
205 tp->lpar = (csr12 >> 16);
206 tp->nwayset = 1;
207
208 if (negotiated & 0x0100) dev->if_port = 5;
209 else if (negotiated & 0x0080) dev->if_port = 3;
210 else if (negotiated & 0x0040) dev->if_port = 4;
211 else if (negotiated & 0x0020) dev->if_port = 0;
212 else {
213 if (tulip_debug > 1)
214 dev_info(&dev->dev,
215 "funny autonegotiate result csr12 %08x advertising %04x\n",
216 csr12, tp->sym_advertise);
217 tp->nwayset = 0;
218
219 if ((csr12 & 2) == 0 && (tp->sym_advertise & 0x0180))
220 dev->if_port = 3;
221 }
222
223
224 tp->full_duplex = 0;
225 if ((dev->if_port == 4) || (dev->if_port == 5))
226 tp->full_duplex = 1;
227
228 if (tulip_debug > 1) {
229 if (tp->nwayset)
230 dev_info(&dev->dev,
231 "Switching to %s based on link negotiation %04x & %04x = %04x\n",
232 medianame[dev->if_port],
233 tp->sym_advertise, tp->lpar,
234 negotiated);
235 }
236
237
238
239
240
241 csr14 = (ioread32(ioaddr + CSR14) & 0xffffff7f);
242 iowrite32(csr14,ioaddr + CSR14);
243
244
245
246
247
248
249
250
251
252
253 tp->csr6 = (ioread32(ioaddr + CSR6) & 0xfe3bd1fd);
254
255
256
257
258
259
260
261 if (dev->if_port & 1) tp->csr6 |= 0x01840000;
262 else tp->csr6 |= 0x00400000;
263
264
265 if (tp->full_duplex) tp->csr6 |= 0x00000200;
266
267 iowrite32(1, ioaddr + CSR13);
268
269 if (tulip_debug > 2)
270 netdev_dbg(dev, "Setting CSR6 %08x/%x CSR12 %08x\n",
271 tp->csr6,
272 ioread32(ioaddr + CSR6),
273 ioread32(ioaddr + CSR12));
274
275
276
277
278 tulip_start_rxtx(tp);
279
280 return;
281
282 } else {
283 dev_info(&dev->dev,
284 "Autonegotiation failed, using %s, link beat status %04x\n",
285 medianame[dev->if_port], csr12);
286
287
288
289
290 csr14 = (ioread32(ioaddr + CSR14) & 0xffffff7f);
291 iowrite32(csr14,ioaddr + CSR14);
292
293
294
295
296
297
298
299
300 dev->if_port = 0;
301 tp->nway = 0;
302 tp->nwayset = 1;
303
304
305
306
307 tp->csr6 = (ioread32(ioaddr + CSR6) & 0xfe3bd1fd);
308 tp->csr6 |= 0x00400000;
309
310 tulip_restart_rxtx(tp);
311
312 return;
313
314 }
315 }
316
317 if ((tp->nwayset && (csr5 & 0x08000000) &&
318 (dev->if_port == 3 || dev->if_port == 5) &&
319 (csr12 & 2) == 2) || (tp->nway && (csr5 & (TPLnkFail)))) {
320
321
322
323 if (tulip_debug > 2)
324 netdev_dbg(dev, "Ugh! Link blew?\n");
325
326 del_timer_sync(&tp->timer);
327 pnic2_start_nway(dev);
328 tp->timer.expires = RUN_AT(3*HZ);
329 add_timer(&tp->timer);
330
331 return;
332 }
333
334
335 if (dev->if_port == 3 || dev->if_port == 5) {
336
337
338
339 if (tulip_debug > 1)
340 dev_info(&dev->dev, "PNIC2 %s link beat %s\n",
341 medianame[dev->if_port],
342 (csr12 & 2) ? "failed" : "good");
343
344
345
346 tp->nway = 0;
347 tp->nwayset = 1;
348
349
350 if ((csr12 & 2) && ! tp->medialock) {
351 del_timer_sync(&tp->timer);
352 pnic2_start_nway(dev);
353 tp->timer.expires = RUN_AT(3*HZ);
354 add_timer(&tp->timer);
355 }
356
357 return;
358 }
359
360 if (dev->if_port == 0 || dev->if_port == 4) {
361
362
363
364 if (tulip_debug > 1)
365 dev_info(&dev->dev, "PNIC2 %s link beat %s\n",
366 medianame[dev->if_port],
367 (csr12 & 4) ? "failed" : "good");
368
369
370 tp->nway = 0;
371 tp->nwayset = 1;
372
373
374 if ((csr12 & 4) && ! tp->medialock) {
375 del_timer_sync(&tp->timer);
376 pnic2_start_nway(dev);
377 tp->timer.expires = RUN_AT(3*HZ);
378 add_timer(&tp->timer);
379 }
380
381 return;
382 }
383
384
385 if (tulip_debug > 1)
386 dev_info(&dev->dev, "PNIC2 Link Change Default?\n");
387
388
389 dev->if_port = 0;
390
391
392 csr14 = (ioread32(ioaddr + CSR14) & 0xffffff7f);
393 iowrite32(csr14,ioaddr + CSR14);
394
395
396
397
398 tp->csr6 = (ioread32(ioaddr + CSR6) & 0xfe3bd1fd);
399 tp->csr6 |= 0x00400000;
400
401 tulip_restart_rxtx(tp);
402}
403
404