aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/pcmcia
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-07-30 03:51:52 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2010-09-29 11:20:23 -0400
commit440eed43e2a95bb842488755683716814da10f2b (patch)
tree45c49181a077f845cd366cfa7dc07f259fd01078 /drivers/scsi/pcmcia
parent9485ee14e143c7076e88deea1e87ca3eb0b2f94e (diff)
pcmcia: introduce autoconfiguration feature
Introduce an autoconfiguration feature to set certain values in pcmcia_loop_config(), instead of copying the same code over and over in each PCMCIA driver. At first, introduce the following options: CONF_AUTO_CHECK_VCC check or matching Vcc entry CONF_AUTO_SET_VPP set Vpp CONF_AUTO_AUDIO enable the speaker line CC: netdev@vger.kernel.org CC: linux-wireless@vger.kernel.org CC: linux-ide@vger.kernel.org CC: linux-usb@vger.kernel.org CC: laforge@gnumonks.org CC: linux-mtd@lists.infradead.org CC: alsa-devel@alsa-project.org CC: linux-serial@vger.kernel.org CC: Jiri Kosina <jkosina@suse.cz> CC: linux-scsi@vger.kernel.org Acked-by: Gustavo F. Padovan <padovan@profusion.mobi> (for drivers/bluetooth) Tested-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/scsi/pcmcia')
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c1
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c1
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c110
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c1
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c1
5 files changed, 42 insertions, 72 deletions
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index e1f748517135..0b5fc2fa0589 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -124,7 +124,6 @@ static void aha152x_detach(struct pcmcia_device *link)
124static int aha152x_config_check(struct pcmcia_device *p_dev, 124static int aha152x_config_check(struct pcmcia_device *p_dev,
125 cistpl_cftable_entry_t *cfg, 125 cistpl_cftable_entry_t *cfg,
126 cistpl_cftable_entry_t *dflt, 126 cistpl_cftable_entry_t *dflt,
127 unsigned int vcc,
128 void *priv_data) 127 void *priv_data)
129{ 128{
130 p_dev->io_lines = 10; 129 p_dev->io_lines = 10;
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index ae263b17bfa5..3b9f311cb035 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -106,7 +106,6 @@ static void fdomain_detach(struct pcmcia_device *link)
106static int fdomain_config_check(struct pcmcia_device *p_dev, 106static int fdomain_config_check(struct pcmcia_device *p_dev,
107 cistpl_cftable_entry_t *cfg, 107 cistpl_cftable_entry_t *cfg,
108 cistpl_cftable_entry_t *dflt, 108 cistpl_cftable_entry_t *dflt,
109 unsigned int vcc,
110 void *priv_data) 109 void *priv_data)
111{ 110{
112 p_dev->io_lines = 10; 111 p_dev->io_lines = 10;
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index d0546c03f57c..344d49900b4c 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1597,7 +1597,6 @@ static void nsp_cs_detach(struct pcmcia_device *link)
1597static int nsp_cs_config_check(struct pcmcia_device *p_dev, 1597static int nsp_cs_config_check(struct pcmcia_device *p_dev,
1598 cistpl_cftable_entry_t *cfg, 1598 cistpl_cftable_entry_t *cfg,
1599 cistpl_cftable_entry_t *dflt, 1599 cistpl_cftable_entry_t *dflt,
1600 unsigned int vcc,
1601 void *priv_data) 1600 void *priv_data)
1602{ 1601{
1603 nsp_hw_data *data = priv_data; 1602 nsp_hw_data *data = priv_data;
@@ -1605,77 +1604,49 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev,
1605 if (cfg->index == 0) 1604 if (cfg->index == 0)
1606 return -ENODEV; 1605 return -ENODEV;
1607 1606
1608 /* Does this card need audio output? */ 1607 /* IO window settings */
1609 if (cfg->flags & CISTPL_CFTABLE_AUDIO) 1608 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
1610 p_dev->config_flags |= CONF_ENABLE_SPKR; 1609 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
1611 1610 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
1612 /* Use power settings for Vcc and Vpp if present */ 1611 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
1613 /* Note that the CIS values need to be rescaled */ 1612 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
1614 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { 1613 p_dev->resource[0]->flags |=
1615 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) 1614 pcmcia_io_cfg_data_width(io->flags);
1616 return -ENODEV; 1615 p_dev->resource[0]->start = io->win[0].base;
1617 else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { 1616 p_dev->resource[0]->end = io->win[0].len;
1618 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) 1617 if (io->nwin > 1) {
1619 return -ENODEV; 1618 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
1620 } 1619 p_dev->resource[1]->start = io->win[1].base;
1621 1620 p_dev->resource[1]->end = io->win[1].len;
1622 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) {
1623 p_dev->vpp =
1624 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
1625 } else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) {
1626 p_dev->vpp =
1627 dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
1628 }
1629
1630 /* Do we need to allocate an interrupt? */
1631 p_dev->config_flags |= CONF_ENABLE_IRQ;
1632
1633 /* IO window settings */
1634 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
1635 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
1636 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
1637 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
1638 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
1639 p_dev->resource[0]->flags |=
1640 pcmcia_io_cfg_data_width(io->flags);
1641 p_dev->resource[0]->start = io->win[0].base;
1642 p_dev->resource[0]->end = io->win[0].len;
1643 if (io->nwin > 1) {
1644 p_dev->resource[1]->flags =
1645 p_dev->resource[0]->flags;
1646 p_dev->resource[1]->start = io->win[1].base;
1647 p_dev->resource[1]->end = io->win[1].len;
1648 }
1649 /* This reserves IO space but doesn't actually enable it */
1650 if (pcmcia_request_io(p_dev) != 0)
1651 goto next_entry;
1652 } 1621 }
1622 /* This reserves IO space but doesn't actually enable it */
1623 if (pcmcia_request_io(p_dev) != 0)
1624 goto next_entry;
1625 }
1653 1626
1654 if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { 1627 if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
1655 cistpl_mem_t *mem = 1628 cistpl_mem_t *mem =
1656 (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; 1629 (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
1657 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 | 1630 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 |
1658 WIN_MEMORY_TYPE_CM | 1631 WIN_MEMORY_TYPE_CM |
1659 WIN_ENABLE); 1632 WIN_ENABLE);
1660 p_dev->resource[2]->start = mem->win[0].host_addr; 1633 p_dev->resource[2]->start = mem->win[0].host_addr;
1661 p_dev->resource[2]->end = mem->win[0].len; 1634 p_dev->resource[2]->end = mem->win[0].len;
1662 if (p_dev->resource[2]->end < 0x1000) 1635 if (p_dev->resource[2]->end < 0x1000)
1663 p_dev->resource[2]->end = 0x1000; 1636 p_dev->resource[2]->end = 0x1000;
1664 if (pcmcia_request_window(p_dev, p_dev->resource[2], 1637 if (pcmcia_request_window(p_dev, p_dev->resource[2], 0) != 0)
1665 0) != 0) 1638 goto next_entry;
1666 goto next_entry; 1639 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2],
1667 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2], 1640 mem->win[0].card_addr) != 0)
1668 mem->win[0].card_addr) != 0) 1641 goto next_entry;
1669 goto next_entry; 1642
1670 1643 data->MmioAddress = (unsigned long)
1671 data->MmioAddress = (unsigned long) 1644 ioremap_nocache(p_dev->resource[2]->start,
1672 ioremap_nocache(p_dev->resource[2]->start,
1673 resource_size(p_dev->resource[2])); 1645 resource_size(p_dev->resource[2]));
1674 data->MmioLength = resource_size(p_dev->resource[2]); 1646 data->MmioLength = resource_size(p_dev->resource[2]);
1675 }
1676 /* If we got this far, we're cool! */
1677 return 0;
1678 } 1647 }
1648 /* If we got this far, we're cool! */
1649 return 0;
1679 1650
1680next_entry: 1651next_entry:
1681 nsp_dbg(NSP_DEBUG_INIT, "next"); 1652 nsp_dbg(NSP_DEBUG_INIT, "next");
@@ -1692,6 +1663,9 @@ static int nsp_cs_config(struct pcmcia_device *link)
1692 1663
1693 nsp_dbg(NSP_DEBUG_INIT, "in"); 1664 nsp_dbg(NSP_DEBUG_INIT, "in");
1694 1665
1666 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC |
1667 CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO;
1668
1695 ret = pcmcia_loop_config(link, nsp_cs_config_check, data); 1669 ret = pcmcia_loop_config(link, nsp_cs_config_check, data);
1696 if (ret) 1670 if (ret)
1697 goto cs_failed; 1671 goto cs_failed;
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 7d3f49c431fd..468fd12fe98d 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -179,7 +179,6 @@ static void qlogic_detach(struct pcmcia_device *link)
179static int qlogic_config_check(struct pcmcia_device *p_dev, 179static int qlogic_config_check(struct pcmcia_device *p_dev,
180 cistpl_cftable_entry_t *cfg, 180 cistpl_cftable_entry_t *cfg,
181 cistpl_cftable_entry_t *dflt, 181 cistpl_cftable_entry_t *dflt,
182 unsigned int vcc,
183 void *priv_data) 182 void *priv_data)
184{ 183{
185 p_dev->io_lines = 10; 184 p_dev->io_lines = 10;
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 600630eb7034..7a0bb9aea042 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -686,7 +686,6 @@ static struct scsi_host_template sym53c500_driver_template = {
686static int SYM53C500_config_check(struct pcmcia_device *p_dev, 686static int SYM53C500_config_check(struct pcmcia_device *p_dev,
687 cistpl_cftable_entry_t *cfg, 687 cistpl_cftable_entry_t *cfg,
688 cistpl_cftable_entry_t *dflt, 688 cistpl_cftable_entry_t *dflt,
689 unsigned int vcc,
690 void *priv_data) 689 void *priv_data)
691{ 690{
692 p_dev->io_lines = 10; 691 p_dev->io_lines = 10;