aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/setup-pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r--drivers/ide/setup-pci.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 7ae6ae45331f..acb467c6f345 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -289,6 +289,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
289 * @d: IDE port info 289 * @d: IDE port info
290 * @port: port number 290 * @port: port number
291 * @irq: PCI IRQ 291 * @irq: PCI IRQ
292 * @hw: hw_regs_t instance corresponding to this port
292 * 293 *
293 * Perform the initial set up for the hardware interface structure. This 294 * Perform the initial set up for the hardware interface structure. This
294 * is done per interface port rather than per PCI device. There may be 295 * is done per interface port rather than per PCI device. There may be
@@ -299,11 +300,11 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
299 300
300static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, 301static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
301 const struct ide_port_info *d, 302 const struct ide_port_info *d,
302 unsigned int port, int irq) 303 unsigned int port, int irq,
304 hw_regs_t *hw)
303{ 305{
304 unsigned long ctl = 0, base = 0; 306 unsigned long ctl = 0, base = 0;
305 ide_hwif_t *hwif; 307 ide_hwif_t *hwif;
306 struct hw_regs_s hw;
307 308
308 if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { 309 if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) {
309 if (ide_pci_check_iomem(dev, d, 2 * port) || 310 if (ide_pci_check_iomem(dev, d, 2 * port) ||
@@ -327,17 +328,17 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
327 return NULL; 328 return NULL;
328 } 329 }
329 330
331 memset(hw, 0, sizeof(*hw));
332 hw->irq = irq;
333 hw->dev = &dev->dev;
334 hw->chipset = d->chipset ? d->chipset : ide_pci;
335 ide_std_init_ports(hw, base, ctl | 2);
336
330 hwif = ide_find_port_slot(d); 337 hwif = ide_find_port_slot(d);
331 if (hwif == NULL) 338 if (hwif == NULL)
332 return NULL; 339 return NULL;
333 340
334 memset(&hw, 0, sizeof(hw)); 341 hwif->chipset = hw->chipset;
335 hw.irq = irq;
336 hw.dev = &dev->dev;
337 hw.chipset = d->chipset ? d->chipset : ide_pci;
338 ide_std_init_ports(&hw, base, ctl | 2);
339
340 ide_init_port_hw(hwif, &hw);
341 342
342 return hwif; 343 return hwif;
343} 344}
@@ -430,6 +431,8 @@ out:
430 * @d: IDE port info 431 * @d: IDE port info
431 * @pciirq: IRQ line 432 * @pciirq: IRQ line
432 * @idx: ATA index table to update 433 * @idx: ATA index table to update
434 * @hw: hw_regs_t instances corresponding to this PCI IDE device
435 * @hws: hw_regs_t pointers table to update
433 * 436 *
434 * Scan the interfaces attached to this device and do any 437 * Scan the interfaces attached to this device and do any
435 * necessary per port setup. Attach the devices and ask the 438 * necessary per port setup. Attach the devices and ask the
@@ -440,7 +443,8 @@ out:
440 * where the chipset setup is not the default PCI IDE one. 443 * where the chipset setup is not the default PCI IDE one.
441 */ 444 */
442 445
443void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) 446void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d,
447 int pciirq, u8 *idx, hw_regs_t *hw, hw_regs_t **hws)
444{ 448{
445 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; 449 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
446 ide_hwif_t *hwif; 450 ide_hwif_t *hwif;
@@ -459,10 +463,11 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int
459 continue; /* port not enabled */ 463 continue; /* port not enabled */
460 } 464 }
461 465
462 hwif = ide_hwif_configure(dev, d, port, pciirq); 466 hwif = ide_hwif_configure(dev, d, port, pciirq, hw + port);
463 if (hwif == NULL) 467 if (hwif == NULL)
464 continue; 468 continue;
465 469
470 *(hws + port) = hw + port;
466 *(idx + port) = hwif->index; 471 *(idx + port) = hwif->index;
467 } 472 }
468} 473}
@@ -537,15 +542,16 @@ out:
537int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) 542int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d)
538{ 543{
539 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 544 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
545 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
540 int ret; 546 int ret;
541 547
542 ret = do_ide_setup_pci_device(dev, d, 1); 548 ret = do_ide_setup_pci_device(dev, d, 1);
543 549
544 if (ret >= 0) { 550 if (ret >= 0) {
545 /* FIXME: silent failure can happen */ 551 /* FIXME: silent failure can happen */
546 ide_pci_setup_ports(dev, d, ret, &idx[0]); 552 ide_pci_setup_ports(dev, d, ret, &idx[0], &hw[0], &hws[0]);
547 553
548 ide_device_add(idx, d); 554 ide_device_add(idx, d, hws);
549 } 555 }
550 556
551 return ret; 557 return ret;
@@ -557,6 +563,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
557{ 563{
558 struct pci_dev *pdev[] = { dev1, dev2 }; 564 struct pci_dev *pdev[] = { dev1, dev2 };
559 int ret, i; 565 int ret, i;
566 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
560 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 567 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
561 568
562 for (i = 0; i < 2; i++) { 569 for (i = 0; i < 2; i++) {
@@ -570,10 +577,11 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
570 goto out; 577 goto out;
571 578
572 /* FIXME: silent failure can happen */ 579 /* FIXME: silent failure can happen */
573 ide_pci_setup_ports(pdev[i], d, ret, &idx[i*2]); 580 ide_pci_setup_ports(pdev[i], d, ret, &idx[i*2], &hw[i*2],
581 &hws[i*2]);
574 } 582 }
575 583
576 ide_device_add(idx, d); 584 ide_device_add(idx, d, hws);
577out: 585out:
578 return ret; 586 return ret;
579} 587}