Browse Source

Finished by hand

tags/v0.9.3
Michael Brown 19 years ago
parent
commit
f39cc6d978
5 changed files with 101 additions and 91 deletions
  1. 11
    8
      src/drivers/net/e1000.c
  2. 16
    14
      src/drivers/net/eepro100.c
  3. 15
    11
      src/drivers/net/epic100.c
  4. 24
    22
      src/drivers/net/forcedeth.c
  5. 35
    36
      src/drivers/net/mtd80x.c

+ 11
- 8
src/drivers/net/e1000.c View File

@@ -85,6 +85,9 @@ typedef enum {
85 85
 #include "e1000_hw.h"
86 86
 
87 87
 /* NIC specific static variables go here */
88
+static struct nic_operations e1000_operations;
89
+static struct pci_driver e1000_driver;
90
+
88 91
 static struct e1000_hw hw;
89 92
 static char tx_pool[128 + 16];
90 93
 static char rx_pool[128 + 16];
@@ -3580,15 +3583,14 @@ PROBE - Look for an adapter, this routine's visible to the outside
3580 3583
 You should omit the last argument struct pci_device * for a non-PCI NIC
3581 3584
 ***************************************************************************/
3582 3585
 static int e1000_probe ( struct dev *dev ) {
3583
-
3584 3586
 	struct nic *nic = nic_device ( dev );
3585
-
3586 3587
 	struct pci_device *p = pci_device ( dev );
3587 3588
 	unsigned long mmio_start, mmio_len;
3588 3589
 	int ret_val, i;
3589 3590
 
3590
-	if (p == 0)
3591
+	if ( ! find_pci_device ( p, &e1000_driver ) )
3591 3592
 		return 0;
3593
+
3592 3594
 	/* Initialize hw with default values */
3593 3595
 	memset(&hw, 0, sizeof(hw));
3594 3596
 	hw.pdev = p;
@@ -3663,17 +3665,18 @@ static int e1000_probe ( struct dev *dev ) {
3663 3665
 	init_descriptor();
3664 3666
 
3665 3667
 	/* point to NIC specific routines */
3666
-static struct nic_operations e1000_operations;
3668
+	nic->nic_op	= &e1000_operations;
3669
+
3670
+	return 1;
3671
+}
3672
+
3667 3673
 static struct nic_operations e1000_operations = {
3668 3674
 	.connect	= dummy_connect,
3669 3675
 	.poll		= e1000_poll,
3670 3676
 	.transmit	= e1000_transmit,
3671 3677
 	.irq		= e1000_irq,
3672 3678
 	.disable	= e1000_disable,
3673
-};	nic->nic_op	= &e1000_operations;
3674
-
3675
-	return 1;
3676
-}
3679
+};
3677 3680
 
3678 3681
 static struct pci_id e1000_nics[] = {
3679 3682
 PCI_ROM(0x8086, 0x1000, "e1000-82542",               "Intel EtherExpressPro1000"),

+ 16
- 14
src/drivers/net/eepro100.c View File

@@ -258,6 +258,9 @@ struct RxFD {               /* Receive frame descriptor. */
258 258
 	char packet[1518];
259 259
 };
260 260
 
261
+static struct nic_operations eepro100_operations;
262
+static struct pci_driver eepro100_driver;
263
+
261 264
 #define RXFD_COUNT 4
262 265
 static struct RxFD rxfds[RXFD_COUNT];
263 266
 static unsigned int rxfd = 0;
@@ -601,9 +604,7 @@ static void eepro100_disable ( struct nic *nic __unused ) {
601 604
  */
602 605
 
603 606
 static int eepro100_probe ( struct dev *dev ) {
604
-
605 607
 	struct nic *nic = nic_device ( dev );
606
-
607 608
 	struct pci_device *p = pci_device ( dev );
608 609
 	unsigned short sum = 0;
609 610
 	int i;
@@ -615,13 +616,14 @@ static int eepro100_probe ( struct dev *dev ) {
615 616
 	   be careful not to access beyond this array */
616 617
 	unsigned short eeprom[16];
617 618
 
619
+	if ( ! find_pci_device ( p, &eepro100_driver ) )
620
+		return 0;
621
+
618 622
 	if (p->ioaddr == 0)
619 623
 		return 0;
620
-	ioaddr = p->ioaddr & ~3; /* Mask the bit that says "this is an io addr" */
624
+	ioaddr = p->ioaddr;
621 625
 	nic->ioaddr = ioaddr;
622 626
 
623
-	adjust_pci_device(p);
624
-
625 627
 	/* Copy IRQ from PCI information */
626 628
 	nic->irqno = p->irq;
627 629
 
@@ -764,17 +766,9 @@ static int eepro100_probe ( struct dev *dev ) {
764 766
 	 */
765 767
 	if (!(mdio_read(eeprom[6] & 0x1f, 1) & (1 << 2))) {
766 768
 		printf("Valid link not established\n");
767
-		eepro100_disable(dev);
769
+		eepro100_disable(nic);
768 770
 		return 0;
769 771
 	}
770
-static struct nic_operations eepro100_operations;
771
-static struct nic_operations eepro100_operations = {
772
-	.connect	= dummy_connect,
773
-	.poll		= eepro100_poll,
774
-	.transmit	= eepro100_transmit,
775
-	.irq		= eepro100_irq,
776
-	.disable	= eepro100_disable,
777
-};
778 772
 	nic->nic_op	= &eepro100_operations;
779 773
 	return 1;
780 774
 }
@@ -799,6 +793,14 @@ void hd (void *where, int n)
799 793
 }
800 794
 #endif
801 795
 
796
+static struct nic_operations eepro100_operations = {
797
+	.connect	= dummy_connect,
798
+	.poll		= eepro100_poll,
799
+	.transmit	= eepro100_transmit,
800
+	.irq		= eepro100_irq,
801
+	.disable	= eepro100_disable,
802
+};
803
+
802 804
 static struct pci_id eepro100_nics[] = {
803 805
 PCI_ROM(0x8086, 0x1029, "id1029",        "Intel EtherExpressPro100 ID1029"),
804 806
 PCI_ROM(0x8086, 0x1030, "id1030",        "Intel EtherExpressPro100 ID1030"),

+ 15
- 11
src/drivers/net/epic100.c View File

@@ -8,6 +8,7 @@
8 8
 #include "pci.h"
9 9
 #include "nic.h"
10 10
 #include "timer.h"
11
+#include "console.h"
11 12
 #include "epic100.h"
12 13
 
13 14
 /* Condensed operations for readability */
@@ -59,6 +60,9 @@ static int	read_eeprom(int location);
59 60
 static int	mii_read(int phy_id, int location);
60 61
 static void     epic100_irq(struct nic *nic, irq_action_t action);
61 62
 
63
+static struct nic_operations epic100_operations;
64
+static struct pci_driver epic100_driver;
65
+
62 66
 static int	ioaddr;
63 67
 
64 68
 static int	command;
@@ -94,16 +98,17 @@ static unsigned char		tx_packet[PKT_BUF_SZ * TX_RING_SIZE];
94 98
 /***********************************************************************/
95 99
 
96 100
 
97
-    static int
101
+static int
98 102
 epic100_probe ( struct dev *dev ) {
99
-
100 103
     struct nic *nic = nic_device ( dev );
101
-
102 104
     struct pci_device *pci = pci_device ( dev );
103 105
     int i;
104 106
     unsigned short* ap;
105 107
     unsigned int phy, phy_idx;
106 108
 
109
+    if ( ! find_pci_device ( pci, &epic100_driver ) )
110
+	    return 0;
111
+
107 112
     if (pci->ioaddr == 0)
108 113
 	return 0;
109 114
 
@@ -202,14 +207,6 @@ epic100_probe ( struct dev *dev ) {
202 207
     }
203 208
 
204 209
     epic100_open();
205
-static struct nic_operations epic100_operations;
206
-static struct nic_operations epic100_operations = {
207
-	.connect	= dummy_connect,
208
-	.poll		= epic100_poll,
209
-	.transmit	= epic100_transmit,
210
-	.irq		= epic100_irq,
211
-	.disable	= epic100_disable,
212
-};
213 210
     nic->nic_op	= &epic100_operations;
214 211
 
215 212
     return 1;
@@ -509,6 +506,13 @@ mii_read(int phy_id, int location)
509 506
     return inw(mmdata);
510 507
 }
511 508
 
509
+static struct nic_operations epic100_operations = {
510
+	.connect	= dummy_connect,
511
+	.poll		= epic100_poll,
512
+	.transmit	= epic100_transmit,
513
+	.irq		= epic100_irq,
514
+	.disable	= epic100_disable,
515
+};
512 516
 
513 517
 static struct pci_id epic100_nics[] = {
514 518
 PCI_ROM(0x10b8, 0x0005, "epic100",    "SMC EtherPowerII"),		/* SMC 83c170 EPIC/100 */

+ 24
- 22
src/drivers/net/forcedeth.c View File

@@ -918,6 +918,23 @@ static void forcedeth_irq(struct nic *nic __unused, irq_action_t action __unused
918 918
   }
919 919
 }
920 920
 
921
+static struct nic_operations forcedeth_operations = {
922
+	.connect	= dummy_connect,
923
+	.poll		= forcedeth_poll,
924
+	.transmit	= forcedeth_transmit,
925
+	.irq		= forcedeth_irq,
926
+	.disable	= forcedeth_disable,
927
+};
928
+
929
+static struct pci_id forcedeth_nics[] = {
930
+	PCI_ROM(0x10de, 0x01C3, "nforce", "nForce Ethernet Controller"),
931
+	PCI_ROM(0x10de, 0x0066, "nforce2", "nForce2 Ethernet Controller"),
932
+	PCI_ROM(0x10de, 0x00D6, "nforce3", "nForce3 Ethernet Controller"),
933
+};
934
+
935
+static struct pci_driver forcedeth_driver =
936
+	PCI_DRIVER ( "forcedeth", forcedeth_nics, PCI_NO_CLASS );
937
+
921 938
 /**************************************************************************
922 939
 PROBE - Look for an adapter, this routine's visible to the outside
923 940
 ***************************************************************************/
@@ -925,22 +942,23 @@ PROBE - Look for an adapter, this routine's visible to the outside
925 942
 #define board_found 1
926 943
 #define valid_link 0
927 944
 static int forcedeth_probe ( struct dev *dev ) {
928
-
929 945
 	struct nic *nic = nic_device ( dev );
930
-
931 946
 	struct pci_device *pci = pci_device ( dev );
932 947
 	unsigned long addr;
933 948
 	int sz;
934 949
 	u8 *base;
935 950
 
951
+	if ( ! find_pci_device ( pci, &forcedeth_driver ) )
952
+		return 0;
953
+
936 954
 	if (pci->ioaddr == 0)
937 955
 		return 0;
938 956
 
939 957
 	printf("forcedeth.c: Found %s, vendor=0x%hX, device=0x%hX\n",
940
-	       pci->name, pci->vendor, pci->dev_id);
958
+	       dev->name, pci->vendor, pci->dev_id);
941 959
 
942 960
 	nic->irqno  = 0;
943
-	nic->ioaddr = pci->ioaddr & ~3;
961
+	nic->ioaddr = pci->ioaddr;
944 962
 
945 963
 	/* point to private storage */
946 964
 	np = &npx;
@@ -988,7 +1006,7 @@ static int forcedeth_probe ( struct dev *dev ) {
988 1006
 		get_random_bytes(&dev->dev_addr[3], 3);
989 1007
 	}
990 1008
 #endif
991
-	printf("%s: MAC Address %!, ", pci->name, nic->node_addr);
1009
+	printf("%s: MAC Address %!, ", dev->name, nic->node_addr);
992 1010
 
993 1011
 	np->tx_flags =
994 1012
 	    cpu_to_le16(NV_TX_LASTPACKET | NV_TX_LASTPACKET1 |
@@ -1015,26 +1033,10 @@ static int forcedeth_probe ( struct dev *dev ) {
1015 1033
 	forcedeth_reset(nic);
1016 1034
 //      if (board_found && valid_link)
1017 1035
 	/* point to NIC specific routines */
1018
-static struct nic_operations forcedeth_operations;
1019
-static struct nic_operations forcedeth_operations = {
1020
-	.connect	= dummy_connect,
1021
-	.poll		= forcedeth_poll,
1022
-	.transmit	= forcedeth_transmit,
1023
-	.irq		= forcedeth_irq,
1024
-	.disable	= forcedeth_disable,
1025
-};	nic->nic_op	= &forcedeth_operations;
1036
+	nic->nic_op	= &forcedeth_operations;
1026 1037
 	return 1;
1027 1038
 //      }
1028 1039
 	/* else */
1029 1040
 }
1030 1041
 
1031
-static struct pci_id forcedeth_nics[] = {
1032
-	PCI_ROM(0x10de, 0x01C3, "nforce", "nForce Ethernet Controller"),
1033
-	PCI_ROM(0x10de, 0x0066, "nforce2", "nForce2 Ethernet Controller"),
1034
-	PCI_ROM(0x10de, 0x00D6, "nforce3", "nForce3 Ethernet Controller"),
1035
-};
1036
-
1037
-static struct pci_driver forcedeth_driver =
1038
-	PCI_DRIVER ( "forcedeth", forcedeth_nics, PCI_NO_CLASS );
1039
-
1040 1042
 BOOT_DRIVER ( "forcedeth", forcedeth_probe );

+ 35
- 36
src/drivers/net/mtd80x.c View File

@@ -153,6 +153,7 @@ enum chip_capability_flags {
153 153
     HAS_CHIP_XCVR,
154 154
 };
155 155
 
156
+#if 0 /* not used */
156 157
 static
157 158
 struct chip_info
158 159
 {
@@ -165,6 +166,7 @@ mtd80x_chips[] = {
165 166
                      {0x0891, HAS_MII_XCVR}
166 167
                  };
167 168
 static int chip_cnt = sizeof( mtd80x_chips ) / sizeof( struct chip_info );
169
+#endif
168 170
 
169 171
 /* Offsets to the Command and Status Registers. */
170 172
 enum mtd_offsets {
@@ -437,7 +439,6 @@ struct mtd_private
437 439
 static struct mtd_private mtdx;
438 440
 
439 441
 static int mdio_read(struct nic * , int phy_id, int location);
440
-static void mdio_write(struct nic * , int phy_id, int location, int value);
441 442
 static void getlinktype(struct nic * );
442 443
 static void getlinkstatus(struct nic * );
443 444
 static void set_rx_mode(struct nic *);
@@ -445,7 +446,7 @@ static void set_rx_mode(struct nic *);
445 446
 /**************************************************************************
446 447
  *  init_ring - setup the tx and rx descriptors
447 448
  *************************************************************************/
448
-static void init_ring(struct nic *nic)
449
+static void init_ring(struct nic *nic __unused)
449 450
 {
450 451
     int i;
451 452
 
@@ -534,7 +535,7 @@ static void mtd_reset(struct nic *nic)
534 535
 /**************************************************************************
535 536
 POLL - Wait for a frame
536 537
 ***************************************************************************/
537
-static int mtd_poll(struct nic *nic)
538
+static int mtd_poll(struct nic *nic, int retrieve)
538 539
 {
539 540
     s32 rx_status = mtdx.cur_rx->status;
540 541
     int retval = 0;
@@ -654,34 +655,46 @@ static void mtd_disable ( struct nic *nic ) {
654 655
     /* Disable Tx Rx*/
655 656
     outl( mtdx.crvalue & (~TxEnable) & (~RxEnable), mtdx.ioaddr + TCRRCR);
656 657
     /* Reset the chip to erase previous misconfiguration. */
657
-    mtd_reset((struct nic *) dev);
658
+    mtd_reset(nic);
658 659
     DBGPRNT(("DISABLE\n"));
659 660
 }
660 661
 
662
+static struct nic_operations mtd_operations = {
663
+	.connect	= dummy_connect,
664
+	.poll		= mtd_poll,
665
+	.transmit	= mtd_transmit,
666
+	.irq		= dummy_irq,
667
+	.disable	= mtd_disable,
668
+};
669
+
670
+static struct pci_id mtd80x_nics[] = {
671
+        PCI_ROM(0x1516, 0x0800, "MTD800", "Myson MTD800"),
672
+        PCI_ROM(0x1516, 0x0803, "MTD803", "Surecom EP-320X"),
673
+        PCI_ROM(0x1516, 0x0891, "MTD891", "Myson MTD891"),
674
+};
675
+
676
+static struct pci_driver mtd80x_driver =
677
+	PCI_DRIVER ( "MTD80X", mtd80x_nics, PCI_NO_CLASS );
678
+
661 679
 /**************************************************************************
662 680
 PROBE - Look for an adapter, this routine's visible to the outside
663 681
 ***************************************************************************/
664 682
 
665 683
 static int mtd_probe ( struct dev *dev ) {
666
-
667 684
     struct nic *nic = nic_device ( dev );
668
-
669 685
     struct pci_device *pci = pci_device ( dev );
670 686
     int i;
671 687
 
672
-    if (pci->ioaddr == 0)
673
-    {
674
-        return 0;
675
-    }
688
+    if ( ! find_pci_device ( pci, &mtd80x_driver ) )
689
+	    return 0;
676 690
 
677
-    printf(" - ");
691
+    if (pci->ioaddr == 0)
692
+	    return 0;
678 693
 
679 694
     /* Mask the bit that says "this is an io addr" */
680
-    mtdx.ioaddr = pci->ioaddr & ~3;
681
-
682
-    adjust_pci_device(pci);
695
+    mtdx.ioaddr = pci->ioaddr;
683 696
 
684
-    mtdx.nic_name = pci->name;
697
+    mtdx.nic_name = dev->name;
685 698
     mtdx.dev_id = pci->dev_id;
686 699
 
687 700
     /* read ethernet id */
@@ -763,26 +776,13 @@ static int mtd_probe ( struct dev *dev ) {
763 776
     mtd_reset( nic );
764 777
 
765 778
     /* point to NIC specific routines */
766
-static struct nic_operations mtd_operations;
767
-static struct nic_operations mtd_operations = {
768
-	.connect	= dummy_connect,
769
-	.poll		= mtd_poll,
770
-	.transmit	= mtd_transmit,
771
-	.irq		= dummy_irq,
772
-	.disable	= mtd_disable,
773
-};    nic->nic_op	= &mtd_operations;
779
+    nic->nic_op	= &mtd_operations;
774 780
     return 1;
775 781
 }
776 782
 
777
-static struct pci_id mtd80x_nics[] =
778
-    {
779
-        PCI_ROM(0x1516, 0x0800, "MTD800", "Myson MTD800"),
780
-        PCI_ROM(0x1516, 0x0803, "MTD803", "Surecom EP-320X"),
781
-        PCI_ROM(0x1516, 0x0891, "MTD891", "Myson MTD891"),
782
-    };
783 783
 
784 784
 /**************************************************************************/
785
-static void set_rx_mode(struct nic *nic)
785
+static void set_rx_mode(struct nic *nic __unused)
786 786
 {
787 787
     u32 mc_filter[2];                       /* Multicast hash filter */
788 788
     u32 rx_mode;
@@ -884,7 +884,7 @@ static u32 m80x_send_cmd_to_phy(long miiport, int opcode, int phyad, int regad)
884 884
     return miir;
885 885
 }
886 886
 
887
-static int mdio_read(struct nic *nic, int phyad, int regad)
887
+static int mdio_read(struct nic *nic __unused, int phyad, int regad)
888 888
 {
889 889
     long miiport = mtdx.ioaddr + MANAGEMENT;
890 890
     u32 miir;
@@ -922,7 +922,9 @@ static int mdio_read(struct nic *nic, int phyad, int regad)
922 922
     return data & 0xffff;
923 923
 }
924 924
 
925
-static void mdio_write(struct nic *nic, int phyad, int regad, int data)
925
+#if 0 /* not used */
926
+static void mdio_write(struct nic *nic __unused, int phyad, int regad,
927
+		       int data)
926 928
 {
927 929
     long miiport = mtdx.ioaddr + MANAGEMENT;
928 930
     u32 miir;
@@ -954,6 +956,7 @@ static void mdio_write(struct nic *nic, int phyad, int regad, int data)
954 956
 
955 957
     return;
956 958
 }
959
+#endif
957 960
 
958 961
 static void getlinkstatus(struct nic *nic)
959 962
 /* function: Routine will read MII Status Register to get link status.       */
@@ -1091,8 +1094,4 @@ static void getlinktype(struct nic *dev)
1091 1094
     }
1092 1095
 }
1093 1096
 
1094
-
1095
-static struct pci_driver mtd80x_driver =
1096
-	PCI_DRIVER ( "MTD80X", mtd80x_nics, PCI_NO_CLASS );
1097
-
1098 1097
 BOOT_DRIVER ( "MTD80X", mtd_probe );

Loading…
Cancel
Save