diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-09-13 14:23:12 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-09-15 11:57:22 -0400 |
commit | b76dc0546709aef18f123847680108c2fd33f203 (patch) | |
tree | 2d84710244028ee5e7e06e280f056181fd909a92 /drivers/net | |
parent | eb838fe109b8f51ba590802761753a2631c3f7f0 (diff) |
pcmcia pcnet_cs: try setting io_lines to 16 if card setup fails
Some pcnet_cs compatible cards require an exact 16-lines match
of the ioport areas specified in CIS, but set the "iolines"
value in the CIS incorrectly. We can easily work around this
issue -- same as we do in serial_cs -- by first trying setting
iolines to the CIS-specified value, and then trying a 16-line
match.
Reported-and-tested-by: Wolfram Sang <w.sang@pengutronix.de>
Hardware-supplied-by: Jochen Frieling <j.frieling@pengutronix.de>
CC: netdev@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/pcmcia/pcnet_cs.c | 139 |
1 files changed, 83 insertions, 56 deletions
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 49279b0ee526..f9b509a6b09a 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -508,7 +508,8 @@ static int pcnet_confcheck(struct pcmcia_device *p_dev, | |||
508 | unsigned int vcc, | 508 | unsigned int vcc, |
509 | void *priv_data) | 509 | void *priv_data) |
510 | { | 510 | { |
511 | int *has_shmem = priv_data; | 511 | int *priv = priv_data; |
512 | int try = (*priv & 0x1); | ||
512 | int i; | 513 | int i; |
513 | cistpl_io_t *io = &cfg->io; | 514 | cistpl_io_t *io = &cfg->io; |
514 | 515 | ||
@@ -525,77 +526,103 @@ static int pcnet_confcheck(struct pcmcia_device *p_dev, | |||
525 | i = p_dev->resource[1]->end = 0; | 526 | i = p_dev->resource[1]->end = 0; |
526 | } | 527 | } |
527 | 528 | ||
528 | *has_shmem = ((cfg->mem.nwin == 1) && | 529 | *priv &= ((cfg->mem.nwin == 1) && |
529 | (cfg->mem.win[0].len >= 0x4000)); | 530 | (cfg->mem.win[0].len >= 0x4000)) ? 0x10 : ~0x10; |
531 | |||
530 | p_dev->resource[0]->start = io->win[i].base; | 532 | p_dev->resource[0]->start = io->win[i].base; |
531 | p_dev->resource[0]->end = io->win[i].len; | 533 | p_dev->resource[0]->end = io->win[i].len; |
532 | p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; | 534 | if (!try) |
535 | p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; | ||
536 | else | ||
537 | p_dev->io_lines = 16; | ||
533 | if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32) | 538 | if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32) |
534 | return try_io_port(p_dev); | 539 | return try_io_port(p_dev); |
535 | 540 | ||
536 | return 0; | 541 | return -EINVAL; |
542 | } | ||
543 | |||
544 | static hw_info_t *pcnet_try_config(struct pcmcia_device *link, | ||
545 | int *has_shmem, int try) | ||
546 | { | ||
547 | struct net_device *dev = link->priv; | ||
548 | hw_info_t *local_hw_info; | ||
549 | pcnet_dev_t *info = PRIV(dev); | ||
550 | int priv = try; | ||
551 | int ret; | ||
552 | |||
553 | ret = pcmcia_loop_config(link, pcnet_confcheck, &priv); | ||
554 | if (ret) { | ||
555 | dev_warn(&link->dev, "no useable port range found\n"); | ||
556 | return NULL; | ||
557 | } | ||
558 | *has_shmem = (priv & 0x10); | ||
559 | |||
560 | if (!link->irq) | ||
561 | return NULL; | ||
562 | |||
563 | if (resource_size(link->resource[1]) == 8) { | ||
564 | link->conf.Attributes |= CONF_ENABLE_SPKR; | ||
565 | link->conf.Status = CCSR_AUDIO_ENA; | ||
566 | } | ||
567 | if ((link->manf_id == MANFID_IBM) && | ||
568 | (link->card_id == PRODID_IBM_HOME_AND_AWAY)) | ||
569 | link->conf.ConfigIndex |= 0x10; | ||
570 | |||
571 | ret = pcmcia_request_configuration(link, &link->conf); | ||
572 | if (ret) | ||
573 | return NULL; | ||
574 | |||
575 | dev->irq = link->irq; | ||
576 | dev->base_addr = link->resource[0]->start; | ||
577 | |||
578 | if (info->flags & HAS_MISC_REG) { | ||
579 | if ((if_port == 1) || (if_port == 2)) | ||
580 | dev->if_port = if_port; | ||
581 | else | ||
582 | dev_notice(&link->dev, "invalid if_port requested\n"); | ||
583 | } else | ||
584 | dev->if_port = 0; | ||
585 | |||
586 | if ((link->conf.ConfigBase == 0x03c0) && | ||
587 | (link->manf_id == 0x149) && (link->card_id == 0xc1ab)) { | ||
588 | dev_info(&link->dev, | ||
589 | "this is an AX88190 card - use axnet_cs instead.\n"); | ||
590 | return NULL; | ||
591 | } | ||
592 | |||
593 | local_hw_info = get_hwinfo(link); | ||
594 | if (!local_hw_info) | ||
595 | local_hw_info = get_prom(link); | ||
596 | if (!local_hw_info) | ||
597 | local_hw_info = get_dl10019(link); | ||
598 | if (!local_hw_info) | ||
599 | local_hw_info = get_ax88190(link); | ||
600 | if (!local_hw_info) | ||
601 | local_hw_info = get_hwired(link); | ||
602 | |||
603 | return local_hw_info; | ||
537 | } | 604 | } |
538 | 605 | ||
539 | static int pcnet_config(struct pcmcia_device *link) | 606 | static int pcnet_config(struct pcmcia_device *link) |
540 | { | 607 | { |
541 | struct net_device *dev = link->priv; | 608 | struct net_device *dev = link->priv; |
542 | pcnet_dev_t *info = PRIV(dev); | 609 | pcnet_dev_t *info = PRIV(dev); |
543 | int ret, start_pg, stop_pg, cm_offset; | 610 | int start_pg, stop_pg, cm_offset; |
544 | int has_shmem = 0; | 611 | int has_shmem = 0; |
545 | hw_info_t *local_hw_info; | 612 | hw_info_t *local_hw_info; |
546 | 613 | ||
547 | dev_dbg(&link->dev, "pcnet_config\n"); | 614 | dev_dbg(&link->dev, "pcnet_config\n"); |
548 | 615 | ||
549 | ret = pcmcia_loop_config(link, pcnet_confcheck, &has_shmem); | 616 | local_hw_info = pcnet_try_config(link, &has_shmem, 0); |
550 | if (ret) | 617 | if (!local_hw_info) { |
551 | goto failed; | 618 | /* check whether forcing io_lines to 16 helps... */ |
552 | 619 | pcmcia_disable_device(link); | |
553 | if (!link->irq) | 620 | local_hw_info = pcnet_try_config(link, &has_shmem, 1); |
554 | goto failed; | 621 | if (local_hw_info == NULL) { |
555 | 622 | dev_notice(&link->dev, "unable to read hardware net" | |
556 | if (resource_size(link->resource[1]) == 8) { | 623 | " address for io base %#3lx\n", dev->base_addr); |
557 | link->conf.Attributes |= CONF_ENABLE_SPKR; | 624 | goto failed; |
558 | link->conf.Status = CCSR_AUDIO_ENA; | 625 | } |
559 | } | ||
560 | if ((link->manf_id == MANFID_IBM) && | ||
561 | (link->card_id == PRODID_IBM_HOME_AND_AWAY)) | ||
562 | link->conf.ConfigIndex |= 0x10; | ||
563 | |||
564 | ret = pcmcia_request_configuration(link, &link->conf); | ||
565 | if (ret) | ||
566 | goto failed; | ||
567 | dev->irq = link->irq; | ||
568 | dev->base_addr = link->resource[0]->start; | ||
569 | if (info->flags & HAS_MISC_REG) { | ||
570 | if ((if_port == 1) || (if_port == 2)) | ||
571 | dev->if_port = if_port; | ||
572 | else | ||
573 | printk(KERN_NOTICE "pcnet_cs: invalid if_port requested\n"); | ||
574 | } else { | ||
575 | dev->if_port = 0; | ||
576 | } | ||
577 | |||
578 | if ((link->conf.ConfigBase == 0x03c0) && | ||
579 | (link->manf_id == 0x149) && (link->card_id == 0xc1ab)) { | ||
580 | printk(KERN_INFO "pcnet_cs: this is an AX88190 card!\n"); | ||
581 | printk(KERN_INFO "pcnet_cs: use axnet_cs instead.\n"); | ||
582 | goto failed; | ||
583 | } | ||
584 | |||
585 | local_hw_info = get_hwinfo(link); | ||
586 | if (local_hw_info == NULL) | ||
587 | local_hw_info = get_prom(link); | ||
588 | if (local_hw_info == NULL) | ||
589 | local_hw_info = get_dl10019(link); | ||
590 | if (local_hw_info == NULL) | ||
591 | local_hw_info = get_ax88190(link); | ||
592 | if (local_hw_info == NULL) | ||
593 | local_hw_info = get_hwired(link); | ||
594 | |||
595 | if (local_hw_info == NULL) { | ||
596 | printk(KERN_NOTICE "pcnet_cs: unable to read hardware net" | ||
597 | " address for io base %#3lx\n", dev->base_addr); | ||
598 | goto failed; | ||
599 | } | 626 | } |
600 | 627 | ||
601 | info->flags = local_hw_info->flags; | 628 | info->flags = local_hw_info->flags; |