Sfoglia il codice sorgente

Finished by hand

tags/v0.9.3
Michael Brown 19 anni fa
parent
commit
951e305081
4 ha cambiato i file con 60 aggiunte e 50 eliminazioni
  1. 13
    9
      src/drivers/net/3c595.c
  2. 12
    11
      src/drivers/net/3c90x.c
  3. 13
    10
      src/drivers/net/davicom.c
  4. 22
    20
      src/drivers/net/dmfe.c

+ 13
- 9
src/drivers/net/3c595.c Vedi File

31
 #include "3c595.h"
31
 #include "3c595.h"
32
 #include "timer.h"
32
 #include "timer.h"
33
 
33
 
34
+static struct nic_operations t595_operations;
35
+static struct pci_driver t595_driver;
36
+
34
 static unsigned short	eth_nic_base;
37
 static unsigned short	eth_nic_base;
35
 static unsigned short	vx_connector, vx_connectors;
38
 static unsigned short	vx_connector, vx_connectors;
36
 
39
 
466
 ETH_PROBE - Look for an adapter
469
 ETH_PROBE - Look for an adapter
467
 ***************************************************************************/
470
 ***************************************************************************/
468
 static int t595_probe ( struct dev *dev ) {
471
 static int t595_probe ( struct dev *dev ) {
469
-
470
 	struct nic *nic = nic_device ( dev );
472
 	struct nic *nic = nic_device ( dev );
471
-
472
 	struct pci_device *pci = pci_device ( dev );
473
 	struct pci_device *pci = pci_device ( dev );
473
 	int i;
474
 	int i;
474
 	unsigned short *p;
475
 	unsigned short *p;
475
 
476
 
477
+	if ( ! find_pci_device ( pci, &t595_driver ) )
478
+		return 0;
479
+
476
 	if (pci->ioaddr == 0)
480
 	if (pci->ioaddr == 0)
477
 		return 0;
481
 		return 0;
478
-/*	eth_nic_base = probeaddrs[0] & ~3; */
479
 	eth_nic_base = pci->ioaddr;
482
 	eth_nic_base = pci->ioaddr;
480
 
483
 
481
 	nic->irqno  = 0;
484
 	nic->irqno  = 0;
482
-	nic->ioaddr = pci->ioaddr & ~3;
485
+	nic->ioaddr = pci->ioaddr;
483
 
486
 
484
 	GO_WINDOW(0);
487
 	GO_WINDOW(0);
485
 	outw(GLOBAL_RESET, BASE + VX_COMMAND);
488
 	outw(GLOBAL_RESET, BASE + VX_COMMAND);
508
 	printf("Ethernet address: %!\n", nic->node_addr);
511
 	printf("Ethernet address: %!\n", nic->node_addr);
509
 
512
 
510
 	t595_reset(nic);
513
 	t595_reset(nic);
511
-static struct nic_operations t595_operations;
514
+	nic->nic_op	= &t595_operations;
515
+	return 1;
516
+
517
+}
518
+
512
 static struct nic_operations t595_operations = {
519
 static struct nic_operations t595_operations = {
513
 	.connect	= dummy_connect,
520
 	.connect	= dummy_connect,
514
 	.poll		= t595_poll,
521
 	.poll		= t595_poll,
515
 	.transmit	= t595_transmit,
522
 	.transmit	= t595_transmit,
516
 	.irq		= t595_irq,
523
 	.irq		= t595_irq,
517
 	.disable	= t595_disable,
524
 	.disable	= t595_disable,
518
-};	nic->nic_op	= &t595_operations;
519
-	return 1;
520
-
521
-}
525
+};
522
 
526
 
523
 static struct pci_id t595_nics[] = {
527
 static struct pci_id t595_nics[] = {
524
 PCI_ROM(0x10b7, 0x5900, "3c590",           "3Com590"),		/* Vortex 10Mbps */
528
 PCI_ROM(0x10b7, 0x5900, "3c590",           "3Com590"),		/* Vortex 10Mbps */

+ 12
- 11
src/drivers/net/3c90x.c Vedi File

42
 #include "pci.h"
42
 #include "pci.h"
43
 #include "timer.h"
43
 #include "timer.h"
44
 
44
 
45
+static struct nic_operations a3c90x_operations;
46
+static struct pci_driver a3c90x_driver;
47
+
45
 #define	XCVR_MAGIC	(0x5A00)
48
 #define	XCVR_MAGIC	(0x5A00)
46
 /** any single transmission fails after 16 collisions or other errors
49
 /** any single transmission fails after 16 collisions or other errors
47
  ** this is the number of times to retry the transmission -- this should
50
  ** this is the number of times to retry the transmission -- this should
688
  *** card.  We just have to init it here.
691
  *** card.  We just have to init it here.
689
  ***/
692
  ***/
690
 static int a3c90x_probe ( struct dev *dev ) {
693
 static int a3c90x_probe ( struct dev *dev ) {
691
-
692
     struct nic *nic = nic_device ( dev );
694
     struct nic *nic = nic_device ( dev );
693
-
694
     struct pci_device *pci = pci_device ( dev );
695
     struct pci_device *pci = pci_device ( dev );
695
     int i, c;
696
     int i, c;
696
     unsigned short eeprom[0x21];
697
     unsigned short eeprom[0x21];
700
     unsigned short linktype;
701
     unsigned short linktype;
701
 #define	HWADDR_OFFSET	10
702
 #define	HWADDR_OFFSET	10
702
 
703
 
704
+    if ( ! find_pci_device ( pci, &a3c90x_driver ) )
705
+	    return 0;
706
+    
703
     if (pci->ioaddr == 0)
707
     if (pci->ioaddr == 0)
704
           return 0;
708
           return 0;
705
 
709
 
706
-    adjust_pci_device(pci);
707
-
708
-    nic->ioaddr = pci->ioaddr & ~3;
710
+    nic->ioaddr = pci->ioaddr;
709
     nic->irqno = 0;
711
     nic->irqno = 0;
710
 
712
 
711
     INF_3C90X.IOAddr = pci->ioaddr & ~3;
713
     INF_3C90X.IOAddr = pci->ioaddr & ~3;
951
                                  cmdAcknowledgeInterrupt, 0x661);
953
                                  cmdAcknowledgeInterrupt, 0x661);
952
 
954
 
953
     /** Set our exported functions **/
955
     /** Set our exported functions **/
954
-static struct nic_operations a3c90x_operations;
956
+    nic->nic_op	= &a3c90x_operations;
957
+    return 1;
958
+}
959
+
955
 static struct nic_operations a3c90x_operations = {
960
 static struct nic_operations a3c90x_operations = {
956
 	.connect	= dummy_connect,
961
 	.connect	= dummy_connect,
957
 	.poll		= a3c90x_poll,
962
 	.poll		= a3c90x_poll,
958
 	.transmit	= a3c90x_transmit,
963
 	.transmit	= a3c90x_transmit,
959
 	.irq		= a3c90x_irq,
964
 	.irq		= a3c90x_irq,
960
 	.disable	= a3c90x_disable,
965
 	.disable	= a3c90x_disable,
961
-};    nic->nic_op	= &a3c90x_operations;
962
-
963
-    return 1;
964
-}
965
-
966
+};
966
 
967
 
967
 static struct pci_id a3c90x_nics[] = {
968
 static struct pci_id a3c90x_nics[] = {
968
 /* Original 90x revisions: */
969
 /* Original 90x revisions: */

+ 13
- 10
src/drivers/net/davicom.c Vedi File

129
 /* Global Storage                                                    */
129
 /* Global Storage                                                    */
130
 /*********************************************************************/
130
 /*********************************************************************/
131
 
131
 
132
+static struct nic_operations davicom_operations;
133
+static struct pci_driver davicom_driver;
134
+
132
 /* PCI Bus parameters */
135
 /* PCI Bus parameters */
133
 static unsigned short vendor, dev_id;
136
 static unsigned short vendor, dev_id;
134
 static unsigned long ioaddr;
137
 static unsigned long ioaddr;
653
 /* eth_probe - Look for an adapter                                   */
656
 /* eth_probe - Look for an adapter                                   */
654
 /*********************************************************************/
657
 /*********************************************************************/
655
 static int davicom_probe ( struct dev *dev ) {
658
 static int davicom_probe ( struct dev *dev ) {
656
-
657
   struct nic *nic = nic_device ( dev );
659
   struct nic *nic = nic_device ( dev );
658
-
659
   struct pci_device *pci = pci_device ( dev );
660
   struct pci_device *pci = pci_device ( dev );
660
   unsigned int i;
661
   unsigned int i;
661
 
662
 
662
   whereami("davicom_probe\n");
663
   whereami("davicom_probe\n");
663
 
664
 
665
+  if ( ! find_pci_device ( pci, &davicom_driver ) )
666
+	  return 0;
667
+
664
   if (pci->ioaddr == 0)
668
   if (pci->ioaddr == 0)
665
     return 0;
669
     return 0;
666
 
670
 
667
   vendor  = pci->vendor;
671
   vendor  = pci->vendor;
668
   dev_id  = pci->dev_id;
672
   dev_id  = pci->dev_id;
669
-  ioaddr  = pci->ioaddr & ~3;
673
+  ioaddr  = pci->ioaddr;
670
 
674
 
671
   nic->irqno  = 0;
675
   nic->irqno  = 0;
672
-  nic->ioaddr = pci->ioaddr & ~3;
676
+  nic->ioaddr = pci->ioaddr;
673
 
677
 
674
   /* wakeup chip */
678
   /* wakeup chip */
675
-  pcibios_write_config_dword(pci->bus, pci->devfn, 0x40, 0x00000000);
679
+  pci_write_config_dword(pci, 0x40, 0x00000000);
676
 
680
 
677
   /* Stop the chip's Tx and Rx processes. */
681
   /* Stop the chip's Tx and Rx processes. */
678
   outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
682
   outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
694
 
698
 
695
   /* initialize device */
699
   /* initialize device */
696
   davicom_reset(nic);
700
   davicom_reset(nic);
697
-static struct nic_operations davicom_operations;
701
+  nic->nic_op	= &davicom_operations;
702
+  return 1;
703
+}
704
+
698
 static struct nic_operations davicom_operations = {
705
 static struct nic_operations davicom_operations = {
699
 	.connect	= dummy_connect,
706
 	.connect	= dummy_connect,
700
 	.poll		= davicom_poll,
707
 	.poll		= davicom_poll,
702
 	.irq		= davicom_irq,
709
 	.irq		= davicom_irq,
703
 	.disable	= davicom_disable,
710
 	.disable	= davicom_disable,
704
 };
711
 };
705
-  nic->nic_op	= &davicom_operations;
706
-
707
-  return 1;
708
-}
709
 
712
 
710
 static struct pci_id davicom_nics[] = {
713
 static struct pci_id davicom_nics[] = {
711
 PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100"),
714
 PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100"),

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

195
 };
195
 };
196
 
196
 
197
 /* Global variable declaration ----------------------------- */
197
 /* Global variable declaration ----------------------------- */
198
-static int dmfe_debug;
198
+static struct nic_operations dmfe_operations;
199
+static struct pci_driver dmfe_driver;
200
+
199
 static unsigned char dmfe_media_mode = DMFE_AUTO;
201
 static unsigned char dmfe_media_mode = DMFE_AUTO;
200
 static u32 dmfe_cr6_user_set;
202
 static u32 dmfe_cr6_user_set;
201
 
203
 
202
 /* For module input parameter */
204
 /* For module input parameter */
203
-static int debug;
204
 static u8 chkmode = 1;
205
 static u8 chkmode = 1;
205
 static u8 HPNA_mode;		/* Default: Low Power/High Speed */
206
 static u8 HPNA_mode;		/* Default: Low Power/High Speed */
206
 static u8 HPNA_rx_cmd;		/* Default: Disable Rx remote command */
207
 static u8 HPNA_rx_cmd;		/* Default: Disable Rx remote command */
245
 static void phy_write(unsigned long, u8, u8, u16, u32);
246
 static void phy_write(unsigned long, u8, u8, u16, u32);
246
 static void phy_write_1bit(unsigned long, u32);
247
 static void phy_write_1bit(unsigned long, u32);
247
 static u16 phy_read_1bit(unsigned long);
248
 static u16 phy_read_1bit(unsigned long);
248
-static u8 dmfe_sense_speed(struct nic *nic);
249
-static void dmfe_process_mode(struct nic *nic);
250
 static void dmfe_set_phyxcer(struct nic *nic);
249
 static void dmfe_set_phyxcer(struct nic *nic);
251
 
250
 
252
 static void dmfe_parse_srom(struct nic *nic);
251
 static void dmfe_parse_srom(struct nic *nic);
461
 #define board_found 1
460
 #define board_found 1
462
 #define valid_link 0
461
 #define valid_link 0
463
 static int dmfe_probe ( struct dev *dev ) {
462
 static int dmfe_probe ( struct dev *dev ) {
464
-
465
 	struct nic *nic = nic_device ( dev );
463
 	struct nic *nic = nic_device ( dev );
466
-
467
 	struct pci_device *pci = pci_device ( dev );
464
 	struct pci_device *pci = pci_device ( dev );
468
 	uint32_t dev_rev, pci_pmr;
465
 	uint32_t dev_rev, pci_pmr;
469
 	int i;
466
 	int i;
470
 
467
 
468
+	if ( ! find_pci_device ( pci, &dmfe_driver ) )
469
+		return 0;
470
+
471
 	if (pci->ioaddr == 0)
471
 	if (pci->ioaddr == 0)
472
 		return 0;
472
 		return 0;
473
 
473
 
474
 	BASE = pci->ioaddr;
474
 	BASE = pci->ioaddr;
475
 	printf("dmfe.c: Found %s Vendor=0x%hX Device=0x%hX\n",
475
 	printf("dmfe.c: Found %s Vendor=0x%hX Device=0x%hX\n",
476
-	       pci->name, pci->vendor, pci->dev_id);
476
+	       dev->name, pci->vendor, pci->dev_id);
477
 
477
 
478
 	/* Read Chip revision */
478
 	/* Read Chip revision */
479
 	pci_read_config_dword(pci, PCI_REVISION_ID, &dev_rev);
479
 	pci_read_config_dword(pci, PCI_REVISION_ID, &dev_rev);
504
 		nic->node_addr[i] = db->srom[20 + i];
504
 		nic->node_addr[i] = db->srom[20 + i];
505
 
505
 
506
 	/* Print out some hardware info */
506
 	/* Print out some hardware info */
507
-	printf("%s: %! at ioaddr %hX\n", pci->name, nic->node_addr, BASE);
507
+	printf("%s: %! at ioaddr %hX\n", dev->name, nic->node_addr, BASE);
508
 
508
 
509
 	/* Set the card as PCI Bus Master */
509
 	/* Set the card as PCI Bus Master */
510
 	adjust_pci_device(pci);
510
 	adjust_pci_device(pci);
515
 	nic->ioaddr = pci->ioaddr;
515
 	nic->ioaddr = pci->ioaddr;
516
 
516
 
517
 	/* point to NIC specific routines */
517
 	/* point to NIC specific routines */
518
-static struct nic_operations dmfe_operations;
519
-static struct nic_operations dmfe_operations = {
520
-	.connect	= dummy_connect,
521
-	.poll		= dmfe_poll,
522
-	.transmit	= dmfe_transmit,
523
-	.irq		= dmfe_irq,
524
-	.disable	= dmfe_disable,
525
-};	nic->nic_op	= &dmfe_operations;
518
+	nic->nic_op	= &dmfe_operations;
526
 
519
 
527
 	return 1;
520
 	return 1;
528
 }
521
 }
551
 		txd[i].tdes1 = cpu_to_le32(0x81000000);	/* IC, chain */
544
 		txd[i].tdes1 = cpu_to_le32(0x81000000);	/* IC, chain */
552
 		txd[i].tdes2 = cpu_to_le32(virt_to_bus(&txb[i]));
545
 		txd[i].tdes2 = cpu_to_le32(virt_to_bus(&txb[i]));
553
 		txd[i].tdes3 = cpu_to_le32(virt_to_bus(&txd[i + 1]));
546
 		txd[i].tdes3 = cpu_to_le32(virt_to_bus(&txd[i + 1]));
554
-		txd[i].next_tx_desc = cpu_to_le32(&txd[i + 1]);	
547
+		txd[i].next_tx_desc = virt_to_le32desc(&txd[i + 1]);	
555
 	}
548
 	}
556
 	/* Mark the last entry as wrapping the ring */
549
 	/* Mark the last entry as wrapping the ring */
557
 	txd[i - 1].tdes3 = virt_to_le32desc(&txd[0]);
550
 	txd[i - 1].tdes3 = virt_to_le32desc(&txd[0]);
565
 		rxd[i].rdes2 =
558
 		rxd[i].rdes2 =
566
 		    cpu_to_le32(virt_to_bus(&rxb[i * RX_ALLOC_SIZE]));
559
 		    cpu_to_le32(virt_to_bus(&rxb[i * RX_ALLOC_SIZE]));
567
 		rxd[i].rdes3 = cpu_to_le32(virt_to_bus(&rxd[i + 1]));
560
 		rxd[i].rdes3 = cpu_to_le32(virt_to_bus(&rxd[i + 1]));
568
-		rxd[i].next_rx_desc = cpu_to_le32(&rxd[i + 1]);
561
+		rxd[i].next_rx_desc = virt_to_le32desc(&rxd[i + 1]);
569
 	}
562
 	}
570
 	/* Mark the last entry as wrapping the ring */
563
 	/* Mark the last entry as wrapping the ring */
571
 	rxd[i - 1].rdes3 = cpu_to_le32(virt_to_bus(&rxd[0]));
564
 	rxd[i - 1].rdes3 = cpu_to_le32(virt_to_bus(&rxd[0]));
722
  *	Auto sense the media mode
715
  *	Auto sense the media mode
723
  */
716
  */
724
 
717
 
718
+#if 0 /* not used */
725
 static u8 dmfe_sense_speed(struct nic *nic __unused)
719
 static u8 dmfe_sense_speed(struct nic *nic __unused)
726
 {
720
 {
727
 	u8 ErrFlag = 0;
721
 	u8 ErrFlag = 0;
769
 
763
 
770
 	return ErrFlag;
764
 	return ErrFlag;
771
 }
765
 }
772
-
766
+#endif
773
 
767
 
774
 /*
768
 /*
775
  *	Set 10/100 phyxcer capability
769
  *	Set 10/100 phyxcer capability
841
  *			N-way force capability with SWITCH
835
  *			N-way force capability with SWITCH
842
  */
836
  */
843
 
837
 
838
+#if 0 /* not used */
844
 static void dmfe_process_mode(struct nic *nic __unused)
839
 static void dmfe_process_mode(struct nic *nic __unused)
845
 {
840
 {
846
 	u16 phy_reg;
841
 	u16 phy_reg;
890
 		}
885
 		}
891
 	}
886
 	}
892
 }
887
 }
893
-
888
+#endif
894
 
889
 
895
 /*
890
 /*
896
  *	Write a word to Phy register
891
  *	Write a word to Phy register
1217
 	phy_write(BASE, db->phy_addr, 25, phy_reg, db->chip_id);
1212
 	phy_write(BASE, db->phy_addr, 25, phy_reg, db->chip_id);
1218
 }
1213
 }
1219
 
1214
 
1215
+static struct nic_operations dmfe_operations = {
1216
+	.connect	= dummy_connect,
1217
+	.poll		= dmfe_poll,
1218
+	.transmit	= dmfe_transmit,
1219
+	.irq		= dmfe_irq,
1220
+	.disable	= dmfe_disable,
1221
+};
1220
 
1222
 
1221
 static struct pci_id dmfe_nics[] = {
1223
 static struct pci_id dmfe_nics[] = {
1222
 	PCI_ROM(0x1282, 0x9100, "dmfe9100", "Davicom 9100"),
1224
 	PCI_ROM(0x1282, 0x9100, "dmfe9100", "Davicom 9100"),

Loading…
Annulla
Salva