]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/mips/au1xxx-ide.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6-omap-h63xx.git] / drivers / ide / mips / au1xxx-ide.c
index 7ec96a030041b61c842f578ee1658c0516775392..9b628248f2f4a8c174c32b027671a21303317c21 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/mips/au1xxx-ide.c  version 01.30.00        Aug. 02 2005
- *
  * BRIEF MODULE DESCRIPTION
  * AMD Alchemy Au1xxx IDE interface routines over the Static Bus
  *
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
-
 #include <linux/init.h>
 #include <linux/ide.h>
-#include <linux/sysdev.h>
-
-#include <linux/dma-mapping.h>
-
-#include "ide-timing.h"
+#include <linux/scatterlist.h>
 
-#include <asm/io.h>
 #include <asm/mach-au1x00/au1xxx.h>
 #include <asm/mach-au1x00/au1xxx_dbdma.h>
-
 #include <asm/mach-au1x00/au1xxx_ide.h>
 
 #define DRV_NAME       "au1200-ide"
-#define DRV_VERSION    "1.0"
 #define DRV_AUTHOR     "Enrico Walther <enrico.walther@amd.com> / Pete Popov <ppopov@embeddedalley.com>"
 
 /* enable the burstmode in the dbdma */
@@ -59,6 +49,8 @@
 static _auide_hwif auide_hwif;
 static int dbdma_init_done;
 
+static int auide_ddma_init(_auide_hwif *auide);
+
 #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
 
 void auide_insw(unsigned long port, void *addr, u32 count)
@@ -209,23 +201,6 @@ static void auide_set_dma_mode(ide_drive_t *drive, const u8 speed)
  */
 
 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
-
-static int auide_build_sglist(ide_drive_t *drive,  struct request *rq)
-{
-       ide_hwif_t *hwif = drive->hwif;
-       struct scatterlist *sg = hwif->sg_table;
-
-       ide_map_sg(drive, rq);
-
-       if (rq_data_dir(rq) == READ)
-               hwif->sg_dma_direction = DMA_FROM_DEVICE;
-       else
-               hwif->sg_dma_direction = DMA_TO_DEVICE;
-
-       return dma_map_sg(hwif->dev, sg, hwif->sg_nents,
-                         hwif->sg_dma_direction);
-}
-
 static int auide_build_dmatable(ide_drive_t *drive)
 {
        int i, iswrite, count = 0;
@@ -240,8 +215,7 @@ static int auide_build_dmatable(ide_drive_t *drive)
        /* Save for interrupt context */
        ahwif->drive = drive;
 
-       /* Build sglist */
-       hwif->sg_nents = i = auide_build_sglist(drive, rq);
+       hwif->sg_nents = i = ide_build_sglist(drive, rq);
 
        if (!i)
                return 0;
@@ -299,10 +273,7 @@ static int auide_build_dmatable(ide_drive_t *drive)
                return 1;
 
  use_pio_instead:
-       dma_unmap_sg(hwif->dev,
-                    hwif->sg_table,
-                    hwif->sg_nents,
-                    hwif->sg_dma_direction);
+       ide_destroy_dmatable(drive);
 
        return 0; /* revert to PIO for this request */
 }
@@ -312,8 +283,7 @@ static int auide_dma_end(ide_drive_t *drive)
        ide_hwif_t *hwif = HWIF(drive);
 
        if (hwif->sg_nents) {
-               dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->sg_nents,
-                            hwif->sg_dma_direction);
+               ide_destroy_dmatable(drive);
                hwif->sg_nents = 0;
        }
 
@@ -573,6 +543,17 @@ static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif)
        *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET);
 }
 
+static const struct ide_port_info au1xxx_port_info = {
+       .host_flags             = IDE_HFLAG_POST_SET_MODE |
+                                 IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
+                                 IDE_HFLAG_NO_IO_32BIT |
+                                 IDE_HFLAG_UNMASK_IRQS,
+       .pio_mask               = ATA_PIO4,
+#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
+       .mwdma_mask             = ATA_MWDMA2,
+#endif
+};
+
 static int au_ide_probe(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
@@ -605,13 +586,14 @@ static int au_ide_probe(struct device *dev)
                goto out;
        }
 
-       if (!request_mem_region (res->start, res->end-res->start, pdev->name)) {
+       if (!request_mem_region(res->start, res->end - res->start + 1,
+                               pdev->name)) {
                pr_debug("%s: request_mem_region failed\n", DRV_NAME);
                ret =  -EBUSY;
                goto out;
        }
 
-       ahwif->regbase = (u32)ioremap(res->start, res->end-res->start);
+       ahwif->regbase = (u32)ioremap(res->start, res->end - res->start + 1);
        if (ahwif->regbase == 0) {
                ret = -ENOMEM;
                goto out;
@@ -624,30 +606,13 @@ static int au_ide_probe(struct device *dev)
        memset(&hw, 0, sizeof(hw));
        auide_setup_ports(&hw, ahwif);
        hw.irq = ahwif->irq;
+       hw.dev = dev;
        hw.chipset = ide_au1xxx;
 
        ide_init_port_hw(hwif, &hw);
 
        hwif->dev = dev;
 
-       hwif->ultra_mask                = 0x0;  /* Disable Ultra DMA */
-#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
-       hwif->mwdma_mask                = 0x07; /* Multimode-2 DMA  */
-       hwif->swdma_mask                = 0x00;
-#else
-       hwif->mwdma_mask                = 0x0;
-       hwif->swdma_mask                = 0x0;
-#endif
-
-       hwif->pio_mask = ATA_PIO4;
-       hwif->host_flags = IDE_HFLAG_POST_SET_MODE;
-
-       hwif->drives[0].unmask          = 1;
-       hwif->drives[1].unmask          = 1;
-
-       /* hold should be on in all cases */
-       hwif->hold                      = 1;
-
        hwif->mmio  = 1;
 
        /* If the user has selected DDMA assisted copies,
@@ -675,16 +640,9 @@ static int au_ide_probe(struct device *dev)
        hwif->ide_dma_test_irq          = &auide_dma_test_irq;
        hwif->dma_lost_irq              = &auide_dma_lost_irq;
 #endif
-       hwif->channel                   = 0;
        hwif->select_data               = 0;    /* no chipset-specific code */
        hwif->config_data               = 0;    /* no chipset-specific code */
 
-       hwif->drives[0].autotune        = 1;    /* 1=autotune, 2=noautotune, 0=default */
-       hwif->drives[1].autotune        = 1;
-
-       hwif->drives[0].no_io_32bit     = 1;
-       hwif->drives[1].no_io_32bit     = 1;
-
        auide_hwif.hwif                 = hwif;
        hwif->hwif_data                 = &auide_hwif;
 
@@ -695,7 +653,7 @@ static int au_ide_probe(struct device *dev)
 
        idx[0] = hwif->index;
 
-       ide_device_add(idx);
+       ide_device_add(idx, &au1xxx_port_info);
 
        dev_set_drvdata(dev, hwif);
 
@@ -712,12 +670,12 @@ static int au_ide_remove(struct device *dev)
        ide_hwif_t *hwif = dev_get_drvdata(dev);
        _auide_hwif *ahwif = &auide_hwif;
 
-       ide_unregister(hwif - ide_hwifs);
+       ide_unregister(hwif->index);
 
        iounmap((void *)ahwif->regbase);
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       release_mem_region(res->start, res->end - res->start);
+       release_mem_region(res->start, res->end - res->start + 1);
 
        return 0;
 }