aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/hostap/hostap_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/hostap/hostap_cs.c')
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c213
1 files changed, 92 insertions, 121 deletions
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 3b4e55cf33c..c768d42d517 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -532,145 +532,118 @@ static void prism2_detach(struct pcmcia_device *link)
532#define CS_CHECK(fn, ret) \ 532#define CS_CHECK(fn, ret) \
533do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 533do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
534 534
535#define CFG_CHECK2(fn, retf) \
536do { int _ret = (retf); \
537if (_ret != 0) { \
538 PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", _ret); \
539 cs_error(link, fn, _ret); \
540 goto next_entry; \
541} \
542} while (0)
543
544 535
545/* run after a CARD_INSERTION event is received to configure the PCMCIA 536/* run after a CARD_INSERTION event is received to configure the PCMCIA
546 * socket and make the device available to the system */ 537 * socket and make the device available to the system */
538
539static int prism2_config_check(struct pcmcia_device *p_dev,
540 cistpl_cftable_entry_t *cfg,
541 cistpl_cftable_entry_t *dflt,
542 unsigned int vcc,
543 void *priv_data)
544{
545 if (cfg->index == 0)
546 return -ENODEV;
547
548 PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
549 "(default 0x%02X)\n", cfg->index, dflt->index);
550
551 /* Does this card need audio output? */
552 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
553 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
554 p_dev->conf.Status = CCSR_AUDIO_ENA;
555 }
556
557 /* Use power settings for Vcc and Vpp if present */
558 /* Note that the CIS values need to be rescaled */
559 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
560 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
561 10000 && !ignore_cis_vcc) {
562 PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping"
563 " this entry\n");
564 return -ENODEV;
565 }
566 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
567 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] /
568 10000 && !ignore_cis_vcc) {
569 PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch "
570 "- skipping this entry\n");
571 return -ENODEV;
572 }
573 }
574
575 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
576 p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
577 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
578 p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
579
580 /* Do we need to allocate an interrupt? */
581 if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
582 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
583 else if (!(p_dev->conf.Attributes & CONF_ENABLE_IRQ)) {
584 /* At least Compaq WL200 does not have IRQInfo1 set,
585 * but it does not work without interrupts.. */
586 printk(KERN_WARNING "Config has no IRQ info, but trying to "
587 "enable IRQ anyway..\n");
588 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
589 }
590
591 /* IO window settings */
592 PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
593 "dflt->io.nwin=%d\n",
594 cfg->io.nwin, dflt->io.nwin);
595 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
596 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
597 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
598 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
599 PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "
600 "io.base=0x%04x, len=%d\n", io->flags,
601 io->win[0].base, io->win[0].len);
602 if (!(io->flags & CISTPL_IO_8BIT))
603 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
604 if (!(io->flags & CISTPL_IO_16BIT))
605 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
606 p_dev->io.IOAddrLines = io->flags &
607 CISTPL_IO_LINES_MASK;
608 p_dev->io.BasePort1 = io->win[0].base;
609 p_dev->io.NumPorts1 = io->win[0].len;
610 if (io->nwin > 1) {
611 p_dev->io.Attributes2 = p_dev->io.Attributes1;
612 p_dev->io.BasePort2 = io->win[1].base;
613 p_dev->io.NumPorts2 = io->win[1].len;
614 }
615 }
616
617 /* This reserves IO space but doesn't actually enable it */
618 return pcmcia_request_io(p_dev, &p_dev->io);
619}
620
547static int prism2_config(struct pcmcia_device *link) 621static int prism2_config(struct pcmcia_device *link)
548{ 622{
549 struct net_device *dev; 623 struct net_device *dev;
550 struct hostap_interface *iface; 624 struct hostap_interface *iface;
551 local_info_t *local; 625 local_info_t *local;
552 int ret = 1; 626 int ret = 1;
553 tuple_t tuple;
554 cisparse_t *parse;
555 int last_fn, last_ret; 627 int last_fn, last_ret;
556 u_char buf[64];
557 config_info_t conf;
558 cistpl_cftable_entry_t dflt = { 0 };
559 struct hostap_cs_priv *hw_priv; 628 struct hostap_cs_priv *hw_priv;
560 629
561 PDEBUG(DEBUG_FLOW, "prism2_config()\n"); 630 PDEBUG(DEBUG_FLOW, "prism2_config()\n");
562 631
563 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
564 hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); 632 hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
565 if (parse == NULL || hw_priv == NULL) { 633 if (hw_priv == NULL) {
566 ret = -ENOMEM; 634 ret = -ENOMEM;
567 goto failed; 635 goto failed;
568 } 636 }
569 637
570 tuple.Attributes = 0;
571 tuple.TupleData = buf;
572 tuple.TupleDataMax = sizeof(buf);
573 tuple.TupleOffset = 0;
574
575 CS_CHECK(GetConfigurationInfo,
576 pcmcia_get_configuration_info(link, &conf));
577
578 /* Look for an appropriate configuration table entry in the CIS */ 638 /* Look for an appropriate configuration table entry in the CIS */
579 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 639 last_ret = pcmcia_loop_config(link, prism2_config_check, NULL);
580 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 640 if (last_ret) {
581 for (;;) { 641 if (!ignore_cis_vcc)
582 cistpl_cftable_entry_t *cfg = &(parse->cftable_entry); 642 printk(KERN_ERR "GetNextTuple(): No matching "
583 CFG_CHECK2(GetTupleData, 643 "CIS configuration. Maybe you need the "
584 pcmcia_get_tuple_data(link, &tuple)); 644 "ignore_cis_vcc=1 parameter.\n");
585 CFG_CHECK2(ParseTuple, 645 cs_error(link, RequestIO, last_ret);
586 pcmcia_parse_tuple(link, &tuple, parse)); 646 goto failed;
587
588 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
589 dflt = *cfg;
590 if (cfg->index == 0)
591 goto next_entry;
592 link->conf.ConfigIndex = cfg->index;
593 PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
594 "(default 0x%02X)\n", cfg->index, dflt.index);
595
596 /* Does this card need audio output? */
597 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
598 link->conf.Attributes |= CONF_ENABLE_SPKR;
599 link->conf.Status = CCSR_AUDIO_ENA;
600 }
601
602 /* Use power settings for Vcc and Vpp if present */
603 /* Note that the CIS values need to be rescaled */
604 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
605 if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
606 10000 && !ignore_cis_vcc) {
607 PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping"
608 " this entry\n");
609 goto next_entry;
610 }
611 } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
612 if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] /
613 10000 && !ignore_cis_vcc) {
614 PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch "
615 "- skipping this entry\n");
616 goto next_entry;
617 }
618 }
619
620 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
621 link->conf.Vpp =
622 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
623 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
624 link->conf.Vpp =
625 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
626
627 /* Do we need to allocate an interrupt? */
628 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
629 link->conf.Attributes |= CONF_ENABLE_IRQ;
630 else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) {
631 /* At least Compaq WL200 does not have IRQInfo1 set,
632 * but it does not work without interrupts.. */
633 printk("Config has no IRQ info, but trying to enable "
634 "IRQ anyway..\n");
635 link->conf.Attributes |= CONF_ENABLE_IRQ;
636 }
637
638 /* IO window settings */
639 PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
640 "dflt.io.nwin=%d\n",
641 cfg->io.nwin, dflt.io.nwin);
642 link->io.NumPorts1 = link->io.NumPorts2 = 0;
643 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
644 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
645 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
646 PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "
647 "io.base=0x%04x, len=%d\n", io->flags,
648 io->win[0].base, io->win[0].len);
649 if (!(io->flags & CISTPL_IO_8BIT))
650 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
651 if (!(io->flags & CISTPL_IO_16BIT))
652 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
653 link->io.IOAddrLines = io->flags &
654 CISTPL_IO_LINES_MASK;
655 link->io.BasePort1 = io->win[0].base;
656 link->io.NumPorts1 = io->win[0].len;
657 if (io->nwin > 1) {
658 link->io.Attributes2 = link->io.Attributes1;
659 link->io.BasePort2 = io->win[1].base;
660 link->io.NumPorts2 = io->win[1].len;
661 }
662 }
663
664 /* This reserves IO space but doesn't actually enable it */
665 CFG_CHECK2(RequestIO,
666 pcmcia_request_io(link, &link->io));
667
668 /* This configuration table entry is OK */
669 break;
670
671 next_entry:
672 CS_CHECK(GetNextTuple,
673 pcmcia_get_next_tuple(link, &tuple));
674 } 647 }
675 648
676 /* Need to allocate net_device before requesting IRQ handler */ 649 /* Need to allocate net_device before requesting IRQ handler */
@@ -738,14 +711,12 @@ static int prism2_config(struct pcmcia_device *link)
738 if (ret == 0 && local->ddev) 711 if (ret == 0 && local->ddev)
739 strcpy(hw_priv->node.dev_name, local->ddev->name); 712 strcpy(hw_priv->node.dev_name, local->ddev->name);
740 } 713 }
741 kfree(parse);
742 return ret; 714 return ret;
743 715
744 cs_failed: 716 cs_failed:
745 cs_error(link, last_fn, last_ret); 717 cs_error(link, last_fn, last_ret);
746 718
747 failed: 719 failed:
748 kfree(parse);
749 kfree(hw_priv); 720 kfree(hw_priv);
750 prism2_release((u_long)link); 721 prism2_release((u_long)link);
751 return ret; 722 return ret;