Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[linux-2.6.git] / drivers / ata / pata_rb532_cf.c
index a108d25..45f1e10 100644 (file)
 #define RB500_CF_MAXPORTS      1
 #define RB500_CF_IO_DELAY      400
 
-#define RB500_CF_REG_CMD       0x0800
+#define RB500_CF_REG_BASE      0x0800
+#define RB500_CF_REG_ERR       0x080D
 #define RB500_CF_REG_CTRL      0x080E
-#define RB500_CF_REG_DATA      0x0C00
+/* 32bit buffered data register offset */
+#define RB500_CF_REG_DBUF32    0x0C00
 
 struct rb532_cf_info {
        void __iomem    *iobase;
        unsigned int    gpio_line;
-       int             frozen;
        unsigned int    irq;
 };
 
 /* ------------------------------------------------------------------------ */
 
-static inline void rb532_pata_finish_io(struct ata_port *ap)
-{
-       struct ata_host *ah = ap->host;
-       struct rb532_cf_info *info = ah->private_data;
-
-       ata_sff_altstatus(ap);
-       ndelay(RB500_CF_IO_DELAY);
-
-       set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH);
-}
-
-static void rb532_pata_exec_command(struct ata_port *ap,
-                               const struct ata_taskfile *tf)
-{
-       writeb(tf->command, ap->ioaddr.command_addr);
-       rb532_pata_finish_io(ap);
-}
-
-static void rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf,
-                               unsigned int buflen, int write_data)
-{
-       struct ata_port *ap = adev->link->ap;
-       void __iomem *ioaddr = ap->ioaddr.data_addr;
-
-       if (write_data) {
-               for (; buflen > 0; buflen--, buf++)
-                       writeb(*buf, ioaddr);
-       } else {
-               for (; buflen > 0; buflen--, buf++)
-                       *buf = readb(ioaddr);
-       }
-
-       rb532_pata_finish_io(adev->link->ap);
-}
-
-static void rb532_pata_freeze(struct ata_port *ap)
-{
-       struct rb532_cf_info *info = ap->host->private_data;
-
-       info->frozen = 1;
-}
-
-static void rb532_pata_thaw(struct ata_port *ap)
-{
-       struct rb532_cf_info *info = ap->host->private_data;
-
-       info->frozen = 0;
-}
-
 static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance)
 {
        struct ata_host *ah = dev_instance;
@@ -108,8 +60,7 @@ static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance)
 
        if (gpio_get_value(info->gpio_line)) {
                set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW);
-               if (!info->frozen)
-                       ata_sff_interrupt(info->irq, dev_instance);
+               ata_sff_interrupt(info->irq, dev_instance);
        } else {
                set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH);
        }
@@ -119,10 +70,7 @@ static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance)
 
 static struct ata_port_operations rb532_pata_port_ops = {
        .inherits               = &ata_sff_port_ops,
-       .sff_exec_command       = rb532_pata_exec_command,
-       .sff_data_xfer          = rb532_pata_data_xfer,
-       .freeze                 = rb532_pata_freeze,
-       .thaw                   = rb532_pata_thaw,
+       .sff_data_xfer          = ata_sff_data_xfer32,
 };
 
 /* ------------------------------------------------------------------------ */
@@ -141,21 +89,22 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
        ap = ah->ports[0];
 
        ap->ops         = &rb532_pata_port_ops;
-       ap->pio_mask    = 0x1f; /* PIO4 */
+       ap->pio_mask    = ATA_PIO4;
        ap->flags       = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO;
 
-       ap->ioaddr.cmd_addr     = info->iobase + RB500_CF_REG_CMD;
+       ap->ioaddr.cmd_addr     = info->iobase + RB500_CF_REG_BASE;
        ap->ioaddr.ctl_addr     = info->iobase + RB500_CF_REG_CTRL;
        ap->ioaddr.altstatus_addr = info->iobase + RB500_CF_REG_CTRL;
 
        ata_sff_std_ports(&ap->ioaddr);
 
-       ap->ioaddr.data_addr    = info->iobase + RB500_CF_REG_DATA;
+       ap->ioaddr.data_addr    = info->iobase + RB500_CF_REG_DBUF32;
+       ap->ioaddr.error_addr   = info->iobase + RB500_CF_REG_ERR;
 }
 
 static __devinit int rb532_pata_driver_probe(struct platform_device *pdev)
 {
-       unsigned int irq;
+       int irq;
        int gpio;
        struct resource *res;
        struct ata_host *ah;
@@ -202,7 +151,7 @@ static __devinit int rb532_pata_driver_probe(struct platform_device *pdev)
        info->irq = irq;
 
        info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
-                               res->end - res->start + 1);
+                               resource_size(res));
        if (!info->iobase)
                return -ENOMEM;