diff options
author | Joe Perches <joe@perches.com> | 2012-05-18 08:56:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-05-18 23:48:06 -0400 |
commit | 204a38ab2fd2fffaf003f6a5a021a1662caca37d (patch) | |
tree | b2315dcd5599c3e789bafde0485c8884d52c2a75 /drivers/net/ethernet/cirrus/cs89x0.c | |
parent | 941a77d582c84492e7433b8359c3bfcde90c9411 (diff) |
cirrus: cs89x0: Code style neatening
Neaten the comments and reflow the code without
changing anything other than whitespace.
git diff -w shows just comment neatening and a few
line removals.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/cirrus/cs89x0.c')
-rw-r--r-- | drivers/net/ethernet/cirrus/cs89x0.c | 734 |
1 files changed, 323 insertions, 411 deletions
diff --git a/drivers/net/ethernet/cirrus/cs89x0.c b/drivers/net/ethernet/cirrus/cs89x0.c index 1d59030e7d94..41c8ac92080b 100644 --- a/drivers/net/ethernet/cirrus/cs89x0.c +++ b/drivers/net/ethernet/cirrus/cs89x0.c | |||
@@ -1,105 +1,27 @@ | |||
1 | /* cs89x0.c: A Crystal Semiconductor (Now Cirrus Logic) CS89[02]0 | 1 | /* cs89x0.c: A Crystal Semiconductor (Now Cirrus Logic) CS89[02]0 |
2 | * driver for linux. | 2 | * driver for linux. |
3 | * Written 1996 by Russell Nelson, with reference to skeleton.c | ||
4 | * written 1993-1994 by Donald Becker. | ||
5 | * | ||
6 | * This software may be used and distributed according to the terms | ||
7 | * of the GNU General Public License, incorporated herein by reference. | ||
8 | * | ||
9 | * The author may be reached at nelson@crynwr.com, Crynwr | ||
10 | * Software, 521 Pleasant Valley Rd., Potsdam, NY 13676 | ||
11 | * | ||
12 | * Other contributors: | ||
13 | * Mike Cruse : mcruse@cti-ltd.com | ||
14 | * Russ Nelson | ||
15 | * Melody Lee : ethernet@crystal.cirrus.com | ||
16 | * Alan Cox | ||
17 | * Andrew Morton | ||
18 | * Oskar Schirmer : oskar@scara.com | ||
19 | * Deepak Saxena : dsaxena@plexity.net | ||
20 | * Dmitry Pervushin : dpervushin@ru.mvista.com | ||
21 | * Deepak Saxena : dsaxena@plexity.net | ||
22 | * Domenico Andreoli : cavokz@gmail.com | ||
3 | */ | 23 | */ |
4 | 24 | ||
5 | /* | ||
6 | Written 1996 by Russell Nelson, with reference to skeleton.c | ||
7 | written 1993-1994 by Donald Becker. | ||
8 | |||
9 | This software may be used and distributed according to the terms | ||
10 | of the GNU General Public License, incorporated herein by reference. | ||
11 | |||
12 | The author may be reached at nelson@crynwr.com, Crynwr | ||
13 | Software, 521 Pleasant Valley Rd., Potsdam, NY 13676 | ||
14 | |||
15 | Changelog: | ||
16 | |||
17 | Mike Cruse : mcruse@cti-ltd.com | ||
18 | : Changes for Linux 2.0 compatibility. | ||
19 | : Added dev_id parameter in net_interrupt(), | ||
20 | : request_irq() and free_irq(). Just NULL for now. | ||
21 | |||
22 | Mike Cruse : Added MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT macros | ||
23 | : in net_open() and net_close() so kerneld would know | ||
24 | : that the module is in use and wouldn't eject the | ||
25 | : driver prematurely. | ||
26 | |||
27 | Mike Cruse : Rewrote init_module() and cleanup_module using 8390.c | ||
28 | : as an example. Disabled autoprobing in init_module(), | ||
29 | : not a good thing to do to other devices while Linux | ||
30 | : is running from all accounts. | ||
31 | |||
32 | Russ Nelson : Jul 13 1998. Added RxOnly DMA support. | ||
33 | |||
34 | Melody Lee : Aug 10 1999. Changes for Linux 2.2.5 compatibility. | ||
35 | : email: ethernet@crystal.cirrus.com | ||
36 | |||
37 | Alan Cox : Removed 1.2 support, added 2.1 extra counters. | ||
38 | |||
39 | Andrew Morton : Kernel 2.3.48 | ||
40 | : Handle kmalloc() failures | ||
41 | : Other resource allocation fixes | ||
42 | : Add SMP locks | ||
43 | : Integrate Russ Nelson's ALLOW_DMA functionality back in. | ||
44 | : If ALLOW_DMA is true, make DMA runtime selectable | ||
45 | : Folded in changes from Cirrus (Melody Lee | ||
46 | : <klee@crystal.cirrus.com>) | ||
47 | : Don't call netif_wake_queue() in net_send_packet() | ||
48 | : Fixed an out-of-mem bug in dma_rx() | ||
49 | : Updated Documentation/networking/cs89x0.txt | ||
50 | |||
51 | Andrew Morton : Kernel 2.3.99-pre1 | ||
52 | : Use skb_reserve to longword align IP header (two places) | ||
53 | : Remove a delay loop from dma_rx() | ||
54 | : Replace '100' with HZ | ||
55 | : Clean up a couple of skb API abuses | ||
56 | : Added 'cs89x0_dma=N' kernel boot option | ||
57 | : Correctly initialise lp->lock in non-module compile | ||
58 | |||
59 | Andrew Morton : Kernel 2.3.99-pre4-1 | ||
60 | : MOD_INC/DEC race fix (see | ||
61 | : http://www.uwsg.indiana.edu/hypermail/linux/kernel/0003.3/1532.html) | ||
62 | |||
63 | Andrew Morton : Kernel 2.4.0-test7-pre2 | ||
64 | : Enhanced EEPROM support to cover more devices, | ||
65 | : abstracted IRQ mapping to support CONFIG_ARCH_CLPS7500 arch | ||
66 | : (Jason Gunthorpe <jgg@ualberta.ca>) | ||
67 | |||
68 | Andrew Morton : Kernel 2.4.0-test11-pre4 | ||
69 | : Use dev->name in request_*() (Andrey Panin) | ||
70 | : Fix an error-path memleak in init_module() | ||
71 | : Preserve return value from request_irq() | ||
72 | : Fix type of `media' module parm (Keith Owens) | ||
73 | : Use SET_MODULE_OWNER() | ||
74 | : Tidied up strange request_irq() abuse in net_open(). | ||
75 | |||
76 | Andrew Morton : Kernel 2.4.3-pre1 | ||
77 | : Request correct number of pages for DMA (Hugh Dickens) | ||
78 | : Select PP_ChipID _after_ unregister_netdev in cleanup_module() | ||
79 | : because unregister_netdev() calls get_stats. | ||
80 | : Make `version[]' __initdata | ||
81 | : Uninlined the read/write reg/word functions. | ||
82 | |||
83 | Oskar Schirmer : oskar@scara.com | ||
84 | : HiCO.SH4 (superh) support added (irq#1, cs89x0_media=) | ||
85 | |||
86 | Deepak Saxena : dsaxena@plexity.net | ||
87 | : Intel IXDP2x01 (XScale ixp2x00 NPU) platform support | ||
88 | |||
89 | Dmitry Pervushin : dpervushin@ru.mvista.com | ||
90 | : PNX010X platform support | ||
91 | |||
92 | Deepak Saxena : dsaxena@plexity.net | ||
93 | : Intel IXDP2351 platform support | ||
94 | |||
95 | Dmitry Pervushin : dpervushin@ru.mvista.com | ||
96 | : PNX010X platform support | ||
97 | |||
98 | Domenico Andreoli : cavokz@gmail.com | ||
99 | : QQ2440 platform support | ||
100 | |||
101 | */ | ||
102 | |||
103 | 25 | ||
104 | /* | 26 | /* |
105 | * Set this to zero to disable DMA code | 27 | * Set this to zero to disable DMA code |
@@ -119,14 +41,10 @@ | |||
119 | */ | 41 | */ |
120 | #define DEBUGGING 1 | 42 | #define DEBUGGING 1 |
121 | 43 | ||
122 | /* | 44 | /* Sources: |
123 | Sources: | 45 | * Crynwr packet driver epktisa. |
124 | 46 | * Crystal Semiconductor data sheets. | |
125 | Crynwr packet driver epktisa. | 47 | */ |
126 | |||
127 | Crystal Semiconductor data sheets. | ||
128 | |||
129 | */ | ||
130 | 48 | ||
131 | #include <linux/module.h> | 49 | #include <linux/module.h> |
132 | #include <linux/printk.h> | 50 | #include <linux/printk.h> |
@@ -158,21 +76,23 @@ | |||
158 | #include "cs89x0.h" | 76 | #include "cs89x0.h" |
159 | 77 | ||
160 | static char version[] __initdata = | 78 | static char version[] __initdata = |
161 | "cs89x0.c: v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton\n"; | 79 | "cs89x0.c: v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton\n"; |
162 | 80 | ||
163 | #define DRV_NAME "cs89x0" | 81 | #define DRV_NAME "cs89x0" |
164 | 82 | ||
165 | /* First, a few definitions that the brave might change. | 83 | /* First, a few definitions that the brave might change. |
166 | A zero-terminated list of I/O addresses to be probed. Some special flags.. | 84 | * A zero-terminated list of I/O addresses to be probed. Some special flags.. |
167 | Addr & 1 = Read back the address port, look for signature and reset | 85 | * Addr & 1 = Read back the address port, look for signature and reset |
168 | the page window before probing | 86 | * the page window before probing |
169 | Addr & 3 = Reset the page window and probe | 87 | * Addr & 3 = Reset the page window and probe |
170 | The CLPS eval board has the Cirrus chip at 0x80090300, in ARM IO space, | 88 | * The CLPS eval board has the Cirrus chip at 0x80090300, in ARM IO space, |
171 | but it is possible that a Cirrus board could be plugged into the ISA | 89 | * but it is possible that a Cirrus board could be plugged into the ISA |
172 | slots. */ | 90 | * slots. |
91 | */ | ||
173 | /* The cs8900 has 4 IRQ pins, software selectable. cs8900_irq_map maps | 92 | /* The cs8900 has 4 IRQ pins, software selectable. cs8900_irq_map maps |
174 | them to system IRQ numbers. This mapping is card specific and is set to | 93 | * them to system IRQ numbers. This mapping is card specific and is set to |
175 | the configuration of the Cirrus Eval board for this chip. */ | 94 | * the configuration of the Cirrus Eval board for this chip. |
95 | */ | ||
176 | #if defined(CONFIG_MACH_IXDP2351) | 96 | #if defined(CONFIG_MACH_IXDP2351) |
177 | #define CS89x0_NONISA_IRQ | 97 | #define CS89x0_NONISA_IRQ |
178 | static unsigned int netcard_portlist[] __used __initdata = {IXDP2351_VIRT_CS8900_BASE, 0}; | 98 | static unsigned int netcard_portlist[] __used __initdata = {IXDP2351_VIRT_CS8900_BASE, 0}; |
@@ -184,8 +104,8 @@ static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0}; | |||
184 | #else | 104 | #else |
185 | #ifndef CONFIG_CS89x0_PLATFORM | 105 | #ifndef CONFIG_CS89x0_PLATFORM |
186 | static unsigned int netcard_portlist[] __used __initdata = | 106 | static unsigned int netcard_portlist[] __used __initdata = |
187 | { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; | 107 | { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; |
188 | static unsigned int cs8900_irq_map[] = {10,11,12,5}; | 108 | static unsigned int cs8900_irq_map[] = {10, 11, 12, 5}; |
189 | #endif | 109 | #endif |
190 | #endif | 110 | #endif |
191 | 111 | ||
@@ -268,7 +188,7 @@ static int g_cs89x0_dma; | |||
268 | 188 | ||
269 | static int __init dma_fn(char *str) | 189 | static int __init dma_fn(char *str) |
270 | { | 190 | { |
271 | g_cs89x0_dma = simple_strtol(str,NULL,0); | 191 | g_cs89x0_dma = simple_strtol(str, NULL, 0); |
272 | return 1; | 192 | return 1; |
273 | } | 193 | } |
274 | 194 | ||
@@ -362,10 +282,11 @@ static int __init | |||
362 | wait_eeprom_ready(struct net_device *dev) | 282 | wait_eeprom_ready(struct net_device *dev) |
363 | { | 283 | { |
364 | int timeout = jiffies; | 284 | int timeout = jiffies; |
365 | /* check to see if the EEPROM is ready, a timeout is used - | 285 | /* check to see if the EEPROM is ready, |
366 | just in case EEPROM is ready when SI_BUSY in the | 286 | * a timeout is used just in case EEPROM is ready when |
367 | PP_SelfST is clear */ | 287 | * SI_BUSY in the PP_SelfST is clear |
368 | while(readreg(dev, PP_SelfST) & SI_BUSY) | 288 | */ |
289 | while (readreg(dev, PP_SelfST) & SI_BUSY) | ||
369 | if (jiffies - timeout >= 40) | 290 | if (jiffies - timeout >= 40) |
370 | return -1; | 291 | return -1; |
371 | return 0; | 292 | return 0; |
@@ -376,7 +297,7 @@ get_eeprom_data(struct net_device *dev, int off, int len, int *buffer) | |||
376 | { | 297 | { |
377 | int i; | 298 | int i; |
378 | 299 | ||
379 | if (net_debug > 3) printk("EEPROM data from %x for %x:\n",off,len); | 300 | if (net_debug > 3) printk("EEPROM data from %x for %x:\n", off, len); |
380 | for (i = 0; i < len; i++) { | 301 | for (i = 0; i < len; i++) { |
381 | if (wait_eeprom_ready(dev) < 0) return -1; | 302 | if (wait_eeprom_ready(dev) < 0) return -1; |
382 | /* Now send the EEPROM read command and EEPROM location to read */ | 303 | /* Now send the EEPROM read command and EEPROM location to read */ |
@@ -386,7 +307,7 @@ get_eeprom_data(struct net_device *dev, int off, int len, int *buffer) | |||
386 | if (net_debug > 3) printk("%04x ", buffer[i]); | 307 | if (net_debug > 3) printk("%04x ", buffer[i]); |
387 | } | 308 | } |
388 | if (net_debug > 3) printk("\n"); | 309 | if (net_debug > 3) printk("\n"); |
389 | return 0; | 310 | return 0; |
390 | } | 311 | } |
391 | 312 | ||
392 | static int __init | 313 | static int __init |
@@ -420,10 +341,10 @@ static const struct net_device_ops net_ops = { | |||
420 | .ndo_open = net_open, | 341 | .ndo_open = net_open, |
421 | .ndo_stop = net_close, | 342 | .ndo_stop = net_close, |
422 | .ndo_tx_timeout = net_timeout, | 343 | .ndo_tx_timeout = net_timeout, |
423 | .ndo_start_xmit = net_send_packet, | 344 | .ndo_start_xmit = net_send_packet, |
424 | .ndo_get_stats = net_get_stats, | 345 | .ndo_get_stats = net_get_stats, |
425 | .ndo_set_rx_mode = set_multicast_list, | 346 | .ndo_set_rx_mode = set_multicast_list, |
426 | .ndo_set_mac_address = set_mac_address, | 347 | .ndo_set_mac_address = set_mac_address, |
427 | #ifdef CONFIG_NET_POLL_CONTROLLER | 348 | #ifdef CONFIG_NET_POLL_CONTROLLER |
428 | .ndo_poll_controller = net_poll_controller, | 349 | .ndo_poll_controller = net_poll_controller, |
429 | #endif | 350 | #endif |
@@ -431,12 +352,12 @@ static const struct net_device_ops net_ops = { | |||
431 | .ndo_validate_addr = eth_validate_addr, | 352 | .ndo_validate_addr = eth_validate_addr, |
432 | }; | 353 | }; |
433 | 354 | ||
434 | /* This is the real probe routine. Linux has a history of friendly device | 355 | /* This is the real probe routine. |
435 | probes on the ISA bus. A good device probes avoids doing writes, and | 356 | * Linux has a history of friendly device probes on the ISA bus. |
436 | verifies that the correct device exists and functions. | 357 | * A good device probes avoids doing writes, and |
437 | Return 0 on success. | 358 | * verifies that the correct device exists and functions. |
359 | * Return 0 on success. | ||
438 | */ | 360 | */ |
439 | |||
440 | static int __init | 361 | static int __init |
441 | cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) | 362 | cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) |
442 | { | 363 | { |
@@ -462,7 +383,7 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) | |||
462 | #endif | 383 | #endif |
463 | lp->force = g_cs89x0_media__force; | 384 | lp->force = g_cs89x0_media__force; |
464 | #endif | 385 | #endif |
465 | } | 386 | } |
466 | 387 | ||
467 | printk(KERN_DEBUG "PP_addr at %p[%x]: 0x%x\n", | 388 | printk(KERN_DEBUG "PP_addr at %p[%x]: 0x%x\n", |
468 | ioaddr, ADD_PORT, ioread16(ioaddr + ADD_PORT)); | 389 | ioaddr, ADD_PORT, ioread16(ioaddr + ADD_PORT)); |
@@ -471,9 +392,9 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) | |||
471 | tmp = ioread16(ioaddr + DATA_PORT); | 392 | tmp = ioread16(ioaddr + DATA_PORT); |
472 | if (tmp != CHIP_EISA_ID_SIG) { | 393 | if (tmp != CHIP_EISA_ID_SIG) { |
473 | printk(KERN_DEBUG "%s: incorrect signature at %p[%x]: 0x%x!=" | 394 | printk(KERN_DEBUG "%s: incorrect signature at %p[%x]: 0x%x!=" |
474 | CHIP_EISA_ID_SIG_STR "\n", | 395 | CHIP_EISA_ID_SIG_STR "\n", |
475 | dev->name, ioaddr, DATA_PORT, tmp); | 396 | dev->name, ioaddr, DATA_PORT, tmp); |
476 | retval = -ENODEV; | 397 | retval = -ENODEV; |
477 | goto out1; | 398 | goto out1; |
478 | } | 399 | } |
479 | 400 | ||
@@ -481,11 +402,11 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) | |||
481 | 402 | ||
482 | /* get the chip type */ | 403 | /* get the chip type */ |
483 | rev_type = readreg(dev, PRODUCT_ID_ADD); | 404 | rev_type = readreg(dev, PRODUCT_ID_ADD); |
484 | lp->chip_type = rev_type &~ REVISON_BITS; | 405 | lp->chip_type = rev_type & ~REVISON_BITS; |
485 | lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A'; | 406 | lp->chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A'; |
486 | 407 | ||
487 | /* Check the chip type and revision in order to set the correct send command | 408 | /* Check the chip type and revision in order to set the correct send command |
488 | CS8920 revision C and CS8900 revision F can use the faster send. */ | 409 | CS8920 revision C and CS8900 revision F can use the faster send. */ |
489 | lp->send_cmd = TX_AFTER_381; | 410 | lp->send_cmd = TX_AFTER_381; |
490 | if (lp->chip_type == CS8900 && lp->chip_revision >= 'F') | 411 | if (lp->chip_type == CS8900 && lp->chip_revision >= 'F') |
491 | lp->send_cmd = TX_NOW; | 412 | lp->send_cmd = TX_NOW; |
@@ -497,45 +418,46 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) | |||
497 | 418 | ||
498 | printk(KERN_INFO "%s: cs89%c0%s rev %c found at %p ", | 419 | printk(KERN_INFO "%s: cs89%c0%s rev %c found at %p ", |
499 | dev->name, | 420 | dev->name, |
500 | lp->chip_type==CS8900?'0':'2', | 421 | lp->chip_type == CS8900 ? '0' : '2', |
501 | lp->chip_type==CS8920M?"M":"", | 422 | lp->chip_type == CS8920M ? "M" : "", |
502 | lp->chip_revision, | 423 | lp->chip_revision, |
503 | lp->virt_addr); | 424 | lp->virt_addr); |
504 | 425 | ||
505 | reset_chip(dev); | 426 | reset_chip(dev); |
506 | 427 | ||
507 | /* Here we read the current configuration of the chip. If there | 428 | /* Here we read the current configuration of the chip. |
508 | is no Extended EEPROM then the idea is to not disturb the chip | 429 | * If there is no Extended EEPROM then the idea is to not disturb |
509 | configuration, it should have been correctly setup by automatic | 430 | * the chip configuration, it should have been correctly setup by |
510 | EEPROM read on reset. So, if the chip says it read the EEPROM | 431 | * automatic EEPROM read on reset. So, if the chip says it read |
511 | the driver will always do *something* instead of complain that | 432 | * the EEPROM the driver will always do *something* instead of |
512 | adapter_cnf is 0. */ | 433 | * complain that adapter_cnf is 0. |
513 | 434 | */ | |
514 | 435 | ||
515 | if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) == | 436 | if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) == |
516 | (EEPROM_OK|EEPROM_PRESENT)) { | 437 | (EEPROM_OK|EEPROM_PRESENT)) { |
517 | /* Load the MAC. */ | 438 | /* Load the MAC. */ |
518 | for (i=0; i < ETH_ALEN/2; i++) { | 439 | for (i = 0; i < ETH_ALEN / 2; i++) { |
519 | unsigned int Addr; | 440 | unsigned int Addr; |
520 | Addr = readreg(dev, PP_IA+i*2); | 441 | Addr = readreg(dev, PP_IA + i * 2); |
521 | dev->dev_addr[i*2] = Addr & 0xFF; | 442 | dev->dev_addr[i * 2] = Addr & 0xFF; |
522 | dev->dev_addr[i*2+1] = Addr >> 8; | 443 | dev->dev_addr[i * 2 + 1] = Addr >> 8; |
523 | } | 444 | } |
524 | 445 | ||
525 | /* Load the Adapter Configuration. | 446 | /* Load the Adapter Configuration. |
526 | Note: Barring any more specific information from some | 447 | * Note: Barring any more specific information from some |
527 | other source (ie EEPROM+Schematics), we would not know | 448 | * other source (ie EEPROM+Schematics), we would not know |
528 | how to operate a 10Base2 interface on the AUI port. | 449 | * how to operate a 10Base2 interface on the AUI port. |
529 | However, since we do read the status of HCB1 and use | 450 | * However, since we do read the status of HCB1 and use |
530 | settings that always result in calls to control_dc_dc(dev,0) | 451 | * settings that always result in calls to control_dc_dc(dev,0) |
531 | a BNC interface should work if the enable pin | 452 | * a BNC interface should work if the enable pin |
532 | (dc/dc converter) is on HCB1. It will be called AUI | 453 | * (dc/dc converter) is on HCB1. |
533 | however. */ | 454 | * It will be called AUI however. |
455 | */ | ||
534 | 456 | ||
535 | lp->adapter_cnf = 0; | 457 | lp->adapter_cnf = 0; |
536 | i = readreg(dev, PP_LineCTL); | 458 | i = readreg(dev, PP_LineCTL); |
537 | /* Preserve the setting of the HCB1 pin. */ | 459 | /* Preserve the setting of the HCB1 pin. */ |
538 | if ((i & (HCB1 | HCB1_ENBL)) == (HCB1 | HCB1_ENBL)) | 460 | if ((i & (HCB1 | HCB1_ENBL)) == (HCB1 | HCB1_ENBL)) |
539 | lp->adapter_cnf |= A_CNF_DC_DC_POLARITY; | 461 | lp->adapter_cnf |= A_CNF_DC_DC_POLARITY; |
540 | /* Save the sqelch bit */ | 462 | /* Save the sqelch bit */ |
541 | if ((i & LOW_RX_SQUELCH) == LOW_RX_SQUELCH) | 463 | if ((i & LOW_RX_SQUELCH) == LOW_RX_SQUELCH) |
@@ -549,92 +471,94 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) | |||
549 | /* Check if the card is in Auto mode. */ | 471 | /* Check if the card is in Auto mode. */ |
550 | if ((i & (AUI_ONLY | AUTO_AUI_10BASET)) == AUTO_AUI_10BASET) | 472 | if ((i & (AUI_ONLY | AUTO_AUI_10BASET)) == AUTO_AUI_10BASET) |
551 | lp->adapter_cnf |= A_CNF_AUI | A_CNF_10B_T | | 473 | lp->adapter_cnf |= A_CNF_AUI | A_CNF_10B_T | |
552 | A_CNF_MEDIA_AUI | A_CNF_MEDIA_10B_T | A_CNF_MEDIA_AUTO; | 474 | A_CNF_MEDIA_AUI | A_CNF_MEDIA_10B_T | A_CNF_MEDIA_AUTO; |
553 | 475 | ||
554 | if (net_debug > 1) | 476 | if (net_debug > 1) |
555 | printk(KERN_INFO "%s: PP_LineCTL=0x%x, adapter_cnf=0x%x\n", | 477 | printk(KERN_INFO "%s: PP_LineCTL=0x%x, adapter_cnf=0x%x\n", |
556 | dev->name, i, lp->adapter_cnf); | 478 | dev->name, i, lp->adapter_cnf); |
557 | 479 | ||
558 | /* IRQ. Other chips already probe, see below. */ | 480 | /* IRQ. Other chips already probe, see below. */ |
559 | if (lp->chip_type == CS8900) | 481 | if (lp->chip_type == CS8900) |
560 | lp->isa_config = readreg(dev, PP_CS8900_ISAINT) & INT_NO_MASK; | 482 | lp->isa_config = readreg(dev, PP_CS8900_ISAINT) & INT_NO_MASK; |
561 | 483 | ||
562 | printk( "[Cirrus EEPROM] "); | 484 | printk("[Cirrus EEPROM] "); |
563 | } | 485 | } |
564 | 486 | ||
565 | printk("\n"); | 487 | printk("\n"); |
566 | 488 | ||
567 | /* First check to see if an EEPROM is attached. */ | 489 | /* First check to see if an EEPROM is attached. */ |
568 | 490 | ||
569 | if ((readreg(dev, PP_SelfST) & EEPROM_PRESENT) == 0) | 491 | if ((readreg(dev, PP_SelfST) & EEPROM_PRESENT) == 0) |
570 | printk(KERN_WARNING "cs89x0: No EEPROM, relying on command line....\n"); | 492 | printk(KERN_WARNING "cs89x0: No EEPROM, relying on command line....\n"); |
571 | else if (get_eeprom_data(dev, START_EEPROM_DATA,CHKSUM_LEN,eeprom_buff) < 0) { | 493 | else if (get_eeprom_data(dev, START_EEPROM_DATA, CHKSUM_LEN, eeprom_buff) < 0) { |
572 | printk(KERN_WARNING "\ncs89x0: EEPROM read failed, relying on command line.\n"); | 494 | printk(KERN_WARNING "\ncs89x0: EEPROM read failed, relying on command line.\n"); |
573 | } else if (get_eeprom_cksum(START_EEPROM_DATA,CHKSUM_LEN,eeprom_buff) < 0) { | 495 | } else if (get_eeprom_cksum(START_EEPROM_DATA, CHKSUM_LEN, eeprom_buff) < 0) { |
574 | /* Check if the chip was able to read its own configuration starting | 496 | /* Check if the chip was able to read its own configuration starting |
575 | at 0 in the EEPROM*/ | 497 | at 0 in the EEPROM*/ |
576 | if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) != | 498 | if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) != |
577 | (EEPROM_OK|EEPROM_PRESENT)) | 499 | (EEPROM_OK | EEPROM_PRESENT)) |
578 | printk(KERN_WARNING "cs89x0: Extended EEPROM checksum bad and no Cirrus EEPROM, relying on command line\n"); | 500 | printk(KERN_WARNING "cs89x0: Extended EEPROM checksum bad and no Cirrus EEPROM, relying on command line\n"); |
579 | 501 | ||
580 | } else { | 502 | } else { |
581 | /* This reads an extended EEPROM that is not documented | 503 | /* This reads an extended EEPROM that is not documented |
582 | in the CS8900 datasheet. */ | 504 | * in the CS8900 datasheet. |
583 | 505 | */ | |
584 | /* get transmission control word but keep the autonegotiation bits */ | 506 | |
585 | if (!lp->auto_neg_cnf) lp->auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET/2]; | 507 | /* get transmission control word but keep the autonegotiation bits */ |
586 | /* Store adapter configuration */ | 508 | if (!lp->auto_neg_cnf) lp->auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET/2]; |
587 | if (!lp->adapter_cnf) lp->adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET/2]; | 509 | /* Store adapter configuration */ |
588 | /* Store ISA configuration */ | 510 | if (!lp->adapter_cnf) lp->adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET/2]; |
589 | lp->isa_config = eeprom_buff[ISA_CNF_OFFSET/2]; | 511 | /* Store ISA configuration */ |
590 | dev->mem_start = eeprom_buff[PACKET_PAGE_OFFSET/2] << 8; | 512 | lp->isa_config = eeprom_buff[ISA_CNF_OFFSET/2]; |
591 | 513 | dev->mem_start = eeprom_buff[PACKET_PAGE_OFFSET/2] << 8; | |
592 | /* eeprom_buff has 32-bit ints, so we can't just memcpy it */ | 514 | |
593 | /* store the initial memory base address */ | 515 | /* eeprom_buff has 32-bit ints, so we can't just memcpy it */ |
594 | for (i = 0; i < ETH_ALEN/2; i++) { | 516 | /* store the initial memory base address */ |
595 | dev->dev_addr[i*2] = eeprom_buff[i]; | 517 | for (i = 0; i < ETH_ALEN / 2; i++) { |
596 | dev->dev_addr[i*2+1] = eeprom_buff[i] >> 8; | 518 | dev->dev_addr[i * 2] = eeprom_buff[i]; |
597 | } | 519 | dev->dev_addr[i * 2 + 1] = eeprom_buff[i] >> 8; |
520 | } | ||
598 | if (net_debug > 1) | 521 | if (net_debug > 1) |
599 | printk(KERN_DEBUG "%s: new adapter_cnf: 0x%x\n", | 522 | printk(KERN_DEBUG "%s: new adapter_cnf: 0x%x\n", |
600 | dev->name, lp->adapter_cnf); | 523 | dev->name, lp->adapter_cnf); |
601 | } | 524 | } |
602 | 525 | ||
603 | /* allow them to force multiple transceivers. If they force multiple, autosense */ | 526 | /* allow them to force multiple transceivers. If they force multiple, autosense */ |
604 | { | 527 | { |
605 | int count = 0; | 528 | int count = 0; |
606 | if (lp->force & FORCE_RJ45) {lp->adapter_cnf |= A_CNF_10B_T; count++; } | 529 | if (lp->force & FORCE_RJ45) {lp->adapter_cnf |= A_CNF_10B_T; count++; } |
607 | if (lp->force & FORCE_AUI) {lp->adapter_cnf |= A_CNF_AUI; count++; } | 530 | if (lp->force & FORCE_AUI) {lp->adapter_cnf |= A_CNF_AUI; count++; } |
608 | if (lp->force & FORCE_BNC) {lp->adapter_cnf |= A_CNF_10B_2; count++; } | 531 | if (lp->force & FORCE_BNC) {lp->adapter_cnf |= A_CNF_10B_2; count++; } |
609 | if (count > 1) {lp->adapter_cnf |= A_CNF_MEDIA_AUTO; } | 532 | if (count > 1) {lp->adapter_cnf |= A_CNF_MEDIA_AUTO; } |
610 | else if (lp->force & FORCE_RJ45){lp->adapter_cnf |= A_CNF_MEDIA_10B_T; } | 533 | else if (lp->force & FORCE_RJ45){lp->adapter_cnf |= A_CNF_MEDIA_10B_T; } |
611 | else if (lp->force & FORCE_AUI) {lp->adapter_cnf |= A_CNF_MEDIA_AUI; } | 534 | else if (lp->force & FORCE_AUI) {lp->adapter_cnf |= A_CNF_MEDIA_AUI; } |
612 | else if (lp->force & FORCE_BNC) {lp->adapter_cnf |= A_CNF_MEDIA_10B_2; } | 535 | else if (lp->force & FORCE_BNC) {lp->adapter_cnf |= A_CNF_MEDIA_10B_2; } |
613 | } | 536 | } |
614 | 537 | ||
615 | if (net_debug > 1) | 538 | if (net_debug > 1) |
616 | printk(KERN_DEBUG "%s: after force 0x%x, adapter_cnf=0x%x\n", | 539 | printk(KERN_DEBUG "%s: after force 0x%x, adapter_cnf=0x%x\n", |
617 | dev->name, lp->force, lp->adapter_cnf); | 540 | dev->name, lp->force, lp->adapter_cnf); |
618 | 541 | ||
619 | /* FIXME: We don't let you set dc-dc polarity or low RX squelch from the command line: add it here */ | 542 | /* FIXME: We don't let you set dc-dc polarity or low RX squelch from the command line: add it here */ |
620 | 543 | ||
621 | /* FIXME: We don't let you set the IMM bit from the command line: add it to lp->auto_neg_cnf here */ | 544 | /* FIXME: We don't let you set the IMM bit from the command line: add it to lp->auto_neg_cnf here */ |
622 | 545 | ||
623 | /* FIXME: we don't set the Ethernet address on the command line. Use | 546 | /* FIXME: we don't set the Ethernet address on the command line. Use |
624 | ifconfig IFACE hw ether AABBCCDDEEFF */ | 547 | * ifconfig IFACE hw ether AABBCCDDEEFF |
548 | */ | ||
625 | 549 | ||
626 | printk(KERN_INFO "cs89x0 media %s%s%s", | 550 | printk(KERN_INFO "cs89x0 media %s%s%s", |
627 | (lp->adapter_cnf & A_CNF_10B_T)?"RJ-45,":"", | 551 | (lp->adapter_cnf & A_CNF_10B_T) ? "RJ-45," : "", |
628 | (lp->adapter_cnf & A_CNF_AUI)?"AUI,":"", | 552 | (lp->adapter_cnf & A_CNF_AUI) ? "AUI," : "", |
629 | (lp->adapter_cnf & A_CNF_10B_2)?"BNC,":""); | 553 | (lp->adapter_cnf & A_CNF_10B_2) ? "BNC," : ""); |
630 | 554 | ||
631 | lp->irq_map = 0xffff; | 555 | lp->irq_map = 0xffff; |
632 | 556 | ||
633 | /* If this is a CS8900 then no pnp soft */ | 557 | /* If this is a CS8900 then no pnp soft */ |
634 | if (lp->chip_type != CS8900 && | 558 | if (lp->chip_type != CS8900 && |
635 | /* Check if the ISA IRQ has been set */ | 559 | /* Check if the ISA IRQ has been set */ |
636 | (i = readreg(dev, PP_CS8920_ISAINT) & 0xff, | 560 | (i = readreg(dev, PP_CS8920_ISAINT) & 0xff, |
637 | (i != 0 && i < CS8920_NO_INTS))) { | 561 | (i != 0 && i < CS8920_NO_INTS))) { |
638 | if (!dev->irq) | 562 | if (!dev->irq) |
639 | dev->irq = i; | 563 | dev->irq = i; |
640 | } else { | 564 | } else { |
@@ -642,7 +566,7 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) | |||
642 | #ifndef CONFIG_CS89x0_PLATFORM | 566 | #ifndef CONFIG_CS89x0_PLATFORM |
643 | if (lp->chip_type == CS8900) { | 567 | if (lp->chip_type == CS8900) { |
644 | #ifdef CS89x0_NONISA_IRQ | 568 | #ifdef CS89x0_NONISA_IRQ |
645 | i = cs8900_irq_map[0]; | 569 | i = cs8900_irq_map[0]; |
646 | #else | 570 | #else |
647 | /* Translate the IRQ using the IRQ mapping table. */ | 571 | /* Translate the IRQ using the IRQ mapping table. */ |
648 | if (i >= ARRAY_SIZE(cs8900_irq_map)) | 572 | if (i >= ARRAY_SIZE(cs8900_irq_map)) |
@@ -655,10 +579,10 @@ cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr, int modular) | |||
655 | int irq_map_buff[IRQ_MAP_LEN/2]; | 579 | int irq_map_buff[IRQ_MAP_LEN/2]; |
656 | 580 | ||
657 | if (get_eeprom_data(dev, IRQ_MAP_EEPROM_DATA, | 581 | if (get_eeprom_data(dev, IRQ_MAP_EEPROM_DATA, |
658 | IRQ_MAP_LEN/2, | 582 | IRQ_MAP_LEN / 2, |
659 | irq_map_buff) >= 0) { | 583 | irq_map_buff) >= 0) { |
660 | if ((irq_map_buff[0] & 0xff) == PNP_IRQ_FRMT) | 584 | if ((irq_map_buff[0] & 0xff) == PNP_IRQ_FRMT) |
661 | lp->irq_map = (irq_map_buff[0]>>8) | (irq_map_buff[1] << 8); | 585 | lp->irq_map = (irq_map_buff[0] >> 8) | (irq_map_buff[1] << 8); |
662 | } | 586 | } |
663 | #endif | 587 | #endif |
664 | } | 588 | } |
@@ -730,9 +654,10 @@ cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular) | |||
730 | } | 654 | } |
731 | 655 | ||
732 | /* if they give us an odd I/O address, then do ONE write to | 656 | /* if they give us an odd I/O address, then do ONE write to |
733 | the address port, to get it back to address zero, where we | 657 | * the address port, to get it back to address zero, where we |
734 | expect to find the EISA signature word. An IO with a base of 0x3 | 658 | * expect to find the EISA signature word. An IO with a base of 0x3 |
735 | will skip the test for the ADD_PORT. */ | 659 | * will skip the test for the ADD_PORT. |
660 | */ | ||
736 | if (ioport & 1) { | 661 | if (ioport & 1) { |
737 | if (net_debug > 1) | 662 | if (net_debug > 1) |
738 | printk(KERN_INFO "%s: odd ioaddr 0x%lx\n", | 663 | printk(KERN_INFO "%s: odd ioaddr 0x%lx\n", |
@@ -742,8 +667,8 @@ cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular) | |||
742 | if ((ioread16(io_mem + ADD_PORT) & ADD_MASK) != | 667 | if ((ioread16(io_mem + ADD_PORT) & ADD_MASK) != |
743 | ADD_SIG) { | 668 | ADD_SIG) { |
744 | printk(KERN_ERR "%s: bad signature 0x%x\n", | 669 | printk(KERN_ERR "%s: bad signature 0x%x\n", |
745 | dev->name, | 670 | dev->name, |
746 | ioread16(io_mem + ADD_PORT)); | 671 | ioread16(io_mem + ADD_PORT)); |
747 | ret = -ENODEV; | 672 | ret = -ENODEV; |
748 | goto unmap; | 673 | goto unmap; |
749 | } | 674 | } |
@@ -762,12 +687,12 @@ out: | |||
762 | 687 | ||
763 | #ifndef MODULE | 688 | #ifndef MODULE |
764 | /* Check for a network adaptor of this type, and return '0' iff one exists. | 689 | /* Check for a network adaptor of this type, and return '0' iff one exists. |
765 | If dev->base_addr == 0, probe all likely locations. | 690 | * If dev->base_addr == 0, probe all likely locations. |
766 | If dev->base_addr == 1, always return failure. | 691 | * If dev->base_addr == 1, always return failure. |
767 | If dev->base_addr == 2, allocate space for the device and return success | 692 | * If dev->base_addr == 2, allocate space for the device and return success |
768 | (detachable devices only). | 693 | * (detachable devices only). |
769 | Return 0 on success. | 694 | * Return 0 on success. |
770 | */ | 695 | */ |
771 | 696 | ||
772 | struct net_device * __init cs89x0_probe(int unit) | 697 | struct net_device * __init cs89x0_probe(int unit) |
773 | { | 698 | { |
@@ -814,7 +739,7 @@ out: | |||
814 | 739 | ||
815 | /********************************* | 740 | /********************************* |
816 | * This page contains DMA routines | 741 | * This page contains DMA routines |
817 | **********************************/ | 742 | *********************************/ |
818 | 743 | ||
819 | #if ALLOW_DMA | 744 | #if ALLOW_DMA |
820 | 745 | ||
@@ -882,7 +807,7 @@ dma_bufcfg(struct net_device *dev) | |||
882 | { | 807 | { |
883 | struct net_local *lp = netdev_priv(dev); | 808 | struct net_local *lp = netdev_priv(dev); |
884 | if (lp->use_dma) | 809 | if (lp->use_dma) |
885 | return (lp->isa_config & ANY_ISA_DMA)? RX_DMA_ENBL : 0; | 810 | return (lp->isa_config & ANY_ISA_DMA) ? RX_DMA_ENBL : 0; |
886 | else | 811 | else |
887 | return 0; | 812 | return 0; |
888 | } | 813 | } |
@@ -916,8 +841,8 @@ dma_rx(struct net_device *dev) | |||
916 | length = bp[2] + (bp[3]<<8); | 841 | length = bp[2] + (bp[3]<<8); |
917 | bp += 4; | 842 | bp += 4; |
918 | if (net_debug > 5) { | 843 | if (net_debug > 5) { |
919 | printk( "%s: receiving DMA packet at %lx, status %x, length %x\n", | 844 | printk("%s: receiving DMA packet at %lx, status %x, length %x\n", |
920 | dev->name, (unsigned long)bp, status, length); | 845 | dev->name, (unsigned long)bp, status, length); |
921 | } | 846 | } |
922 | if ((status & RX_OK) == 0) { | 847 | if ((status & RX_OK) == 0) { |
923 | count_rx_errors(status, dev); | 848 | count_rx_errors(status, dev); |
@@ -942,22 +867,22 @@ skip_this_frame: | |||
942 | 867 | ||
943 | if (bp + length > lp->end_dma_buff) { | 868 | if (bp + length > lp->end_dma_buff) { |
944 | int semi_cnt = lp->end_dma_buff - bp; | 869 | int semi_cnt = lp->end_dma_buff - bp; |
945 | memcpy(skb_put(skb,semi_cnt), bp, semi_cnt); | 870 | memcpy(skb_put(skb, semi_cnt), bp, semi_cnt); |
946 | memcpy(skb_put(skb,length - semi_cnt), lp->dma_buff, | 871 | memcpy(skb_put(skb, length - semi_cnt), lp->dma_buff, |
947 | length - semi_cnt); | 872 | length - semi_cnt); |
948 | } else { | 873 | } else { |
949 | memcpy(skb_put(skb,length), bp, length); | 874 | memcpy(skb_put(skb, length), bp, length); |
950 | } | 875 | } |
951 | bp += (length + 3) & ~3; | 876 | bp += (length + 3) & ~3; |
952 | if (bp >= lp->end_dma_buff) bp -= lp->dmasize*1024; | 877 | if (bp >= lp->end_dma_buff) bp -= lp->dmasize*1024; |
953 | lp->rx_dma_ptr = bp; | 878 | lp->rx_dma_ptr = bp; |
954 | 879 | ||
955 | if (net_debug > 3) { | 880 | if (net_debug > 3) { |
956 | printk( "%s: received %d byte DMA packet of type %x\n", | 881 | printk("%s: received %d byte DMA packet of type %x\n", |
957 | dev->name, length, | 882 | dev->name, length, |
958 | (skb->data[ETH_ALEN+ETH_ALEN] << 8) | skb->data[ETH_ALEN+ETH_ALEN+1]); | 883 | (skb->data[ETH_ALEN + ETH_ALEN] << 8) | skb->data[ETH_ALEN + ETH_ALEN + 1]); |
959 | } | 884 | } |
960 | skb->protocol=eth_type_trans(skb,dev); | 885 | skb->protocol = eth_type_trans(skb, dev); |
961 | netif_rx(skb); | 886 | netif_rx(skb); |
962 | dev->stats.rx_packets++; | 887 | dev->stats.rx_packets++; |
963 | dev->stats.rx_bytes += length; | 888 | dev->stats.rx_bytes += length; |
@@ -995,7 +920,7 @@ static void __init reset_chip(struct net_device *dev) | |||
995 | 920 | ||
996 | /* Wait until the chip is reset */ | 921 | /* Wait until the chip is reset */ |
997 | reset_start_time = jiffies; | 922 | reset_start_time = jiffies; |
998 | while( (readreg(dev, PP_SelfST) & INIT_DONE) == 0 && jiffies - reset_start_time < 2) | 923 | while ((readreg(dev, PP_SelfST) & INIT_DONE) == 0 && jiffies - reset_start_time < 2) |
999 | ; | 924 | ; |
1000 | #endif /* !CONFIG_MACH_MX31ADS */ | 925 | #endif /* !CONFIG_MACH_MX31ADS */ |
1001 | } | 926 | } |
@@ -1038,38 +963,38 @@ detect_tp(struct net_device *dev) | |||
1038 | 963 | ||
1039 | if (net_debug > 1) printk("%s: Attempting TP\n", dev->name); | 964 | if (net_debug > 1) printk("%s: Attempting TP\n", dev->name); |
1040 | 965 | ||
1041 | /* If connected to another full duplex capable 10-Base-T card the link pulses | 966 | /* If connected to another full duplex capable 10-Base-T card the link pulses |
1042 | seem to be lost when the auto detect bit in the LineCTL is set. | 967 | seem to be lost when the auto detect bit in the LineCTL is set. |
1043 | To overcome this the auto detect bit will be cleared whilst testing the | 968 | To overcome this the auto detect bit will be cleared whilst testing the |
1044 | 10-Base-T interface. This would not be necessary for the sparrow chip but | 969 | 10-Base-T interface. This would not be necessary for the sparrow chip but |
1045 | is simpler to do it anyway. */ | 970 | is simpler to do it anyway. */ |
1046 | writereg(dev, PP_LineCTL, lp->linectl &~ AUI_ONLY); | 971 | writereg(dev, PP_LineCTL, lp->linectl & ~AUI_ONLY); |
1047 | control_dc_dc(dev, 0); | 972 | control_dc_dc(dev, 0); |
1048 | 973 | ||
1049 | /* Delay for the hardware to work out if the TP cable is present - 150ms */ | 974 | /* Delay for the hardware to work out if the TP cable is present - 150ms */ |
1050 | for (timenow = jiffies; jiffies - timenow < 15; ) | 975 | for (timenow = jiffies; jiffies - timenow < 15; ) |
1051 | ; | 976 | ; |
1052 | if ((readreg(dev, PP_LineST) & LINK_OK) == 0) | 977 | if ((readreg(dev, PP_LineST) & LINK_OK) == 0) |
1053 | return DETECTED_NONE; | 978 | return DETECTED_NONE; |
1054 | 979 | ||
1055 | if (lp->chip_type == CS8900) { | 980 | if (lp->chip_type == CS8900) { |
1056 | switch (lp->force & 0xf0) { | 981 | switch (lp->force & 0xf0) { |
1057 | #if 0 | 982 | #if 0 |
1058 | case FORCE_AUTO: | 983 | case FORCE_AUTO: |
1059 | printk("%s: cs8900 doesn't autonegotiate\n",dev->name); | 984 | printk("%s: cs8900 doesn't autonegotiate\n", dev->name); |
1060 | return DETECTED_NONE; | 985 | return DETECTED_NONE; |
1061 | #endif | 986 | #endif |
1062 | /* CS8900 doesn't support AUTO, change to HALF*/ | 987 | /* CS8900 doesn't support AUTO, change to HALF*/ |
1063 | case FORCE_AUTO: | 988 | case FORCE_AUTO: |
1064 | lp->force &= ~FORCE_AUTO; | 989 | lp->force &= ~FORCE_AUTO; |
1065 | lp->force |= FORCE_HALF; | 990 | lp->force |= FORCE_HALF; |
1066 | break; | 991 | break; |
1067 | case FORCE_HALF: | 992 | case FORCE_HALF: |
1068 | break; | 993 | break; |
1069 | case FORCE_FULL: | 994 | case FORCE_FULL: |
1070 | writereg(dev, PP_TestCTL, readreg(dev, PP_TestCTL) | FDX_8900); | 995 | writereg(dev, PP_TestCTL, readreg(dev, PP_TestCTL) | FDX_8900); |
1071 | break; | 996 | break; |
1072 | } | 997 | } |
1073 | fdx = readreg(dev, PP_TestCTL) & FDX_8900; | 998 | fdx = readreg(dev, PP_TestCTL) & FDX_8900; |
1074 | } else { | 999 | } else { |
1075 | switch (lp->force & 0xf0) { | 1000 | switch (lp->force & 0xf0) { |
@@ -1082,12 +1007,12 @@ detect_tp(struct net_device *dev) | |||
1082 | case FORCE_FULL: | 1007 | case FORCE_FULL: |
1083 | lp->auto_neg_cnf = RE_NEG_NOW | ALLOW_FDX; | 1008 | lp->auto_neg_cnf = RE_NEG_NOW | ALLOW_FDX; |
1084 | break; | 1009 | break; |
1085 | } | 1010 | } |
1086 | 1011 | ||
1087 | writereg(dev, PP_AutoNegCTL, lp->auto_neg_cnf & AUTO_NEG_MASK); | 1012 | writereg(dev, PP_AutoNegCTL, lp->auto_neg_cnf & AUTO_NEG_MASK); |
1088 | 1013 | ||
1089 | if ((lp->auto_neg_cnf & AUTO_NEG_BITS) == AUTO_NEG_ENABLE) { | 1014 | if ((lp->auto_neg_cnf & AUTO_NEG_BITS) == AUTO_NEG_ENABLE) { |
1090 | printk(KERN_INFO "%s: negotiating duplex...\n",dev->name); | 1015 | printk(KERN_INFO "%s: negotiating duplex...\n", dev->name); |
1091 | while (readreg(dev, PP_AutoNegST) & AUTO_NEG_BUSY) { | 1016 | while (readreg(dev, PP_AutoNegST) & AUTO_NEG_BUSY) { |
1092 | if (jiffies - timenow > 4000) { | 1017 | if (jiffies - timenow > 4000) { |
1093 | printk(KERN_ERR "**** Full / half duplex auto-negotiation timed out ****\n"); | 1018 | printk(KERN_ERR "**** Full / half duplex auto-negotiation timed out ****\n"); |
@@ -1109,15 +1034,15 @@ send_test_pkt(struct net_device *dev) | |||
1109 | { | 1034 | { |
1110 | struct net_local *lp = netdev_priv(dev); | 1035 | struct net_local *lp = netdev_priv(dev); |
1111 | char test_packet[] = { 0,0,0,0,0,0, 0,0,0,0,0,0, | 1036 | char test_packet[] = { 0,0,0,0,0,0, 0,0,0,0,0,0, |
1112 | 0, 46, /* A 46 in network order */ | 1037 | 0, 46, /* A 46 in network order */ |
1113 | 0, 0, /* DSAP=0 & SSAP=0 fields */ | 1038 | 0, 0, /* DSAP=0 & SSAP=0 fields */ |
1114 | 0xf3, 0 /* Control (Test Req + P bit set) */ }; | 1039 | 0xf3, 0 /* Control (Test Req + P bit set) */ }; |
1115 | long timenow = jiffies; | 1040 | long timenow = jiffies; |
1116 | 1041 | ||
1117 | writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_TX_ON); | 1042 | writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) | SERIAL_TX_ON); |
1118 | 1043 | ||
1119 | memcpy(test_packet, dev->dev_addr, ETH_ALEN); | 1044 | memcpy(test_packet, dev->dev_addr, ETH_ALEN); |
1120 | memcpy(test_packet+ETH_ALEN, dev->dev_addr, ETH_ALEN); | 1045 | memcpy(test_packet + ETH_ALEN, dev->dev_addr, ETH_ALEN); |
1121 | 1046 | ||
1122 | iowrite16(TX_AFTER_ALL, lp->virt_addr + TX_CMD_PORT); | 1047 | iowrite16(TX_AFTER_ALL, lp->virt_addr + TX_CMD_PORT); |
1123 | iowrite16(ETH_ZLEN, lp->virt_addr + TX_LEN_PORT); | 1048 | iowrite16(ETH_ZLEN, lp->virt_addr + TX_LEN_PORT); |
@@ -1135,11 +1060,11 @@ send_test_pkt(struct net_device *dev) | |||
1135 | if (net_debug > 1) printk("Sending test packet "); | 1060 | if (net_debug > 1) printk("Sending test packet "); |
1136 | /* wait a couple of jiffies for packet to be received */ | 1061 | /* wait a couple of jiffies for packet to be received */ |
1137 | for (timenow = jiffies; jiffies - timenow < 3; ) | 1062 | for (timenow = jiffies; jiffies - timenow < 3; ) |
1138 | ; | 1063 | ; |
1139 | if ((readreg(dev, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) { | 1064 | if ((readreg(dev, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) { |
1140 | if (net_debug > 1) printk("succeeded\n"); | 1065 | if (net_debug > 1) printk("succeeded\n"); |
1141 | return 1; | 1066 | return 1; |
1142 | } | 1067 | } |
1143 | if (net_debug > 1) printk("failed\n"); | 1068 | if (net_debug > 1) printk("failed\n"); |
1144 | return 0; | 1069 | return 0; |
1145 | } | 1070 | } |
@@ -1153,7 +1078,7 @@ detect_aui(struct net_device *dev) | |||
1153 | if (net_debug > 1) printk("%s: Attempting AUI\n", dev->name); | 1078 | if (net_debug > 1) printk("%s: Attempting AUI\n", dev->name); |
1154 | control_dc_dc(dev, 0); | 1079 | control_dc_dc(dev, 0); |
1155 | 1080 | ||
1156 | writereg(dev, PP_LineCTL, (lp->linectl &~ AUTO_AUI_10BASET) | AUI_ONLY); | 1081 | writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY); |
1157 | 1082 | ||
1158 | if (send_test_pkt(dev)) | 1083 | if (send_test_pkt(dev)) |
1159 | return DETECTED_AUI; | 1084 | return DETECTED_AUI; |
@@ -1169,7 +1094,7 @@ detect_bnc(struct net_device *dev) | |||
1169 | if (net_debug > 1) printk("%s: Attempting BNC\n", dev->name); | 1094 | if (net_debug > 1) printk("%s: Attempting BNC\n", dev->name); |
1170 | control_dc_dc(dev, 1); | 1095 | control_dc_dc(dev, 1); |
1171 | 1096 | ||
1172 | writereg(dev, PP_LineCTL, (lp->linectl &~ AUTO_AUI_10BASET) | AUI_ONLY); | 1097 | writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY); |
1173 | 1098 | ||
1174 | if (send_test_pkt(dev)) | 1099 | if (send_test_pkt(dev)) |
1175 | return DETECTED_BNC; | 1100 | return DETECTED_BNC; |
@@ -1208,7 +1133,7 @@ write_irq(struct net_device *dev, int chip_type, int irq) | |||
1208 | This routine should set everything up anew at each open, even | 1133 | This routine should set everything up anew at each open, even |
1209 | registers that "should" only need to be set once at boot, so that | 1134 | registers that "should" only need to be set once at boot, so that |
1210 | there is non-reboot way to recover if something goes wrong. | 1135 | there is non-reboot way to recover if something goes wrong. |
1211 | */ | 1136 | */ |
1212 | 1137 | ||
1213 | /* AKPM: do we need to do any locking here? */ | 1138 | /* AKPM: do we need to do any locking here? */ |
1214 | 1139 | ||
@@ -1224,7 +1149,7 @@ net_open(struct net_device *dev) | |||
1224 | /* Allow interrupts to be generated by the chip */ | 1149 | /* Allow interrupts to be generated by the chip */ |
1225 | /* Cirrus' release had this: */ | 1150 | /* Cirrus' release had this: */ |
1226 | #if 0 | 1151 | #if 0 |
1227 | writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL)|ENABLE_IRQ ); | 1152 | writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL) | ENABLE_IRQ); |
1228 | #endif | 1153 | #endif |
1229 | /* And 2.3.47 had this: */ | 1154 | /* And 2.3.47 had this: */ |
1230 | writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON); | 1155 | writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON); |
@@ -1252,13 +1177,13 @@ net_open(struct net_device *dev) | |||
1252 | #if !defined(CS89x0_NONISA_IRQ) && !defined(CONFIG_CS89x0_PLATFORM) | 1177 | #if !defined(CS89x0_NONISA_IRQ) && !defined(CONFIG_CS89x0_PLATFORM) |
1253 | if (((1 << dev->irq) & lp->irq_map) == 0) { | 1178 | if (((1 << dev->irq) & lp->irq_map) == 0) { |
1254 | printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n", | 1179 | printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n", |
1255 | dev->name, dev->irq, lp->irq_map); | 1180 | dev->name, dev->irq, lp->irq_map); |
1256 | ret = -EAGAIN; | 1181 | ret = -EAGAIN; |
1257 | goto bad_out; | 1182 | goto bad_out; |
1258 | } | 1183 | } |
1259 | #endif | 1184 | #endif |
1260 | /* FIXME: Cirrus' release had this: */ | 1185 | /* FIXME: Cirrus' release had this: */ |
1261 | writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL)|ENABLE_IRQ ); | 1186 | writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL)|ENABLE_IRQ); |
1262 | /* And 2.3.47 had this: */ | 1187 | /* And 2.3.47 had this: */ |
1263 | #if 0 | 1188 | #if 0 |
1264 | writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON); | 1189 | writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON); |
@@ -1276,17 +1201,17 @@ net_open(struct net_device *dev) | |||
1276 | if (lp->isa_config & ANY_ISA_DMA) { | 1201 | if (lp->isa_config & ANY_ISA_DMA) { |
1277 | unsigned long flags; | 1202 | unsigned long flags; |
1278 | lp->dma_buff = (unsigned char *)__get_dma_pages(GFP_KERNEL, | 1203 | lp->dma_buff = (unsigned char *)__get_dma_pages(GFP_KERNEL, |
1279 | get_order(lp->dmasize * 1024)); | 1204 | get_order(lp->dmasize * 1024)); |
1280 | 1205 | ||
1281 | if (!lp->dma_buff) { | 1206 | if (!lp->dma_buff) { |
1282 | printk(KERN_ERR "%s: cannot get %dK memory for DMA\n", dev->name, lp->dmasize); | 1207 | printk(KERN_ERR "%s: cannot get %dK memory for DMA\n", dev->name, lp->dmasize); |
1283 | goto release_irq; | 1208 | goto release_irq; |
1284 | } | 1209 | } |
1285 | if (net_debug > 1) { | 1210 | if (net_debug > 1) { |
1286 | printk( "%s: dma %lx %lx\n", | 1211 | printk("%s: dma %lx %lx\n", |
1287 | dev->name, | 1212 | dev->name, |
1288 | (unsigned long)lp->dma_buff, | 1213 | (unsigned long)lp->dma_buff, |
1289 | (unsigned long)isa_virt_to_bus(lp->dma_buff)); | 1214 | (unsigned long)isa_virt_to_bus(lp->dma_buff)); |
1290 | } | 1215 | } |
1291 | if ((unsigned long) lp->dma_buff >= MAX_DMA_ADDRESS || | 1216 | if ((unsigned long) lp->dma_buff >= MAX_DMA_ADDRESS || |
1292 | !dma_page_eq(lp->dma_buff, lp->dma_buff+lp->dmasize*1024-1)) { | 1217 | !dma_page_eq(lp->dma_buff, lp->dma_buff+lp->dmasize*1024-1)) { |
@@ -1314,64 +1239,64 @@ net_open(struct net_device *dev) | |||
1314 | #endif /* ALLOW_DMA */ | 1239 | #endif /* ALLOW_DMA */ |
1315 | 1240 | ||
1316 | /* set the Ethernet address */ | 1241 | /* set the Ethernet address */ |
1317 | for (i=0; i < ETH_ALEN/2; i++) | 1242 | for (i = 0; i < ETH_ALEN / 2; i++) |
1318 | writereg(dev, PP_IA+i*2, dev->dev_addr[i*2] | (dev->dev_addr[i*2+1] << 8)); | 1243 | writereg(dev, PP_IA + i * 2, dev->dev_addr[i * 2] | (dev->dev_addr[i * 2 + 1] << 8)); |
1319 | 1244 | ||
1320 | /* while we're testing the interface, leave interrupts disabled */ | 1245 | /* while we're testing the interface, leave interrupts disabled */ |
1321 | writereg(dev, PP_BusCTL, MEMORY_ON); | 1246 | writereg(dev, PP_BusCTL, MEMORY_ON); |
1322 | 1247 | ||
1323 | /* Set the LineCTL quintuplet based on adapter configuration read from EEPROM */ | 1248 | /* Set the LineCTL quintuplet based on adapter configuration read from EEPROM */ |
1324 | if ((lp->adapter_cnf & A_CNF_EXTND_10B_2) && (lp->adapter_cnf & A_CNF_LOW_RX_SQUELCH)) | 1249 | if ((lp->adapter_cnf & A_CNF_EXTND_10B_2) && (lp->adapter_cnf & A_CNF_LOW_RX_SQUELCH)) |
1325 | lp->linectl = LOW_RX_SQUELCH; | 1250 | lp->linectl = LOW_RX_SQUELCH; |
1326 | else | 1251 | else |
1327 | lp->linectl = 0; | 1252 | lp->linectl = 0; |
1328 | 1253 | ||
1329 | /* check to make sure that they have the "right" hardware available */ | 1254 | /* check to make sure that they have the "right" hardware available */ |
1330 | switch(lp->adapter_cnf & A_CNF_MEDIA_TYPE) { | 1255 | switch (lp->adapter_cnf & A_CNF_MEDIA_TYPE) { |
1331 | case A_CNF_MEDIA_10B_T: result = lp->adapter_cnf & A_CNF_10B_T; break; | 1256 | case A_CNF_MEDIA_10B_T: result = lp->adapter_cnf & A_CNF_10B_T; break; |
1332 | case A_CNF_MEDIA_AUI: result = lp->adapter_cnf & A_CNF_AUI; break; | 1257 | case A_CNF_MEDIA_AUI: result = lp->adapter_cnf & A_CNF_AUI; break; |
1333 | case A_CNF_MEDIA_10B_2: result = lp->adapter_cnf & A_CNF_10B_2; break; | 1258 | case A_CNF_MEDIA_10B_2: result = lp->adapter_cnf & A_CNF_10B_2; break; |
1334 | default: result = lp->adapter_cnf & (A_CNF_10B_T | A_CNF_AUI | A_CNF_10B_2); | 1259 | default: result = lp->adapter_cnf & (A_CNF_10B_T | A_CNF_AUI | A_CNF_10B_2); |
1335 | } | 1260 | } |
1336 | if (!result) { | 1261 | if (!result) { |
1337 | printk(KERN_ERR "%s: EEPROM is configured for unavailable media\n", dev->name); | 1262 | printk(KERN_ERR "%s: EEPROM is configured for unavailable media\n", dev->name); |
1338 | release_dma: | 1263 | release_dma: |
1339 | #if ALLOW_DMA | 1264 | #if ALLOW_DMA |
1340 | free_dma(dev->dma); | 1265 | free_dma(dev->dma); |
1341 | release_irq: | 1266 | release_irq: |
1342 | release_dma_buff(lp); | 1267 | release_dma_buff(lp); |
1343 | #endif | 1268 | #endif |
1344 | writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) & ~(SERIAL_TX_ON | SERIAL_RX_ON)); | 1269 | writereg(dev, PP_LineCTL, readreg(dev, PP_LineCTL) & ~(SERIAL_TX_ON | SERIAL_RX_ON)); |
1345 | free_irq(dev->irq, dev); | 1270 | free_irq(dev->irq, dev); |
1346 | ret = -EAGAIN; | 1271 | ret = -EAGAIN; |
1347 | goto bad_out; | 1272 | goto bad_out; |
1348 | } | 1273 | } |
1349 | 1274 | ||
1350 | /* set the hardware to the configured choice */ | 1275 | /* set the hardware to the configured choice */ |
1351 | switch(lp->adapter_cnf & A_CNF_MEDIA_TYPE) { | 1276 | switch (lp->adapter_cnf & A_CNF_MEDIA_TYPE) { |
1352 | case A_CNF_MEDIA_10B_T: | 1277 | case A_CNF_MEDIA_10B_T: |
1353 | result = detect_tp(dev); | 1278 | result = detect_tp(dev); |
1354 | if (result==DETECTED_NONE) { | 1279 | if (result == DETECTED_NONE) { |
1355 | printk(KERN_WARNING "%s: 10Base-T (RJ-45) has no cable\n", dev->name); | 1280 | printk(KERN_WARNING "%s: 10Base-T (RJ-45) has no cable\n", dev->name); |
1356 | if (lp->auto_neg_cnf & IMM_BIT) /* check "ignore missing media" bit */ | 1281 | if (lp->auto_neg_cnf & IMM_BIT) /* check "ignore missing media" bit */ |
1357 | result = DETECTED_RJ45H; /* Yes! I don't care if I see a link pulse */ | 1282 | result = DETECTED_RJ45H; /* Yes! I don't care if I see a link pulse */ |
1358 | } | 1283 | } |
1359 | break; | 1284 | break; |
1360 | case A_CNF_MEDIA_AUI: | 1285 | case A_CNF_MEDIA_AUI: |
1361 | result = detect_aui(dev); | 1286 | result = detect_aui(dev); |
1362 | if (result==DETECTED_NONE) { | 1287 | if (result == DETECTED_NONE) { |
1363 | printk(KERN_WARNING "%s: 10Base-5 (AUI) has no cable\n", dev->name); | 1288 | printk(KERN_WARNING "%s: 10Base-5 (AUI) has no cable\n", dev->name); |
1364 | if (lp->auto_neg_cnf & IMM_BIT) /* check "ignore missing media" bit */ | 1289 | if (lp->auto_neg_cnf & IMM_BIT) /* check "ignore missing media" bit */ |
1365 | result = DETECTED_AUI; /* Yes! I don't care if I see a carrrier */ | 1290 | result = DETECTED_AUI; /* Yes! I don't care if I see a carrrier */ |
1366 | } | 1291 | } |
1367 | break; | 1292 | break; |
1368 | case A_CNF_MEDIA_10B_2: | 1293 | case A_CNF_MEDIA_10B_2: |
1369 | result = detect_bnc(dev); | 1294 | result = detect_bnc(dev); |
1370 | if (result==DETECTED_NONE) { | 1295 | if (result == DETECTED_NONE) { |
1371 | printk(KERN_WARNING "%s: 10Base-2 (BNC) has no cable\n", dev->name); | 1296 | printk(KERN_WARNING "%s: 10Base-2 (BNC) has no cable\n", dev->name); |
1372 | if (lp->auto_neg_cnf & IMM_BIT) /* check "ignore missing media" bit */ | 1297 | if (lp->auto_neg_cnf & IMM_BIT) /* check "ignore missing media" bit */ |
1373 | result = DETECTED_BNC; /* Yes! I don't care if I can xmit a packet */ | 1298 | result = DETECTED_BNC; /* Yes! I don't care if I can xmit a packet */ |
1374 | } | 1299 | } |
1375 | break; | 1300 | break; |
1376 | case A_CNF_MEDIA_AUTO: | 1301 | case A_CNF_MEDIA_AUTO: |
1377 | writereg(dev, PP_LineCTL, lp->linectl | AUTO_AUI_10BASET); | 1302 | writereg(dev, PP_LineCTL, lp->linectl | AUTO_AUI_10BASET); |
@@ -1387,7 +1312,7 @@ release_irq: | |||
1387 | printk(KERN_ERR "%s: no media detected\n", dev->name); | 1312 | printk(KERN_ERR "%s: no media detected\n", dev->name); |
1388 | goto release_dma; | 1313 | goto release_dma; |
1389 | } | 1314 | } |
1390 | switch(result) { | 1315 | switch (result) { |
1391 | case DETECTED_NONE: | 1316 | case DETECTED_NONE: |
1392 | printk(KERN_ERR "%s: no network cable attached to configured media\n", dev->name); | 1317 | printk(KERN_ERR "%s: no network cable attached to configured media\n", dev->name); |
1393 | goto release_dma; | 1318 | goto release_dma; |
@@ -1422,22 +1347,22 @@ release_irq: | |||
1422 | writereg(dev, PP_RxCFG, lp->curr_rx_cfg); | 1347 | writereg(dev, PP_RxCFG, lp->curr_rx_cfg); |
1423 | 1348 | ||
1424 | writereg(dev, PP_TxCFG, TX_LOST_CRS_ENBL | TX_SQE_ERROR_ENBL | TX_OK_ENBL | | 1349 | writereg(dev, PP_TxCFG, TX_LOST_CRS_ENBL | TX_SQE_ERROR_ENBL | TX_OK_ENBL | |
1425 | TX_LATE_COL_ENBL | TX_JBR_ENBL | TX_ANY_COL_ENBL | TX_16_COL_ENBL); | 1350 | TX_LATE_COL_ENBL | TX_JBR_ENBL | TX_ANY_COL_ENBL | TX_16_COL_ENBL); |
1426 | 1351 | ||
1427 | writereg(dev, PP_BufCFG, READY_FOR_TX_ENBL | RX_MISS_COUNT_OVRFLOW_ENBL | | 1352 | writereg(dev, PP_BufCFG, READY_FOR_TX_ENBL | RX_MISS_COUNT_OVRFLOW_ENBL | |
1428 | #if ALLOW_DMA | 1353 | #if ALLOW_DMA |
1429 | dma_bufcfg(dev) | | 1354 | dma_bufcfg(dev) | |
1430 | #endif | 1355 | #endif |
1431 | TX_COL_COUNT_OVRFLOW_ENBL | TX_UNDERRUN_ENBL); | 1356 | TX_COL_COUNT_OVRFLOW_ENBL | TX_UNDERRUN_ENBL); |
1432 | 1357 | ||
1433 | /* now that we've got our act together, enable everything */ | 1358 | /* now that we've got our act together, enable everything */ |
1434 | writereg(dev, PP_BusCTL, ENABLE_IRQ | 1359 | writereg(dev, PP_BusCTL, ENABLE_IRQ |
1435 | | (dev->mem_start?MEMORY_ON : 0) /* turn memory on */ | 1360 | | (dev->mem_start ? MEMORY_ON : 0) /* turn memory on */ |
1436 | #if ALLOW_DMA | 1361 | #if ALLOW_DMA |
1437 | | dma_busctl(dev) | 1362 | | dma_busctl(dev) |
1438 | #endif | 1363 | #endif |
1439 | ); | 1364 | ); |
1440 | netif_start_queue(dev); | 1365 | netif_start_queue(dev); |
1441 | if (net_debug > 1) | 1366 | if (net_debug > 1) |
1442 | printk("cs89x0: net_open() succeeded\n"); | 1367 | printk("cs89x0: net_open() succeeded\n"); |
1443 | return 0; | 1368 | return 0; |
@@ -1450,25 +1375,25 @@ static void net_timeout(struct net_device *dev) | |||
1450 | /* If we get here, some higher level has decided we are broken. | 1375 | /* If we get here, some higher level has decided we are broken. |
1451 | There should really be a "kick me" function call instead. */ | 1376 | There should really be a "kick me" function call instead. */ |
1452 | if (net_debug > 0) printk("%s: transmit timed out, %s?\n", dev->name, | 1377 | if (net_debug > 0) printk("%s: transmit timed out, %s?\n", dev->name, |
1453 | tx_done(dev) ? "IRQ conflict ?" : "network cable problem"); | 1378 | tx_done(dev) ? "IRQ conflict ?" : "network cable problem"); |
1454 | /* Try to restart the adaptor. */ | 1379 | /* Try to restart the adaptor. */ |
1455 | netif_wake_queue(dev); | 1380 | netif_wake_queue(dev); |
1456 | } | 1381 | } |
1457 | 1382 | ||
1458 | static netdev_tx_t net_send_packet(struct sk_buff *skb,struct net_device *dev) | 1383 | static netdev_tx_t net_send_packet(struct sk_buff *skb, struct net_device *dev) |
1459 | { | 1384 | { |
1460 | struct net_local *lp = netdev_priv(dev); | 1385 | struct net_local *lp = netdev_priv(dev); |
1461 | unsigned long flags; | 1386 | unsigned long flags; |
1462 | 1387 | ||
1463 | if (net_debug > 3) { | 1388 | if (net_debug > 3) { |
1464 | printk("%s: sent %d byte packet of type %x\n", | 1389 | printk("%s: sent %d byte packet of type %x\n", |
1465 | dev->name, skb->len, | 1390 | dev->name, skb->len, |
1466 | (skb->data[ETH_ALEN+ETH_ALEN] << 8) | skb->data[ETH_ALEN+ETH_ALEN+1]); | 1391 | (skb->data[ETH_ALEN + ETH_ALEN] << 8) | skb->data[ETH_ALEN + ETH_ALEN + 1]); |
1467 | } | 1392 | } |
1468 | 1393 | ||
1469 | /* keep the upload from being interrupted, since we | 1394 | /* keep the upload from being interrupted, since we |
1470 | ask the chip to start transmitting before the | 1395 | ask the chip to start transmitting before the |
1471 | whole packet has been completely uploaded. */ | 1396 | whole packet has been completely uploaded. */ |
1472 | 1397 | ||
1473 | spin_lock_irqsave(&lp->lock, flags); | 1398 | spin_lock_irqsave(&lp->lock, flags); |
1474 | netif_stop_queue(dev); | 1399 | netif_stop_queue(dev); |
@@ -1479,8 +1404,7 @@ static netdev_tx_t net_send_packet(struct sk_buff *skb,struct net_device *dev) | |||
1479 | 1404 | ||
1480 | /* Test to see if the chip has allocated memory for the packet */ | 1405 | /* Test to see if the chip has allocated memory for the packet */ |
1481 | if ((readreg(dev, PP_BusST) & READY_FOR_TX_NOW) == 0) { | 1406 | if ((readreg(dev, PP_BusST) & READY_FOR_TX_NOW) == 0) { |
1482 | /* | 1407 | /* Gasp! It hasn't. But that shouldn't happen since |
1483 | * Gasp! It hasn't. But that shouldn't happen since | ||
1484 | * we're waiting for TxOk, so return 1 and requeue this packet. | 1408 | * we're waiting for TxOk, so return 1 and requeue this packet. |
1485 | */ | 1409 | */ |
1486 | 1410 | ||
@@ -1492,10 +1416,9 @@ static netdev_tx_t net_send_packet(struct sk_buff *skb,struct net_device *dev) | |||
1492 | writewords(lp, TX_FRAME_PORT, skb->data, (skb->len+1) >> 1); | 1416 | writewords(lp, TX_FRAME_PORT, skb->data, (skb->len+1) >> 1); |
1493 | spin_unlock_irqrestore(&lp->lock, flags); | 1417 | spin_unlock_irqrestore(&lp->lock, flags); |
1494 | dev->stats.tx_bytes += skb->len; | 1418 | dev->stats.tx_bytes += skb->len; |
1495 | dev_kfree_skb (skb); | 1419 | dev_kfree_skb(skb); |
1496 | 1420 | ||
1497 | /* | 1421 | /* We DO NOT call netif_wake_queue() here. |
1498 | * We DO NOT call netif_wake_queue() here. | ||
1499 | * We also DO NOT call netif_start_queue(). | 1422 | * We also DO NOT call netif_start_queue(). |
1500 | * | 1423 | * |
1501 | * Either of these would cause another bottom half run through | 1424 | * Either of these would cause another bottom half run through |
@@ -1509,28 +1432,30 @@ static netdev_tx_t net_send_packet(struct sk_buff *skb,struct net_device *dev) | |||
1509 | } | 1432 | } |
1510 | 1433 | ||
1511 | /* The typical workload of the driver: | 1434 | /* The typical workload of the driver: |
1512 | Handle the network interface interrupts. */ | 1435 | * Handle the network interface interrupts. |
1436 | */ | ||
1513 | 1437 | ||
1514 | static irqreturn_t net_interrupt(int irq, void *dev_id) | 1438 | static irqreturn_t net_interrupt(int irq, void *dev_id) |
1515 | { | 1439 | { |
1516 | struct net_device *dev = dev_id; | 1440 | struct net_device *dev = dev_id; |
1517 | struct net_local *lp; | 1441 | struct net_local *lp; |
1518 | int status; | 1442 | int status; |
1519 | int handled = 0; | 1443 | int handled = 0; |
1520 | 1444 | ||
1521 | lp = netdev_priv(dev); | 1445 | lp = netdev_priv(dev); |
1522 | 1446 | ||
1523 | /* we MUST read all the events out of the ISQ, otherwise we'll never | 1447 | /* we MUST read all the events out of the ISQ, otherwise we'll never |
1524 | get interrupted again. As a consequence, we can't have any limit | 1448 | * get interrupted again. As a consequence, we can't have any limit |
1525 | on the number of times we loop in the interrupt handler. The | 1449 | * on the number of times we loop in the interrupt handler. The |
1526 | hardware guarantees that eventually we'll run out of events. Of | 1450 | * hardware guarantees that eventually we'll run out of events. Of |
1527 | course, if you're on a slow machine, and packets are arriving | 1451 | * course, if you're on a slow machine, and packets are arriving |
1528 | faster than you can read them off, you're screwed. Hasta la | 1452 | * faster than you can read them off, you're screwed. Hasta la |
1529 | vista, baby! */ | 1453 | * vista, baby! |
1454 | */ | ||
1530 | while ((status = ioread16(lp->virt_addr + ISQ_PORT))) { | 1455 | while ((status = ioread16(lp->virt_addr + ISQ_PORT))) { |
1531 | if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status); | 1456 | if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status); |
1532 | handled = 1; | 1457 | handled = 1; |
1533 | switch(status & ISQ_EVENT_MASK) { | 1458 | switch (status & ISQ_EVENT_MASK) { |
1534 | case ISQ_RECEIVER_EVENT: | 1459 | case ISQ_RECEIVER_EVENT: |
1535 | /* Got a packet(s). */ | 1460 | /* Got a packet(s). */ |
1536 | net_rx(dev); | 1461 | net_rx(dev); |
@@ -1538,11 +1463,11 @@ static irqreturn_t net_interrupt(int irq, void *dev_id) | |||
1538 | case ISQ_TRANSMITTER_EVENT: | 1463 | case ISQ_TRANSMITTER_EVENT: |
1539 | dev->stats.tx_packets++; | 1464 | dev->stats.tx_packets++; |
1540 | netif_wake_queue(dev); /* Inform upper layers. */ | 1465 | netif_wake_queue(dev); /* Inform upper layers. */ |
1541 | if ((status & ( TX_OK | | 1466 | if ((status & (TX_OK | |
1542 | TX_LOST_CRS | | 1467 | TX_LOST_CRS | |
1543 | TX_SQE_ERROR | | 1468 | TX_SQE_ERROR | |
1544 | TX_LATE_COL | | 1469 | TX_LATE_COL | |
1545 | TX_16_COL)) != TX_OK) { | 1470 | TX_16_COL)) != TX_OK) { |
1546 | if ((status & TX_OK) == 0) | 1471 | if ((status & TX_OK) == 0) |
1547 | dev->stats.tx_errors++; | 1472 | dev->stats.tx_errors++; |
1548 | if (status & TX_LOST_CRS) | 1473 | if (status & TX_LOST_CRS) |
@@ -1558,31 +1483,33 @@ static irqreturn_t net_interrupt(int irq, void *dev_id) | |||
1558 | case ISQ_BUFFER_EVENT: | 1483 | case ISQ_BUFFER_EVENT: |
1559 | if (status & READY_FOR_TX) { | 1484 | if (status & READY_FOR_TX) { |
1560 | /* we tried to transmit a packet earlier, | 1485 | /* we tried to transmit a packet earlier, |
1561 | but inexplicably ran out of buffers. | 1486 | * but inexplicably ran out of buffers. |
1562 | That shouldn't happen since we only ever | 1487 | * That shouldn't happen since we only ever |
1563 | load one packet. Shrug. Do the right | 1488 | * load one packet. Shrug. Do the right |
1564 | thing anyway. */ | 1489 | * thing anyway. |
1490 | */ | ||
1565 | netif_wake_queue(dev); /* Inform upper layers. */ | 1491 | netif_wake_queue(dev); /* Inform upper layers. */ |
1566 | } | 1492 | } |
1567 | if (status & TX_UNDERRUN) { | 1493 | if (status & TX_UNDERRUN) { |
1568 | if (net_debug > 0) printk("%s: transmit underrun\n", dev->name); | 1494 | if (net_debug > 0) printk("%s: transmit underrun\n", dev->name); |
1569 | lp->send_underrun++; | 1495 | lp->send_underrun++; |
1570 | if (lp->send_underrun == 3) lp->send_cmd = TX_AFTER_381; | 1496 | if (lp->send_underrun == 3) lp->send_cmd = TX_AFTER_381; |
1571 | else if (lp->send_underrun == 6) lp->send_cmd = TX_AFTER_ALL; | 1497 | else if (lp->send_underrun == 6) lp->send_cmd = TX_AFTER_ALL; |
1572 | /* transmit cycle is done, although | 1498 | /* transmit cycle is done, although |
1573 | frame wasn't transmitted - this | 1499 | * frame wasn't transmitted - this |
1574 | avoids having to wait for the upper | 1500 | * avoids having to wait for the upper |
1575 | layers to timeout on us, in the | 1501 | * layers to timeout on us, in the |
1576 | event of a tx underrun */ | 1502 | * event of a tx underrun |
1503 | */ | ||
1577 | netif_wake_queue(dev); /* Inform upper layers. */ | 1504 | netif_wake_queue(dev); /* Inform upper layers. */ |
1578 | } | 1505 | } |
1579 | #if ALLOW_DMA | 1506 | #if ALLOW_DMA |
1580 | if (lp->use_dma && (status & RX_DMA)) { | 1507 | if (lp->use_dma && (status & RX_DMA)) { |
1581 | int count = readreg(dev, PP_DmaFrameCnt); | 1508 | int count = readreg(dev, PP_DmaFrameCnt); |
1582 | while(count) { | 1509 | while (count) { |
1583 | if (net_debug > 5) | 1510 | if (net_debug > 5) |
1584 | printk("%s: receiving %d DMA frames\n", dev->name, count); | 1511 | printk("%s: receiving %d DMA frames\n", dev->name, count); |
1585 | if (net_debug > 2 && count >1) | 1512 | if (net_debug > 2 && count > 1) |
1586 | printk("%s: receiving %d DMA frames\n", dev->name, count); | 1513 | printk("%s: receiving %d DMA frames\n", dev->name, count); |
1587 | dma_rx(dev); | 1514 | dma_rx(dev); |
1588 | if (--count == 0) | 1515 | if (--count == 0) |
@@ -1651,12 +1578,12 @@ net_rx(struct net_device *dev) | |||
1651 | skb->data[length-1] = ioread16(lp->virt_addr + RX_FRAME_PORT); | 1578 | skb->data[length-1] = ioread16(lp->virt_addr + RX_FRAME_PORT); |
1652 | 1579 | ||
1653 | if (net_debug > 3) { | 1580 | if (net_debug > 3) { |
1654 | printk( "%s: received %d byte packet of type %x\n", | 1581 | printk("%s: received %d byte packet of type %x\n", |
1655 | dev->name, length, | 1582 | dev->name, length, |
1656 | (skb->data[ETH_ALEN+ETH_ALEN] << 8) | skb->data[ETH_ALEN+ETH_ALEN+1]); | 1583 | (skb->data[ETH_ALEN + ETH_ALEN] << 8) | skb->data[ETH_ALEN + ETH_ALEN + 1]); |
1657 | } | 1584 | } |
1658 | 1585 | ||
1659 | skb->protocol=eth_type_trans(skb,dev); | 1586 | skb->protocol = eth_type_trans(skb, dev); |
1660 | netif_rx(skb); | 1587 | netif_rx(skb); |
1661 | dev->stats.rx_packets++; | 1588 | dev->stats.rx_packets++; |
1662 | dev->stats.rx_bytes += length; | 1589 | dev->stats.rx_bytes += length; |
@@ -1700,8 +1627,9 @@ net_close(struct net_device *dev) | |||
1700 | return 0; | 1627 | return 0; |
1701 | } | 1628 | } |
1702 | 1629 | ||
1703 | /* Get the current statistics. This may be called with the card open or | 1630 | /* Get the current statistics. |
1704 | closed. */ | 1631 | * This may be called with the card open or closed. |
1632 | */ | ||
1705 | static struct net_device_stats * | 1633 | static struct net_device_stats * |
1706 | net_get_stats(struct net_device *dev) | 1634 | net_get_stats(struct net_device *dev) |
1707 | { | 1635 | { |
@@ -1723,7 +1651,7 @@ static void set_multicast_list(struct net_device *dev) | |||
1723 | unsigned long flags; | 1651 | unsigned long flags; |
1724 | 1652 | ||
1725 | spin_lock_irqsave(&lp->lock, flags); | 1653 | spin_lock_irqsave(&lp->lock, flags); |
1726 | if(dev->flags&IFF_PROMISC) | 1654 | if (dev->flags&IFF_PROMISC) |
1727 | { | 1655 | { |
1728 | lp->rx_mode = RX_ALL_ACCEPT; | 1656 | lp->rx_mode = RX_ALL_ACCEPT; |
1729 | } | 1657 | } |
@@ -1740,7 +1668,7 @@ static void set_multicast_list(struct net_device *dev) | |||
1740 | 1668 | ||
1741 | /* in promiscuous mode, we accept errored packets, so we have to enable interrupts on them also */ | 1669 | /* in promiscuous mode, we accept errored packets, so we have to enable interrupts on them also */ |
1742 | writereg(dev, PP_RxCFG, lp->curr_rx_cfg | | 1670 | writereg(dev, PP_RxCFG, lp->curr_rx_cfg | |
1743 | (lp->rx_mode == RX_ALL_ACCEPT? (RX_CRC_ERROR_ENBL|RX_RUNT_ENBL|RX_EXTRA_DATA_ENBL) : 0)); | 1671 | (lp->rx_mode == RX_ALL_ACCEPT ? (RX_CRC_ERROR_ENBL|RX_RUNT_ENBL|RX_EXTRA_DATA_ENBL) : 0)); |
1744 | spin_unlock_irqrestore(&lp->lock, flags); | 1672 | spin_unlock_irqrestore(&lp->lock, flags); |
1745 | } | 1673 | } |
1746 | 1674 | ||
@@ -1760,8 +1688,8 @@ static int set_mac_address(struct net_device *dev, void *p) | |||
1760 | dev->name, dev->dev_addr); | 1688 | dev->name, dev->dev_addr); |
1761 | 1689 | ||
1762 | /* set the Ethernet address */ | 1690 | /* set the Ethernet address */ |
1763 | for (i=0; i < ETH_ALEN/2; i++) | 1691 | for (i = 0; i < ETH_ALEN / 2; i++) |
1764 | writereg(dev, PP_IA+i*2, dev->dev_addr[i*2] | (dev->dev_addr[i*2+1] << 8)); | 1692 | writereg(dev, PP_IA + i * 2, dev->dev_addr[i * 2] | (dev->dev_addr[i * 2 + 1] << 8)); |
1765 | 1693 | ||
1766 | return 0; | 1694 | return 0; |
1767 | } | 1695 | } |
@@ -1770,8 +1698,7 @@ static int set_mac_address(struct net_device *dev, void *p) | |||
1770 | 1698 | ||
1771 | static struct net_device *dev_cs89x0; | 1699 | static struct net_device *dev_cs89x0; |
1772 | 1700 | ||
1773 | /* | 1701 | /* Support the 'debug' module parm even if we're compiled for non-debug to |
1774 | * Support the 'debug' module parm even if we're compiled for non-debug to | ||
1775 | * avoid breaking someone's startup scripts | 1702 | * avoid breaking someone's startup scripts |
1776 | */ | 1703 | */ |
1777 | 1704 | ||
@@ -1779,11 +1706,11 @@ static int io; | |||
1779 | static int irq; | 1706 | static int irq; |
1780 | static int debug; | 1707 | static int debug; |
1781 | static char media[8]; | 1708 | static char media[8]; |
1782 | static int duplex=-1; | 1709 | static int duplex = -1; |
1783 | 1710 | ||
1784 | static int use_dma; /* These generate unused var warnings if ALLOW_DMA = 0 */ | 1711 | static int use_dma; /* These generate unused var warnings if ALLOW_DMA = 0 */ |
1785 | static int dma; | 1712 | static int dma; |
1786 | static int dmasize=16; /* or 64 */ | 1713 | static int dmasize = 16; /* or 64 */ |
1787 | 1714 | ||
1788 | module_param(io, int, 0); | 1715 | module_param(io, int, 0); |
1789 | module_param(irq, int, 0); | 1716 | module_param(irq, int, 0); |
@@ -1816,32 +1743,28 @@ MODULE_PARM_DESC(use_dma , "(ignored)"); | |||
1816 | MODULE_AUTHOR("Mike Cruse, Russwll Nelson <nelson@crynwr.com>, Andrew Morton"); | 1743 | MODULE_AUTHOR("Mike Cruse, Russwll Nelson <nelson@crynwr.com>, Andrew Morton"); |
1817 | MODULE_LICENSE("GPL"); | 1744 | MODULE_LICENSE("GPL"); |
1818 | 1745 | ||
1819 | |||
1820 | /* | 1746 | /* |
1821 | * media=t - specify media type | 1747 | * media=t - specify media type |
1822 | or media=2 | 1748 | * or media=2 |
1823 | or media=aui | 1749 | * or media=aui |
1824 | or medai=auto | 1750 | * or medai=auto |
1825 | * duplex=0 - specify forced half/full/autonegotiate duplex | 1751 | * duplex=0 - specify forced half/full/autonegotiate duplex |
1826 | * debug=# - debug level | 1752 | * debug=# - debug level |
1827 | 1753 | * | |
1828 | 1754 | * Default Chip Configuration: | |
1829 | * Default Chip Configuration: | 1755 | * DMA Burst = enabled |
1830 | * DMA Burst = enabled | 1756 | * IOCHRDY Enabled = enabled |
1831 | * IOCHRDY Enabled = enabled | 1757 | * UseSA = enabled |
1832 | * UseSA = enabled | 1758 | * CS8900 defaults to half-duplex if not specified on command-line |
1833 | * CS8900 defaults to half-duplex if not specified on command-line | 1759 | * CS8920 defaults to autoneg if not specified on command-line |
1834 | * CS8920 defaults to autoneg if not specified on command-line | 1760 | * Use reset defaults for other config parameters |
1835 | * Use reset defaults for other config parameters | 1761 | * |
1836 | 1762 | * Assumptions: | |
1837 | * Assumptions: | 1763 | * media type specified is supported (circuitry is present) |
1838 | * media type specified is supported (circuitry is present) | 1764 | * if memory address is > 1MB, then required mem decode hw is present |
1839 | * if memory address is > 1MB, then required mem decode hw is present | 1765 | * if 10B-2, then agent other than driver will enable DC/DC converter |
1840 | * if 10B-2, then agent other than driver will enable DC/DC converter | 1766 | * (hw or software util) |
1841 | (hw or software util) | 1767 | */ |
1842 | |||
1843 | |||
1844 | */ | ||
1845 | 1768 | ||
1846 | int __init init_module(void) | 1769 | int __init init_module(void) |
1847 | { | 1770 | { |
@@ -1871,8 +1794,8 @@ int __init init_module(void) | |||
1871 | 1794 | ||
1872 | spin_lock_init(&lp->lock); | 1795 | spin_lock_init(&lp->lock); |
1873 | 1796 | ||
1874 | /* boy, they'd better get these right */ | 1797 | /* boy, they'd better get these right */ |
1875 | if (!strcmp(media, "rj45")) | 1798 | if (!strcmp(media, "rj45")) |
1876 | lp->adapter_cnf = A_CNF_MEDIA_10B_T | A_CNF_10B_T; | 1799 | lp->adapter_cnf = A_CNF_MEDIA_10B_T | A_CNF_10B_T; |
1877 | else if (!strcmp(media, "aui")) | 1800 | else if (!strcmp(media, "aui")) |
1878 | lp->adapter_cnf = A_CNF_MEDIA_AUI | A_CNF_AUI; | 1801 | lp->adapter_cnf = A_CNF_MEDIA_AUI | A_CNF_AUI; |
@@ -1881,15 +1804,15 @@ int __init init_module(void) | |||
1881 | else | 1804 | else |
1882 | lp->adapter_cnf = A_CNF_MEDIA_10B_T | A_CNF_10B_T; | 1805 | lp->adapter_cnf = A_CNF_MEDIA_10B_T | A_CNF_10B_T; |
1883 | 1806 | ||
1884 | if (duplex==-1) | 1807 | if (duplex == -1) |
1885 | lp->auto_neg_cnf = AUTO_NEG_ENABLE; | 1808 | lp->auto_neg_cnf = AUTO_NEG_ENABLE; |
1886 | 1809 | ||
1887 | if (io == 0) { | 1810 | if (io == 0) { |
1888 | printk(KERN_ERR "cs89x0.c: Module autoprobing not allowed.\n"); | 1811 | printk(KERN_ERR "cs89x0.c: Module autoprobing not allowed.\n"); |
1889 | printk(KERN_ERR "cs89x0.c: Append io=0xNNN\n"); | 1812 | printk(KERN_ERR "cs89x0.c: Append io=0xNNN\n"); |
1890 | ret = -EPERM; | 1813 | ret = -EPERM; |
1891 | goto out; | 1814 | goto out; |
1892 | } else if (io <= 0x1ff) { | 1815 | } else if (io <= 0x1ff) { |
1893 | ret = -ENXIO; | 1816 | ret = -ENXIO; |
1894 | goto out; | 1817 | goto out; |
1895 | } | 1818 | } |
@@ -1985,8 +1908,7 @@ static int cs89x0_platform_remove(struct platform_device *pdev) | |||
1985 | struct net_local *lp = netdev_priv(dev); | 1908 | struct net_local *lp = netdev_priv(dev); |
1986 | struct resource *mem_res; | 1909 | struct resource *mem_res; |
1987 | 1910 | ||
1988 | /* | 1911 | /* This platform_get_resource() call will not return NULL, because |
1989 | * This platform_get_resource() call will not return NULL, because | ||
1990 | * the same call in cs89x0_platform_probe() has returned a non NULL | 1912 | * the same call in cs89x0_platform_probe() has returned a non NULL |
1991 | * value. | 1913 | * value. |
1992 | */ | 1914 | */ |
@@ -2021,13 +1943,3 @@ static void __exit cs89x0_cleanup(void) | |||
2021 | module_exit(cs89x0_cleanup); | 1943 | module_exit(cs89x0_cleanup); |
2022 | 1944 | ||
2023 | #endif /* CONFIG_CS89x0_PLATFORM */ | 1945 | #endif /* CONFIG_CS89x0_PLATFORM */ |
2024 | |||
2025 | /* | ||
2026 | * Local variables: | ||
2027 | * version-control: t | ||
2028 | * kept-new-versions: 5 | ||
2029 | * c-indent-level: 8 | ||
2030 | * tab-width: 8 | ||
2031 | * End: | ||
2032 | * | ||
2033 | */ | ||