aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/smc91c92_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/pcmcia/smc91c92_cs.c')
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c114
1 files changed, 34 insertions, 80 deletions
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 7204a4b5529b..8a9ff5318923 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -46,7 +46,6 @@
46#include <linux/jiffies.h> 46#include <linux/jiffies.h>
47#include <linux/firmware.h> 47#include <linux/firmware.h>
48 48
49#include <pcmcia/cs.h>
50#include <pcmcia/cistpl.h> 49#include <pcmcia/cistpl.h>
51#include <pcmcia/cisreg.h> 50#include <pcmcia/cisreg.h>
52#include <pcmcia/ciscode.h> 51#include <pcmcia/ciscode.h>
@@ -302,14 +301,6 @@ static const struct net_device_ops smc_netdev_ops = {
302 .ndo_validate_addr = eth_validate_addr, 301 .ndo_validate_addr = eth_validate_addr,
303}; 302};
304 303
305/*======================================================================
306
307 smc91c92_attach() creates an "instance" of the driver, allocating
308 local data structures for one device. The device is registered
309 with Card Services.
310
311======================================================================*/
312
313static int smc91c92_probe(struct pcmcia_device *link) 304static int smc91c92_probe(struct pcmcia_device *link)
314{ 305{
315 struct smc_private *smc; 306 struct smc_private *smc;
@@ -326,10 +317,6 @@ static int smc91c92_probe(struct pcmcia_device *link)
326 link->priv = dev; 317 link->priv = dev;
327 318
328 spin_lock_init(&smc->lock); 319 spin_lock_init(&smc->lock);
329 link->resource[0]->end = 16;
330 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
331 link->conf.Attributes = CONF_ENABLE_IRQ;
332 link->conf.IntType = INT_MEMORY_AND_IO;
333 320
334 /* The SMC91c92-specific entries in the device structure. */ 321 /* The SMC91c92-specific entries in the device structure. */
335 dev->netdev_ops = &smc_netdev_ops; 322 dev->netdev_ops = &smc_netdev_ops;
@@ -345,15 +332,6 @@ static int smc91c92_probe(struct pcmcia_device *link)
345 return smc91c92_config(link); 332 return smc91c92_config(link);
346} /* smc91c92_attach */ 333} /* smc91c92_attach */
347 334
348/*======================================================================
349
350 This deletes a driver "instance". The device is de-registered
351 with Card Services. If it has been released, all local data
352 structures are freed. Otherwise, the structures will be freed
353 when the device is released.
354
355======================================================================*/
356
357static void smc91c92_detach(struct pcmcia_device *link) 335static void smc91c92_detach(struct pcmcia_device *link)
358{ 336{
359 struct net_device *dev = link->priv; 337 struct net_device *dev = link->priv;
@@ -414,26 +392,28 @@ static int mhz_3288_power(struct pcmcia_device *link)
414 mdelay(200); 392 mdelay(200);
415 393
416 /* Now read and write the COR... */ 394 /* Now read and write the COR... */
417 tmp = readb(smc->base + link->conf.ConfigBase + CISREG_COR); 395 tmp = readb(smc->base + link->config_base + CISREG_COR);
418 udelay(5); 396 udelay(5);
419 writeb(tmp, smc->base + link->conf.ConfigBase + CISREG_COR); 397 writeb(tmp, smc->base + link->config_base + CISREG_COR);
420 398
421 return 0; 399 return 0;
422} 400}
423 401
424static int mhz_mfc_config_check(struct pcmcia_device *p_dev, 402static int mhz_mfc_config_check(struct pcmcia_device *p_dev, void *priv_data)
425 cistpl_cftable_entry_t *cf,
426 cistpl_cftable_entry_t *dflt,
427 unsigned int vcc,
428 void *priv_data)
429{ 403{
430 int k; 404 int k;
431 p_dev->resource[1]->start = cf->io.win[0].base; 405 p_dev->io_lines = 16;
406 p_dev->resource[1]->start = p_dev->resource[0]->start;
407 p_dev->resource[1]->end = 8;
408 p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
409 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
410 p_dev->resource[0]->end = 16;
411 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
412 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
432 for (k = 0; k < 0x400; k += 0x10) { 413 for (k = 0; k < 0x400; k += 0x10) {
433 if (k & 0x80) 414 if (k & 0x80)
434 continue; 415 continue;
435 p_dev->resource[0]->start = k ^ 0x300; 416 p_dev->resource[0]->start = k ^ 0x300;
436 p_dev->io_lines = 16;
437 if (!pcmcia_request_io(p_dev)) 417 if (!pcmcia_request_io(p_dev))
438 return 0; 418 return 0;
439 } 419 }
@@ -444,14 +424,11 @@ static int mhz_mfc_config(struct pcmcia_device *link)
444{ 424{
445 struct net_device *dev = link->priv; 425 struct net_device *dev = link->priv;
446 struct smc_private *smc = netdev_priv(dev); 426 struct smc_private *smc = netdev_priv(dev);
447 win_req_t req;
448 unsigned int offset; 427 unsigned int offset;
449 int i; 428 int i;
450 429
451 link->conf.Attributes |= CONF_ENABLE_SPKR; 430 link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ |
452 link->conf.Status = CCSR_AUDIO_ENA; 431 CONF_AUTO_SET_IO;
453 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
454 link->resource[1]->end = 8;
455 432
456 /* The Megahertz combo cards have modem-like CIS entries, so 433 /* The Megahertz combo cards have modem-like CIS entries, so
457 we have to explicitly try a bunch of port combinations. */ 434 we have to explicitly try a bunch of port combinations. */
@@ -461,16 +438,16 @@ static int mhz_mfc_config(struct pcmcia_device *link)
461 dev->base_addr = link->resource[0]->start; 438 dev->base_addr = link->resource[0]->start;
462 439
463 /* Allocate a memory window, for accessing the ISR */ 440 /* Allocate a memory window, for accessing the ISR */
464 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 441 link->resource[2]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
465 req.Base = req.Size = 0; 442 link->resource[2]->start = link->resource[2]->end = 0;
466 req.AccessSpeed = 0; 443 i = pcmcia_request_window(link, link->resource[2], 0);
467 i = pcmcia_request_window(link, &req, &link->win);
468 if (i != 0) 444 if (i != 0)
469 return -ENODEV; 445 return -ENODEV;
470 446
471 smc->base = ioremap(req.Base, req.Size); 447 smc->base = ioremap(link->resource[2]->start,
472 offset = (smc->manfid == MANFID_MOTOROLA) ? link->conf.ConfigBase : 0; 448 resource_size(link->resource[2]));
473 i = pcmcia_map_mem_page(link, link->win, offset); 449 offset = (smc->manfid == MANFID_MOTOROLA) ? link->config_base : 0;
450 i = pcmcia_map_mem_page(link, link->resource[2], offset);
474 if ((i == 0) && 451 if ((i == 0) &&
475 (smc->manfid == MANFID_MEGAHERTZ) && 452 (smc->manfid == MANFID_MEGAHERTZ) &&
476 (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 453 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
@@ -593,14 +570,12 @@ static int mot_setup(struct pcmcia_device *link)
593 570
594/*====================================================================*/ 571/*====================================================================*/
595 572
596static int smc_configcheck(struct pcmcia_device *p_dev, 573static int smc_configcheck(struct pcmcia_device *p_dev, void *priv_data)
597 cistpl_cftable_entry_t *cf,
598 cistpl_cftable_entry_t *dflt,
599 unsigned int vcc,
600 void *priv_data)
601{ 574{
602 p_dev->resource[0]->start = cf->io.win[0].base; 575 p_dev->resource[0]->end = 16;
603 p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 576 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
577 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
578
604 return pcmcia_request_io(p_dev); 579 return pcmcia_request_io(p_dev);
605} 580}
606 581
@@ -609,7 +584,8 @@ static int smc_config(struct pcmcia_device *link)
609 struct net_device *dev = link->priv; 584 struct net_device *dev = link->priv;
610 int i; 585 int i;
611 586
612 link->resource[0]->end = 16; 587 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
588
613 i = pcmcia_loop_config(link, smc_configcheck, NULL); 589 i = pcmcia_loop_config(link, smc_configcheck, NULL);
614 if (!i) 590 if (!i)
615 dev->base_addr = link->resource[0]->start; 591 dev->base_addr = link->resource[0]->start;
@@ -642,15 +618,14 @@ static int osi_config(struct pcmcia_device *link)
642 static const unsigned int com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; 618 static const unsigned int com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
643 int i, j; 619 int i, j;
644 620
645 link->conf.Attributes |= CONF_ENABLE_SPKR; 621 link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ;
646 link->conf.Status = CCSR_AUDIO_ENA;
647 link->resource[0]->end = 64; 622 link->resource[0]->end = 64;
648 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 623 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
649 link->resource[1]->end = 8; 624 link->resource[1]->end = 8;
650 625
651 /* Enable Hard Decode, LAN, Modem */ 626 /* Enable Hard Decode, LAN, Modem */
652 link->conf.ConfigIndex = 0x23;
653 link->io_lines = 16; 627 link->io_lines = 16;
628 link->config_index = 0x23;
654 629
655 for (i = j = 0; j < 4; j++) { 630 for (i = j = 0; j < 4; j++) {
656 link->resource[1]->start = com[j]; 631 link->resource[1]->start = com[j];
@@ -660,7 +635,7 @@ static int osi_config(struct pcmcia_device *link)
660 } 635 }
661 if (i != 0) { 636 if (i != 0) {
662 /* Fallback: turn off hard decode */ 637 /* Fallback: turn off hard decode */
663 link->conf.ConfigIndex = 0x03; 638 link->config_index = 0x03;
664 link->resource[1]->end = 0; 639 link->resource[1]->end = 0;
665 i = pcmcia_request_io(link); 640 i = pcmcia_request_io(link);
666 } 641 }
@@ -819,27 +794,16 @@ static int check_sig(struct pcmcia_device *link)
819 } 794 }
820 795
821 if (width) { 796 if (width) {
822 modconf_t mod = {
823 .Attributes = CONF_IO_CHANGE_WIDTH,
824 };
825 pr_info("using 8-bit IO window\n"); 797 pr_info("using 8-bit IO window\n");
826 798
827 smc91c92_suspend(link); 799 smc91c92_suspend(link);
828 pcmcia_modify_configuration(link, &mod); 800 pcmcia_fixup_iowidth(link);
829 smc91c92_resume(link); 801 smc91c92_resume(link);
830 return check_sig(link); 802 return check_sig(link);
831 } 803 }
832 return -ENODEV; 804 return -ENODEV;
833} 805}
834 806
835/*======================================================================
836
837 smc91c92_config() is scheduled to run after a CARD_INSERTION event
838 is received, to configure the PCMCIA socket, and to make the
839 ethernet device available to the system.
840
841======================================================================*/
842
843static int smc91c92_config(struct pcmcia_device *link) 807static int smc91c92_config(struct pcmcia_device *link)
844{ 808{
845 struct net_device *dev = link->priv; 809 struct net_device *dev = link->priv;
@@ -871,7 +835,7 @@ static int smc91c92_config(struct pcmcia_device *link)
871 i = pcmcia_request_irq(link, smc_interrupt); 835 i = pcmcia_request_irq(link, smc_interrupt);
872 if (i) 836 if (i)
873 goto config_failed; 837 goto config_failed;
874 i = pcmcia_request_configuration(link, &link->conf); 838 i = pcmcia_enable_device(link);
875 if (i) 839 if (i)
876 goto config_failed; 840 goto config_failed;
877 841
@@ -988,18 +952,10 @@ config_failed:
988 return -ENODEV; 952 return -ENODEV;
989} /* smc91c92_config */ 953} /* smc91c92_config */
990 954
991/*======================================================================
992
993 After a card is removed, smc91c92_release() will unregister the net
994 device, and release the PCMCIA configuration. If the device is
995 still open, this will be postponed until it is closed.
996
997======================================================================*/
998
999static void smc91c92_release(struct pcmcia_device *link) 955static void smc91c92_release(struct pcmcia_device *link)
1000{ 956{
1001 dev_dbg(&link->dev, "smc91c92_release\n"); 957 dev_dbg(&link->dev, "smc91c92_release\n");
1002 if (link->win) { 958 if (link->resource[2]->end) {
1003 struct net_device *dev = link->priv; 959 struct net_device *dev = link->priv;
1004 struct smc_private *smc = netdev_priv(dev); 960 struct smc_private *smc = netdev_priv(dev);
1005 iounmap(smc->base); 961 iounmap(smc->base);
@@ -2092,9 +2048,7 @@ MODULE_DEVICE_TABLE(pcmcia, smc91c92_ids);
2092 2048
2093static struct pcmcia_driver smc91c92_cs_driver = { 2049static struct pcmcia_driver smc91c92_cs_driver = {
2094 .owner = THIS_MODULE, 2050 .owner = THIS_MODULE,
2095 .drv = { 2051 .name = "smc91c92_cs",
2096 .name = "smc91c92_cs",
2097 },
2098 .probe = smc91c92_probe, 2052 .probe = smc91c92_probe,
2099 .remove = smc91c92_detach, 2053 .remove = smc91c92_detach,
2100 .id_table = smc91c92_ids, 2054 .id_table = smc91c92_ids,