aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sb1000.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sb1000.c')
-rw-r--r--drivers/net/sb1000.c101
1 files changed, 56 insertions, 45 deletions
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index 487f9d2ac5b4..5986cec17f19 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -88,31 +88,31 @@ static int sb1000_close(struct net_device *dev);
88 88
89 89
90/* SB1000 hardware routines to be used during open/configuration phases */ 90/* SB1000 hardware routines to be used during open/configuration phases */
91static inline int card_wait_for_busy_clear(const int ioaddr[], 91static int card_wait_for_busy_clear(const int ioaddr[],
92 const char* name); 92 const char* name);
93static inline int card_wait_for_ready(const int ioaddr[], const char* name, 93static int card_wait_for_ready(const int ioaddr[], const char* name,
94 unsigned char in[]); 94 unsigned char in[]);
95static int card_send_command(const int ioaddr[], const char* name, 95static int card_send_command(const int ioaddr[], const char* name,
96 const unsigned char out[], unsigned char in[]); 96 const unsigned char out[], unsigned char in[]);
97 97
98/* SB1000 hardware routines to be used during frame rx interrupt */ 98/* SB1000 hardware routines to be used during frame rx interrupt */
99static inline int sb1000_wait_for_ready(const int ioaddr[], const char* name); 99static int sb1000_wait_for_ready(const int ioaddr[], const char* name);
100static inline int sb1000_wait_for_ready_clear(const int ioaddr[], 100static int sb1000_wait_for_ready_clear(const int ioaddr[],
101 const char* name); 101 const char* name);
102static inline void sb1000_send_command(const int ioaddr[], const char* name, 102static void sb1000_send_command(const int ioaddr[], const char* name,
103 const unsigned char out[]); 103 const unsigned char out[]);
104static inline void sb1000_read_status(const int ioaddr[], unsigned char in[]); 104static void sb1000_read_status(const int ioaddr[], unsigned char in[]);
105static inline void sb1000_issue_read_command(const int ioaddr[], 105static void sb1000_issue_read_command(const int ioaddr[],
106 const char* name); 106 const char* name);
107 107
108/* SB1000 commands for open/configuration */ 108/* SB1000 commands for open/configuration */
109static inline int sb1000_reset(const int ioaddr[], const char* name); 109static int sb1000_reset(const int ioaddr[], const char* name);
110static inline int sb1000_check_CRC(const int ioaddr[], const char* name); 110static int sb1000_check_CRC(const int ioaddr[], const char* name);
111static inline int sb1000_start_get_set_command(const int ioaddr[], 111static inline int sb1000_start_get_set_command(const int ioaddr[],
112 const char* name); 112 const char* name);
113static inline int sb1000_end_get_set_command(const int ioaddr[], 113static int sb1000_end_get_set_command(const int ioaddr[],
114 const char* name); 114 const char* name);
115static inline int sb1000_activate(const int ioaddr[], const char* name); 115static int sb1000_activate(const int ioaddr[], const char* name);
116static int sb1000_get_firmware_version(const int ioaddr[], 116static int sb1000_get_firmware_version(const int ioaddr[],
117 const char* name, unsigned char version[], int do_end); 117 const char* name, unsigned char version[], int do_end);
118static int sb1000_get_frequency(const int ioaddr[], const char* name, 118static int sb1000_get_frequency(const int ioaddr[], const char* name,
@@ -125,8 +125,8 @@ static int sb1000_set_PIDs(const int ioaddr[], const char* name,
125 const short PID[]); 125 const short PID[]);
126 126
127/* SB1000 commands for frame rx interrupt */ 127/* SB1000 commands for frame rx interrupt */
128static inline int sb1000_rx(struct net_device *dev); 128static int sb1000_rx(struct net_device *dev);
129static inline void sb1000_error_dpc(struct net_device *dev); 129static void sb1000_error_dpc(struct net_device *dev);
130 130
131static const struct pnp_device_id sb1000_pnp_ids[] = { 131static const struct pnp_device_id sb1000_pnp_ids[] = {
132 { "GIC1000", 0 }, 132 { "GIC1000", 0 },
@@ -250,7 +250,7 @@ static struct pnp_driver sb1000_driver = {
250static const int TimeOutJiffies = (875 * HZ) / 100; 250static const int TimeOutJiffies = (875 * HZ) / 100;
251 251
252/* Card Wait For Busy Clear (cannot be used during an interrupt) */ 252/* Card Wait For Busy Clear (cannot be used during an interrupt) */
253static inline int 253static int
254card_wait_for_busy_clear(const int ioaddr[], const char* name) 254card_wait_for_busy_clear(const int ioaddr[], const char* name)
255{ 255{
256 unsigned char a; 256 unsigned char a;
@@ -274,7 +274,7 @@ card_wait_for_busy_clear(const int ioaddr[], const char* name)
274} 274}
275 275
276/* Card Wait For Ready (cannot be used during an interrupt) */ 276/* Card Wait For Ready (cannot be used during an interrupt) */
277static inline int 277static int
278card_wait_for_ready(const int ioaddr[], const char* name, unsigned char in[]) 278card_wait_for_ready(const int ioaddr[], const char* name, unsigned char in[])
279{ 279{
280 unsigned char a; 280 unsigned char a;
@@ -354,7 +354,7 @@ card_send_command(const int ioaddr[], const char* name,
354static const int Sb1000TimeOutJiffies = 7 * HZ; 354static const int Sb1000TimeOutJiffies = 7 * HZ;
355 355
356/* Card Wait For Ready (to be used during frame rx) */ 356/* Card Wait For Ready (to be used during frame rx) */
357static inline int 357static int
358sb1000_wait_for_ready(const int ioaddr[], const char* name) 358sb1000_wait_for_ready(const int ioaddr[], const char* name)
359{ 359{
360 unsigned long timeout; 360 unsigned long timeout;
@@ -380,7 +380,7 @@ sb1000_wait_for_ready(const int ioaddr[], const char* name)
380} 380}
381 381
382/* Card Wait For Ready Clear (to be used during frame rx) */ 382/* Card Wait For Ready Clear (to be used during frame rx) */
383static inline int 383static int
384sb1000_wait_for_ready_clear(const int ioaddr[], const char* name) 384sb1000_wait_for_ready_clear(const int ioaddr[], const char* name)
385{ 385{
386 unsigned long timeout; 386 unsigned long timeout;
@@ -405,7 +405,7 @@ sb1000_wait_for_ready_clear(const int ioaddr[], const char* name)
405} 405}
406 406
407/* Card Send Command (to be used during frame rx) */ 407/* Card Send Command (to be used during frame rx) */
408static inline void 408static void
409sb1000_send_command(const int ioaddr[], const char* name, 409sb1000_send_command(const int ioaddr[], const char* name,
410 const unsigned char out[]) 410 const unsigned char out[])
411{ 411{
@@ -422,7 +422,7 @@ sb1000_send_command(const int ioaddr[], const char* name,
422} 422}
423 423
424/* Card Read Status (to be used during frame rx) */ 424/* Card Read Status (to be used during frame rx) */
425static inline void 425static void
426sb1000_read_status(const int ioaddr[], unsigned char in[]) 426sb1000_read_status(const int ioaddr[], unsigned char in[])
427{ 427{
428 in[1] = inb(ioaddr[0] + 1); 428 in[1] = inb(ioaddr[0] + 1);
@@ -434,10 +434,10 @@ sb1000_read_status(const int ioaddr[], unsigned char in[])
434} 434}
435 435
436/* Issue Read Command (to be used during frame rx) */ 436/* Issue Read Command (to be used during frame rx) */
437static inline void 437static void
438sb1000_issue_read_command(const int ioaddr[], const char* name) 438sb1000_issue_read_command(const int ioaddr[], const char* name)
439{ 439{
440 const unsigned char Command0[6] = {0x20, 0x00, 0x00, 0x01, 0x00, 0x00}; 440 static const unsigned char Command0[6] = {0x20, 0x00, 0x00, 0x01, 0x00, 0x00};
441 441
442 sb1000_wait_for_ready_clear(ioaddr, name); 442 sb1000_wait_for_ready_clear(ioaddr, name);
443 outb(0xa0, ioaddr[0] + 6); 443 outb(0xa0, ioaddr[0] + 6);
@@ -450,12 +450,13 @@ sb1000_issue_read_command(const int ioaddr[], const char* name)
450 * SB1000 commands for open/configuration 450 * SB1000 commands for open/configuration
451 */ 451 */
452/* reset SB1000 card */ 452/* reset SB1000 card */
453static inline int 453static int
454sb1000_reset(const int ioaddr[], const char* name) 454sb1000_reset(const int ioaddr[], const char* name)
455{ 455{
456 static const unsigned char Command0[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00};
457
456 unsigned char st[7]; 458 unsigned char st[7];
457 int port, status; 459 int port, status;
458 const unsigned char Command0[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00};
459 460
460 port = ioaddr[1] + 6; 461 port = ioaddr[1] + 6;
461 outb(0x4, port); 462 outb(0x4, port);
@@ -479,12 +480,13 @@ sb1000_reset(const int ioaddr[], const char* name)
479} 480}
480 481
481/* check SB1000 firmware CRC */ 482/* check SB1000 firmware CRC */
482static inline int 483static int
483sb1000_check_CRC(const int ioaddr[], const char* name) 484sb1000_check_CRC(const int ioaddr[], const char* name)
484{ 485{
486 static const unsigned char Command0[6] = {0x80, 0x1f, 0x00, 0x00, 0x00, 0x00};
487
485 unsigned char st[7]; 488 unsigned char st[7];
486 int crc, status; 489 int crc, status;
487 const unsigned char Command0[6] = {0x80, 0x1f, 0x00, 0x00, 0x00, 0x00};
488 490
489 /* check CRC */ 491 /* check CRC */
490 if ((status = card_send_command(ioaddr, name, Command0, st))) 492 if ((status = card_send_command(ioaddr, name, Command0, st)))
@@ -498,32 +500,35 @@ sb1000_check_CRC(const int ioaddr[], const char* name)
498static inline int 500static inline int
499sb1000_start_get_set_command(const int ioaddr[], const char* name) 501sb1000_start_get_set_command(const int ioaddr[], const char* name)
500{ 502{
503 static const unsigned char Command0[6] = {0x80, 0x1b, 0x00, 0x00, 0x00, 0x00};
504
501 unsigned char st[7]; 505 unsigned char st[7];
502 const unsigned char Command0[6] = {0x80, 0x1b, 0x00, 0x00, 0x00, 0x00};
503 506
504 return card_send_command(ioaddr, name, Command0, st); 507 return card_send_command(ioaddr, name, Command0, st);
505} 508}
506 509
507static inline int 510static int
508sb1000_end_get_set_command(const int ioaddr[], const char* name) 511sb1000_end_get_set_command(const int ioaddr[], const char* name)
509{ 512{
513 static const unsigned char Command0[6] = {0x80, 0x1b, 0x02, 0x00, 0x00, 0x00};
514 static const unsigned char Command1[6] = {0x20, 0x00, 0x00, 0x00, 0x00, 0x00};
515
510 unsigned char st[7]; 516 unsigned char st[7];
511 int status; 517 int status;
512 const unsigned char Command0[6] = {0x80, 0x1b, 0x02, 0x00, 0x00, 0x00};
513 const unsigned char Command1[6] = {0x20, 0x00, 0x00, 0x00, 0x00, 0x00};
514 518
515 if ((status = card_send_command(ioaddr, name, Command0, st))) 519 if ((status = card_send_command(ioaddr, name, Command0, st)))
516 return status; 520 return status;
517 return card_send_command(ioaddr, name, Command1, st); 521 return card_send_command(ioaddr, name, Command1, st);
518} 522}
519 523
520static inline int 524static int
521sb1000_activate(const int ioaddr[], const char* name) 525sb1000_activate(const int ioaddr[], const char* name)
522{ 526{
527 static const unsigned char Command0[6] = {0x80, 0x11, 0x00, 0x00, 0x00, 0x00};
528 static const unsigned char Command1[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00};
529
523 unsigned char st[7]; 530 unsigned char st[7];
524 int status; 531 int status;
525 const unsigned char Command0[6] = {0x80, 0x11, 0x00, 0x00, 0x00, 0x00};
526 const unsigned char Command1[6] = {0x80, 0x16, 0x00, 0x00, 0x00, 0x00};
527 532
528 ssleep(1); 533 ssleep(1);
529 if ((status = card_send_command(ioaddr, name, Command0, st))) 534 if ((status = card_send_command(ioaddr, name, Command0, st)))
@@ -544,9 +549,10 @@ static int
544sb1000_get_firmware_version(const int ioaddr[], const char* name, 549sb1000_get_firmware_version(const int ioaddr[], const char* name,
545 unsigned char version[], int do_end) 550 unsigned char version[], int do_end)
546{ 551{
552 static const unsigned char Command0[6] = {0x80, 0x23, 0x00, 0x00, 0x00, 0x00};
553
547 unsigned char st[7]; 554 unsigned char st[7];
548 int status; 555 int status;
549 const unsigned char Command0[6] = {0x80, 0x23, 0x00, 0x00, 0x00, 0x00};
550 556
551 if ((status = sb1000_start_get_set_command(ioaddr, name))) 557 if ((status = sb1000_start_get_set_command(ioaddr, name)))
552 return status; 558 return status;
@@ -566,9 +572,10 @@ sb1000_get_firmware_version(const int ioaddr[], const char* name,
566static int 572static int
567sb1000_get_frequency(const int ioaddr[], const char* name, int* frequency) 573sb1000_get_frequency(const int ioaddr[], const char* name, int* frequency)
568{ 574{
575 static const unsigned char Command0[6] = {0x80, 0x44, 0x00, 0x00, 0x00, 0x00};
576
569 unsigned char st[7]; 577 unsigned char st[7];
570 int status; 578 int status;
571 const unsigned char Command0[6] = {0x80, 0x44, 0x00, 0x00, 0x00, 0x00};
572 579
573 udelay(1000); 580 udelay(1000);
574 if ((status = sb1000_start_get_set_command(ioaddr, name))) 581 if ((status = sb1000_start_get_set_command(ioaddr, name)))
@@ -613,12 +620,13 @@ sb1000_set_frequency(const int ioaddr[], const char* name, int frequency)
613static int 620static int
614sb1000_get_PIDs(const int ioaddr[], const char* name, short PID[]) 621sb1000_get_PIDs(const int ioaddr[], const char* name, short PID[])
615{ 622{
623 static const unsigned char Command0[6] = {0x80, 0x40, 0x00, 0x00, 0x00, 0x00};
624 static const unsigned char Command1[6] = {0x80, 0x41, 0x00, 0x00, 0x00, 0x00};
625 static const unsigned char Command2[6] = {0x80, 0x42, 0x00, 0x00, 0x00, 0x00};
626 static const unsigned char Command3[6] = {0x80, 0x43, 0x00, 0x00, 0x00, 0x00};
627
616 unsigned char st[7]; 628 unsigned char st[7];
617 int status; 629 int status;
618 const unsigned char Command0[6] = {0x80, 0x40, 0x00, 0x00, 0x00, 0x00};
619 const unsigned char Command1[6] = {0x80, 0x41, 0x00, 0x00, 0x00, 0x00};
620 const unsigned char Command2[6] = {0x80, 0x42, 0x00, 0x00, 0x00, 0x00};
621 const unsigned char Command3[6] = {0x80, 0x43, 0x00, 0x00, 0x00, 0x00};
622 630
623 udelay(1000); 631 udelay(1000);
624 if ((status = sb1000_start_get_set_command(ioaddr, name))) 632 if ((status = sb1000_start_get_set_command(ioaddr, name)))
@@ -647,6 +655,8 @@ sb1000_get_PIDs(const int ioaddr[], const char* name, short PID[])
647static int 655static int
648sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[]) 656sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[])
649{ 657{
658 static const unsigned char Command4[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00};
659
650 unsigned char st[7]; 660 unsigned char st[7];
651 short p; 661 short p;
652 int status; 662 int status;
@@ -654,7 +664,6 @@ sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[])
654 unsigned char Command1[6] = {0x80, 0x32, 0x00, 0x00, 0x00, 0x00}; 664 unsigned char Command1[6] = {0x80, 0x32, 0x00, 0x00, 0x00, 0x00};
655 unsigned char Command2[6] = {0x80, 0x33, 0x00, 0x00, 0x00, 0x00}; 665 unsigned char Command2[6] = {0x80, 0x33, 0x00, 0x00, 0x00, 0x00};
656 unsigned char Command3[6] = {0x80, 0x34, 0x00, 0x00, 0x00, 0x00}; 666 unsigned char Command3[6] = {0x80, 0x34, 0x00, 0x00, 0x00, 0x00};
657 const unsigned char Command4[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00};
658 667
659 udelay(1000); 668 udelay(1000);
660 if ((status = sb1000_start_get_set_command(ioaddr, name))) 669 if ((status = sb1000_start_get_set_command(ioaddr, name)))
@@ -694,7 +703,7 @@ sb1000_set_PIDs(const int ioaddr[], const char* name, const short PID[])
694} 703}
695 704
696 705
697static inline void 706static void
698sb1000_print_status_buffer(const char* name, unsigned char st[], 707sb1000_print_status_buffer(const char* name, unsigned char st[],
699 unsigned char buffer[], int size) 708 unsigned char buffer[], int size)
700{ 709{
@@ -725,7 +734,7 @@ sb1000_print_status_buffer(const char* name, unsigned char st[],
725/* receive a single frame and assemble datagram 734/* receive a single frame and assemble datagram
726 * (this is the heart of the interrupt routine) 735 * (this is the heart of the interrupt routine)
727 */ 736 */
728static inline int 737static int
729sb1000_rx(struct net_device *dev) 738sb1000_rx(struct net_device *dev)
730{ 739{
731 740
@@ -888,14 +897,15 @@ dropped_frame:
888 return -1; 897 return -1;
889} 898}
890 899
891static inline void 900static void
892sb1000_error_dpc(struct net_device *dev) 901sb1000_error_dpc(struct net_device *dev)
893{ 902{
903 static const unsigned char Command0[6] = {0x80, 0x26, 0x00, 0x00, 0x00, 0x00};
904
894 char *name; 905 char *name;
895 unsigned char st[5]; 906 unsigned char st[5];
896 int ioaddr[2]; 907 int ioaddr[2];
897 struct sb1000_private *lp = netdev_priv(dev); 908 struct sb1000_private *lp = netdev_priv(dev);
898 const unsigned char Command0[6] = {0x80, 0x26, 0x00, 0x00, 0x00, 0x00};
899 const int ErrorDpcCounterInitialize = 200; 909 const int ErrorDpcCounterInitialize = 200;
900 910
901 ioaddr[0] = dev->base_addr; 911 ioaddr[0] = dev->base_addr;
@@ -1077,14 +1087,15 @@ sb1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
1077/* SB1000 interrupt handler. */ 1087/* SB1000 interrupt handler. */
1078static irqreturn_t sb1000_interrupt(int irq, void *dev_id) 1088static irqreturn_t sb1000_interrupt(int irq, void *dev_id)
1079{ 1089{
1090 static const unsigned char Command0[6] = {0x80, 0x2c, 0x00, 0x00, 0x00, 0x00};
1091 static const unsigned char Command1[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00};
1092
1080 char *name; 1093 char *name;
1081 unsigned char st; 1094 unsigned char st;
1082 int ioaddr[2]; 1095 int ioaddr[2];
1083 struct net_device *dev = dev_id; 1096 struct net_device *dev = dev_id;
1084 struct sb1000_private *lp = netdev_priv(dev); 1097 struct sb1000_private *lp = netdev_priv(dev);
1085 1098
1086 const unsigned char Command0[6] = {0x80, 0x2c, 0x00, 0x00, 0x00, 0x00};
1087 const unsigned char Command1[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00};
1088 const int MaxRxErrorCount = 6; 1099 const int MaxRxErrorCount = 6;
1089 1100
1090 ioaddr[0] = dev->base_addr; 1101 ioaddr[0] = dev->base_addr;