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#include "et131x_version.h"
59#include "et131x_defs.h"
60
61#include <linux/pci.h>
62#include <linux/init.h>
63#include <linux/module.h>
64#include <linux/types.h>
65#include <linux/kernel.h>
66
67#include <linux/sched.h>
68#include <linux/ptrace.h>
69#include <linux/ctype.h>
70#include <linux/string.h>
71#include <linux/timer.h>
72#include <linux/interrupt.h>
73#include <linux/in.h>
74#include <linux/delay.h>
75#include <linux/io.h>
76#include <linux/bitops.h>
77#include <asm/system.h>
78
79#include <linux/netdevice.h>
80#include <linux/etherdevice.h>
81#include <linux/skbuff.h>
82#include <linux/if_arp.h>
83#include <linux/ioport.h>
84#include <linux/random.h>
85
86#include "et1310_phy.h"
87
88#include "et131x_adapter.h"
89
90#include "et1310_address_map.h"
91#include "et1310_tx.h"
92#include "et1310_rx.h"
93
94#include "et131x.h"
95
96
97static void et131x_xcvr_init(struct et131x_adapter *etdev);
98
99
100
101
102
103
104
105
106
107
108int PhyMiRead(struct et131x_adapter *etdev, u8 xcvrAddr,
109 u8 xcvrReg, u16 *value)
110{
111 struct mac_regs __iomem *mac = &etdev->regs->mac;
112 int status = 0;
113 u32 delay;
114 u32 miiAddr;
115 u32 miiCmd;
116 u32 miiIndicator;
117
118
119
120
121 miiAddr = readl(&mac->mii_mgmt_addr);
122 miiCmd = readl(&mac->mii_mgmt_cmd);
123
124
125 writel(0, &mac->mii_mgmt_cmd);
126
127
128 writel(MII_ADDR(xcvrAddr, xcvrReg), &mac->mii_mgmt_addr);
129
130
131 delay = 0;
132
133 writel(0x1, &mac->mii_mgmt_cmd);
134
135 do {
136 udelay(50);
137 delay++;
138 miiIndicator = readl(&mac->mii_mgmt_indicator);
139 } while ((miiIndicator & MGMT_WAIT) && delay < 50);
140
141
142 if (delay == 50) {
143 dev_warn(&etdev->pdev->dev,
144 "xcvrReg 0x%08x could not be read\n", xcvrReg);
145 dev_warn(&etdev->pdev->dev, "status is 0x%08x\n",
146 miiIndicator);
147
148 status = -EIO;
149 }
150
151
152
153 *value = readl(&mac->mii_mgmt_stat) & 0xFFFF;
154
155
156 writel(0, &mac->mii_mgmt_cmd);
157
158
159
160
161 writel(miiAddr, &mac->mii_mgmt_addr);
162 writel(miiCmd, &mac->mii_mgmt_cmd);
163
164 return status;
165}
166
167
168
169
170
171
172
173
174
175
176
177int MiWrite(struct et131x_adapter *etdev, u8 xcvrReg, u16 value)
178{
179 struct mac_regs __iomem *mac = &etdev->regs->mac;
180 int status = 0;
181 u8 xcvrAddr = etdev->stats.xcvr_addr;
182 u32 delay;
183 u32 miiAddr;
184 u32 miiCmd;
185 u32 miiIndicator;
186
187
188
189
190 miiAddr = readl(&mac->mii_mgmt_addr);
191 miiCmd = readl(&mac->mii_mgmt_cmd);
192
193
194 writel(0, &mac->mii_mgmt_cmd);
195
196
197 writel(MII_ADDR(xcvrAddr, xcvrReg), &mac->mii_mgmt_addr);
198
199
200 writel(value, &mac->mii_mgmt_ctrl);
201 delay = 0;
202
203 do {
204 udelay(50);
205 delay++;
206 miiIndicator = readl(&mac->mii_mgmt_indicator);
207 } while ((miiIndicator & MGMT_BUSY) && delay < 100);
208
209
210 if (delay == 100) {
211 u16 TempValue;
212
213 dev_warn(&etdev->pdev->dev,
214 "xcvrReg 0x%08x could not be written", xcvrReg);
215 dev_warn(&etdev->pdev->dev, "status is 0x%08x\n",
216 miiIndicator);
217 dev_warn(&etdev->pdev->dev, "command is 0x%08x\n",
218 readl(&mac->mii_mgmt_cmd));
219
220 MiRead(etdev, xcvrReg, &TempValue);
221
222 status = -EIO;
223 }
224
225 writel(0, &mac->mii_mgmt_cmd);
226
227
228
229
230 writel(miiAddr, &mac->mii_mgmt_addr);
231 writel(miiCmd, &mac->mii_mgmt_cmd);
232
233 return status;
234}
235
236
237
238
239
240
241
242int et131x_xcvr_find(struct et131x_adapter *etdev)
243{
244 u8 xcvr_addr;
245 u16 idr1;
246 u16 idr2;
247 u32 xcvr_id;
248
249
250 for (xcvr_addr = 0; xcvr_addr < 32; xcvr_addr++) {
251
252 PhyMiRead(etdev, xcvr_addr,
253 (u8) offsetof(struct mi_regs, idr1),
254 &idr1);
255 PhyMiRead(etdev, xcvr_addr,
256 (u8) offsetof(struct mi_regs, idr2),
257 &idr2);
258
259 xcvr_id = (u32) ((idr1 << 16) | idr2);
260
261 if (idr1 != 0 && idr1 != 0xffff) {
262 etdev->stats.xcvr_id = xcvr_id;
263 etdev->stats.xcvr_addr = xcvr_addr;
264 return 0;
265 }
266 }
267 return -ENODEV;
268}
269
270void ET1310_PhyReset(struct et131x_adapter *etdev)
271{
272 MiWrite(etdev, PHY_CONTROL, 0x8000);
273}
274
275
276
277
278
279
280
281
282
283
284
285
286void ET1310_PhyPowerDown(struct et131x_adapter *etdev, bool down)
287{
288 u16 data;
289
290 MiRead(etdev, PHY_CONTROL, &data);
291 data &= ~0x0800;
292 if (down)
293 data |= 0x0800;
294 MiWrite(etdev, PHY_CONTROL, data);
295}
296
297
298
299
300
301
302
303
304
305
306static void ET1310_PhyAutoNeg(struct et131x_adapter *etdev, bool enable)
307{
308 u16 data;
309
310 MiRead(etdev, PHY_CONTROL, &data);
311 data &= ~0x1000;
312 if (enable)
313 data |= 0x1000;
314 MiWrite(etdev, PHY_CONTROL, data);
315}
316
317
318
319
320
321
322
323
324
325static void ET1310_PhyDuplexMode(struct et131x_adapter *etdev, u16 duplex)
326{
327 u16 data;
328
329 MiRead(etdev, PHY_CONTROL, &data);
330 data &= ~0x100;
331 if (duplex == TRUEPHY_DUPLEX_FULL)
332 data |= 0x100;
333 MiWrite(etdev, PHY_CONTROL, data);
334}
335
336
337
338
339
340
341
342
343
344static void ET1310_PhySpeedSelect(struct et131x_adapter *etdev, u16 speed)
345{
346 u16 data;
347 static const u16 bits[3] = {0x0000, 0x2000, 0x0040};
348
349
350 MiRead(etdev, PHY_CONTROL, &data);
351
352 data &= ~0x2040;
353
354 MiWrite(etdev, PHY_CONTROL, data | bits[speed]);
355}
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374static void ET1310_PhyLinkStatus(struct et131x_adapter *etdev,
375 u8 *link_status,
376 u32 *autoneg,
377 u32 *linkspeed,
378 u32 *duplex_mode,
379 u32 *mdi_mdix,
380 u32 *masterslave, u32 *polarity)
381{
382 u16 mistatus = 0;
383 u16 is1000BaseT = 0;
384 u16 vmi_phystatus = 0;
385 u16 control = 0;
386
387 MiRead(etdev, PHY_STATUS, &mistatus);
388 MiRead(etdev, PHY_1000_STATUS, &is1000BaseT);
389 MiRead(etdev, PHY_PHY_STATUS, &vmi_phystatus);
390 MiRead(etdev, PHY_CONTROL, &control);
391
392 *link_status = (vmi_phystatus & 0x0040) ? 1 : 0;
393 *autoneg = (control & 0x1000) ? ((vmi_phystatus & 0x0020) ?
394 TRUEPHY_ANEG_COMPLETE :
395 TRUEPHY_ANEG_NOT_COMPLETE) :
396 TRUEPHY_ANEG_DISABLED;
397 *linkspeed = (vmi_phystatus & 0x0300) >> 8;
398 *duplex_mode = (vmi_phystatus & 0x0080) >> 7;
399
400 *mdi_mdix = 0;
401
402 *masterslave = (is1000BaseT & 0x4000) ?
403 TRUEPHY_CFG_MASTER : TRUEPHY_CFG_SLAVE;
404 *polarity = (vmi_phystatus & 0x0400) ?
405 TRUEPHY_POLARITY_INVERTED : TRUEPHY_POLARITY_NORMAL;
406}
407
408static void ET1310_PhyAndOrReg(struct et131x_adapter *etdev,
409 u16 regnum, u16 andMask, u16 orMask)
410{
411 u16 reg;
412
413 MiRead(etdev, regnum, ®);
414 reg &= andMask;
415 reg |= orMask;
416 MiWrite(etdev, regnum, reg);
417}
418
419
420void ET1310_PhyAccessMiBit(struct et131x_adapter *etdev, u16 action,
421 u16 regnum, u16 bitnum, u8 *value)
422{
423 u16 reg;
424 u16 mask = 0x0001 << bitnum;
425
426
427 MiRead(etdev, regnum, ®);
428
429 switch (action) {
430 case TRUEPHY_BIT_READ:
431 *value = (reg & mask) >> bitnum;
432 break;
433
434 case TRUEPHY_BIT_SET:
435 MiWrite(etdev, regnum, reg | mask);
436 break;
437
438 case TRUEPHY_BIT_CLEAR:
439 MiWrite(etdev, regnum, reg & ~mask);
440 break;
441
442 default:
443 break;
444 }
445}
446
447void ET1310_PhyAdvertise1000BaseT(struct et131x_adapter *etdev,
448 u16 duplex)
449{
450 u16 data;
451
452
453 MiRead(etdev, PHY_1000_CONTROL, &data);
454
455
456 data &= ~0x0300;
457
458 switch (duplex) {
459 case TRUEPHY_ADV_DUPLEX_NONE:
460
461 break;
462
463 case TRUEPHY_ADV_DUPLEX_FULL:
464
465 data |= 0x0200;
466 break;
467
468 case TRUEPHY_ADV_DUPLEX_HALF:
469
470 data |= 0x0100;
471 break;
472
473 case TRUEPHY_ADV_DUPLEX_BOTH:
474 default:
475 data |= 0x0300;
476 break;
477 }
478
479
480 MiWrite(etdev, PHY_1000_CONTROL, data);
481}
482
483static void ET1310_PhyAdvertise100BaseT(struct et131x_adapter *etdev,
484 u16 duplex)
485{
486 u16 data;
487
488
489 MiRead(etdev, PHY_AUTO_ADVERTISEMENT, &data);
490
491
492 data &= ~0x0180;
493
494 switch (duplex) {
495 case TRUEPHY_ADV_DUPLEX_NONE:
496
497 break;
498
499 case TRUEPHY_ADV_DUPLEX_FULL:
500
501 data |= 0x0100;
502 break;
503
504 case TRUEPHY_ADV_DUPLEX_HALF:
505
506 data |= 0x0080;
507 break;
508
509 case TRUEPHY_ADV_DUPLEX_BOTH:
510 default:
511
512 data |= 0x0180;
513 break;
514 }
515
516
517 MiWrite(etdev, PHY_AUTO_ADVERTISEMENT, data);
518}
519
520static void ET1310_PhyAdvertise10BaseT(struct et131x_adapter *etdev,
521 u16 duplex)
522{
523 u16 data;
524
525
526 MiRead(etdev, PHY_AUTO_ADVERTISEMENT, &data);
527
528
529 data &= ~0x0060;
530
531 switch (duplex) {
532 case TRUEPHY_ADV_DUPLEX_NONE:
533
534 break;
535
536 case TRUEPHY_ADV_DUPLEX_FULL:
537
538 data |= 0x0040;
539 break;
540
541 case TRUEPHY_ADV_DUPLEX_HALF:
542
543 data |= 0x0020;
544 break;
545
546 case TRUEPHY_ADV_DUPLEX_BOTH:
547 default:
548
549 data |= 0x0060;
550 break;
551 }
552
553
554 MiWrite(etdev, PHY_AUTO_ADVERTISEMENT, data);
555}
556
557
558
559
560
561
562
563
564
565void et131x_setphy_normal(struct et131x_adapter *etdev)
566{
567
568 ET1310_PhyPowerDown(etdev, 0);
569 et131x_xcvr_init(etdev);
570}
571
572
573
574
575
576
577
578static void et131x_xcvr_init(struct et131x_adapter *etdev)
579{
580 u16 imr;
581 u16 isr;
582 u16 lcr2;
583
584
585 etdev->bmsr = 0;
586
587 MiRead(etdev, (u8) offsetof(struct mi_regs, isr), &isr);
588 MiRead(etdev, (u8) offsetof(struct mi_regs, imr), &imr);
589
590
591
592
593 imr |= 0x0105;
594
595 MiWrite(etdev, (u8) offsetof(struct mi_regs, imr), imr);
596
597
598
599
600
601
602
603
604
605 if ((etdev->eeprom_data[1] & 0x4) == 0) {
606 MiRead(etdev, (u8) offsetof(struct mi_regs, lcr2),
607 &lcr2);
608
609 lcr2 &= 0x00FF;
610 lcr2 |= 0xA000;
611
612 if ((etdev->eeprom_data[1] & 0x8) == 0)
613 lcr2 |= 0x0300;
614 else
615 lcr2 |= 0x0400;
616
617 MiWrite(etdev, (u8) offsetof(struct mi_regs, lcr2),
618 lcr2);
619 }
620
621
622 if (etdev->AiForceSpeed == 0 && etdev->AiForceDpx == 0) {
623 if (etdev->wanted_flow == FLOW_TXONLY ||
624 etdev->wanted_flow == FLOW_BOTH)
625 ET1310_PhyAccessMiBit(etdev,
626 TRUEPHY_BIT_SET, 4, 11, NULL);
627 else
628 ET1310_PhyAccessMiBit(etdev,
629 TRUEPHY_BIT_CLEAR, 4, 11, NULL);
630
631 if (etdev->wanted_flow == FLOW_BOTH)
632 ET1310_PhyAccessMiBit(etdev,
633 TRUEPHY_BIT_SET, 4, 10, NULL);
634 else
635 ET1310_PhyAccessMiBit(etdev,
636 TRUEPHY_BIT_CLEAR, 4, 10, NULL);
637
638
639 ET1310_PhyAutoNeg(etdev, true);
640
641
642 ET1310_PhyAccessMiBit(etdev, TRUEPHY_BIT_SET, 0, 9, NULL);
643 return;
644 }
645
646 ET1310_PhyAutoNeg(etdev, false);
647
648
649 if (etdev->AiForceDpx != 1) {
650 if (etdev->wanted_flow == FLOW_TXONLY ||
651 etdev->wanted_flow == FLOW_BOTH)
652 ET1310_PhyAccessMiBit(etdev,
653 TRUEPHY_BIT_SET, 4, 11, NULL);
654 else
655 ET1310_PhyAccessMiBit(etdev,
656 TRUEPHY_BIT_CLEAR, 4, 11, NULL);
657
658 if (etdev->wanted_flow == FLOW_BOTH)
659 ET1310_PhyAccessMiBit(etdev,
660 TRUEPHY_BIT_SET, 4, 10, NULL);
661 else
662 ET1310_PhyAccessMiBit(etdev,
663 TRUEPHY_BIT_CLEAR, 4, 10, NULL);
664 } else {
665 ET1310_PhyAccessMiBit(etdev, TRUEPHY_BIT_CLEAR, 4, 10, NULL);
666 ET1310_PhyAccessMiBit(etdev, TRUEPHY_BIT_CLEAR, 4, 11, NULL);
667 }
668 ET1310_PhyPowerDown(etdev, 1);
669 switch (etdev->AiForceSpeed) {
670 case 10:
671
672 ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE);
673 ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE);
674 if (etdev->AiForceDpx == 1) {
675
676 ET1310_PhyAdvertise10BaseT(etdev,
677 TRUEPHY_ADV_DUPLEX_HALF);
678 } else if (etdev->AiForceDpx == 2) {
679
680 ET1310_PhyAdvertise10BaseT(etdev,
681 TRUEPHY_ADV_DUPLEX_FULL);
682 } else {
683
684 ET1310_PhyAutoNeg(etdev, false);
685
686 ET1310_PhyAdvertise10BaseT(etdev,
687 TRUEPHY_ADV_DUPLEX_NONE);
688
689 ET1310_PhySpeedSelect(etdev, TRUEPHY_SPEED_10MBPS);
690
691 ET1310_PhyDuplexMode(etdev, TRUEPHY_DUPLEX_FULL);
692 }
693 break;
694 case 100:
695
696 ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE);
697 ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE);
698 if (etdev->AiForceDpx == 1) {
699
700 ET1310_PhyAdvertise100BaseT(etdev,
701 TRUEPHY_ADV_DUPLEX_HALF);
702
703 ET1310_PhySpeedSelect(etdev, TRUEPHY_SPEED_100MBPS);
704 } else if (etdev->AiForceDpx == 2) {
705
706 ET1310_PhyAdvertise100BaseT(etdev,
707 TRUEPHY_ADV_DUPLEX_FULL);
708 } else {
709
710 ET1310_PhyAutoNeg(etdev, false);
711
712 ET1310_PhyAdvertise100BaseT(etdev,
713 TRUEPHY_ADV_DUPLEX_NONE);
714
715 ET1310_PhySpeedSelect(etdev, TRUEPHY_SPEED_100MBPS);
716
717 ET1310_PhyDuplexMode(etdev, TRUEPHY_DUPLEX_FULL);
718 }
719 break;
720 case 1000:
721
722 ET1310_PhyAdvertise100BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE);
723 ET1310_PhyAdvertise10BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE);
724
725 ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL);
726 break;
727 }
728 ET1310_PhyPowerDown(etdev, 0);
729}
730
731void et131x_Mii_check(struct et131x_adapter *etdev,
732 u16 bmsr, u16 bmsr_ints)
733{
734 u8 link_status;
735 u32 autoneg_status;
736 u32 speed;
737 u32 duplex;
738 u32 mdi_mdix;
739 u32 masterslave;
740 u32 polarity;
741 unsigned long flags;
742
743 if (bmsr_ints & MI_BMSR_LINK_STATUS) {
744 if (bmsr & MI_BMSR_LINK_STATUS) {
745 etdev->boot_coma = 20;
746
747
748
749
750 spin_lock_irqsave(&etdev->Lock, flags);
751
752 etdev->MediaState = NETIF_STATUS_MEDIA_CONNECT;
753
754 spin_unlock_irqrestore(&etdev->Lock, flags);
755
756 netif_carrier_on(etdev->netdev);
757 } else {
758 dev_warn(&etdev->pdev->dev,
759 "Link down - cable problem ?\n");
760
761 if (etdev->linkspeed == TRUEPHY_SPEED_10MBPS) {
762
763
764
765
766
767 u16 Register18;
768
769 MiRead(etdev, 0x12, &Register18);
770 MiWrite(etdev, 0x12, Register18 | 0x4);
771 MiWrite(etdev, 0x10, Register18 | 0x8402);
772 MiWrite(etdev, 0x11, Register18 | 511);
773 MiWrite(etdev, 0x12, Register18);
774 }
775
776
777
778
779
780
781
782 if ((etdev->MediaState == NETIF_STATUS_MEDIA_DISCONNECT)) {
783 spin_lock_irqsave(&etdev->Lock, flags);
784 etdev->MediaState =
785 NETIF_STATUS_MEDIA_DISCONNECT;
786 spin_unlock_irqrestore(&etdev->Lock,
787 flags);
788
789 netif_carrier_off(etdev->netdev);
790 }
791
792 etdev->linkspeed = 0;
793 etdev->duplex_mode = 0;
794
795
796 et131x_free_busy_send_packets(etdev);
797
798
799 et131x_init_send(etdev);
800
801
802 et131x_reset_recv(etdev);
803
804
805
806
807
808
809
810 et131x_soft_reset(etdev);
811
812
813 et131x_adapter_setup(etdev);
814
815
816
817
818 if (etdev->RegistryPhyComa == 1)
819 EnablePhyComa(etdev);
820 }
821 }
822
823 if ((bmsr_ints & MI_BMSR_AUTO_NEG_COMPLETE) ||
824 (etdev->AiForceDpx == 3 && (bmsr_ints & MI_BMSR_LINK_STATUS))) {
825 if ((bmsr & MI_BMSR_AUTO_NEG_COMPLETE) ||
826 etdev->AiForceDpx == 3) {
827 ET1310_PhyLinkStatus(etdev,
828 &link_status, &autoneg_status,
829 &speed, &duplex, &mdi_mdix,
830 &masterslave, &polarity);
831
832 etdev->linkspeed = speed;
833 etdev->duplex_mode = duplex;
834
835 etdev->boot_coma = 20;
836
837 if (etdev->linkspeed == TRUEPHY_SPEED_10MBPS) {
838
839
840
841
842
843
844 u16 Register18;
845
846 MiRead(etdev, 0x12, &Register18);
847 MiWrite(etdev, 0x12, Register18 | 0x4);
848 MiWrite(etdev, 0x10, Register18 | 0x8402);
849 MiWrite(etdev, 0x11, Register18 | 511);
850 MiWrite(etdev, 0x12, Register18);
851 }
852
853 ConfigFlowControl(etdev);
854
855 if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS &&
856 etdev->RegistryJumboPacket > 2048)
857 ET1310_PhyAndOrReg(etdev, 0x16, 0xcfff,
858 0x2000);
859
860 SetRxDmaTimer(etdev);
861 ConfigMACRegs2(etdev);
862 }
863 }
864}
865
866
867
868
869
870
871
872static const u16 ConfigPhy[25][2] = {
873
874
875 {0x880B, 0x0926},
876 {0x880C, 0x0926},
877 {0x880D, 0x0926},
878
879 {0x880E, 0xB4D3},
880 {0x880F, 0xB4D3},
881 {0x8810, 0xB4D3},
882
883 {0x8805, 0xB03E},
884 {0x8806, 0xB03E},
885 {0x8807, 0xFF00},
886
887 {0x8808, 0xE090},
888 {0x8809, 0xE110},
889 {0x880A, 0x0000},
890
891 {0x300D, 1},
892
893 {0x280C, 0x0180},
894
895 {0x1C21, 0x0002},
896
897 {0x3821, 6},
898 {0x381D, 1},
899 {0x381E, 1},
900 {0x381F, 1},
901 {0x3820, 1},
902
903 {0x8402, 0x01F0},
904 {0x800E, 20},
905 {0x800F, 24},
906 {0x8010, 46},
907
908 {0, 0}
909
910};
911
912
913void ET1310_PhyInit(struct et131x_adapter *etdev)
914{
915 u16 data, index;
916
917 if (etdev == NULL)
918 return;
919
920
921 MiRead(etdev, PHY_ID_1, &data);
922 MiRead(etdev, PHY_ID_2, &data);
923
924
925 MiRead(etdev, PHY_MPHY_CONTROL_REG, &data);
926 MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0006);
927
928
929
930 MiWrite(etdev, PHY_INDEX_REG, 0x0402);
931 MiRead(etdev, PHY_DATA_REG, &data);
932
933
934 MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0002);
935
936
937 MiRead(etdev, PHY_ID_1, &data);
938 MiRead(etdev, PHY_ID_2, &data);
939
940
941 MiRead(etdev, PHY_MPHY_CONTROL_REG, &data);
942 MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0006);
943
944
945
946 MiWrite(etdev, PHY_INDEX_REG, 0x0402);
947 MiRead(etdev, PHY_DATA_REG, &data);
948
949 MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0002);
950
951
952 MiRead(etdev, PHY_CONTROL, &data);
953 MiRead(etdev, PHY_MPHY_CONTROL_REG, &data);
954 MiWrite(etdev, PHY_CONTROL, 0x1840);
955
956 MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0007);
957
958
959 index = 0;
960 while (ConfigPhy[index][0] != 0x0000) {
961
962 MiWrite(etdev, PHY_INDEX_REG, ConfigPhy[index][0]);
963 MiWrite(etdev, PHY_DATA_REG, ConfigPhy[index][1]);
964
965
966 MiWrite(etdev, PHY_INDEX_REG, ConfigPhy[index][0]);
967 MiRead(etdev, PHY_DATA_REG, &data);
968
969
970 index++;
971 }
972
973
974 MiRead(etdev, PHY_CONTROL, &data);
975 MiRead(etdev, PHY_MPHY_CONTROL_REG, &data);
976 MiWrite(etdev, PHY_CONTROL, 0x1040);
977 MiWrite(etdev, PHY_MPHY_CONTROL_REG, 0x0002);
978}
979
980