]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
Merge branch 'omap-clock-fixes' of git://git.pwsan.com/linux-2.6
[linux-2.6-omap-h63xx.git] / drivers / scsi / aic7xxx / aic7xxx_osm_pci.c
index 3d3eaef65fb3e6ded30a548eb7e1d25eab1e5300..78fc70c24e078638478b8f9defd9dbd801eaea4f 100644 (file)
@@ -46,7 +46,7 @@
 */
 #define ID(x)  ID_C(x, PCI_CLASS_STORAGE_SCSI)
 
-static struct pci_device_id ahc_linux_pci_id_table[] = {
+static const struct pci_device_id ahc_linux_pci_id_table[] = {
        /* aic7850 based controllers */
        ID(ID_AHA_2902_04_10_15_20C_30C),
        /* aic7860 based controllers */
@@ -206,7 +206,7 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        const uint64_t   mask_39bit = 0x7FFFFFFFFFULL;
        struct           ahc_softc *ahc;
        ahc_dev_softc_t  pci;
-       struct           ahc_pci_identity *entry;
+       const struct ahc_pci_identity *entry;
        char            *name;
        int              error;
        struct device   *dev = &pdev->dev;
@@ -241,10 +241,10 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (sizeof(dma_addr_t) > 4
            && ahc->features & AHC_LARGE_SCBS
            && dma_set_mask(dev, mask_39bit) == 0
-           && dma_get_required_mask(dev) > DMA_32BIT_MASK) {
+           && dma_get_required_mask(dev) > DMA_BIT_MASK(32)) {
                ahc->flags |= AHC_39BIT_ADDRESSING;
        } else {
-               if (dma_set_mask(dev, DMA_32BIT_MASK)) {
+               if (dma_set_mask(dev, DMA_BIT_MASK(32))) {
                        ahc_free(ahc);
                        printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
                        return (-ENODEV);
@@ -269,6 +269,57 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        return (0);
 }
 
+/******************************* PCI Routines *********************************/
+uint32_t
+ahc_pci_read_config(ahc_dev_softc_t pci, int reg, int width)
+{
+       switch (width) {
+       case 1:
+       {
+               uint8_t retval;
+
+               pci_read_config_byte(pci, reg, &retval);
+               return (retval);
+       }
+       case 2:
+       {
+               uint16_t retval;
+               pci_read_config_word(pci, reg, &retval);
+               return (retval);
+       }
+       case 4:
+       {
+               uint32_t retval;
+               pci_read_config_dword(pci, reg, &retval);
+               return (retval);
+       }
+       default:
+               panic("ahc_pci_read_config: Read size too big");
+               /* NOTREACHED */
+               return (0);
+       }
+}
+
+void
+ahc_pci_write_config(ahc_dev_softc_t pci, int reg, uint32_t value, int width)
+{
+       switch (width) {
+       case 1:
+               pci_write_config_byte(pci, reg, value);
+               break;
+       case 2:
+               pci_write_config_word(pci, reg, value);
+               break;
+       case 4:
+               pci_write_config_dword(pci, reg, value);
+               break;
+       default:
+               panic("ahc_pci_write_config: Write size too big");
+               /* NOTREACHED */
+       }
+}
+
+
 static struct pci_driver aic7xxx_pci_driver = {
        .name           = "aic7xxx",
        .probe          = ahc_linux_pci_dev_probe,
@@ -293,7 +344,7 @@ ahc_linux_pci_exit(void)
 }
 
 static int
-ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc, u_long *base)
+ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc, resource_size_t *base)
 {
        if (aic7xxx_allow_memio == 0)
                return (ENOMEM);
@@ -301,24 +352,24 @@ ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc, u_long *base)
        *base = pci_resource_start(ahc->dev_softc, 0);
        if (*base == 0)
                return (ENOMEM);
-       if (request_region(*base, 256, "aic7xxx") == 0)
+       if (!request_region(*base, 256, "aic7xxx"))
                return (ENOMEM);
        return (0);
 }
 
 static int
 ahc_linux_pci_reserve_mem_region(struct ahc_softc *ahc,
-                                u_long *bus_addr,
+                                resource_size_t *bus_addr,
                                 uint8_t __iomem **maddr)
 {
-       u_long  start;
+       resource_size_t start;
        int     error;
 
        error = 0;
        start = pci_resource_start(ahc->dev_softc, 1);
        if (start != 0) {
                *bus_addr = start;
-               if (request_mem_region(start, 0x1000, "aic7xxx") == 0)
+               if (!request_mem_region(start, 0x1000, "aic7xxx"))
                        error = ENOMEM;
                if (error == 0) {
                        *maddr = ioremap_nocache(start, 256);
@@ -336,7 +387,7 @@ int
 ahc_pci_map_registers(struct ahc_softc *ahc)
 {
        uint32_t command;
-       u_long   base;
+       resource_size_t base;
        uint8_t __iomem *maddr;
        int      error;
 
@@ -374,12 +425,12 @@ ahc_pci_map_registers(struct ahc_softc *ahc)
                } else
                        command |= PCIM_CMD_MEMEN;
        } else {
-               printf("aic7xxx: PCI%d:%d:%d MEM region 0x%lx "
+               printf("aic7xxx: PCI%d:%d:%d MEM region 0x%llx "
                       "unavailable. Cannot memory map device.\n",
                       ahc_get_pci_bus(ahc->dev_softc),
                       ahc_get_pci_slot(ahc->dev_softc),
                       ahc_get_pci_function(ahc->dev_softc),
-                      base);
+                      (unsigned long long)base);
        }
 
        /*
@@ -390,15 +441,15 @@ ahc_pci_map_registers(struct ahc_softc *ahc)
                error = ahc_linux_pci_reserve_io_region(ahc, &base);
                if (error == 0) {
                        ahc->tag = BUS_SPACE_PIO;
-                       ahc->bsh.ioport = base;
+                       ahc->bsh.ioport = (u_long)base;
                        command |= PCIM_CMD_PORTEN;
                } else {
-                       printf("aic7xxx: PCI%d:%d:%d IO region 0x%lx[0..255] "
+                       printf("aic7xxx: PCI%d:%d:%d IO region 0x%llx[0..255] "
                               "unavailable. Cannot map device.\n",
                               ahc_get_pci_bus(ahc->dev_softc),
                               ahc_get_pci_slot(ahc->dev_softc),
                               ahc_get_pci_function(ahc->dev_softc),
-                              base);
+                              (unsigned long long)base);
                }
        }
        ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, command, 4);