Merge branch 'drm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[safe/jmp/linux-2.6] / drivers / ata / pata_mpc52xx.c
index 8a9d80c..a9e8273 100644 (file)
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/libata.h>
+#include <linux/of_platform.h>
 
 #include <asm/types.h>
 #include <asm/prom.h>
-#include <asm/of_platform.h>
 #include <asm/mpc52xx.h>
 
 
 #define DRV_NAME       "mpc52xx_ata"
-#define DRV_VERSION    "0.1.0"
+#define DRV_VERSION    "0.1.2"
 
 
 /* Private structures used by the driver */
@@ -252,78 +252,43 @@ mpc52xx_ata_dev_select(struct ata_port *ap, unsigned int device)
        if (device != priv->csel)
                mpc52xx_ata_apply_timings(priv, device);
 
-       ata_std_dev_select(ap,device);
+       ata_sff_dev_select(ap,device);
 }
 
-static void
-mpc52xx_ata_error_handler(struct ata_port *ap)
-{
-       ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL,
-                       ata_std_postreset);
-}
-
-
-
 static struct scsi_host_template mpc52xx_ata_sht = {
-       .module                 = THIS_MODULE,
-       .name                   = DRV_NAME,
-       .ioctl                  = ata_scsi_ioctl,
-       .queuecommand           = ata_scsi_queuecmd,
-       .can_queue              = ATA_DEF_QUEUE,
-       .this_id                = ATA_SHT_THIS_ID,
-       .sg_tablesize           = LIBATA_MAX_PRD,
-       .max_sectors            = ATA_MAX_SECTORS,
-       .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
-       .emulated               = ATA_SHT_EMULATED,
-       .use_clustering         = ATA_SHT_USE_CLUSTERING,
-       .proc_name              = DRV_NAME,
-       .dma_boundary           = ATA_DMA_BOUNDARY,
-       .slave_configure        = ata_scsi_slave_config,
-       .bios_param             = ata_std_bios_param,
+       ATA_PIO_SHT(DRV_NAME),
 };
 
 static struct ata_port_operations mpc52xx_ata_port_ops = {
-       .port_disable           = ata_port_disable,
+       .inherits               = &ata_sff_port_ops,
+       .sff_dev_select         = mpc52xx_ata_dev_select,
+       .cable_detect           = ata_cable_40wire,
        .set_piomode            = mpc52xx_ata_set_piomode,
-       .dev_select             = mpc52xx_ata_dev_select,
-       .tf_load                = ata_tf_load,
-       .tf_read                = ata_tf_read,
-       .check_status           = ata_check_status,
-       .exec_command           = ata_exec_command,
-       .freeze                 = ata_bmdma_freeze,
-       .thaw                   = ata_bmdma_thaw,
-       .error_handler          = mpc52xx_ata_error_handler,
-       .qc_prep                = ata_qc_prep,
-       .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_data_xfer,
-       .irq_handler            = ata_interrupt,
-       .irq_clear              = ata_bmdma_irq_clear,
-       .port_start             = ata_port_start,
-};
-
-static struct ata_probe_ent mpc52xx_ata_probe_ent = {
-       .port_ops       = &mpc52xx_ata_port_ops,
-       .sht            = &mpc52xx_ata_sht,
-       .n_ports        = 1,
-       .pio_mask       = 0x1f,         /* Up to PIO4 */
-       .mwdma_mask     = 0x00,         /* No MWDMA   */
-       .udma_mask      = 0x00,         /* No UDMA    */
-       .port_flags     = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
-       .irq_flags      = 0,
+       .post_internal_cmd      = ATA_OP_NULL,
 };
 
 static int __devinit
-mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv)
+mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv,
+                    unsigned long raw_ata_regs)
 {
-       struct ata_probe_ent *ae = &mpc52xx_ata_probe_ent;
-       struct ata_ioports *aio = &ae->port[0];
-       int rv;
-
-       INIT_LIST_HEAD(&ae->node);
-       ae->dev = dev;
-       ae->irq = priv->ata_irq;
-
-       aio->cmd_addr           = 0;    /* Don't have a classic reg block */
+       struct ata_host *host;
+       struct ata_port *ap;
+       struct ata_ioports *aio;
+
+       host = ata_host_alloc(dev, 1);
+       if (!host)
+               return -ENOMEM;
+
+       ap = host->ports[0];
+       ap->flags               |= ATA_FLAG_SLAVE_POSS;
+       ap->pio_mask            = 0x1f; /* Up to PIO4 */
+       ap->mwdma_mask          = 0x00; /* No MWDMA   */
+       ap->udma_mask           = 0x00; /* No UDMA    */
+       ap->ops                 = &mpc52xx_ata_port_ops;
+       host->private_data      = priv;
+
+       aio = &ap->ioaddr;
+       aio->cmd_addr           = NULL; /* Don't have a classic reg block */
        aio->altstatus_addr     = &priv->ata_regs->tf_control;
        aio->ctl_addr           = &priv->ata_regs->tf_control;
        aio->data_addr          = &priv->ata_regs->tf_data;
@@ -337,11 +302,11 @@ mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv)
        aio->status_addr        = &priv->ata_regs->tf_command;
        aio->command_addr       = &priv->ata_regs->tf_command;
 
-       ae->private_data = priv;
-
-       rv = ata_device_add(ae);
+       ata_port_desc(ap, "ata_regs 0x%lx", raw_ata_regs);
 
-       return rv ? 0 : -EINVAL;
+       /* activate host */
+       return ata_host_activate(host, priv->ata_irq, ata_sff_interrupt, 0,
+                                &mpc52xx_ata_sht);
 }
 
 static struct mpc52xx_ata_priv *
@@ -365,7 +330,7 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
 {
        unsigned int ipb_freq;
        struct resource res_mem;
-       int ata_irq = NO_IRQ;
+       int ata_irq;
        struct mpc52xx_ata __iomem *ata_regs;
        struct mpc52xx_ata_priv *priv;
        int rv;
@@ -435,7 +400,7 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match)
        }
 
        /* Register ourselves to libata */
-       rv = mpc52xx_ata_init_one(&op->dev, priv);
+       rv = mpc52xx_ata_init_one(&op->dev, priv, res_mem.start);
        if (rv) {
                printk(KERN_ERR DRV_NAME ": "
                        "Error while registering to ATA layer\n");
@@ -468,25 +433,35 @@ mpc52xx_ata_remove(struct of_device *op)
 static int
 mpc52xx_ata_suspend(struct of_device *op, pm_message_t state)
 {
-       return 0;       /* FIXME : What to do here ? */
+       struct ata_host *host = dev_get_drvdata(&op->dev);
+
+       return ata_host_suspend(host, state);
 }
 
 static int
 mpc52xx_ata_resume(struct of_device *op)
 {
-       return 0;       /* FIXME : What to do here ? */
+       struct ata_host *host = dev_get_drvdata(&op->dev);
+       struct mpc52xx_ata_priv *priv = host->private_data;
+       int rv;
+
+       rv = mpc52xx_ata_hw_init(priv);
+       if (rv) {
+               printk(KERN_ERR DRV_NAME ": Error during HW init\n");
+               return rv;
+       }
+
+       ata_host_resume(host);
+
+       return 0;
 }
 
 #endif
 
 
 static struct of_device_id mpc52xx_ata_of_match[] = {
-       {
-               .compatible = "mpc5200-ata",
-       },
-       {
-               .compatible = "mpc52xx-ata",
-       },
+       { .compatible = "fsl,mpc5200-ata", },
+       { .compatible = "mpc5200-ata", },
        {},
 };