9 #include <linux/types.h>
10 #include <linux/kernel.h>
11 #include <linux/export.h>
12 #include <linux/pci.h>
33 static int ide_setup_pci_baseregs(
struct pci_dev *
dev,
const char *
name)
42 if ((progif & 0xa) != 0xa) {
44 "native PCI mode\n", name, pci_name(dev));
48 "mode\n", name, pci_name(dev));
53 "wanted 0x%04x, got 0x%04x\n",
54 name, pci_name(dev), progif | 5, progif);
61 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI
62 static int ide_pci_clear_simplex(
unsigned long dma_base,
const char *name)
64 u8 dma_stat =
inb(dma_base + 2);
66 outb(dma_stat & 0x60, dma_base + 2);
67 dma_stat =
inb(dma_base + 2);
69 return (dma_stat & 0x80) ? 1 : 0;
83 unsigned long dma_base = 0;
88 if (hwif->
mate && hwif->
mate->dma_base) {
89 dma_base = hwif->
mate->dma_base - (hwif->
channel ? 0 : 8);
97 d->
name, pci_name(dev));
120 d->
name, pci_name(dev));
134 dma_stat = hwif->
dma_ops->dma_sff_read_status(hwif);
135 if ((dma_stat & 0x80) && hwif->
mate && hwif->
mate->dma_base) {
137 d->
name, pci_name(dev));
148 int ide_pci_set_master(
struct pci_dev *dev,
const char *name)
157 if (pci_read_config_word(dev,
PCI_COMMAND, &pcicmd) ||
158 (pcicmd & PCI_COMMAND_MASTER) == 0) {
160 name, pci_name(dev));
173 d->
name, pci_name(dev),
200 d->
name, pci_name(dev));
204 d->
name, pci_name(dev));
215 d->
name, pci_name(dev));
234 d->
name, pci_name(dev));
258 if (ide_setup_pci_baseregs(dev, d->
name) ||
261 d->
name, pci_name(dev));
264 if (pci_read_config_word(dev,
PCI_COMMAND, &pcicmd)) {
266 d->
name, pci_name(dev));
271 d->
name, pci_name(dev));
321 unsigned long ctl = 0,
base = 0;
324 if (ide_pci_check_iomem(dev, d, 2 * port) ||
325 ide_pci_check_iomem(dev, d, 2 * port + 1)) {
327 "reported as MEM for port %d!\n",
328 d->
name, pci_name(dev), port);
336 ctl = port ? 0x374 : 0x3f4;
337 base = port ? 0x170 : 0x1f0;
342 d->
name, pci_name(dev), port);
346 memset(hw, 0,
sizeof(*hw));
348 ide_std_init_ports(hw, base, ctl | 2);
353 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI
370 (dev->
class & 0x80))) {
371 unsigned long base = ide_pci_dma_base(hwif, d);
381 if (ide_pci_check_simplex(hwif, d) < 0)
384 if (ide_pci_set_master(dev, d->
name) < 0)
391 hwif->
name, base, base + 7);
414 static int ide_setup_pci_controller(
struct pci_dev *dev,
423 ret = ide_pci_enable(dev, d);
427 ret = pci_read_config_word(dev,
PCI_COMMAND, &pcicmd);
430 d->
name, pci_name(dev));
433 if (!(pcicmd & PCI_COMMAND_IO)) {
434 ret = ide_pci_configure(dev, d);
438 d->
name, pci_name(dev));
474 if (e->
reg && (pci_read_config_byte(dev, e->
reg, &tmp) ||
477 d->
name, pci_name(dev));
481 if (ide_hw_configure(dev, d, port, hw + port))
484 *(hws +
port) = hw + port;
499 static int do_ide_setup_pci_device(
struct pci_dev *dev,
520 if (ide_pci_is_in_compatibility_mode(dev)) {
523 "probe irqs later\n", d->
name, pci_name(dev));
525 }
else if (!pciirq && noisy) {
527 d->
name, pci_name(dev), pciirq);
530 d->
name, pci_name(dev), pciirq);
546 for (i = 0; i < n_ports / 2; i++) {
547 ret = ide_setup_pci_controller(pdev[i], d, !i);
560 host->
dev[0] = &dev1->
dev;
562 host->
dev[1] = &dev2->
dev;
567 pci_set_drvdata(pdev[0], host);
569 pci_set_drvdata(pdev[1], host);
571 for (i = 0; i < n_ports / 2; i++) {
572 ret = do_ide_setup_pci_device(pdev[i], d, !i);
582 if (ide_pci_is_in_compatibility_mode(pdev[i])) {
583 hw[i*2].
irq = pci_get_legacy_ide_irq(pdev[i], 0);
584 hw[i*2 + 1].
irq = pci_get_legacy_ide_irq(pdev[i], 1);