Merge branch 'release-2.6.27' of git://git.kernel.org/pub/scm/linux/kernel/git/ak...
[pandora-kernel.git] / drivers / ide / mips / au1xxx-ide.c
index 296b9c6..11b7f61 100644 (file)
@@ -48,8 +48,6 @@
 
 static _auide_hwif auide_hwif;
 
-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)
@@ -88,6 +86,17 @@ void auide_outsw(unsigned long port, void *addr, u32 count)
        ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
 }
 
+static void au1xxx_input_data(ide_drive_t *drive, struct request *rq,
+                             void *buf, unsigned int len)
+{
+       auide_insw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
+}
+
+static void au1xxx_output_data(ide_drive_t *drive, struct request *rq,
+                              void *buf, unsigned int len)
+{
+       auide_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
+}
 #endif
 
 static void au1xxx_set_pio_mode(ide_drive_t *drive, const u8 pio)
@@ -204,10 +213,8 @@ static int auide_build_dmatable(ide_drive_t *drive)
 {
        int i, iswrite, count = 0;
        ide_hwif_t *hwif = HWIF(drive);
-
        struct request *rq = HWGROUP(drive)->rq;
-
-       _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
+       _auide_hwif *ahwif = &auide_hwif;
        struct scatterlist *sg;
 
        iswrite = (rq_data_dir(rq) == WRITE);
@@ -359,7 +366,7 @@ static void auide_ddma_rx_callback(int irq, void *param)
 static void auide_init_dbdma_dev(dbdev_tab_t *dev, u32 dev_id, u32 tsize, u32 devwidth, u32 flags)
 {
        dev->dev_id          = dev_id;
-       dev->dev_physaddr    = (u32)AU1XXX_ATA_PHYS_ADDR;
+       dev->dev_physaddr    = (u32)IDE_PHYS_ADDR;
        dev->dev_intlevel    = 0;
        dev->dev_intpolarity = 0;
        dev->dev_tsize       = tsize;
@@ -393,11 +400,11 @@ static const struct ide_dma_ops au1xxx_dma_ops = {
 
 static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
 {
-       _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data;
+       _auide_hwif *auide = &auide_hwif;
        dbdev_tab_t source_dev_tab, target_dev_tab;
        u32 dev_id, tsize, devwidth, flags;
 
-       dev_id   = AU1XXX_ATA_DDMA_REQ;
+       dev_id   = IDE_DDMA_REQ;
 
        tsize    =  8; /*  1 */
        devwidth = 32; /* 16 */
@@ -454,7 +461,7 @@ static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
 #else
 static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
 {
-       _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data;
+       _auide_hwif *auide = &auide_hwif;
        dbdev_tab_t source_dev_tab;
        int flags;
 
@@ -506,12 +513,29 @@ static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif)
 
        /* FIXME? */
        for (i = 0; i < 8; i++)
-               *ata_regs++ = ahwif->regbase + (i << AU1XXX_ATA_REG_OFFSET);
+               *ata_regs++ = ahwif->regbase + (i << IDE_REG_SHIFT);
 
        /* set the Alternative Status register */
-       *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET);
+       *ata_regs = ahwif->regbase + (14 << IDE_REG_SHIFT);
 }
 
+#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
+static const struct ide_tp_ops au1xxx_tp_ops = {
+       .exec_command           = ide_exec_command,
+       .read_status            = ide_read_status,
+       .read_altstatus         = ide_read_altstatus,
+       .read_sff_dma_status    = ide_read_sff_dma_status,
+
+       .set_irq                = ide_set_irq,
+
+       .tf_load                = ide_tf_load,
+       .tf_read                = ide_tf_read,
+
+       .input_data             = au1xxx_input_data,
+       .output_data            = au1xxx_output_data,
+};
+#endif
+
 static const struct ide_port_ops au1xxx_port_ops = {
        .set_pio_mode           = au1xxx_set_pio_mode,
        .set_dma_mode           = auide_set_dma_mode,
@@ -519,6 +543,9 @@ static const struct ide_port_ops au1xxx_port_ops = {
 
 static const struct ide_port_info au1xxx_port_info = {
        .init_dma               = auide_ddma_init,
+#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
+       .tp_ops                 = &au1xxx_tp_ops,
+#endif
        .port_ops               = &au1xxx_port_ops,
 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
        .dma_ops                = &au1xxx_dma_ops,
@@ -536,11 +563,10 @@ static int au_ide_probe(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        _auide_hwif *ahwif = &auide_hwif;
-       ide_hwif_t *hwif;
        struct resource *res;
+       struct ide_host *host;
        int ret = 0;
-       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
-       hw_regs_t hw;
+       hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
 
 #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
        char *mode = "MWDMA2";
@@ -577,41 +603,19 @@ static int au_ide_probe(struct device *dev)
                goto out;
        }
 
-       hwif = ide_find_port();
-       if (hwif == NULL) {
-               ret = -ENOENT;
-               goto out;
-       }
-
        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;
-
-       /* If the user has selected DDMA assisted copies,
-          then set up a few local I/O function entry points 
-       */
-
-#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA     
-       hwif->INSW                      = auide_insw;
-       hwif->OUTSW                     = auide_outsw;
-#endif
-       hwif->select_data               = 0;    /* no chipset-specific code */
-       hwif->config_data               = 0;    /* no chipset-specific code */
-
-       auide_hwif.hwif                 = hwif;
-       hwif->hwif_data                 = &auide_hwif;
-
-       idx[0] = hwif->index;
+       ret = ide_host_add(&au1xxx_port_info, hws, &host);
+       if (ret)
+               goto out;
 
-       ide_device_add(idx, &au1xxx_port_info);
+       auide_hwif.hwif = host->ports[0];
 
-       dev_set_drvdata(dev, hwif);
+       dev_set_drvdata(dev, host);
 
        printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
 
@@ -623,10 +627,10 @@ static int au_ide_remove(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct resource *res;
-       ide_hwif_t *hwif = dev_get_drvdata(dev);
+       struct ide_host *host = dev_get_drvdata(dev);
        _auide_hwif *ahwif = &auide_hwif;
 
-       ide_unregister(hwif);
+       ide_host_remove(host);
 
        iounmap((void *)ahwif->regbase);