]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ppc/pmac.c
Merge branch 'reg-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg...
[linux-2.6-omap-h63xx.git] / drivers / ide / ppc / pmac.c
index 7c3a84f8fbed71fc51de9fff5b31b7aa4a3a98a5..fa2be26272d565fe6284ae2ea37878f0456c6932 100644 (file)
@@ -486,18 +486,25 @@ pmac_ide_do_update_timings(ide_drive_t *drive)
                pmac_ide_selectproc(drive);
 }
 
-static void pmac_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port)
+static void pmac_exec_command(ide_hwif_t *hwif, u8 cmd)
 {
-       u32 tmp;
-       
-       writeb(value, (void __iomem *) port);
-       tmp = readl((void __iomem *)(hwif->io_ports.data_addr
+       writeb(cmd, (void __iomem *)hwif->io_ports.command_addr);
+       (void)readl((void __iomem *)(hwif->io_ports.data_addr
                                     + IDE_TIMING_CONFIG));
 }
 
-static void pmac_exec_command(ide_hwif_t *hwif, u8 cmd)
+static void pmac_set_irq(ide_hwif_t *hwif, int on)
 {
-       writeb(cmd, (void __iomem *)hwif->io_ports.command_addr);
+       u8 ctl = ATA_DEVCTL_OBS;
+
+       if (on == 4) { /* hack for SRST */
+               ctl |= 4;
+               on &= ~4;
+       }
+
+       ctl |= on ? 0 : 2;
+
+       writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr);
        (void)readl((void __iomem *)(hwif->io_ports.data_addr
                                     + IDE_TIMING_CONFIG));
 }
@@ -967,6 +974,21 @@ static void pmac_ide_init_dev(ide_drive_t *drive)
        }
 }
 
+static const struct ide_tp_ops pmac_tp_ops = {
+       .exec_command           = pmac_exec_command,
+       .read_status            = ide_read_status,
+       .read_altstatus         = ide_read_altstatus,
+       .read_sff_dma_status    = ide_read_sff_dma_status,
+
+       .set_irq                = pmac_set_irq,
+
+       .tf_load                = ide_tf_load,
+       .tf_read                = ide_tf_read,
+
+       .input_data             = ide_input_data,
+       .output_data            = ide_output_data,
+};
+
 static const struct ide_port_ops pmac_ide_ata6_port_ops = {
        .init_dev               = pmac_ide_init_dev,
        .set_pio_mode           = pmac_ide_set_pio_mode,
@@ -996,10 +1018,11 @@ static const struct ide_port_info pmac_port_info = {
        .name                   = DRV_NAME,
        .init_dma               = pmac_ide_init_dma,
        .chipset                = ide_pmac,
+       .tp_ops                 = &pmac_tp_ops,
+       .port_ops               = &pmac_ide_port_ops,
 #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
        .dma_ops                = &pmac_dma_ops,
 #endif
-       .port_ops               = &pmac_ide_port_ops,
        .host_flags             = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA |
                                  IDE_HFLAG_POST_SET_MODE |
                                  IDE_HFLAG_MMIO |
@@ -1016,10 +1039,11 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
 {
        struct device_node *np = pmif->node;
        const int *bidp;
+       struct ide_host *host;
        ide_hwif_t *hwif;
        hw_regs_t *hws[] = { hw, NULL, NULL, NULL };
-       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
        struct ide_port_info d = pmac_port_info;
+       int rc;
 
        pmif->broken_dma = pmif->broken_dma_warn = 0;
        if (of_device_is_compatible(np, "shasta-ata")) {
@@ -1062,6 +1086,11 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
        /* Make sure we have sane timings */
        sanitize_timings(pmif);
 
+       host = ide_host_alloc(&d, hws);
+       if (host == NULL)
+               return -ENOMEM;
+       hwif = host->ports[0];
+
 #ifndef CONFIG_PPC64
        /* XXX FIXME: Media bay stuff need re-organizing */
        if (np->parent && np->parent->name
@@ -1095,19 +1124,11 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
                         pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id,
                         pmif->mediabay ? " (mediabay)" : "", hw->irq);
 
-       hwif = ide_find_port_slot(&d);
-       if (hwif == NULL)
-               return -ENOENT;
-
-       hwif->exec_command = pmac_exec_command;
-
-       /* Setup MMIO ops */
-       default_hwif_mmiops(hwif);
-               hwif->OUTBSYNC = pmac_outbsync;
-
-       idx[0] = hwif->index;
-
-       ide_device_add(idx, &d, hws);
+       rc = ide_host_register(host, &d, hws);
+       if (rc) {
+               ide_host_free(host);
+               return rc;
+       }
 
        return 0;
 }