aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/pcmcia
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-07-30 07:13:46 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2010-09-29 11:20:24 -0400
commit00990e7ce0b0e596fe41d9c64d6933ea70084003 (patch)
tree189e0dd92860feba84231c66955749574cac5d6d /drivers/scsi/pcmcia
parent440eed43e2a95bb842488755683716814da10f2b (diff)
pcmcia: use autoconfiguration feature for ioports and iomem
When CONF_AUTO_SET_IO or CONF_AUTO_SET_IOMEM are set, the corresponding fields in struct pcmcia_device *p_dev->resource[0,1,2] are set accordinly. Drivers wishing to override certain settings may do so in the callback function, but they no longer need to parse the CIS entries stored in cistpl_cftable_entry_t themselves. 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: linux-bluetooth@vger.kernel.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 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.c34
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c13
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c47
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c13
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c13
5 files changed, 38 insertions, 82 deletions
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 0b5fc2fa0589..bd9ce09b7ff8 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -99,9 +99,7 @@ static int aha152x_probe(struct pcmcia_device *link)
99 info->p_dev = link; 99 info->p_dev = link;
100 link->priv = info; 100 link->priv = info;
101 101
102 link->resource[0]->end = 0x20; 102 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
103 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
104 link->config_flags |= CONF_ENABLE_IRQ;
105 link->config_regs = PRESENT_OPTION; 103 link->config_regs = PRESENT_OPTION;
106 104
107 return aha152x_config_cs(link); 105 return aha152x_config_cs(link);
@@ -121,24 +119,24 @@ static void aha152x_detach(struct pcmcia_device *link)
121 119
122/*====================================================================*/ 120/*====================================================================*/
123 121
124static int aha152x_config_check(struct pcmcia_device *p_dev, 122static int aha152x_config_check(struct pcmcia_device *p_dev, void *priv_data)
125 cistpl_cftable_entry_t *cfg,
126 cistpl_cftable_entry_t *dflt,
127 void *priv_data)
128{ 123{
129 p_dev->io_lines = 10; 124 p_dev->io_lines = 10;
125
130 /* For New Media T&J, look for a SCSI window */ 126 /* For New Media T&J, look for a SCSI window */
131 if (cfg->io.win[0].len >= 0x20) 127 if ((p_dev->resource[0]->end < 0x20) &&
132 p_dev->resource[0]->start = cfg->io.win[0].base; 128 (p_dev->resource[1]->end >= 0x20))
133 else if ((cfg->io.nwin > 1) && 129 p_dev->resource[0]->start = p_dev->resource[1]->start;
134 (cfg->io.win[1].len >= 0x20)) 130
135 p_dev->resource[0]->start = cfg->io.win[1].base; 131 if (p_dev->resource[0]->start >= 0xffff)
136 if ((cfg->io.nwin > 0) && 132 return -EINVAL;
137 (p_dev->resource[0]->start < 0xffff)) { 133
138 if (!pcmcia_request_io(p_dev)) 134 p_dev->resource[1]->start = p_dev->resource[1]->end = 0;
139 return 0; 135 p_dev->resource[0]->end = 0x20;
140 } 136 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
141 return -EINVAL; 137 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
138
139 return pcmcia_request_io(p_dev);
142} 140}
143 141
144static int aha152x_config_cs(struct pcmcia_device *link) 142static int aha152x_config_cs(struct pcmcia_device *link)
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 3b9f311cb035..f2dc627e9da2 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -82,9 +82,7 @@ static int fdomain_probe(struct pcmcia_device *link)
82 82
83 info->p_dev = link; 83 info->p_dev = link;
84 link->priv = info; 84 link->priv = info;
85 link->resource[0]->end = 0x10; 85 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
86 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
87 link->config_flags |= CONF_ENABLE_IRQ;
88 link->config_regs = PRESENT_OPTION; 86 link->config_regs = PRESENT_OPTION;
89 87
90 return fdomain_config(link); 88 return fdomain_config(link);
@@ -103,13 +101,12 @@ static void fdomain_detach(struct pcmcia_device *link)
103 101
104/*====================================================================*/ 102/*====================================================================*/
105 103
106static int fdomain_config_check(struct pcmcia_device *p_dev, 104static int fdomain_config_check(struct pcmcia_device *p_dev, void *priv_data)
107 cistpl_cftable_entry_t *cfg,
108 cistpl_cftable_entry_t *dflt,
109 void *priv_data)
110{ 105{
111 p_dev->io_lines = 10; 106 p_dev->io_lines = 10;
112 p_dev->resource[0]->start = cfg->io.win[0].base; 107 p_dev->resource[0]->end = 0x10;
108 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
109 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
113 return pcmcia_request_io(p_dev); 110 return pcmcia_request_io(p_dev);
114} 111}
115 112
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 344d49900b4c..3b90ad9d1956 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1556,13 +1556,6 @@ static int nsp_cs_probe(struct pcmcia_device *link)
1556 1556
1557 nsp_dbg(NSP_DEBUG_INIT, "info=0x%p", info); 1557 nsp_dbg(NSP_DEBUG_INIT, "info=0x%p", info);
1558 1558
1559 /* The io structure describes IO port mapping */
1560 link->resource[0]->end = 0x10;
1561 link->resource[0]->flags = IO_DATA_PATH_WIDTH_AUTO;
1562
1563 /* General socket configuration */
1564 link->config_flags |= CONF_ENABLE_IRQ;
1565
1566 ret = nsp_cs_config(link); 1559 ret = nsp_cs_config(link);
1567 1560
1568 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); 1561 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link);
@@ -1594,50 +1587,27 @@ static void nsp_cs_detach(struct pcmcia_device *link)
1594 ethernet device available to the system. 1587 ethernet device available to the system.
1595======================================================================*/ 1588======================================================================*/
1596 1589
1597static int nsp_cs_config_check(struct pcmcia_device *p_dev, 1590static int nsp_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
1598 cistpl_cftable_entry_t *cfg,
1599 cistpl_cftable_entry_t *dflt,
1600 void *priv_data)
1601{ 1591{
1602 nsp_hw_data *data = priv_data; 1592 nsp_hw_data *data = priv_data;
1603 1593
1604 if (cfg->index == 0) 1594 if (p_dev->config_index == 0)
1605 return -ENODEV; 1595 return -ENODEV;
1606 1596
1607 /* IO window settings */ 1597 /* This reserves IO space but doesn't actually enable it */
1608 p_dev->resource[0]->end = p_dev->resource[1]->end = 0; 1598 if (pcmcia_request_io(p_dev) != 0)
1609 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 1599 goto next_entry;
1610 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
1611 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
1612 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
1613 p_dev->resource[0]->flags |=
1614 pcmcia_io_cfg_data_width(io->flags);
1615 p_dev->resource[0]->start = io->win[0].base;
1616 p_dev->resource[0]->end = io->win[0].len;
1617 if (io->nwin > 1) {
1618 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
1619 p_dev->resource[1]->start = io->win[1].base;
1620 p_dev->resource[1]->end = io->win[1].len;
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 }
1626 1600
1627 if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { 1601 if (resource_size(p_dev->resource[2])) {
1628 cistpl_mem_t *mem =
1629 (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
1630 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 | 1602 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 |
1631 WIN_MEMORY_TYPE_CM | 1603 WIN_MEMORY_TYPE_CM |
1632 WIN_ENABLE); 1604 WIN_ENABLE);
1633 p_dev->resource[2]->start = mem->win[0].host_addr;
1634 p_dev->resource[2]->end = mem->win[0].len;
1635 if (p_dev->resource[2]->end < 0x1000) 1605 if (p_dev->resource[2]->end < 0x1000)
1636 p_dev->resource[2]->end = 0x1000; 1606 p_dev->resource[2]->end = 0x1000;
1637 if (pcmcia_request_window(p_dev, p_dev->resource[2], 0) != 0) 1607 if (pcmcia_request_window(p_dev, p_dev->resource[2], 0) != 0)
1638 goto next_entry; 1608 goto next_entry;
1639 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2], 1609 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2],
1640 mem->win[0].card_addr) != 0) 1610 p_dev->card_addr) != 0)
1641 goto next_entry; 1611 goto next_entry;
1642 1612
1643 data->MmioAddress = (unsigned long) 1613 data->MmioAddress = (unsigned long)
@@ -1664,7 +1634,8 @@ static int nsp_cs_config(struct pcmcia_device *link)
1664 nsp_dbg(NSP_DEBUG_INIT, "in"); 1634 nsp_dbg(NSP_DEBUG_INIT, "in");
1665 1635
1666 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC | 1636 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC |
1667 CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO; 1637 CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | CONF_AUTO_SET_IOMEM |
1638 CONF_AUTO_SET_IO;
1668 1639
1669 ret = pcmcia_loop_config(link, nsp_cs_config_check, data); 1640 ret = pcmcia_loop_config(link, nsp_cs_config_check, data);
1670 if (ret) 1641 if (ret)
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 468fd12fe98d..e8a06e3a384c 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -155,9 +155,7 @@ static int qlogic_probe(struct pcmcia_device *link)
155 return -ENOMEM; 155 return -ENOMEM;
156 info->p_dev = link; 156 info->p_dev = link;
157 link->priv = info; 157 link->priv = info;
158 link->resource[0]->end = 16; 158 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
159 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
160 link->config_flags |= CONF_ENABLE_IRQ;
161 link->config_regs = PRESENT_OPTION; 159 link->config_regs = PRESENT_OPTION;
162 160
163 return qlogic_config(link); 161 return qlogic_config(link);
@@ -176,14 +174,11 @@ static void qlogic_detach(struct pcmcia_device *link)
176 174
177/*====================================================================*/ 175/*====================================================================*/
178 176
179static int qlogic_config_check(struct pcmcia_device *p_dev, 177static int qlogic_config_check(struct pcmcia_device *p_dev, void *priv_data)
180 cistpl_cftable_entry_t *cfg,
181 cistpl_cftable_entry_t *dflt,
182 void *priv_data)
183{ 178{
184 p_dev->io_lines = 10; 179 p_dev->io_lines = 10;
185 p_dev->resource[0]->start = cfg->io.win[0].base; 180 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
186 p_dev->resource[0]->end = cfg->io.win[0].len; 181 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
187 182
188 if (p_dev->resource[0]->start == 0) 183 if (p_dev->resource[0]->start == 0)
189 return -ENODEV; 184 return -ENODEV;
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 7a0bb9aea042..6ceb57c355fa 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -683,14 +683,11 @@ static struct scsi_host_template sym53c500_driver_template = {
683 .shost_attrs = SYM53C500_shost_attrs 683 .shost_attrs = SYM53C500_shost_attrs
684}; 684};
685 685
686static int SYM53C500_config_check(struct pcmcia_device *p_dev, 686static int SYM53C500_config_check(struct pcmcia_device *p_dev, void *priv_data)
687 cistpl_cftable_entry_t *cfg,
688 cistpl_cftable_entry_t *dflt,
689 void *priv_data)
690{ 687{
691 p_dev->io_lines = 10; 688 p_dev->io_lines = 10;
692 p_dev->resource[0]->start = cfg->io.win[0].base; 689 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
693 p_dev->resource[0]->end = cfg->io.win[0].len; 690 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
694 691
695 if (p_dev->resource[0]->start == 0) 692 if (p_dev->resource[0]->start == 0)
696 return -ENODEV; 693 return -ENODEV;
@@ -857,9 +854,7 @@ SYM53C500_probe(struct pcmcia_device *link)
857 return -ENOMEM; 854 return -ENOMEM;
858 info->p_dev = link; 855 info->p_dev = link;
859 link->priv = info; 856 link->priv = info;
860 link->resource[0]->end = 16; 857 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
861 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
862 link->config_flags |= CONF_ENABLE_IRQ;
863 858
864 return SYM53C500_config(link); 859 return SYM53C500_config(link);
865} /* SYM53C500_attach */ 860} /* SYM53C500_attach */