ソースを参照

Updated to work with new ISAPnP bus code.

tags/v0.9.3
Michael Brown 19年前
コミット
a26edc2eec
1個のファイルの変更142行の追加189行の削除
  1. 142
    189
      src/drivers/net/3c515.c

+ 142
- 189
src/drivers/net/3c515.c ファイルの表示

44
 * *********************************************************/
44
 * *********************************************************/
45
 
45
 
46
 
46
 
47
-#define ISA_PNP
48
-/*#define EDEBUG1*/
49
-
50
 /* to get some global routines like printf */
47
 /* to get some global routines like printf */
51
 #include "etherboot.h"
48
 #include "etherboot.h"
52
 /* to get the interface to the body of the program */
49
 /* to get the interface to the body of the program */
53
 #include "nic.h"
50
 #include "nic.h"
54
-#include "isa.h"
51
+#include "isapnp.h"
52
+#include "isa.h" /* for ISA_ROM */
55
 #include "timer.h"
53
 #include "timer.h"
56
 
54
 
57
-#ifdef ISA_PNP
58
-
59
 static void t3c515_wait(unsigned int nticks)
55
 static void t3c515_wait(unsigned int nticks)
60
 {
56
 {
61
 	unsigned int to = currticks() + nticks;
57
 	unsigned int to = currticks() + nticks;
62
 	while (currticks() < to)
58
 	while (currticks() < to)
63
 		/* wait */ ;
59
 		/* wait */ ;
64
 }
60
 }
65
-#endif
61
+
66
 /* TJL definations */
62
 /* TJL definations */
67
 #define HZ      100
63
 #define HZ      100
68
 #define u16 unsigned short
64
 #define u16 unsigned short
69
 #define u32 unsigned long
65
 #define u32 unsigned long
70
 #define s16 signed short
66
 #define s16 signed short
71
 #define s32 signed long
67
 #define s32 signed long
72
-static unsigned short eth_nic_base;
73
-#define BASE 	(eth_nic_base)
74
 static int if_port;
68
 static int if_port;
75
 struct corkscrew_private *vp;
69
 struct corkscrew_private *vp;
76
 /* Brought directly from 3c515.c by Becker */
70
 /* Brought directly from 3c515.c by Becker */
103
 static int rx_nocopy, rx_copy, queued_packet;
97
 static int rx_nocopy, rx_copy, queued_packet;
104
 */
98
 */
105
 
99
 
106
-#ifdef DRIVER_DEBUG
107
-static int corkscrew_debug = DRIVER_DEBUG;
108
-#else
109
-static int corkscrew_debug = 1;
110
-#endif
111
-
112
 #define CORKSCREW_ID 10
100
 #define CORKSCREW_ID 10
113
 
101
 
114
-#define EL3WINDOW(win_num) outw(SelectWindow + (win_num), ioaddr + EL3_CMD)
102
+#define EL3WINDOW(win_num) \
103
+	outw(SelectWindow + (win_num), nic->ioaddr + EL3_CMD)
115
 #define EL3_CMD 0x0e
104
 #define EL3_CMD 0x0e
116
 #define EL3_STATUS 0x0e
105
 #define EL3_STATUS 0x0e
117
 #define RX_BYTES_MASK			(unsigned short) (0x07ff)
106
 #define RX_BYTES_MASK			(unsigned short) (0x07ff)
296
 
285
 
297
 /* This driver uses 'options' to pass the media type, full-duplex flag, etc. */
286
 /* This driver uses 'options' to pass the media type, full-duplex flag, etc. */
298
 /* Note: this is the only limit on the number of cards supported!! */
287
 /* Note: this is the only limit on the number of cards supported!! */
299
-static int options[8] = { -1, -1, -1, -1, -1, -1, -1, -1, };
288
+static int options = -1;
300
 
289
 
301
 /* End Brought directly from 3c515.c by Becker */
290
 /* End Brought directly from 3c515.c by Becker */
302
 
291
 
305
 ***************************************************************************/
294
 ***************************************************************************/
306
 static void t515_reset(struct nic *nic)
295
 static void t515_reset(struct nic *nic)
307
 {
296
 {
308
-	int ioaddr = BASE;
309
 	union wn3_config config;
297
 	union wn3_config config;
310
 	int i;
298
 	int i;
311
 
299
 
312
 	/* Before initializing select the active media port. */
300
 	/* Before initializing select the active media port. */
313
 	EL3WINDOW(3);
301
 	EL3WINDOW(3);
314
 	if (vp->full_duplex)
302
 	if (vp->full_duplex)
315
-		outb(0x20, ioaddr + Wn3_MAC_Ctrl);	/* Set the full-duplex bit. */
316
-	config.i = inl(ioaddr + Wn3_Config);
303
+		outb(0x20, nic->ioaddr + Wn3_MAC_Ctrl);	/* Set the full-duplex bit. */
304
+	config.i = inl(nic->ioaddr + Wn3_Config);
317
 
305
 
318
 	if (vp->media_override != 7) {
306
 	if (vp->media_override != 7) {
319
-		if (corkscrew_debug > 1)
320
-			printf("Media override to transceiver %d (%s).\n",
321
-			       vp->media_override,
322
-			       media_tbl[vp->media_override].name);
307
+		DBG ( "Media override to transceiver %d (%s).\n",
308
+		      vp->media_override,
309
+		      media_tbl[vp->media_override].name);
323
 		if_port = vp->media_override;
310
 		if_port = vp->media_override;
324
 	} else if (vp->autoselect) {
311
 	} else if (vp->autoselect) {
325
 		/* Find first available media type, starting with 100baseTx. */
312
 		/* Find first available media type, starting with 100baseTx. */
327
 		while (!(vp->available_media & media_tbl[if_port].mask))
314
 		while (!(vp->available_media & media_tbl[if_port].mask))
328
 			if_port = media_tbl[if_port].next;
315
 			if_port = media_tbl[if_port].next;
329
 
316
 
330
-		if (corkscrew_debug > 1)
331
-			printf("Initial media type %s.\n",
332
-			       media_tbl[if_port].name);
317
+		DBG ( "Initial media type %s.\n",
318
+		      media_tbl[if_port].name);
333
 	} else
319
 	} else
334
 		if_port = vp->default_media;
320
 		if_port = vp->default_media;
335
 
321
 
336
 	config.u.xcvr = if_port;
322
 	config.u.xcvr = if_port;
337
-	outl(config.i, ioaddr + Wn3_Config);
323
+	outl(config.i, nic->ioaddr + Wn3_Config);
338
 
324
 
339
-	if (corkscrew_debug > 1) {
340
-		printf("corkscrew_open() InternalConfig 0x%hX.\n",
341
-		       config.i);
342
-	}
325
+	DBG ( "corkscrew_open() InternalConfig 0x%hX.\n",
326
+	      config.i);
343
 
327
 
344
-	outw(TxReset, ioaddr + EL3_CMD);
328
+	outw(TxReset, nic->ioaddr + EL3_CMD);
345
 	for (i = 20; i >= 0; i--)
329
 	for (i = 20; i >= 0; i--)
346
-		if (!(inw(ioaddr + EL3_STATUS) & CmdInProgress))
330
+		if (!(inw(nic->ioaddr + EL3_STATUS) & CmdInProgress))
347
 			break;
331
 			break;
348
 
332
 
349
-	outw(RxReset, ioaddr + EL3_CMD);
333
+	outw(RxReset, nic->ioaddr + EL3_CMD);
350
 	/* Wait a few ticks for the RxReset command to complete. */
334
 	/* Wait a few ticks for the RxReset command to complete. */
351
 	for (i = 20; i >= 0; i--)
335
 	for (i = 20; i >= 0; i--)
352
-		if (!(inw(ioaddr + EL3_STATUS) & CmdInProgress))
336
+		if (!(inw(nic->ioaddr + EL3_STATUS) & CmdInProgress))
353
 			break;
337
 			break;
354
 
338
 
355
-	outw(SetStatusEnb | 0x00, ioaddr + EL3_CMD);
339
+	outw(SetStatusEnb | 0x00, nic->ioaddr + EL3_CMD);
356
 
340
 
357
-	if (corkscrew_debug > 1) {
341
+#ifdef debug_3c515
358
 		EL3WINDOW(4);
342
 		EL3WINDOW(4);
359
-		printf("FIXME: fix print for irq, not 9");
360
-		printf("corkscrew_open() irq %d media status 0x%hX.\n",
361
-		       9, inw(ioaddr + Wn4_Media));
362
-	}
343
+		DBG ( "FIXME: fix print for irq, not 9" );
344
+		DBG ( "corkscrew_open() irq %d media status 0x%hX.\n",
345
+		      9, inw(nic->ioaddr + Wn4_Media) );
346
+#endif
363
 
347
 
364
 	/* Set the station address and mask in window 2 each time opened. */
348
 	/* Set the station address and mask in window 2 each time opened. */
365
 	EL3WINDOW(2);
349
 	EL3WINDOW(2);
366
 	for (i = 0; i < 6; i++)
350
 	for (i = 0; i < 6; i++)
367
-		outb(nic->node_addr[i], ioaddr + i);
351
+		outb(nic->node_addr[i], nic->ioaddr + i);
368
 	for (; i < 12; i += 2)
352
 	for (; i < 12; i += 2)
369
-		outw(0, ioaddr + i);
353
+		outw(0, nic->ioaddr + i);
370
 
354
 
371
 	if (if_port == 3)
355
 	if (if_port == 3)
372
 		/* Start the thinnet transceiver. We should really wait 50ms... */
356
 		/* Start the thinnet transceiver. We should really wait 50ms... */
373
-		outw(StartCoax, ioaddr + EL3_CMD);
357
+		outw(StartCoax, nic->ioaddr + EL3_CMD);
374
 	EL3WINDOW(4);
358
 	EL3WINDOW(4);
375
-	outw((inw(ioaddr + Wn4_Media) & ~(Media_10TP | Media_SQE)) |
376
-	     media_tbl[if_port].media_bits, ioaddr + Wn4_Media);
359
+	outw((inw(nic->ioaddr + Wn4_Media) & ~(Media_10TP | Media_SQE)) |
360
+	     media_tbl[if_port].media_bits, nic->ioaddr + Wn4_Media);
377
 
361
 
378
 	/* Switch to the stats window, and clear all stats by reading. */
362
 	/* Switch to the stats window, and clear all stats by reading. */
379
-/*	outw(StatsDisable, ioaddr + EL3_CMD);*/
363
+/*	outw(StatsDisable, nic->ioaddr + EL3_CMD);*/
380
 	EL3WINDOW(6);
364
 	EL3WINDOW(6);
381
 	for (i = 0; i < 10; i++)
365
 	for (i = 0; i < 10; i++)
382
-		inb(ioaddr + i);
383
-	inw(ioaddr + 10);
384
-	inw(ioaddr + 12);
366
+		inb(nic->ioaddr + i);
367
+	inw(nic->ioaddr + 10);
368
+	inw(nic->ioaddr + 12);
385
 	/* New: On the Vortex we must also clear the BadSSD counter. */
369
 	/* New: On the Vortex we must also clear the BadSSD counter. */
386
 	EL3WINDOW(4);
370
 	EL3WINDOW(4);
387
-	inb(ioaddr + 12);
371
+	inb(nic->ioaddr + 12);
388
 	/* ..and on the Boomerang we enable the extra statistics bits. */
372
 	/* ..and on the Boomerang we enable the extra statistics bits. */
389
-	outw(0x0040, ioaddr + Wn4_NetDiag);
373
+	outw(0x0040, nic->ioaddr + Wn4_NetDiag);
390
 
374
 
391
 	/* Switch to register set 7 for normal use. */
375
 	/* Switch to register set 7 for normal use. */
392
 	EL3WINDOW(7);
376
 	EL3WINDOW(7);
397
 	if (vp->full_bus_master_rx) {	/* Boomerang bus master. */
381
 	if (vp->full_bus_master_rx) {	/* Boomerang bus master. */
398
 		printf("FIXME: Is this if necessary");
382
 		printf("FIXME: Is this if necessary");
399
 		vp->cur_rx = vp->dirty_rx = 0;
383
 		vp->cur_rx = vp->dirty_rx = 0;
400
-		if (corkscrew_debug > 2)
401
-			printf("   Filling in the Rx ring.\n");
384
+		DBG ( "   Filling in the Rx ring.\n" );
402
 		for (i = 0; i < RX_RING_SIZE; i++) {
385
 		for (i = 0; i < RX_RING_SIZE; i++) {
403
 			printf("FIXME: Is this if necessary");
386
 			printf("FIXME: Is this if necessary");
404
 		}
387
 		}
405
 	}
388
 	}
406
 	if (vp->full_bus_master_tx) {	/* Boomerang bus master Tx. */
389
 	if (vp->full_bus_master_tx) {	/* Boomerang bus master Tx. */
407
 		vp->cur_tx = vp->dirty_tx = 0;
390
 		vp->cur_tx = vp->dirty_tx = 0;
408
-		outb(PKT_BUF_SZ >> 8, ioaddr + TxFreeThreshold);	/* Room for a packet. */
391
+		outb(PKT_BUF_SZ >> 8, nic->ioaddr + TxFreeThreshold);	/* Room for a packet. */
409
 		/* Clear the Tx ring. */
392
 		/* Clear the Tx ring. */
410
 		for (i = 0; i < TX_RING_SIZE; i++)
393
 		for (i = 0; i < TX_RING_SIZE; i++)
411
 			vp->tx_skbuff[i] = 0;
394
 			vp->tx_skbuff[i] = 0;
412
-		outl(0, ioaddr + DownListPtr);
395
+		outl(0, nic->ioaddr + DownListPtr);
413
 	}
396
 	}
414
 	/* Set receiver mode: presumably accept b-case and phys addr only. */
397
 	/* Set receiver mode: presumably accept b-case and phys addr only. */
415
 	outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm,
398
 	outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm,
416
-	     ioaddr + EL3_CMD);
399
+	     nic->ioaddr + EL3_CMD);
417
 
400
 
418
-	outw(RxEnable, ioaddr + EL3_CMD);	/* Enable the receiver. */
419
-	outw(TxEnable, ioaddr + EL3_CMD);	/* Enable transmitter. */
401
+	outw(RxEnable, nic->ioaddr + EL3_CMD);	/* Enable the receiver. */
402
+	outw(TxEnable, nic->ioaddr + EL3_CMD);	/* Enable transmitter. */
420
 	/* Allow status bits to be seen. */
403
 	/* Allow status bits to be seen. */
421
 	outw(SetStatusEnb | AdapterFailure | IntReq | StatsFull |
404
 	outw(SetStatusEnb | AdapterFailure | IntReq | StatsFull |
422
 	     (vp->full_bus_master_tx ? DownComplete : TxAvailable) |
405
 	     (vp->full_bus_master_tx ? DownComplete : TxAvailable) |
423
 	     (vp->full_bus_master_rx ? UpComplete : RxComplete) |
406
 	     (vp->full_bus_master_rx ? UpComplete : RxComplete) |
424
-	     (vp->bus_master ? DMADone : 0), ioaddr + EL3_CMD);
407
+	     (vp->bus_master ? DMADone : 0), nic->ioaddr + EL3_CMD);
425
 	/* Ack all pending events, and set active indicator mask. */
408
 	/* Ack all pending events, and set active indicator mask. */
426
 	outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
409
 	outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
427
-	     ioaddr + EL3_CMD);
410
+	     nic->ioaddr + EL3_CMD);
428
 	outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete | StatsFull
411
 	outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete | StatsFull
429
 	     | (vp->bus_master ? DMADone : 0) | UpComplete | DownComplete,
412
 	     | (vp->bus_master ? DMADone : 0) | UpComplete | DownComplete,
430
-	     ioaddr + EL3_CMD);
413
+	     nic->ioaddr + EL3_CMD);
431
 
414
 
432
 }
415
 }
433
 
416
 
439
 	short status, cst;
422
 	short status, cst;
440
 	register short rx_fifo;
423
 	register short rx_fifo;
441
 
424
 
442
-	cst = inw(BASE + EL3_STATUS);
425
+	cst = inw(nic->ioaddr + EL3_STATUS);
443
 
426
 
444
 	if ((cst & RxComplete) == 0) {
427
 	if ((cst & RxComplete) == 0) {
445
 		/* Ack all pending events, and set active indicator mask. */
428
 		/* Ack all pending events, and set active indicator mask. */
446
 		outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
429
 		outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
447
-		     BASE + EL3_CMD);
430
+		     nic->ioaddr + EL3_CMD);
448
 		outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete |
431
 		outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete |
449
 		     StatsFull | (vp->
432
 		     StatsFull | (vp->
450
 				  bus_master ? DMADone : 0) | UpComplete |
433
 				  bus_master ? DMADone : 0) | UpComplete |
451
-		     DownComplete, BASE + EL3_CMD);
434
+		     DownComplete, nic->ioaddr + EL3_CMD);
452
 		return 0;
435
 		return 0;
453
 	}
436
 	}
454
-	status = inw(BASE + RxStatus);
437
+	status = inw(nic->ioaddr + RxStatus);
455
 
438
 
456
 	if (status & RxDError) {
439
 	if (status & RxDError) {
457
 		printf("RxDError\n");
440
 		printf("RxDError\n");
458
-		outw(RxDiscard, BASE + EL3_CMD);
441
+		outw(RxDiscard, nic->ioaddr + EL3_CMD);
459
 		return 0;
442
 		return 0;
460
 	}
443
 	}
461
 
444
 
465
 
448
 
466
 	if ( ! retrieve ) return 1;
449
 	if ( ! retrieve ) return 1;
467
 
450
 
468
-#ifdef EDEBUG
469
-	printf("[l=%d", rx_fifo);
470
-#endif
471
-	insw(BASE + RX_FIFO, nic->packet, rx_fifo / 2);
451
+	DBG ( "[l=%d", rx_fifo );
452
+	insw(nic->ioaddr + RX_FIFO, nic->packet, rx_fifo / 2);
472
 	if (rx_fifo & 1)
453
 	if (rx_fifo & 1)
473
-		nic->packet[rx_fifo - 1] = inb(BASE + RX_FIFO);
454
+		nic->packet[rx_fifo - 1] = inb(nic->ioaddr + RX_FIFO);
474
 	nic->packetlen = rx_fifo;
455
 	nic->packetlen = rx_fifo;
475
 
456
 
476
 	while (1) {
457
 	while (1) {
477
-		status = inw(BASE + RxStatus);
478
-#ifdef EDEBUG
479
-		printf("0x%hX*", status);
480
-#endif
458
+		status = inw(nic->ioaddr + RxStatus);
459
+		DBG ( "0x%hX*", status );
481
 		rx_fifo = status & RX_BYTES_MASK;
460
 		rx_fifo = status & RX_BYTES_MASK;
482
 
461
 
483
 		if (rx_fifo > 0) {
462
 		if (rx_fifo > 0) {
484
-			insw(BASE + RX_FIFO, nic->packet + nic->packetlen,
463
+			insw(nic->ioaddr + RX_FIFO, nic->packet + nic->packetlen,
485
 			     rx_fifo / 2);
464
 			     rx_fifo / 2);
486
 			if (rx_fifo & 1)
465
 			if (rx_fifo & 1)
487
 				nic->packet[nic->packetlen + rx_fifo - 1] =
466
 				nic->packet[nic->packetlen + rx_fifo - 1] =
488
-				    inb(BASE + RX_FIFO);
467
+				    inb(nic->ioaddr + RX_FIFO);
489
 			nic->packetlen += rx_fifo;
468
 			nic->packetlen += rx_fifo;
490
-#ifdef EDEBUG
491
-			printf("+%d", rx_fifo);
492
-#endif
469
+			DBG ( "+%d", rx_fifo );
493
 		}
470
 		}
494
 		if ((status & RxComplete) == 0) {
471
 		if ((status & RxComplete) == 0) {
495
-#ifdef EDEBUG
496
-			printf("=%d", nic->packetlen);
497
-#endif
472
+			DBG ( "=%d", nic->packetlen );
498
 			break;
473
 			break;
499
 		}
474
 		}
500
 		udelay(1000);
475
 		udelay(1000);
501
 	}
476
 	}
502
 
477
 
503
 	/* acknowledge reception of packet */
478
 	/* acknowledge reception of packet */
504
-	outw(RxDiscard, BASE + EL3_CMD);
505
-	while (inw(BASE + EL3_STATUS) & CmdInProgress);
506
-#ifdef EDEBUG
479
+	outw(RxDiscard, nic->ioaddr + EL3_CMD);
480
+	while (inw(nic->ioaddr + EL3_STATUS) & CmdInProgress);
481
+#ifdef debug_3c515
507
 	{
482
 	{
508
 		unsigned short type = 0;
483
 		unsigned short type = 0;
509
 		type = (nic->packet[12] << 8) | nic->packet[13];
484
 		type = (nic->packet[12] << 8) | nic->packet[13];
510
 		if (nic->packet[0] + nic->packet[1] + nic->packet[2] +
485
 		if (nic->packet[0] + nic->packet[1] + nic->packet[2] +
511
 		    nic->packet[3] + nic->packet[4] + nic->packet[5] ==
486
 		    nic->packet[3] + nic->packet[4] + nic->packet[5] ==
512
 		    0xFF * ETH_ALEN)
487
 		    0xFF * ETH_ALEN)
513
-			printf(",t=0x%hX,b]", type);
488
+			DBG ( ",t=0x%hX,b]", type );
514
 		else
489
 		else
515
-			printf(",t=0x%hX]", type);
490
+			DBG ( ",t=0x%hX]", type );
516
 	}
491
 	}
517
 #endif
492
 #endif
518
 
493
 
537
 	int pad;
512
 	int pad;
538
 	int status;
513
 	int status;
539
 
514
 
540
-#ifdef EDEBUG
541
-	printf("{l=%d,t=0x%hX}", s + ETH_HLEN, t);
542
-#endif
515
+	DBG ( "{l=%d,t=0x%hX}", s + ETH_HLEN, t );
543
 
516
 
544
 	/* swap bytes of type */
517
 	/* swap bytes of type */
545
 	t = htons(t);
518
 	t = htons(t);
557
 		return;
530
 		return;
558
 	}
531
 	}
559
 	/* drop acknowledgements */
532
 	/* drop acknowledgements */
560
-	while ((status = inb(BASE + TxStatus)) & TxComplete) {
533
+	while ((status = inb(nic->ioaddr + TxStatus)) & TxComplete) {
561
 		/*if(status & (TXS_UNDERRUN|0x88|TXS_STATUS_OVERFLOW)) { */
534
 		/*if(status & (TXS_UNDERRUN|0x88|TXS_STATUS_OVERFLOW)) { */
562
-		outw(TxReset, BASE + EL3_CMD);
563
-		outw(TxEnable, BASE + EL3_CMD);
535
+		outw(TxReset, nic->ioaddr + EL3_CMD);
536
+		outw(TxEnable, nic->ioaddr + EL3_CMD);
564
 /*		}                                                          */
537
 /*		}                                                          */
565
 
538
 
566
-		outb(0x0, BASE + TxStatus);
539
+		outb(0x0, nic->ioaddr + TxStatus);
567
 	}
540
 	}
568
 
541
 
569
-	while (inw(BASE + TxFree) < len + pad + 4) {
542
+	while (inw(nic->ioaddr + TxFree) < len + pad + 4) {
570
 		/* no room in FIFO */
543
 		/* no room in FIFO */
571
 	}
544
 	}
572
 
545
 
573
-	outw(len, BASE + TX_FIFO);
574
-	outw(0x0, BASE + TX_FIFO);	/* Second dword meaningless */
546
+	outw(len, nic->ioaddr + TX_FIFO);
547
+	outw(0x0, nic->ioaddr + TX_FIFO);	/* Second dword meaningless */
575
 
548
 
576
 	/* write packet */
549
 	/* write packet */
577
-	outsw(BASE + TX_FIFO, d, ETH_ALEN / 2);
578
-	outsw(BASE + TX_FIFO, nic->node_addr, ETH_ALEN / 2);
579
-	outw(t, BASE + TX_FIFO);
580
-	outsw(BASE + TX_FIFO, p, s / 2);
550
+	outsw(nic->ioaddr + TX_FIFO, d, ETH_ALEN / 2);
551
+	outsw(nic->ioaddr + TX_FIFO, nic->node_addr, ETH_ALEN / 2);
552
+	outw(t, nic->ioaddr + TX_FIFO);
553
+	outsw(nic->ioaddr + TX_FIFO, p, s / 2);
581
 
554
 
582
 	if (s & 1)
555
 	if (s & 1)
583
-		outb(*(p + s - 1), BASE + TX_FIFO);
556
+		outb(*(p + s - 1), nic->ioaddr + TX_FIFO);
584
 
557
 
585
 	while (pad--)
558
 	while (pad--)
586
-		outb(0, BASE + TX_FIFO);	/* Padding */
559
+		outb(0, nic->ioaddr + TX_FIFO);	/* Padding */
587
 
560
 
588
 	/* wait for Tx complete */
561
 	/* wait for Tx complete */
589
-	while ((inw(BASE + EL3_STATUS) & CmdInProgress) != 0);
562
+	while ((inw(nic->ioaddr + EL3_STATUS) & CmdInProgress) != 0);
590
 }
563
 }
591
 
564
 
592
 /**************************************************************************
565
 /**************************************************************************
602
 	   have no way to determine if this works */
575
 	   have no way to determine if this works */
603
 
576
 
604
 	/* Disable the receiver and transmitter. */
577
 	/* Disable the receiver and transmitter. */
605
-	outw(RxDisable, BASE + EL3_CMD);
606
-	outw(TxDisable, BASE + EL3_CMD);
578
+	outw(RxDisable, nic->ioaddr + EL3_CMD);
579
+	outw(TxDisable, nic->ioaddr + EL3_CMD);
607
 
580
 
608
 	if (if_port == XCVR_10base2)
581
 	if (if_port == XCVR_10base2)
609
 		/* Turn off thinnet power.  Green! */
582
 		/* Turn off thinnet power.  Green! */
610
-		outw(StopCoax, BASE + EL3_CMD);
583
+		outw(StopCoax, nic->ioaddr + EL3_CMD);
611
 
584
 
612
 
585
 
613
-	outw(SetIntrEnb | 0x0000, BASE + EL3_CMD);
586
+	outw(SetIntrEnb | 0x0000, nic->ioaddr + EL3_CMD);
614
 #ifdef ISA_PNP
587
 #ifdef ISA_PNP
615
 	/*Deactivate */
588
 	/*Deactivate */
616
 /*    ACTIVATE;
589
 /*    ACTIVATE;
632
   }
605
   }
633
 }
606
 }
634
 
607
 
635
-/**************************************************************************
636
-PROBE - Look for an adapter, this routine's visible to the outside
637
-You should omit the last argument struct pci_device * for a non-PCI NIC
638
-***************************************************************************/
639
-void config_pnp_device(void);
640
-
641
-static int t515_probe(struct dev *dev,
642
-		      unsigned short *probe_addrs __unused)
643
-{
644
-	struct nic *nic = (struct nic *) dev;
645
-	/* Direct copy from Beckers 3c515.c removing any ISAPNP sections */
646
-	int cards_found = 0;
647
-	static int ioaddr;
648
-#ifdef ISA_PNP
649
-	config_pnp_device();
650
-#endif
651
-	/* Check all locations on the ISA bus -- evil! */
652
-	for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x20) {
653
-		int irq;
654
-
655
-		/* Check the resource configuration for a matching ioaddr. */
656
-		if ((inw(ioaddr + 0x2002) & 0x1f0) != (ioaddr & 0x1f0))
657
-			continue;
658
-		/* Verify by reading the device ID from the EEPROM. */
659
-		{
660
-			int timer;
661
-			outw(EEPROM_Read + 7, ioaddr + Wn0EepromCmd);
662
-			/* Pause for at least 162 us. for the read to take place. */
663
-			for (timer = 4; timer >= 0; timer--) {
664
-				t3c515_wait(1);
665
-				if ((inw(ioaddr + Wn0EepromCmd) & 0x0200)
666
-				    == 0)
667
-					break;
668
-			}
669
-			if (inw(ioaddr + Wn0EepromData) != 0x6d50)
670
-				continue;
671
-		}
672
-		printf
673
-		    ("3c515 Resource configuration register 0x%hX, DCR 0x%hX.\n",
674
-		     inl(ioaddr + 0x2002), inw(ioaddr + 0x2000));
675
-		irq = inw(ioaddr + 0x2002) & 15;
676
-		BASE = ioaddr;
677
-		corkscrew_found_device(BASE, irq, CORKSCREW_ID,
678
-				       options[cards_found], nic);
679
-		cards_found++;
680
-	}
681
-	if (corkscrew_debug)
682
-		printf("%d 3c515 cards found.\n", cards_found);
683
-
684
-	if (cards_found > 0) {
685
-		t515_reset(nic);
686
-
687
-		nic->irqno    = 0;
688
-		nic->ioaddr   = BASE;
689
-static struct nic_operations t515_operations;
690
 static struct nic_operations t515_operations = {
608
 static struct nic_operations t515_operations = {
691
 	.connect	= dummy_connect,
609
 	.connect	= dummy_connect,
692
 	.poll		= t515_poll,
610
 	.poll		= t515_poll,
694
 	.irq		= t515_irq,
612
 	.irq		= t515_irq,
695
 	.disable	= t515_disable,
613
 	.disable	= t515_disable,
696
 };
614
 };
697
-		nic->nic_op	= &t515_operations;
698
 
615
 
699
-		/* Based on PnP ISA map */
700
-		dev->devid.vendor_id = htons(ISAPNP_VENDOR('T', 'C', 'M'));
701
-		dev->devid.device_id = htons(0x5051);
702
-		return 1;
703
-	} else
616
+/**************************************************************************
617
+PROBE - Look for an adapter, this routine's visible to the outside
618
+You should omit the last argument struct pci_device * for a non-PCI NIC
619
+***************************************************************************/
620
+static int t515_probe ( struct dev *dev, struct isapnp_device *isapnp ) {
621
+	struct nic *nic = nic_device ( dev );
622
+	/* Direct copy from Beckers 3c515.c removing any ISAPNP sections */
623
+
624
+	nic->ioaddr = isapnp->ioaddr;
625
+	nic->irqno = isapnp->irqno;
626
+	activate_isapnp_device ( isapnp, 1 );
627
+
628
+	/* Check the resource configuration for a matching ioaddr. */
629
+	if ((unsigned)(inw(nic->ioaddr + 0x2002) & 0x1f0)
630
+	    != (nic->ioaddr & 0x1f0)) {
631
+		DBG ( "3c515 ioaddr mismatch\n" );
704
 		return 0;
632
 		return 0;
633
+	}
634
+
635
+	/* Verify by reading the device ID from the EEPROM. */
636
+	{
637
+		int timer;
638
+		outw(EEPROM_Read + 7, nic->ioaddr + Wn0EepromCmd);
639
+		/* Pause for at least 162 us. for the read to take place. */
640
+		for (timer = 4; timer >= 0; timer--) {
641
+			t3c515_wait(1);
642
+			if ((inw(nic->ioaddr + Wn0EepromCmd) & 0x0200) == 0)
643
+				break;
644
+		}
645
+		if (inw(nic->ioaddr + Wn0EepromData) != 0x6d50) {
646
+			DBG ( "3c515 read incorrect vendor ID from EEPROM" );
647
+			return 0;
648
+		}
705
 
649
 
650
+	}
651
+	DBG ( "3c515 Resource configuration register 0x%hX, DCR 0x%hX.\n",
652
+	      inl(nic->ioaddr + 0x2002), inw(nic->ioaddr + 0x2000) );
653
+	corkscrew_found_device(nic->ioaddr, nic->irqno, CORKSCREW_ID,
654
+			       options, nic);
655
+	
656
+	t515_reset(nic);	
657
+	nic->nic_op	= &t515_operations;
658
+	return 1;
706
 }
659
 }
707
 
660
 
708
 static int
661
 static int
733
 {
686
 {
734
 	unsigned int eeprom[0x40], checksum = 0;	/* EEPROM contents */
687
 	unsigned int eeprom[0x40], checksum = 0;	/* EEPROM contents */
735
 	int i;
688
 	int i;
736
-	ioaddr = BASE;
737
 
689
 
738
 	printf("3Com %s at 0x%hX, ", vp->product_name, ioaddr);
690
 	printf("3Com %s at 0x%hX, ", vp->product_name, ioaddr);
739
 
691
 
750
 				break;
702
 				break;
751
 		}
703
 		}
752
 		eeprom[i] = inw(ioaddr + Wn0EepromData);
704
 		eeprom[i] = inw(ioaddr + Wn0EepromData);
753
-#ifdef EDEBUG1
754
-		printf("Value %d: %hX        ", i, eeprom[i]);
755
-#endif
705
+		DBG ( "Value %d: %hX        ", i, eeprom[i] );
756
 		checksum ^= eeprom[i];
706
 		checksum ^= eeprom[i];
757
 		if (i < 3)
707
 		if (i < 3)
758
 			phys_addr[i] = htons(eeprom[i]);
708
 			phys_addr[i] = htons(eeprom[i]);
767
 	}
717
 	}
768
 	printf(", IRQ %d\n", irq);
718
 	printf(", IRQ %d\n", irq);
769
 	/* Tell them about an invalid IRQ. */
719
 	/* Tell them about an invalid IRQ. */
770
-	if (corkscrew_debug && (irq <= 0 || irq > 15))
771
-		printf
772
-		    (" *** Warning: this IRQ is unlikely to work! ***\n");
720
+	if ( (irq <= 0 || irq > 15) ) {
721
+		DBG (" *** Warning: this IRQ is unlikely to work! ***\n" );
722
+	}
773
 
723
 
774
 	{
724
 	{
775
 		char *ram_split[] = { "5:3", "3:1", "1:1", "3:5" };
725
 		char *ram_split[] = { "5:3", "3:1", "1:1", "3:5" };
777
 		EL3WINDOW(3);
727
 		EL3WINDOW(3);
778
 		vp->available_media = inw(ioaddr + Wn3_Options);
728
 		vp->available_media = inw(ioaddr + Wn3_Options);
779
 		config.i = inl(ioaddr + Wn3_Config);
729
 		config.i = inl(ioaddr + Wn3_Config);
780
-		if (corkscrew_debug > 1)
781
-			printf
782
-			    ("  Internal config register is %4.4x, transceivers 0x%hX.\n",
783
-			     config.i, inw(ioaddr + Wn3_Options));
730
+		DBG ( "  Internal config register is %4.4x, "
731
+		      "transceivers 0x%hX.\n",
732
+		      config.i, inw(ioaddr + Wn3_Options) );
784
 		printf
733
 		printf
785
 		    ("  %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n",
734
 		    ("  %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n",
786
 		     8 << config.u.ram_size,
735
 		     8 << config.u.ram_size,
808
 	return 0;
757
 	return 0;
809
 }
758
 }
810
 
759
 
811
-static struct isa_driver t515_driver __isa_driver = {
812
-	.type = NIC_DRIVER,
813
-	.name = "3C515",
814
-	.probe = t515_probe,
815
-	.ioaddrs = 0,
760
+static struct isapnp_id t515_adapters[] = {
761
+	{ "3c515 (ISAPnP)", ISAPNP_VENDOR('T','C','M'), 0x5051 },
816
 };
762
 };
817
-ISA_ROM("3c515","3c515, Fast EtherLink ISA");
763
+
764
+static struct isapnp_driver t515_driver =
765
+	ISAPNP_DRIVER ( "3c515", t515_adapters );
766
+
767
+BOOT_DRIVER ( "3c515", find_isapnp_boot_device, t515_driver,
768
+	      t515_probe );
769
+
770
+ISA_ROM ( "3c515", "3c515 Fast EtherLink ISAPnP" );

読み込み中…
キャンセル
保存