aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/legacy/ide-cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/legacy/ide-cs.c')
-rw-r--r--drivers/ide/legacy/ide-cs.c81
1 files changed, 10 insertions, 71 deletions
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index b7e459e4f284..602797a44208 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -146,16 +146,7 @@ static void ide_detach(struct pcmcia_device *link)
146 kfree(link->priv); 146 kfree(link->priv);
147} /* ide_detach */ 147} /* ide_detach */
148 148
149static void idecs_mmio_fixup(ide_hwif_t *hwif) 149static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle)
150{
151 default_hwif_mmiops(hwif);
152 hwif->mmio = 2;
153
154 ide_undecoded_slave(hwif);
155}
156
157static int idecs_register(unsigned long io, unsigned long ctl,
158 unsigned long irq, struct pcmcia_device *handle, int is_mmio)
159{ 150{
160 hw_regs_t hw; 151 hw_regs_t hw;
161 memset(&hw, 0, sizeof(hw)); 152 memset(&hw, 0, sizeof(hw));
@@ -163,19 +154,7 @@ static int idecs_register(unsigned long io, unsigned long ctl,
163 hw.irq = irq; 154 hw.irq = irq;
164 hw.chipset = ide_pci; 155 hw.chipset = ide_pci;
165 hw.dev = &handle->dev; 156 hw.dev = &handle->dev;
166 157 return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave);
167 if(is_mmio)
168 return ide_register_hw_with_fixup(&hw, NULL, idecs_mmio_fixup);
169 else
170 return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave);
171}
172
173void outb_io(unsigned char value, unsigned long port) {
174 outb(value, port);
175}
176
177void outb_mem(unsigned char value, unsigned long port) {
178 writeb(value, (void __iomem *) port);
179} 158}
180 159
181/*====================================================================== 160/*======================================================================
@@ -201,8 +180,7 @@ static int ide_config(struct pcmcia_device *link)
201 } *stk = NULL; 180 } *stk = NULL;
202 cistpl_cftable_entry_t *cfg; 181 cistpl_cftable_entry_t *cfg;
203 int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0; 182 int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0;
204 unsigned long io_base, ctl_base, is_mmio, try_slave; 183 unsigned long io_base, ctl_base;
205 void (*my_outb)(unsigned char, unsigned long);
206 184
207 DEBUG(0, "ide_config(0x%p)\n", link); 185 DEBUG(0, "ide_config(0x%p)\n", link);
208 186
@@ -232,7 +210,7 @@ static int ide_config(struct pcmcia_device *link)
232 /* Not sure if this is right... look up the current Vcc */ 210 /* Not sure if this is right... look up the current Vcc */
233 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); 211 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf));
234 212
235 pass = io_base = ctl_base = is_mmio = try_slave = 0; 213 pass = io_base = ctl_base = 0;
236 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 214 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
237 tuple.Attributes = 0; 215 tuple.Attributes = 0;
238 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 216 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
@@ -280,45 +258,11 @@ static int ide_config(struct pcmcia_device *link)
280 goto next_entry; 258 goto next_entry;
281 io_base = link->io.BasePort1; 259 io_base = link->io.BasePort1;
282 ctl_base = link->io.BasePort1 + 0x0e; 260 ctl_base = link->io.BasePort1 + 0x0e;
283
284 if (io->win[0].len >= 0x20)
285 try_slave = 1;
286
287 } else goto next_entry; 261 } else goto next_entry;
288 /* If we've got this far, we're done */ 262 /* If we've got this far, we're done */
289 break; 263 break;
290 } 264 }
291 265
292 if ((cfg->mem.nwin > 0) || (stk->dflt.mem.nwin > 0)) {
293 win_req_t req;
294 memreq_t map;
295 cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &stk->dflt.mem;
296
297 if (mem->win[0].len < 16)
298 goto next_entry;
299
300 req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
301 req.Attributes |= WIN_ENABLE;
302 req.Base = mem->win[0].host_addr;
303 req.Size = 0;
304
305 req.AccessSpeed = 0;
306 if (pcmcia_request_window(&link, &req, &link->win) != 0)
307 goto next_entry;
308 map.Page = 0; map.CardOffset = mem->win[0].card_addr;
309 if (pcmcia_map_mem_page(link->win, &map) != 0)
310 goto next_entry;
311
312 io_base = (unsigned long) ioremap(req.Base, req.Size);
313 ctl_base = io_base + 0x0e;
314 is_mmio = 1;
315
316 if (mem->win[0].len >= 0x20)
317 try_slave = 1;
318
319 break;
320 }
321
322 next_entry: 266 next_entry:
323 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 267 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
324 memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); 268 memcpy(&stk->dflt, cfg, sizeof(stk->dflt));
@@ -334,26 +278,21 @@ static int ide_config(struct pcmcia_device *link)
334 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 278 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
335 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 279 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
336 280
337 if(is_mmio)
338 my_outb = outb_mem;
339 else
340 my_outb = outb_io;
341
342 /* disable drive interrupts during IDE probe */ 281 /* disable drive interrupts during IDE probe */
343 my_outb(0x02, ctl_base); 282 outb(0x02, ctl_base);
344 283
345 /* special setup for KXLC005 card */ 284 /* special setup for KXLC005 card */
346 if (is_kme) 285 if (is_kme)
347 my_outb(0x81, ctl_base+1); 286 outb(0x81, ctl_base+1);
348 287
349 /* retry registration in case device is still spinning up */ 288 /* retry registration in case device is still spinning up */
350 for (hd = -1, i = 0; i < 10; i++) { 289 for (hd = -1, i = 0; i < 10; i++) {
351 hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link, is_mmio); 290 hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link);
352 if (hd >= 0) break; 291 if (hd >= 0) break;
353 if (try_slave) { 292 if (link->io.NumPorts1 == 0x20) {
354 my_outb(0x02, ctl_base + 0x10); 293 outb(0x02, ctl_base + 0x10);
355 hd = idecs_register(io_base + 0x10, ctl_base + 0x10, 294 hd = idecs_register(io_base + 0x10, ctl_base + 0x10,
356 link->irq.AssignedIRQ, link, is_mmio); 295 link->irq.AssignedIRQ, link);
357 if (hd >= 0) { 296 if (hd >= 0) {
358 io_base += 0x10; 297 io_base += 0x10;
359 ctl_base += 0x10; 298 ctl_base += 0x10;