Sfoglia il codice sorgente

Finished by hand

tags/v0.9.3
Michael Brown 19 anni fa
parent
commit
9848135950

+ 19
- 15
src/drivers/net/natsemi.c Vedi File

181
 
181
 
182
 /* Globals */
182
 /* Globals */
183
 
183
 
184
+static struct nic_operations natsemi_operations;
185
+static struct pci_driver natsemi_driver;
186
+
184
 static int natsemi_debug = 1;			/* 1 normal messages, 0 quiet .. 7 verbose. */
187
 static int natsemi_debug = 1;			/* 1 normal messages, 0 quiet .. 7 verbose. */
185
 
188
 
186
 const char *nic_name;
189
 const char *nic_name;
248
     int i;
251
     int i;
249
     int prev_eedata;
252
     int prev_eedata;
250
     u32 tmp;
253
     u32 tmp;
254
+    
255
+    if ( ! find_pci_device ( pci, &natsemi_driver ) )
256
+	return 0;
251
 
257
 
252
     if (pci->ioaddr == 0)
258
     if (pci->ioaddr == 0)
253
         return 0;
259
         return 0;
254
 
260
 
255
-    adjust_pci_device(pci);
256
-
257
     /* initialize some commonly used globals */
261
     /* initialize some commonly used globals */
258
 	
262
 	
259
     nic->irqno  = 0;
263
     nic->irqno  = 0;
260
-    nic->ioaddr = pci->ioaddr & ~3;
264
+    nic->ioaddr = pci->ioaddr;
261
 
265
 
262
-    ioaddr     = pci->ioaddr & ~3;
266
+    ioaddr     = pci->ioaddr;
263
     vendor     = pci->vendor;
267
     vendor     = pci->vendor;
264
     dev_id     = pci->dev_id;
268
     dev_id     = pci->dev_id;
265
-    nic_name   = pci->name;
269
+    nic_name   = dev->name;
266
 
270
 
267
     /* natsemi has a non-standard PM control register
271
     /* natsemi has a non-standard PM control register
268
      * in PCI config space.  Some boards apparently need
272
      * in PCI config space.  Some boards apparently need
269
      * to be brought to D0 in this manner.
273
      * to be brought to D0 in this manner.
270
      */
274
      */
271
-    pcibios_read_config_dword(pci->bus, pci->devfn, PCIPM, &tmp);
275
+    pci_read_config_dword(pci, PCIPM, &tmp);
272
     if (tmp & (0x03|0x100)) {
276
     if (tmp & (0x03|0x100)) {
273
 	/* D0 state, disable PME assertion */
277
 	/* D0 state, disable PME assertion */
274
 	u32 newtmp = tmp & ~(0x03|0x100);
278
 	u32 newtmp = tmp & ~(0x03|0x100);
275
-	pcibios_write_config_dword(pci->bus, pci->devfn, PCIPM, newtmp);
279
+	pci_write_config_dword(pci, PCIPM, newtmp);
276
     }
280
     }
277
 
281
 
278
     /* get MAC address */
282
     /* get MAC address */
316
 
320
 
317
     /* initialize device */
321
     /* initialize device */
318
     natsemi_init(nic);
322
     natsemi_init(nic);
319
-static struct nic_operations natsemi_operations;
320
-static struct nic_operations natsemi_operations = {
321
-	.connect	= dummy_connect,
322
-	.poll		= natsemi_poll,
323
-	.transmit	= natsemi_transmit,
324
-	.irq		= natsemi_irq,
325
-	.disable	= natsemi_disable,
326
-};
327
     nic->nic_op	= &natsemi_operations;
323
     nic->nic_op	= &natsemi_operations;
328
 
324
 
329
     return 1;
325
     return 1;
770
   }
766
   }
771
 }
767
 }
772
 
768
 
769
+static struct nic_operations natsemi_operations = {
770
+	.connect	= dummy_connect,
771
+	.poll		= natsemi_poll,
772
+	.transmit	= natsemi_transmit,
773
+	.irq		= natsemi_irq,
774
+	.disable	= natsemi_disable,
775
+};
776
+
773
 static struct pci_id natsemi_nics[] = {
777
 static struct pci_id natsemi_nics[] = {
774
 PCI_ROM(0x100b, 0x0020, "dp83815", "DP83815"),
778
 PCI_ROM(0x100b, 0x0020, "dp83815", "DP83815"),
775
 };
779
 };

+ 23
- 21
src/drivers/net/ns83820.c Vedi File

774
 
774
 
775
 	ns->up = 0;
775
 	ns->up = 0;
776
 
776
 
777
-	ns83820_do_reset((struct nic *) dev, CR_RST);
777
+	ns83820_do_reset(nic, CR_RST);
778
 
778
 
779
 	ns->IMR_cache &=
779
 	ns->IMR_cache &=
780
 	    ~(ISR_RXOK | ISR_RXDESC | ISR_RXERR | ISR_RXEARLY |
780
 	    ~(ISR_RXOK | ISR_RXDESC | ISR_RXERR | ISR_RXEARLY |
804
   }
804
   }
805
 }
805
 }
806
 
806
 
807
+static struct nic_operations ns83820_operations = {
808
+	.connect	= dummy_connect,
809
+	.poll		= ns83820_poll,
810
+	.transmit	= ns83820_transmit,
811
+	.irq		= ns83820_irq,
812
+	.disable	= ns83820_disable,
813
+};
814
+
815
+static struct pci_id ns83820_nics[] = {
816
+	PCI_ROM(0x100b, 0x0022, "ns83820", "National Semiconductor 83820"),
817
+};
818
+
819
+static struct pci_driver ns83820_driver =
820
+	PCI_DRIVER ( "NS83820/PCI", ns83820_nics, PCI_NO_CLASS );
821
+
807
 /**************************************************************************
822
 /**************************************************************************
808
 PROBE - Look for an adapter, this routine's visible to the outside
823
 PROBE - Look for an adapter, this routine's visible to the outside
809
 ***************************************************************************/
824
 ***************************************************************************/
811
 #define board_found 1
826
 #define board_found 1
812
 #define valid_link 0
827
 #define valid_link 0
813
 static int ns83820_probe ( struct dev *dev ) {
828
 static int ns83820_probe ( struct dev *dev ) {
814
-
815
 	struct nic *nic = nic_device ( dev );
829
 	struct nic *nic = nic_device ( dev );
816
-
817
 	struct pci_device *pci = pci_device ( dev );
830
 	struct pci_device *pci = pci_device ( dev );
818
 	int sz;
831
 	int sz;
819
 	long addr;
832
 	long addr;
820
 	int using_dac = 0;
833
 	int using_dac = 0;
821
 
834
 
835
+	if ( ! find_pci_device ( pci, &ns83820_driver ) )
836
+		return 0;
837
+
822
 	if (pci->ioaddr == 0)
838
 	if (pci->ioaddr == 0)
823
 		return 0;
839
 		return 0;
824
 
840
 
825
 	printf("ns83820.c: Found %s, vendor=0x%hX, device=0x%hX\n",
841
 	printf("ns83820.c: Found %s, vendor=0x%hX, device=0x%hX\n",
826
-	       pci->name, pci->vendor, pci->dev_id);
842
+	       dev->name, pci->vendor, pci->dev_id);
827
 
843
 
828
 	/* point to private storage */
844
 	/* point to private storage */
829
 	ns = &nsx;
845
 	ns = &nsx;
863
 	ns->CFG_cache = readl(ns->base + CFG);
879
 	ns->CFG_cache = readl(ns->base + CFG);
864
 
880
 
865
 	if ((ns->CFG_cache & CFG_PCI64_DET)) {
881
 	if ((ns->CFG_cache & CFG_PCI64_DET)) {
866
-		printf("%s: detected 64 bit PCI data bus.\n", pci->name);
882
+		printf("%s: detected 64 bit PCI data bus.\n", dev->name);
867
 		/*dev->CFG_cache |= CFG_DATA64_EN; */
883
 		/*dev->CFG_cache |= CFG_DATA64_EN; */
868
 		if (!(ns->CFG_cache & CFG_DATA64_EN))
884
 		if (!(ns->CFG_cache & CFG_DATA64_EN))
869
 			printf
885
 			printf
870
 			    ("%s: EEPROM did not enable 64 bit bus.  Disabled.\n",
886
 			    ("%s: EEPROM did not enable 64 bit bus.  Disabled.\n",
871
-			     pci->name);
887
+			     dev->name);
872
 	} else
888
 	} else
873
 		ns->CFG_cache &= ~(CFG_DATA64_EN);
889
 		ns->CFG_cache &= ~(CFG_DATA64_EN);
874
 
890
 
1000
 
1016
 
1001
 	ns83820_reset(nic);
1017
 	ns83820_reset(nic);
1002
 	/* point to NIC specific routines */
1018
 	/* point to NIC specific routines */
1003
-static struct nic_operations ns83820_operations;
1004
-static struct nic_operations ns83820_operations = {
1005
-	.connect	= dummy_connect,
1006
-	.poll		= ns83820_poll,
1007
-	.transmit	= ns83820_transmit,
1008
-	.irq		= ns83820_irq,
1009
-	.disable	= ns83820_disable,
1010
-};	nic->nic_op	= &ns83820_operations;
1019
+	nic->nic_op	= &ns83820_operations;
1011
 	return 1;
1020
 	return 1;
1012
 }
1021
 }
1013
 
1022
 
1014
-static struct pci_id ns83820_nics[] = {
1015
-	PCI_ROM(0x100b, 0x0022, "ns83820", "National Semiconductor 83820"),
1016
-};
1017
-
1018
-static struct pci_driver ns83820_driver =
1019
-	PCI_DRIVER ( "NS83820/PCI", ns83820_nics, PCI_NO_CLASS );
1020
-
1021
 BOOT_DRIVER ( "NS83820/PCI", ns83820_probe );
1023
 BOOT_DRIVER ( "NS83820/PCI", ns83820_probe );

+ 17
- 13
src/drivers/net/pcnet32.c Vedi File

62
 typedef signed int s32;
62
 typedef signed int s32;
63
 
63
 
64
 static u32 ioaddr;		/* Globally used for the card's io address */
64
 static u32 ioaddr;		/* Globally used for the card's io address */
65
+static struct nic_operations pcnet32_operations;
66
+static struct pci_driver pcnet32_driver;
65
 
67
 
66
 #ifdef EDEBUG
68
 #ifdef EDEBUG
67
 #define dprintf(x) printf x
69
 #define dprintf(x) printf x
665
 You should omit the last argument struct pci_device * for a non-PCI NIC
667
 You should omit the last argument struct pci_device * for a non-PCI NIC
666
 ***************************************************************************/
668
 ***************************************************************************/
667
 static int pcnet32_probe ( struct dev *dev ) {
669
 static int pcnet32_probe ( struct dev *dev ) {
668
-
669
 	struct nic *nic = nic_device ( dev );
670
 	struct nic *nic = nic_device ( dev );
670
-
671
 	struct pci_device *pci = pci_device ( dev );
671
 	struct pci_device *pci = pci_device ( dev );
672
 	int i, media;
672
 	int i, media;
673
 	int fdx, mii, fset, dxsuflo, ltint;
673
 	int fdx, mii, fset, dxsuflo, ltint;
675
 	char *chipname;
675
 	char *chipname;
676
 	struct pcnet32_access *a = NULL;
676
 	struct pcnet32_access *a = NULL;
677
 	u8 promaddr[6];
677
 	u8 promaddr[6];
678
-
679
 	int shared = 1;
678
 	int shared = 1;
679
+
680
+	if ( ! find_pci_device ( pci, &pcnet32_driver ) )
681
+		return 0;
682
+
680
 	if (pci->ioaddr == 0)
683
 	if (pci->ioaddr == 0)
681
 		return 0;
684
 		return 0;
682
 
685
 
683
 	/* BASE is used throughout to address the card */
686
 	/* BASE is used throughout to address the card */
684
 	ioaddr = pci->ioaddr;
687
 	ioaddr = pci->ioaddr;
685
 	printf("pcnet32.c: Found %s, Vendor=0x%hX Device=0x%hX\n",
688
 	printf("pcnet32.c: Found %s, Vendor=0x%hX Device=0x%hX\n",
686
-	       pci->name, pci->vendor, pci->dev_id);
689
+	       dev->name, pci->vendor, pci->dev_id);
687
 
690
 
688
 	nic->irqno  = 0;
691
 	nic->irqno  = 0;
689
 	nic->ioaddr = pci->ioaddr & ~3;
692
 	nic->ioaddr = pci->ioaddr & ~3;
801
 		nic->node_addr[i] = promaddr[i];
804
 		nic->node_addr[i] = promaddr[i];
802
 	}
805
 	}
803
 	/* Print out some hardware info */
806
 	/* Print out some hardware info */
804
-	printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr,
807
+	printf("%s: %! at ioaddr %hX, ", dev->name, nic->node_addr,
805
 	       ioaddr);
808
 	       ioaddr);
806
 
809
 
807
 	/* Set to pci bus master */
810
 	/* Set to pci bus master */
945
 		else
948
 		else
946
 			printf("\n");
949
 			printf("\n");
947
 	}
950
 	}
948
-static struct nic_operations pcnet32_operations;
949
-static struct nic_operations pcnet32_operations = {
950
-	.connect	= dummy_connect,
951
-	.poll		= pcnet32_poll,
952
-	.transmit	= pcnet32_transmit,
953
-	.irq		= pcnet32_irq,
954
-	.disable	= pcnet32_disable,
955
-};
951
+
956
 	nic->nic_op	= &pcnet32_operations;
952
 	nic->nic_op	= &pcnet32_operations;
957
 
953
 
958
 	return 1;
954
 	return 1;
993
 }
989
 }
994
 #endif
990
 #endif
995
 
991
 
992
+static struct nic_operations pcnet32_operations = {
993
+	.connect	= dummy_connect,
994
+	.poll		= pcnet32_poll,
995
+	.transmit	= pcnet32_transmit,
996
+	.irq		= pcnet32_irq,
997
+	.disable	= pcnet32_disable,
998
+};
999
+
996
 static struct pci_id pcnet32_nics[] = {
1000
 static struct pci_id pcnet32_nics[] = {
997
 	PCI_ROM(0x1022, 0x2000, "lancepci", "AMD Lance/PCI"),
1001
 	PCI_ROM(0x1022, 0x2000, "lancepci", "AMD Lance/PCI"),
998
 	PCI_ROM(0x1022, 0x2625, "pcnetfastiii", "AMD Lance/PCI PCNet/32"),
1002
 	PCI_ROM(0x1022, 0x2625, "pcnetfastiii", "AMD Lance/PCI PCNet/32"),

+ 22
- 20
src/drivers/net/r8169.c Vedi File

702
 	}
702
 	}
703
 }
703
 }
704
 
704
 
705
+static struct nic_operations r8169_operations = {
706
+	.connect	= dummy_connect,
707
+	.poll		= r8169_poll,
708
+	.transmit	= r8169_transmit,
709
+	.irq		= r8169_irq,
710
+	.disable	= r8169_disable,
711
+};
712
+
713
+static struct pci_id r8169_nics[] = {
714
+	PCI_ROM(0x10ec, 0x8169, "r8169", "RealTek RTL8169 Gigabit Ethernet"),
715
+};
716
+
717
+static struct pci_driver r8169_driver =
718
+	PCI_DRIVER ( "r8169/PCI", r8169_nics, PCI_NO_CLASS );
719
+
705
 /**************************************************************************
720
 /**************************************************************************
706
 PROBE - Look for an adapter, this routine's visible to the outside
721
 PROBE - Look for an adapter, this routine's visible to the outside
707
 ***************************************************************************/
722
 ***************************************************************************/
709
 #define board_found 1
724
 #define board_found 1
710
 #define valid_link 0
725
 #define valid_link 0
711
 static int r8169_probe ( struct dev *dev ) {
726
 static int r8169_probe ( struct dev *dev ) {
712
-
713
 	struct nic *nic = nic_device ( dev );
727
 	struct nic *nic = nic_device ( dev );
714
-
715
 	struct pci_device *pci = pci_device ( dev );
728
 	struct pci_device *pci = pci_device ( dev );
716
 	static int board_idx = -1;
729
 	static int board_idx = -1;
717
 	static int printed_version = 0;
730
 	static int printed_version = 0;
718
 	int i, rc;
731
 	int i, rc;
719
 	int option = -1, Cap10_100 = 0, Cap1000 = 0;
732
 	int option = -1, Cap10_100 = 0, Cap1000 = 0;
720
 
733
 
734
+	if ( ! find_pci_device ( pci, &r8169_driver ) )
735
+		return 0;
736
+
721
 	printf("r8169.c: Found %s, Vendor=%hX Device=%hX\n",
737
 	printf("r8169.c: Found %s, Vendor=%hX Device=%hX\n",
722
-	       pci->name, pci->vendor, pci->dev_id);
738
+	       dev->name, pci->vendor, pci->dev_id);
723
 
739
 
724
 	board_idx++;
740
 	board_idx++;
725
 
741
 
737
 	dprintf(("%s: Identified chip type is '%s'.\n", pci->name,
753
 	dprintf(("%s: Identified chip type is '%s'.\n", pci->name,
738
 		 rtl_chip_info[tpc->chipset].name));
754
 		 rtl_chip_info[tpc->chipset].name));
739
 	/* Print out some hardware info */
755
 	/* Print out some hardware info */
740
-	printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr,
756
+	printf("%s: %! at ioaddr %hX, ", dev->name, nic->node_addr,
741
 	       ioaddr);
757
 	       ioaddr);
742
 
758
 
743
 	/* if TBI is not endbled */
759
 	/* if TBI is not endbled */
824
 		udelay(100);
840
 		udelay(100);
825
 		printf
841
 		printf
826
 		    ("%s: 1000Mbps Full-duplex operation, TBI Link %s!\n",
842
 		    ("%s: 1000Mbps Full-duplex operation, TBI Link %s!\n",
827
-		     pci->name,
843
+		     dev->name,
828
 		     (RTL_R32(TBICSR) & TBILinkOK) ? "OK" : "Failed");
844
 		     (RTL_R32(TBICSR) & TBILinkOK) ? "OK" : "Failed");
829
 
845
 
830
 	}
846
 	}
831
 
847
 
832
 	r8169_reset(nic);
848
 	r8169_reset(nic);
833
 	/* point to NIC specific routines */
849
 	/* point to NIC specific routines */
834
-static struct nic_operations r8169_operations;
835
-static struct nic_operations r8169_operations = {
836
-	.connect	= dummy_connect,
837
-	.poll		= r8169_poll,
838
-	.transmit	= r8169_transmit,
839
-	.irq		= r8169_irq,
840
-	.disable	= r8169_disable,
841
-};	nic->nic_op	= &r8169_operations;
850
+	nic->nic_op	= &r8169_operations;
842
 	nic->irqno = pci->irq;
851
 	nic->irqno = pci->irq;
843
 	nic->ioaddr = ioaddr;
852
 	nic->ioaddr = ioaddr;
844
 	return 1;
853
 	return 1;
845
 
854
 
846
 }
855
 }
847
 
856
 
848
-static struct pci_id r8169_nics[] = {
849
-	PCI_ROM(0x10ec, 0x8169, "r8169", "RealTek RTL8169 Gigabit Ethernet"),
850
-};
851
-
852
-static struct pci_driver r8169_driver =
853
-	PCI_DRIVER ( "r8169/PCI", r8169_nics, PCI_NO_CLASS );
854
-
855
 BOOT_DRIVER ( "r8169/PCI", r8169_probe );
857
 BOOT_DRIVER ( "r8169/PCI", r8169_probe );

+ 16
- 12
src/drivers/net/sis900.c Vedi File

52
 
52
 
53
 /* Globals */
53
 /* Globals */
54
 
54
 
55
+static struct nic_operations sis900_operations;
56
+static struct pci_driver sis900_driver;
57
+
55
 static int sis900_debug = 0;
58
 static int sis900_debug = 0;
56
 
59
 
57
 static unsigned short vendor, dev_id;
60
 static unsigned short vendor, dev_id;
308
  */
311
  */
309
 
312
 
310
 static int sis900_probe ( struct dev *dev ) {
313
 static int sis900_probe ( struct dev *dev ) {
311
-
312
     struct nic *nic = nic_device ( dev );
314
     struct nic *nic = nic_device ( dev );
313
-
314
     struct pci_device *pci = pci_device ( dev );
315
     struct pci_device *pci = pci_device ( dev );
315
     int i;
316
     int i;
316
     int found=0;
317
     int found=0;
318
     u8 revision;
319
     u8 revision;
319
     int ret;
320
     int ret;
320
 
321
 
322
+    if ( ! find_pci_device ( pci, &sis900_driver ) )
323
+	return 0;
324
+
321
     if (pci->ioaddr == 0)
325
     if (pci->ioaddr == 0)
322
         return 0;
326
         return 0;
323
 
327
 
324
     nic->irqno  = 0;
328
     nic->irqno  = 0;
325
-    nic->ioaddr = pci->ioaddr & ~3;
326
-    ioaddr  = pci->ioaddr & ~3;
329
+    nic->ioaddr = pci->ioaddr;
330
+    ioaddr  = pci->ioaddr;
327
     vendor  = pci->vendor;
331
     vendor  = pci->vendor;
328
     dev_id  = pci->dev_id;
332
     dev_id  = pci->dev_id;
329
 
333
 
409
 
413
 
410
     /* initialize device */
414
     /* initialize device */
411
     sis900_init(nic);
415
     sis900_init(nic);
412
-static struct nic_operations sis900_operations;
413
-static struct nic_operations sis900_operations = {
414
-	.connect	= dummy_connect,
415
-	.poll		= sis900_poll,
416
-	.transmit	= sis900_transmit,
417
-	.irq		= sis900_irq,
418
-	.disable	= sis900_disable,
419
-};
420
     nic->nic_op	= &sis900_operations;
416
     nic->nic_op	= &sis900_operations;
421
 
417
 
422
     return 1;
418
     return 1;
1253
   }
1249
   }
1254
 }
1250
 }
1255
 
1251
 
1252
+static struct nic_operations sis900_operations = {
1253
+	.connect	= dummy_connect,
1254
+	.poll		= sis900_poll,
1255
+	.transmit	= sis900_transmit,
1256
+	.irq		= sis900_irq,
1257
+	.disable	= sis900_disable,
1258
+};
1259
+
1256
 static struct pci_id sis900_nics[] = {
1260
 static struct pci_id sis900_nics[] = {
1257
 PCI_ROM(0x1039, 0x0900, "sis900",  "SIS900"),
1261
 PCI_ROM(0x1039, 0x0900, "sis900",  "SIS900"),
1258
 PCI_ROM(0x1039, 0x7016, "sis7016", "SIS7016"),
1262
 PCI_ROM(0x1039, 0x7016, "sis7016", "SIS7016"),

+ 15
- 14
src/drivers/net/sundance.c Vedi File

571
 	outw(TxDisable | RxDisable | StatsDisable, BASE + MACCtrl1);
571
 	outw(TxDisable | RxDisable | StatsDisable, BASE + MACCtrl1);
572
 }
572
 }
573
 
573
 
574
-
574
+static struct nic_operations sundance_operations = {
575
+	.connect	= dummy_connect,
576
+	.poll		= sundance_poll,
577
+	.transmit	= sundance_transmit,
578
+	.irq		= sundance_irq,
579
+	.disable	= sundance_disable,
580
+};
581
+static struct pci_driver sundance_driver;
575
 
582
 
576
 /**************************************************************************
583
 /**************************************************************************
577
 PROBE - Look for an adapter, this routine's visible to the outside
584
 PROBE - Look for an adapter, this routine's visible to the outside
578
 ***************************************************************************/
585
 ***************************************************************************/
579
 static int sundance_probe ( struct dev *dev ) {
586
 static int sundance_probe ( struct dev *dev ) {
580
-
581
 	struct nic *nic = nic_device ( dev );
587
 	struct nic *nic = nic_device ( dev );
582
-
583
 	struct pci_device *pci = pci_device ( dev );
588
 	struct pci_device *pci = pci_device ( dev );
584
 	u8 ee_data[EEPROM_SIZE];
589
 	u8 ee_data[EEPROM_SIZE];
585
 	u16 mii_ctl;
590
 	u16 mii_ctl;
586
 	int i;
591
 	int i;
587
 	int speed;
592
 	int speed;
588
 
593
 
594
+	if ( ! find_pci_device ( pci, &sundance_driver ) )
595
+		return 0;
596
+
589
 	if (pci->ioaddr == 0)
597
 	if (pci->ioaddr == 0)
590
 		return 0;
598
 		return 0;
591
 
599
 
592
 	/* BASE is used throughout to address the card */
600
 	/* BASE is used throughout to address the card */
593
 	BASE = pci->ioaddr;
601
 	BASE = pci->ioaddr;
594
 	printf(" sundance.c: Found %s Vendor=0x%hX Device=0x%hX\n",
602
 	printf(" sundance.c: Found %s Vendor=0x%hX Device=0x%hX\n",
595
-	       pci->name, pci->vendor, pci->dev_id);
603
+	       dev->name, pci->vendor, pci->dev_id);
596
 
604
 
597
 	/* Get the MAC Address by reading the EEPROM */
605
 	/* Get the MAC Address by reading the EEPROM */
598
 	for (i = 0; i < 3; i++) {
606
 	for (i = 0; i < 3; i++) {
614
 	/* point to private storage */
622
 	/* point to private storage */
615
 	sdc = &sdx;
623
 	sdc = &sdx;
616
 
624
 
617
-	sdc->nic_name = pci->name;
625
+	sdc->nic_name = dev->name;
618
 	sdc->mtu = mtu;
626
 	sdc->mtu = mtu;
619
 
627
 
620
 	pci_read_config_byte(pci, PCI_REVISION_ID, &sdc->pci_rev_id);
628
 	pci_read_config_byte(pci, PCI_REVISION_ID, &sdc->pci_rev_id);
621
 	dprintf(("Device revision id: %hx\n", sdc->pci_rev_id));
629
 	dprintf(("Device revision id: %hx\n", sdc->pci_rev_id));
622
 	/* Print out some hardware info */
630
 	/* Print out some hardware info */
623
-	printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr, BASE);
631
+	printf("%s: %! at ioaddr %hX, ", dev->name, nic->node_addr, BASE);
624
 	sdc->mii_preamble_required = 0;
632
 	sdc->mii_preamble_required = 0;
625
 	if (1) {
633
 	if (1) {
626
 		int phy, phy_idx = 0;
634
 		int phy, phy_idx = 0;
735
 	       sdc->mii_if.full_duplex ? "Full" : "Half");
743
 	       sdc->mii_if.full_duplex ? "Full" : "Half");
736
 
744
 
737
 	/* point to NIC specific routines */
745
 	/* point to NIC specific routines */
738
-static struct nic_operations sundance_operations;
739
-static struct nic_operations sundance_operations = {
740
-	.connect	= dummy_connect,
741
-	.poll		= sundance_poll,
742
-	.transmit	= sundance_transmit,
743
-	.irq		= sundance_irq,
744
-	.disable	= sundance_disable,
745
-};	nic->nic_op	= &sundance_operations;
746
+	nic->nic_op	= &sundance_operations;
746
 	nic->irqno = pci->irq;
747
 	nic->irqno = pci->irq;
747
 	nic->ioaddr = BASE;
748
 	nic->ioaddr = BASE;
748
 
749
 

+ 46
- 48
src/drivers/net/tg3.c Vedi File

2875
 	struct nic *nic = tp->nic;
2875
 	struct nic *nic = tp->nic;
2876
 	uint32_t hi, lo, mac_offset;
2876
 	uint32_t hi, lo, mac_offset;
2877
 
2877
 
2878
-	if (PCI_FUNC(tp->pdev->devfn) == 0)
2878
+	if (PCI_FUNC(tp->pdev->busdevfn) == 0)
2879
 		mac_offset = 0x7c;
2879
 		mac_offset = 0x7c;
2880
 	else
2880
 	else
2881
 		mac_offset = 0xcc;
2881
 		mac_offset = 0xcc;
3219
   }
3219
   }
3220
 }
3220
 }
3221
 
3221
 
3222
+static struct nic_operations tg3_operations = {
3223
+	.connect	= dummy_connect,
3224
+	.poll		= tg3_poll,
3225
+	.transmit	= tg3_transmit,
3226
+	.irq		= tg3_irq,
3227
+	.disable	= tg3_disable,
3228
+};
3229
+
3230
+
3231
+static struct pci_id tg3_nics[] = {
3232
+PCI_ROM(0x14e4, 0x1644, "tg3-5700",        "Broadcom Tigon 3 5700"),
3233
+PCI_ROM(0x14e4, 0x1645, "tg3-5701",        "Broadcom Tigon 3 5701"),
3234
+PCI_ROM(0x14e4, 0x1646, "tg3-5702",        "Broadcom Tigon 3 5702"),
3235
+PCI_ROM(0x14e4, 0x1647, "tg3-5703",        "Broadcom Tigon 3 5703"),
3236
+PCI_ROM(0x14e4, 0x1648, "tg3-5704",        "Broadcom Tigon 3 5704"),
3237
+PCI_ROM(0x14e4, 0x164d, "tg3-5702FE",      "Broadcom Tigon 3 5702FE"),
3238
+PCI_ROM(0x14e4, 0x1653, "tg3-5705",        "Broadcom Tigon 3 5705"),
3239
+PCI_ROM(0x14e4, 0x1654, "tg3-5705_2",      "Broadcom Tigon 3 5705_2"),
3240
+PCI_ROM(0x14e4, 0x165d, "tg3-5705M",       "Broadcom Tigon 3 5705M"),
3241
+PCI_ROM(0x14e4, 0x165e, "tg3-5705M_2",     "Broadcom Tigon 3 5705M_2"),
3242
+PCI_ROM(0x14e4, 0x1677, "tg3-5751",        "Broadcom Tigon 3 5751"),
3243
+PCI_ROM(0x14e4, 0x1696, "tg3-5782",        "Broadcom Tigon 3 5782"),
3244
+PCI_ROM(0x14e4, 0x169c, "tg3-5788",        "Broadcom Tigon 3 5788"),
3245
+PCI_ROM(0x14e4, 0x16a6, "tg3-5702X",       "Broadcom Tigon 3 5702X"),
3246
+PCI_ROM(0x14e4, 0x16a7, "tg3-5703X",       "Broadcom Tigon 3 5703X"),
3247
+PCI_ROM(0x14e4, 0x16a8, "tg3-5704S",       "Broadcom Tigon 3 5704S"),
3248
+PCI_ROM(0x14e4, 0x16c6, "tg3-5702A3",      "Broadcom Tigon 3 5702A3"),
3249
+PCI_ROM(0x14e4, 0x16c7, "tg3-5703A3",      "Broadcom Tigon 3 5703A3"),
3250
+PCI_ROM(0x14e4, 0x170d, "tg3-5901",        "Broadcom Tigon 3 5901"),
3251
+PCI_ROM(0x14e4, 0x170e, "tg3-5901_2",      "Broadcom Tigon 3 5901_2"),
3252
+PCI_ROM(0x1148, 0x4400, "tg3-9DXX",        "Syskonnect 9DXX"),
3253
+PCI_ROM(0x1148, 0x4500, "tg3-9MXX",        "Syskonnect 9MXX"),
3254
+PCI_ROM(0x173b, 0x03e8, "tg3-ac1000",      "Altima AC1000"),
3255
+PCI_ROM(0x173b, 0x03e9, "tg3-ac1001",      "Altima AC1001"),
3256
+PCI_ROM(0x173b, 0x03ea, "tg3-ac9100",      "Altima AC9100"),
3257
+PCI_ROM(0x173b, 0x03eb, "tg3-ac1003",      "Altima AC1003"),
3258
+};
3259
+
3260
+static struct pci_driver tg3_driver =
3261
+	PCI_DRIVER ( "TG3", tg3_nics, PCI_NO_CLASS );
3262
+
3222
 /**************************************************************************
3263
 /**************************************************************************
3223
 PROBE - Look for an adapter, this routine's visible to the outside
3264
 PROBE - Look for an adapter, this routine's visible to the outside
3224
 You should omit the last argument struct pci_device * for a non-PCI NIC
3265
 You should omit the last argument struct pci_device * for a non-PCI NIC
3225
 ***************************************************************************/
3266
 ***************************************************************************/
3226
 static int tg3_probe ( struct dev *dev ) {
3267
 static int tg3_probe ( struct dev *dev ) {
3227
-
3228
 	struct nic *nic = nic_device ( dev );
3268
 	struct nic *nic = nic_device ( dev );
3229
-
3230
 	struct pci_device *pdev = pci_device ( dev );
3269
 	struct pci_device *pdev = pci_device ( dev );
3231
 	struct tg3 *tp = &tg3;
3270
 	struct tg3 *tp = &tg3;
3232
 	unsigned long tg3reg_base, tg3reg_len;
3271
 	unsigned long tg3reg_base, tg3reg_len;
3233
 	int i, err, pm_cap;
3272
 	int i, err, pm_cap;
3234
 
3273
 
3235
-	if (pdev == 0)
3274
+	if ( ! find_pci_device ( pdev, &tg3_driver ) )
3236
 		return 0;
3275
 		return 0;
3237
 
3276
 
3238
 	memset(tp, 0, sizeof(*tp));
3277
 	memset(tp, 0, sizeof(*tp));
3239
 
3278
 
3240
-	adjust_pci_device(pdev);
3241
-
3242
 	nic->irqno  = 0;
3279
 	nic->irqno  = 0;
3243
-	nic->ioaddr = pdev->ioaddr & ~3;
3280
+	nic->ioaddr = pdev->ioaddr;
3244
 
3281
 
3245
 	/* Find power-management capability. */
3282
 	/* Find power-management capability. */
3246
 	pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
3283
 	pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
3340
 		printf("Valid link not established\n");
3377
 		printf("Valid link not established\n");
3341
 		goto err_out_disable;
3378
 		goto err_out_disable;
3342
 	}
3379
 	}
3343
-static struct nic_operations tg3_operations;
3344
-static struct nic_operations tg3_operations = {
3345
-	.connect	= dummy_connect,
3346
-	.poll		= tg3_poll,
3347
-	.transmit	= tg3_transmit,
3348
-	.irq		= tg3_irq,
3349
-	.disable	= tg3_disable,
3350
-};
3380
+
3351
 	nic->nic_op	= &tg3_operations;
3381
 	nic->nic_op	= &tg3_operations;
3352
 
3382
 
3353
 	return 1;
3383
 	return 1;
3356
 	iounmap((void *)tp->regs);
3386
 	iounmap((void *)tp->regs);
3357
 	return 0;
3387
 	return 0;
3358
  err_out_disable:
3388
  err_out_disable:
3359
-	tg3_disable(dev);
3389
+	tg3_disable(nic);
3360
 	return 0;
3390
 	return 0;
3361
 }
3391
 }
3362
 
3392
 
3363
-static struct pci_id tg3_nics[] = {
3364
-PCI_ROM(0x14e4, 0x1644, "tg3-5700",        "Broadcom Tigon 3 5700"),
3365
-PCI_ROM(0x14e4, 0x1645, "tg3-5701",        "Broadcom Tigon 3 5701"),
3366
-PCI_ROM(0x14e4, 0x1646, "tg3-5702",        "Broadcom Tigon 3 5702"),
3367
-PCI_ROM(0x14e4, 0x1647, "tg3-5703",        "Broadcom Tigon 3 5703"),
3368
-PCI_ROM(0x14e4, 0x1648, "tg3-5704",        "Broadcom Tigon 3 5704"),
3369
-PCI_ROM(0x14e4, 0x164d, "tg3-5702FE",      "Broadcom Tigon 3 5702FE"),
3370
-PCI_ROM(0x14e4, 0x1653, "tg3-5705",        "Broadcom Tigon 3 5705"),
3371
-PCI_ROM(0x14e4, 0x1654, "tg3-5705_2",      "Broadcom Tigon 3 5705_2"),
3372
-PCI_ROM(0x14e4, 0x165d, "tg3-5705M",       "Broadcom Tigon 3 5705M"),
3373
-PCI_ROM(0x14e4, 0x165e, "tg3-5705M_2",     "Broadcom Tigon 3 5705M_2"),
3374
-PCI_ROM(0x14e4, 0x1677, "tg3-5751",        "Broadcom Tigon 3 5751"),
3375
-PCI_ROM(0x14e4, 0x1696, "tg3-5782",        "Broadcom Tigon 3 5782"),
3376
-PCI_ROM(0x14e4, 0x169c, "tg3-5788",        "Broadcom Tigon 3 5788"),
3377
-PCI_ROM(0x14e4, 0x16a6, "tg3-5702X",       "Broadcom Tigon 3 5702X"),
3378
-PCI_ROM(0x14e4, 0x16a7, "tg3-5703X",       "Broadcom Tigon 3 5703X"),
3379
-PCI_ROM(0x14e4, 0x16a8, "tg3-5704S",       "Broadcom Tigon 3 5704S"),
3380
-PCI_ROM(0x14e4, 0x16c6, "tg3-5702A3",      "Broadcom Tigon 3 5702A3"),
3381
-PCI_ROM(0x14e4, 0x16c7, "tg3-5703A3",      "Broadcom Tigon 3 5703A3"),
3382
-PCI_ROM(0x14e4, 0x170d, "tg3-5901",        "Broadcom Tigon 3 5901"),
3383
-PCI_ROM(0x14e4, 0x170e, "tg3-5901_2",      "Broadcom Tigon 3 5901_2"),
3384
-PCI_ROM(0x1148, 0x4400, "tg3-9DXX",        "Syskonnect 9DXX"),
3385
-PCI_ROM(0x1148, 0x4500, "tg3-9MXX",        "Syskonnect 9MXX"),
3386
-PCI_ROM(0x173b, 0x03e8, "tg3-ac1000",      "Altima AC1000"),
3387
-PCI_ROM(0x173b, 0x03e9, "tg3-ac1001",      "Altima AC1001"),
3388
-PCI_ROM(0x173b, 0x03ea, "tg3-ac9100",      "Altima AC9100"),
3389
-PCI_ROM(0x173b, 0x03eb, "tg3-ac1003",      "Altima AC1003"),
3390
-};
3391
-
3392
-static struct pci_driver tg3_driver =
3393
-	PCI_DRIVER ( "TG3", tg3_nics, PCI_NO_CLASS );
3394
-
3395
 BOOT_DRIVER ( "TG3", tg3_probe );
3393
 BOOT_DRIVER ( "TG3", tg3_probe );

+ 19
- 21
src/drivers/net/tlan.c Vedi File

65
 #define dprintf(x)
65
 #define dprintf(x)
66
 #endif
66
 #endif
67
 
67
 
68
+static struct pci_driver tlan_driver;
69
+
68
 static void TLan_ResetLists(struct nic *nic __unused);
70
 static void TLan_ResetLists(struct nic *nic __unused);
69
 static void TLan_ResetAdapter(struct nic *nic __unused);
71
 static void TLan_ResetAdapter(struct nic *nic __unused);
70
 static void TLan_FinishReset(struct nic *nic __unused);
72
 static void TLan_FinishReset(struct nic *nic __unused);
438
 				     "Full" : "Half"));
440
 				     "Full" : "Half"));
439
 				dprintf(("TLAN: Partner capability: "));
441
 				dprintf(("TLAN: Partner capability: "));
440
 				for (i = 5; i <= 10; i++)
442
 				for (i = 5; i <= 10; i++)
441
-					if (partner & (1 << i))
443
+					if (partner & (1 << i)) {
442
 						dprintf(("%s", media[i - 5]));
444
 						dprintf(("%s", media[i - 5]));
445
+					}
443
 				dprintf(("\n"));
446
 				dprintf(("\n"));
444
 			}
447
 			}
445
 
448
 
748
   }
751
   }
749
 }
752
 }
750
 
753
 
754
+static struct nic_operations tlan_operations = {
755
+	.connect	= dummy_connect,
756
+	.poll		= tlan_poll,
757
+	.transmit	= tlan_transmit,
758
+	.irq		= tlan_irq,
759
+	.disable	= tlan_disable,
760
+};
761
+
751
 static void TLan_SetMulticastList(struct nic *nic) {
762
 static void TLan_SetMulticastList(struct nic *nic) {
752
 	int i;
763
 	int i;
753
 	u8 tmp;
764
 	u8 tmp;
771
 #define board_found 1
782
 #define board_found 1
772
 #define valid_link 0
783
 #define valid_link 0
773
 static int tlan_probe ( struct dev *dev ) {
784
 static int tlan_probe ( struct dev *dev ) {
774
-
775
 	struct nic *nic = nic_device ( dev );
785
 	struct nic *nic = nic_device ( dev );
776
-
777
 	struct pci_device *pci = pci_device ( dev );
786
 	struct pci_device *pci = pci_device ( dev );
778
 	u16 data = 0;
787
 	u16 data = 0;
779
 	int err;
788
 	int err;
780
 	int i;
789
 	int i;
781
 
790
 
791
+	if ( ! find_pci_device ( pci, &tlan_driver ) )
792
+		return 0;
793
+
782
 	if (pci->ioaddr == 0)
794
 	if (pci->ioaddr == 0)
783
 		return 0;
795
 		return 0;
784
 
796
 
785
 	nic->irqno  = 0;
797
 	nic->irqno  = 0;
786
-	nic->ioaddr = pci->ioaddr & ~3;
798
+	nic->ioaddr = pci->ioaddr;
787
 
799
 
788
 	BASE = pci->ioaddr;
800
 	BASE = pci->ioaddr;
789
 	
801
 	
790
-	printf("tlan.c: Found %s, Vendor 0x%hX, Device 0x%hX\n", 
791
-		pci->name, pci->vendor, pci->dev_id);
792
-
793
-	/* Set nic as PCI bus master */
794
-	adjust_pci_device(pci);
795
-
796
 	/* Point to private storage */
802
 	/* Point to private storage */
797
 	priv = &TLanPrivateInfo;
803
 	priv = &TLanPrivateInfo;
798
 
804
 
810
 
816
 
811
 	priv->vendor_id = pci->vendor;
817
 	priv->vendor_id = pci->vendor;
812
 	priv->dev_id = pci->dev_id;
818
 	priv->dev_id = pci->dev_id;
813
-	priv->nic_name = pci->name;
819
+	priv->nic_name = dev->name;
814
 	priv->eoc = 0;
820
 	priv->eoc = 0;
815
 
821
 
816
 	err = 0;
822
 	err = 0;
821
 				       (u8 *) & nic->node_addr[i]);
827
 				       (u8 *) & nic->node_addr[i]);
822
 	if (err) {
828
 	if (err) {
823
 		printf("TLAN: %s: Error reading MAC from eeprom: %d\n",
829
 		printf("TLAN: %s: Error reading MAC from eeprom: %d\n",
824
-		       pci->name, err);
830
+		       dev->name, err);
825
 	} else 
831
 	} else 
826
 		/* Print out some hardware info */
832
 		/* Print out some hardware info */
827
 		printf("%s: %! at ioaddr %hX, ", 
833
 		printf("%s: %! at ioaddr %hX, ", 
828
-			pci->name, nic->node_addr, pci->ioaddr);
834
+			dev->name, nic->node_addr, pci->ioaddr);
829
 
835
 
830
 	priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
836
 	priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
831
 	printf("revision: 0x%hX\n", priv->tlanRev);
837
 	printf("revision: 0x%hX\n", priv->tlanRev);
844
 /*	if (board_found && valid_link)
850
 /*	if (board_found && valid_link)
845
 	{*/
851
 	{*/
846
 	/* point to NIC specific routines */
852
 	/* point to NIC specific routines */
847
-static struct nic_operations tlan_operations;
848
-static struct nic_operations tlan_operations = {
849
-	.connect	= dummy_connect,
850
-	.poll		= tlan_poll,
851
-	.transmit	= tlan_transmit,
852
-	.irq		= tlan_irq,
853
-	.disable	= tlan_disable,
854
-};
855
 	nic->nic_op	= &tlan_operations;
853
 	nic->nic_op	= &tlan_operations;
856
 	return 1;
854
 	return 1;
857
 }
855
 }

+ 15
- 13
src/drivers/net/tulip.c Vedi File

1213
   }
1213
   }
1214
 }
1214
 }
1215
 
1215
 
1216
+static struct nic_operations tulip_operations = {
1217
+	.connect	= dummy_connect,
1218
+	.poll		= tulip_poll,
1219
+	.transmit	= tulip_transmit,
1220
+	.irq		= tulip_irq,
1221
+	.disable	= tulip_disable,
1222
+};
1223
+static struct pci_driver tulip_driver;
1224
+
1216
 /*********************************************************************/
1225
 /*********************************************************************/
1217
 /* eth_probe - Look for an adapter                                   */
1226
 /* eth_probe - Look for an adapter                                   */
1218
 /*********************************************************************/
1227
 /*********************************************************************/
1219
 static int tulip_probe ( struct dev *dev ) {
1228
 static int tulip_probe ( struct dev *dev ) {
1220
-
1221
     struct nic *nic = nic_device ( dev );
1229
     struct nic *nic = nic_device ( dev );
1222
-
1223
     struct pci_device *pci = pci_device ( dev );
1230
     struct pci_device *pci = pci_device ( dev );
1224
     u32 i;
1231
     u32 i;
1225
     u8  chip_rev;
1232
     u8  chip_rev;
1228
     int chip_idx;
1235
     int chip_idx;
1229
     static unsigned char last_phys_addr[ETH_ALEN] = {0x00, 'L', 'i', 'n', 'u', 'x'};
1236
     static unsigned char last_phys_addr[ETH_ALEN] = {0x00, 'L', 'i', 'n', 'u', 'x'};
1230
 
1237
 
1238
+    if ( ! find_pci_device ( pci, &tulip_driver ) )
1239
+	return 0;
1240
+
1231
     if (pci->ioaddr == 0)
1241
     if (pci->ioaddr == 0)
1232
         return 0;
1242
         return 0;
1233
 
1243
 
1240
 
1250
 
1241
     tp->vendor_id  = pci->vendor;
1251
     tp->vendor_id  = pci->vendor;
1242
     tp->dev_id     = pci->dev_id;
1252
     tp->dev_id     = pci->dev_id;
1243
-    tp->nic_name   = pci->name;
1253
+    tp->nic_name   = dev->name;
1244
 
1254
 
1245
     tp->if_port = 0;
1255
     tp->if_port = 0;
1246
     tp->default_port = 0;
1256
     tp->default_port = 0;
1301
     /* Bring the 21041/21143 out of sleep mode.
1311
     /* Bring the 21041/21143 out of sleep mode.
1302
        Caution: Snooze mode does not work with some boards! */
1312
        Caution: Snooze mode does not work with some boards! */
1303
     if (tp->flags & HAS_PWRDWN)
1313
     if (tp->flags & HAS_PWRDWN)
1304
-        pcibios_write_config_dword(pci->bus, pci->devfn, 0x40, 0x00000000);
1314
+        pci_write_config_dword(pci, 0x40, 0x00000000);
1305
 
1315
 
1306
     if (inl(ioaddr + CSR5) == 0xFFFFFFFF) {
1316
     if (inl(ioaddr + CSR5) == 0xFFFFFFFF) {
1307
         printf("%s: The Tulip chip at %X is not functioning.\n",
1317
         printf("%s: The Tulip chip at %X is not functioning.\n",
1309
         return 0;
1319
         return 0;
1310
     }
1320
     }
1311
    
1321
    
1312
-    pcibios_read_config_byte(pci->bus, pci->devfn, PCI_REVISION, &chip_rev);
1322
+    pci_read_config_byte(pci, PCI_REVISION, &chip_rev);
1313
 
1323
 
1314
     printf("%s: [chip: %s] rev %d at %hX\n", tp->nic_name,
1324
     printf("%s: [chip: %s] rev %d at %hX\n", tp->nic_name,
1315
            tulip_tbl[chip_idx].chip_name, chip_rev, ioaddr);
1325
            tulip_tbl[chip_idx].chip_name, chip_rev, ioaddr);
1422
 
1432
 
1423
     /* reset the device and make ready for tx and rx of packets */
1433
     /* reset the device and make ready for tx and rx of packets */
1424
     tulip_reset(nic);
1434
     tulip_reset(nic);
1425
-static struct nic_operations tulip_operations;
1426
-static struct nic_operations tulip_operations = {
1427
-	.connect	= dummy_connect,
1428
-	.poll		= tulip_poll,
1429
-	.transmit	= tulip_transmit,
1430
-	.irq		= tulip_irq,
1431
-	.disable	= tulip_disable,
1432
-};
1433
     nic->nic_op	= &tulip_operations;
1435
     nic->nic_op	= &tulip_operations;
1434
 
1436
 
1435
     /* give the board a chance to reset before returning */
1437
     /* give the board a chance to reset before returning */

Loading…
Annulla
Salva