]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/setup-pci.c
V4L/DVB (8301): sms1xxx: add capability to define device-specific firmware filenames
[linux-2.6-omap-h63xx.git] / drivers / ide / setup-pci.c
index bf28970b0278ef44a65595c235be05875e727938..65fc08b6b6d0e813f4eed2e5594c1149a5233d7b 100644 (file)
@@ -6,19 +6,15 @@
  *  May be copied or modified under the terms of the GNU General Public License
  */
 
-#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/init.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/ide.h>
 #include <linux/dma-mapping.h>
 
 #include <asm/io.h>
-#include <asm/irq.h>
 
 /**
  *     ide_setup_pci_baseregs  -       place a PCI IDE controller native
@@ -72,22 +68,22 @@ static void ide_pci_clear_simplex(unsigned long dma_base, const char *name)
 }
 
 /**
- *     ide_get_or_set_dma_base         -       setup BMIBA
- *     @d: IDE port info
+ *     ide_pci_dma_base        -       setup BMIBA
  *     @hwif: IDE interface
+ *     @d: IDE port info
  *
  *     Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space.
  *     Where a device has a partner that is already in DMA mode we check
  *     and enforce IDE simplex rules.
  */
 
-static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif)
+unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d)
 {
        struct pci_dev *dev = to_pci_dev(hwif->dev);
        unsigned long dma_base = 0;
        u8 dma_stat = 0;
 
-       if (hwif->mmio)
+       if (hwif->host_flags & IDE_HFLAG_MMIO)
                return hwif->dma_base;
 
        if (hwif->mate && hwif->mate->dma_base) {
@@ -132,11 +128,12 @@ static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_
 out:
        return dma_base;
 }
+EXPORT_SYMBOL_GPL(ide_pci_dma_base);
 
 /*
  * Set up BM-DMA capability (PnP BIOS should have done this)
  */
-static int ide_pci_set_master(struct pci_dev *dev, const char *name)
+int ide_pci_set_master(struct pci_dev *dev, const char *name)
 {
        u16 pcicmd;
 
@@ -155,6 +152,7 @@ static int ide_pci_set_master(struct pci_dev *dev, const char *name)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(ide_pci_set_master);
 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
 
 void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d)
@@ -317,25 +315,22 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
 
                ctl  = pci_resource_start(dev, 2*port+1);
                base = pci_resource_start(dev, 2*port);
-               if ((ctl && !base) || (base && !ctl)) {
-                       printk(KERN_ERR "%s: inconsistent baseregs (BIOS) "
-                               "for port %d, skipping\n", d->name, port);
-                       return NULL;
-               }
-       }
-       if (!ctl) {
+       } else {
                /* Use default values */
                ctl = port ? 0x374 : 0x3f4;
                base = port ? 0x170 : 0x1f0;
        }
 
-       hwif = ide_find_port_slot(d);
-       if (hwif == NULL) {
-               printk(KERN_ERR "%s: too many IDE interfaces, no room in "
-                               "table\n", d->name);
+       if (!base || !ctl) {
+               printk(KERN_ERR "%s: bad PCI BARs for port %d, skipping\n",
+                               d->name, port);
                return NULL;
        }
 
+       hwif = ide_find_port_slot(d);
+       if (hwif == NULL)
+               return NULL;
+
        memset(&hw, 0, sizeof(hw));
        hw.irq = irq;
        hw.dev = &dev->dev;
@@ -344,8 +339,6 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
 
        ide_init_port_hw(hwif, &hw);
 
-       hwif->dev = &dev->dev;
-
        return hwif;
 }
 
@@ -360,29 +353,33 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
  *     state
  */
 
-void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d)
+int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d)
 {
        struct pci_dev *dev = to_pci_dev(hwif->dev);
 
        if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 ||
            ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE &&
             (dev->class & 0x80))) {
-               unsigned long dma_base = ide_get_or_set_dma_base(d, hwif);
+               unsigned long base = ide_pci_dma_base(hwif, d);
+
+               if (base == 0 || ide_pci_set_master(dev, d->name) < 0)
+                       return -1;
 
-               if (dma_base == 0 || ide_pci_set_master(dev, d->name) < 0)
-                       goto out_disabled;
+               if (hwif->host_flags & IDE_HFLAG_MMIO)
+                       printk(KERN_INFO "    %s: MMIO-DMA\n", hwif->name);
+               else
+                       printk(KERN_INFO "    %s: BM-DMA at 0x%04lx-0x%04lx\n",
+                                        hwif->name, base, base + 7);
 
-               if (d->init_dma)
-                       d->init_dma(hwif, dma_base);
+               hwif->extra_base = base + (hwif->channel ? 8 : 16);
 
-               ide_setup_dma(hwif, dma_base);
-       }
+               if (ide_allocate_dma_engine(hwif))
+                       return -1;
 
-       return;
+               ide_setup_dma(hwif, base);
+       }
 
-out_disabled:
-       printk(KERN_INFO "%s: Bus-Master DMA disabled (BIOS) on %s\n",
-                        d->name, pci_name(dev));
+       return 0;
 }
 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */