Browse Source

added change log to natsemi.c

tags/v0.9.3
Udayan Kumar 18 years ago
parent
commit
9ad59b60c5
1 changed files with 72 additions and 48 deletions
  1. 72
    48
      src/drivers/net/natsemi.c

+ 72
- 48
src/drivers/net/natsemi.c View File

1
-/* natsemi.c - gPXE driver for the NatSemi DP8381x series. 
1
+/* natsemi.c - gPXE driver for the NatSemi DP8381x series. */
2
+
3
+/*
4
+
2
  
5
  
6
+   natsemi.c: An Etherboot driver for the NatSemi DP8381x series.
7
+
8
+   Copyright (C) 2001 Entity Cyber, Inc.
9
+   
10
+   This development of this Etherboot driver was funded by 
11
+   
12
+      Sicom Systems: http://www.sicompos.com/
13
+   
14
+   Author: Marty Connor (mdc@thinguin.org)	   
15
+   Adapted from a Linux driver which was written by Donald Becker
16
+   
17
+   This software may be used and distributed according to the terms
18
+   of the GNU Public License (GPL), incorporated herein by reference.
19
+   
20
+   Original Copyright Notice:
21
+   
22
+   Written/copyright 1999-2001 by Donald Becker.
23
+   
24
+   This software may be used and distributed according to the terms of
25
+   the GNU General Public License (GPL), incorporated herein by reference.
26
+   Drivers based on or derived from this code fall under the GPL and must
27
+   retain the authorship, copyright and license notice.  This file is not
28
+   a complete program and may only be used when the entire operating
29
+   system is licensed under the GPL.  License for under other terms may be
30
+   available.  Contact the original author for details.
31
+   
32
+   The original author may be reached as becker@scyld.com, or at
33
+   Scyld Computing Corporation
34
+   410 Severn Ave., Suite 210
35
+   Annapolis MD 21403
36
+   
37
+   Support information and updates available at
38
+   http://www.scyld.com/network/netsemi.html
39
+   
40
+   References:
41
+   
42
+   http://www.scyld.com/expert/100mbps.html
43
+   http://www.scyld.com/expert/NWay.html
44
+   Datasheet is available from:
45
+   http://www.national.com/pf/DP/DP83815.html
46
+
47
+*/
48
+
49
+/* Revision History */
3
 
50
 
51
+/*
52
+  02 JUL 2007 Udayan Kumar	 1.2 ported the driver from etherboot to gPXE API
53
+		      	      	 Added a circular buffer for transmit and receive.
54
+		                 transmit routine will not wait for transmission to finish
55
+			         poll routine deals with it.
56
+
57
+  13 Dec 2003 timlegge 		1.1 Enabled Multicast Support
58
+  29 May 2001  mdc     		1.0
59
+     Initial Release.  		Tested with Netgear FA311 and FA312 boards
4
 */
60
 */
61
+ 
62
+
63
+
5
 
64
 
6
 #include <stdint.h>
65
 #include <stdint.h>
7
 #include <stdlib.h>
66
 #include <stdlib.h>
21
 
80
 
22
 #define TX_RING_SIZE 4
81
 #define TX_RING_SIZE 4
23
 #define NUM_RX_DESC  4
82
 #define NUM_RX_DESC  4
83
+#define RX_BUF_SIZE 1536
84
+#define OWN       0x80000000
85
+#define DSIZE     0x00000FFF
86
+#define CRC_SIZE  4
24
 
87
 
25
 struct natsemi_tx {
88
 struct natsemi_tx {
26
 	uint32_t link;
89
 	uint32_t link;
46
 	 * give the same.*/
109
 	 * give the same.*/
47
 	struct io_buffer *iobuf[NUM_RX_DESC];
110
 	struct io_buffer *iobuf[NUM_RX_DESC];
48
 	/*netdev_tx_complete needs pointer to the iobuf of the data so as to free 
111
 	/*netdev_tx_complete needs pointer to the iobuf of the data so as to free 
49
-	  it form the memory.*/
112
+	  it from the memory.*/
50
 	struct io_buffer *tx_iobuf[TX_RING_SIZE];
113
 	struct io_buffer *tx_iobuf[TX_RING_SIZE];
51
 	struct spi_bit_basher spibit;
114
 	struct spi_bit_basher spibit;
52
 	struct spi_device eeprom;
115
 	struct spi_device eeprom;
53
 	struct nvo_block nvo;
116
 	struct nvo_block nvo;
54
 };
117
 };
55
 
118
 
56
-/* Tuning Parameters */
57
-#define TX_FIFO_THRESH	256	/* In bytes, rounded down to 32 byte units. */
58
-#define RX_FIFO_THRESH	4	/* Rx buffer level before first PCI xfer.  */
59
-#define RX_DMA_BURST	4	/* Maximum PCI burst, '4' is 256 bytes */
60
-#define TX_DMA_BURST	4	/* Calculate as 16<<val. */
61
-#define TX_IPG		3	/* This is the only valid value */
62
-//#define RX_BUF_LEN_IDX	0	/*  */
63
-#define RX_BUF_LEN    8192   /*buffer size should be multiple of 32 */ 
64
-#define RX_BUF_PAD 4
65
-#define RX_BUF_SIZE 1536
66
-#define OWN       0x80000000
67
-#define DSIZE     0x00000FFF
68
-#define CRC_SIZE  4
69
 
119
 
70
 /* NATSEMI: Offsets to the device registers.
120
 /* NATSEMI: Offsets to the device registers.
71
    Unlike software-only systems, device drivers interact with complex hardware.
121
    Unlike software-only systems, device drivers interact with complex hardware.
153
 
203
 
154
 
204
 
155
 /*  EEPROM access , values are devices specific*/
205
 /*  EEPROM access , values are devices specific*/
156
-//#define EE_M1		0x80	/* Mode select bit 1 */
157
-//#define EE_M0		0x40	/* Mode select bit 0 */
158
 #define EE_CS		0x08	/* EEPROM chip select */
206
 #define EE_CS		0x08	/* EEPROM chip select */
159
 #define EE_SK		0x04	/* EEPROM shift clock */
207
 #define EE_SK		0x04	/* EEPROM shift clock */
160
 #define EE_DI		0x01	/* Data in */
208
 #define EE_DI		0x01	/* Data in */
208
  * detect that the card is not supporting VPD.
256
  * detect that the card is not supporting VPD.
209
  */
257
  */
210
 static struct nvo_fragment nat_nvo_fragments[] = {
258
 static struct nvo_fragment nat_nvo_fragments[] = {
211
-	{ 0x0f, 0x40 },
259
+	{ 0x0c, 0x40 },
212
 	{ 0, 0 }
260
 	{ 0, 0 }
213
 };
261
 };
214
 
262
 
218
  * @v NAT		NATSEMI NIC
266
  * @v NAT		NATSEMI NIC
219
  */
267
  */
220
  void nat_init_eeprom ( struct natsemi_nic *nat ) {
268
  void nat_init_eeprom ( struct natsemi_nic *nat ) {
221
-	int ee9356;
222
-	int vpd;
223
 
269
 
224
 	// Initialise three-wire bus 
270
 	// Initialise three-wire bus 
225
 	nat->spibit.basher.op = &nat_basher_ops;
271
 	nat->spibit.basher.op = &nat_basher_ops;
227
 	nat->spibit.endianness = SPI_BIT_LITTLE_ENDIAN;
273
 	nat->spibit.endianness = SPI_BIT_LITTLE_ENDIAN;
228
 	init_spi_bit_basher ( &nat->spibit );
274
 	init_spi_bit_basher ( &nat->spibit );
229
 
275
 
230
-	DBG ( "EEPROM is an AT93C46\n" );
276
+	/*natsemi DP 83815 only supports at93c46 */
231
 	init_at93c46 ( &nat->eeprom, 16 );
277
 	init_at93c46 ( &nat->eeprom, 16 );
232
 	nat->eeprom.bus = &nat->spibit.bus;
278
 	nat->eeprom.bus = &nat->spibit.bus;
233
 
279
 
234
-	// Initialise space for non-volatile options, if available 
235
-	//vpd = ( inw ( rtl->ioaddr + Config1 ) & VPDEnable );
236
-	//if ( vpd ) {
237
-	//	DBG ( "EEPROM in use for VPD; cannot use for options\n" );
238
-	//} else {
239
 		nat->nvo.nvs = &nat->eeprom.nvs;
280
 		nat->nvo.nvs = &nat->eeprom.nvs;
240
 		nat->nvo.fragments = nat_nvo_fragments;
281
 		nat->nvo.fragments = nat_nvo_fragments;
241
-//	}
242
 }
282
 }
243
 
283
 
244
 /**
284
 /**
280
  */
320
  */
281
 static int nat_open ( struct net_device *netdev ) {
321
 static int nat_open ( struct net_device *netdev ) {
282
 	struct natsemi_nic *nat = netdev->priv;
322
 	struct natsemi_nic *nat = netdev->priv;
283
-	//struct io_buffer *iobuf;
284
 	int i;
323
 	int i;
285
 	uint32_t tx_config,rx_config;
324
 	uint32_t tx_config,rx_config;
286
 	
325
 	
296
 		
335
 		
297
 
336
 
298
 
337
 
299
-	/* Program the MAC address TODO enable this comment */
300
 	 uint8_t last=0;
338
 	 uint8_t last=0;
301
 	 uint8_t last1=0;
339
 	 uint8_t last1=0;
302
 	 for ( i = 0 ; i < ETH_ALEN ; i+=2 )
340
 	 for ( i = 0 ; i < ETH_ALEN ; i+=2 )
303
 	 {
341
 	 {
304
-	//	DBG("MAC address %d octet :%X %X\n",i,netdev->ll_addr[i],netdev->ll_addr[i+1]);
305
-	//	DBG("LAst = %d last1 = %d\n",last,last1);
306
 		outl(i,nat->ioaddr+RxFilterAddr);
342
 		outl(i,nat->ioaddr+RxFilterAddr);
307
 		last1=netdev->ll_addr[i]>>7;
343
 		last1=netdev->ll_addr[i]>>7;
308
 	 	netdev->ll_addr[i]=netdev->ll_addr[i]<<1|last;
344
 	 	netdev->ll_addr[i]=netdev->ll_addr[i]<<1|last;
310
 		netdev->ll_addr[i+1]=(netdev->ll_addr[i+1]<<1)+last1;
346
 		netdev->ll_addr[i+1]=(netdev->ll_addr[i+1]<<1)+last1;
311
 
347
 
312
 		outw ( netdev->ll_addr[i] + (netdev->ll_addr[i+1]<<8), nat->ioaddr +RxFilterData);
348
 		outw ( netdev->ll_addr[i] + (netdev->ll_addr[i+1]<<8), nat->ioaddr +RxFilterData);
313
-		//outw ( (fullbyte>>8)+(fullbyte<<8), nat->ioaddr +RxFilterData);
314
-	//	DBG("MAC address %d octet :%X %X\n",i,netdev->ll_addr[i],netdev->ll_addr[i+1]);
315
-	//	DBG("LAst = %d last1 = %d\n",last,last1);
316
 	}
349
 	}
317
        
350
        
318
 
351
 
417
 		return -ENOBUFS;
450
 		return -ENOBUFS;
418
 	}
451
 	}
419
 
452
 
420
-	//DBG_HD(iobuf->data,iob_len(iobuf));
421
 	/* to be used in netdev_tx_complete*/
453
 	/* to be used in netdev_tx_complete*/
422
 	nat->tx_iobuf[nat->tx_cur]=iobuf;
454
 	nat->tx_iobuf[nat->tx_cur]=iobuf;
423
 
455
 
432
 	nat->tx[nat->tx_cur].cmdsts= (uint32_t) iob_len(iobuf)|OWN;
464
 	nat->tx[nat->tx_cur].cmdsts= (uint32_t) iob_len(iobuf)|OWN;
433
 
465
 
434
 
466
 
435
-	//DBG_HD(bus_to_virt(nat->tx[nat->tx_cur].bufptr), iob_len(iobuf) );
436
 	nat->tx_cur=(nat->tx_cur+1) % TX_RING_SIZE;
467
 	nat->tx_cur=(nat->tx_cur+1) % TX_RING_SIZE;
437
 
468
 
438
 	/*start the transmitter  */
469
 	/*start the transmitter  */
459
 	i=nat->tx_dirty;
490
 	i=nat->tx_dirty;
460
 	while(i!=nat->tx_cur)
491
 	while(i!=nat->tx_cur)
461
 	{
492
 	{
462
-		//status=(uint32_t)bus_to_virt(nat->tx[nat->tx_dirty].cmdsts);
463
 		status=nat->tx[nat->tx_dirty].cmdsts;
493
 		status=nat->tx[nat->tx_dirty].cmdsts;
464
 		DBG("value of tx_dirty = %d tx_cur=%d status=%X\n",
494
 		DBG("value of tx_dirty = %d tx_cur=%d status=%X\n",
465
 			nat->tx_dirty,nat->tx_cur,status);
495
 			nat->tx_dirty,nat->tx_cur,status);
487
 	}
517
 	}
488
 			
518
 			
489
 	
519
 	
490
-	//rx_status=(unsigned int)bus_to_virt(nat->rx[nat->rx_cur].cmdsts); 
491
 	rx_status=(unsigned int)nat->rx[nat->rx_cur].cmdsts; 
520
 	rx_status=(unsigned int)nat->rx[nat->rx_cur].cmdsts; 
492
-	//DBG ("Receiver Status = %x\n",rx_status);
493
 	/* Handle received packets */
521
 	/* Handle received packets */
494
 	while (rx_quota && (rx_status & OWN))
522
 	while (rx_quota && (rx_status & OWN))
495
 	{
523
 	{
510
 				return;
538
 				return;
511
 			memcpy(iob_put(rx_iob,rx_len),
539
 			memcpy(iob_put(rx_iob,rx_len),
512
 					bus_to_virt(nat->rx[nat->rx_cur].bufptr),rx_len);
540
 					bus_to_virt(nat->rx[nat->rx_cur].bufptr),rx_len);
513
-			//DBG_HD(bus_to_virt(nat->rx[nat->rx_cur].bufptr),rx_len);
514
 
541
 
515
-			DBG("received packet");
542
+			DBG("received packet\n");
516
 			/* add to the receive queue. */
543
 			/* add to the receive queue. */
517
 			netdev_rx(netdev,rx_iob);
544
 			netdev_rx(netdev,rx_iob);
518
 			rx_quota--;
545
 			rx_quota--;
519
 		}
546
 		}
520
 		nat->rx[nat->rx_cur].cmdsts = RX_BUF_SIZE;
547
 		nat->rx[nat->rx_cur].cmdsts = RX_BUF_SIZE;
521
 		nat->rx_cur=(nat->rx_cur+1) % NUM_RX_DESC;
548
 		nat->rx_cur=(nat->rx_cur+1) % NUM_RX_DESC;
522
-		//rx_status=(unsigned int)bus_to_virt(nat->rx[nat->rx_cur].cmdsts); 
523
 		rx_status=(unsigned int)nat->rx[nat->rx_cur].cmdsts; 
549
 		rx_status=(unsigned int)nat->rx[nat->rx_cur].cmdsts; 
524
 	}
550
 	}
525
 
551
 
568
 	nat_init_eeprom ( nat );
594
 	nat_init_eeprom ( nat );
569
 	nvs_read ( &nat->eeprom.nvs, EE_MAC, netdev->ll_addr, ETH_ALEN );
595
 	nvs_read ( &nat->eeprom.nvs, EE_MAC, netdev->ll_addr, ETH_ALEN );
570
 	uint8_t  eetest[128];	
596
 	uint8_t  eetest[128];	
571
-	int i;
572
 	nvs_read ( &nat->eeprom.nvs, 0, eetest,128 );
597
 	nvs_read ( &nat->eeprom.nvs, 0, eetest,128 );
573
-	//	DBG_HD(&eetest,128);
574
 	
598
 	
575
 
599
 
576
 	/* mdio routine of etherboot-5.4.0 natsemi driver has been removed and 
600
 	/* mdio routine of etherboot-5.4.0 natsemi driver has been removed and 
633
 static void nat_remove ( struct pci_device *pci ) {
657
 static void nat_remove ( struct pci_device *pci ) {
634
 	struct net_device *netdev = pci_get_drvdata ( pci );
658
 	struct net_device *netdev = pci_get_drvdata ( pci );
635
 	struct natsemi_nic *nat = netdev->priv;
659
 	struct natsemi_nic *nat = netdev->priv;
636
-/* TODO 
637
-	if ( rtl->nvo.nvs )
638
-		nvo_unregister ( &rtl->nvo );
639
-		*/
660
+ 
661
+	if ( nat->nvo.nvs )
662
+		nvo_unregister ( &nat->nvo );
663
+		
640
 	unregister_netdev ( netdev );
664
 	unregister_netdev ( netdev );
641
 	nat_reset ( nat );
665
 	nat_reset ( nat );
642
 	netdev_put ( netdev );
666
 	netdev_put ( netdev );

Loading…
Cancel
Save