]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ata/sata_fsl.c
ata/sata_fsl: Remove unnecessary SCR cases
[linux-2.6-omap-h63xx.git] / drivers / ata / sata_fsl.c
index b4c37b9e413c1268cd95bd9da40ac5fa9e0493f0..e04fb75e58fb2779e1e189eaf5ebb7cc285f8366 100644 (file)
@@ -34,7 +34,8 @@ enum {
 
        SATA_FSL_HOST_FLAGS     = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
                                ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
-                               ATA_FLAG_NCQ  | ATA_FLAG_SKIP_D2H_BSY),
+                               ATA_FLAG_NCQ),
+       SATA_FSL_HOST_LFLAGS    = ATA_LFLAG_SKIP_D2H_BSY,
 
        SATA_FSL_MAX_CMDS       = SATA_FSL_QUEUE_DEPTH,
        SATA_FSL_CMD_HDR_SIZE   = 16,   /* 4 DWORDS */
@@ -264,6 +265,7 @@ struct sata_fsl_host_priv {
        void __iomem *hcr_base;
        void __iomem *ssr_base;
        void __iomem *csr_base;
+       int irq;
 };
 
 static inline unsigned int sata_fsl_tag(unsigned int tag,
@@ -353,7 +355,7 @@ static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc,
                                        "s/g len unaligned : 0x%x\n", sg_len);
 
                if ((num_prde == (SATA_FSL_MAX_PRD_DIRECT - 1)) &&
-                   !ata_sg_is_last(sg, qc)) {
+                   (qc->n_iter + 1 != qc->n_elem)) {
                        VPRINTK("setting indirect prde\n");
                        prd_ptr_to_indirect_ext = prd;
                        prd->dba = cpu_to_le32(indirect_ext_segment_paddr);
@@ -470,16 +472,10 @@ static int sata_fsl_scr_write(struct ata_port *ap, unsigned int sc_reg_in,
 
        switch (sc_reg_in) {
        case SCR_STATUS:
-               sc_reg = 0;
-               break;
        case SCR_ERROR:
-               sc_reg = 1;
-               break;
        case SCR_CONTROL:
-               sc_reg = 2;
-               break;
        case SCR_ACTIVE:
-               sc_reg = 3;
+               sc_reg = sc_reg_in;
                break;
        default:
                return -EINVAL;
@@ -500,16 +496,10 @@ static int sata_fsl_scr_read(struct ata_port *ap, unsigned int sc_reg_in,
 
        switch (sc_reg_in) {
        case SCR_STATUS:
-               sc_reg = 0;
-               break;
        case SCR_ERROR:
-               sc_reg = 1;
-               break;
        case SCR_CONTROL:
-               sc_reg = 2;
-               break;
        case SCR_ACTIVE:
-               sc_reg = 3;
+               sc_reg = sc_reg_in;
                break;
        default:
                return -EINVAL;
@@ -728,9 +718,10 @@ static unsigned int sata_fsl_dev_classify(struct ata_port *ap)
        return ata_dev_classify(&tf);
 }
 
-static int sata_fsl_softreset(struct ata_port *ap, unsigned int *class,
+static int sata_fsl_softreset(struct ata_link *link, unsigned int *class,
                              unsigned long deadline)
 {
+       struct ata_port *ap = link->ap;
        struct sata_fsl_port_priv *pp = ap->private_data;
        struct sata_fsl_host_priv *host_priv = ap->host->private_data;
        void __iomem *hcr_base = host_priv->hcr_base;
@@ -811,7 +802,7 @@ try_offline_again:
         */
 
        temp = ata_wait_register(hcr_base + HSTATUS, 0xFF, 0, 1, 500);
-       if ((!(temp & 0x10)) || ata_port_offline(ap)) {
+       if ((!(temp & 0x10)) || ata_link_offline(link)) {
                ata_port_printk(ap, KERN_WARNING,
                                "No Device OR PHYRDY change,Hstatus = 0x%x\n",
                                ioread32(hcr_base + HSTATUS));
@@ -842,12 +833,12 @@ try_offline_again:
         * reached here, we can send a command to the target device
         */
 
-       if (ap->sactive)
+       if (link->sactive)
                goto skip_srst_do_ncq_error_handling;
 
        DPRINTK("Sending SRST/device reset\n");
 
-       ata_tf_init(ap->device, &tf);
+       ata_tf_init(link->device, &tf);
        cfis = (u8 *) & pp->cmdentry->cfis;
 
        /* device reset/SRST is a control register update FIS, uses tag0 */
@@ -919,7 +910,7 @@ skip_srst_do_ncq_error_handling:
        VPRINTK("Sending read log ext(10h) command\n");
 
        memset(&qc, 0, sizeof(struct ata_queued_cmd));
-       ata_tf_init(ap->device, &tf);
+       ata_tf_init(link->device, &tf);
 
        tf.command = ATA_CMD_READ_LOG_EXT;
        tf.lbal = ATA_LOG_SATA_NCQ;
@@ -931,7 +922,7 @@ skip_srst_do_ncq_error_handling:
        qc.tag = ATA_TAG_INTERNAL;
        qc.scsicmd = NULL;
        qc.ap = ap;
-       qc.dev = ap->device;
+       qc.dev = link->device;
 
        qc.tf = tf;
        qc.flags |= ATA_QCFLAG_RESULT_TF;
@@ -981,7 +972,7 @@ skip_srst_do_ncq_error_handling:
        *class = ATA_DEV_NONE;
 
        /* Verify if SStatus indicates device presence */
-       if (ata_port_online(ap)) {
+       if (ata_link_online(link)) {
                /*
                 * if we are here, device presence has been detected,
                 * 1st D2H FIS would have been received, but sfis in
@@ -1042,7 +1033,8 @@ static void sata_fsl_irq_clear(struct ata_port *ap)
 
 static void sata_fsl_error_intr(struct ata_port *ap)
 {
-       struct ata_eh_info *ehi = &ap->eh_info;
+       struct ata_link *link = &ap->link;
+       struct ata_eh_info *ehi = &link->eh_info;
        struct sata_fsl_host_priv *host_priv = ap->host->private_data;
        void __iomem *hcr_base = host_priv->hcr_base;
        u32 hstatus, dereg, cereg = 0, SError = 0;
@@ -1111,7 +1103,7 @@ static void sata_fsl_error_intr(struct ata_port *ap)
        }
 
        /* record error info */
-       qc = ata_qc_from_tag(ap, ap->active_tag);
+       qc = ata_qc_from_tag(ap, link->active_tag);
 
        if (qc) {
                sata_fsl_cache_taskfile_from_d2h_fis(qc, qc->ap);
@@ -1139,6 +1131,7 @@ static void sata_fsl_qc_complete(struct ata_queued_cmd *qc)
 
 static void sata_fsl_host_intr(struct ata_port *ap)
 {
+       struct ata_link *link = &ap->link;
        struct sata_fsl_host_priv *host_priv = ap->host->private_data;
        void __iomem *hcr_base = host_priv->hcr_base;
        u32 hstatus, qc_active = 0;
@@ -1161,7 +1154,7 @@ static void sata_fsl_host_intr(struct ata_port *ap)
                return;
        }
 
-       if (ap->sactive) {      /* only true for NCQ commands */
+       if (link->sactive) {    /* only true for NCQ commands */
                int i;
                /* Read command completed register */
                qc_active = ioread32(hcr_base + CC);
@@ -1190,10 +1183,10 @@ static void sata_fsl_host_intr(struct ata_port *ap)
 
        } else if (ap->qc_active) {
                iowrite32(1, hcr_base + CC);
-               qc = ata_qc_from_tag(ap, ap->active_tag);
+               qc = ata_qc_from_tag(ap, link->active_tag);
 
                DPRINTK("completing non-ncq cmd, tag=%d,CC=0x%x\n",
-                       ap->active_tag, ioread32(hcr_base + CC));
+                       link->active_tag, ioread32(hcr_base + CC));
 
                if (qc) {
                        sata_fsl_qc_complete(qc);
@@ -1319,8 +1312,6 @@ static struct scsi_host_template sata_fsl_sht = {
 };
 
 static const struct ata_port_operations sata_fsl_ops = {
-       .port_disable = ata_port_disable,
-
        .check_status = sata_fsl_check_status,
        .check_altstatus = sata_fsl_check_status,
        .dev_select = ata_noop_dev_select,
@@ -1330,8 +1321,6 @@ static const struct ata_port_operations sata_fsl_ops = {
        .qc_prep = sata_fsl_qc_prep,
        .qc_issue = sata_fsl_qc_issue,
        .irq_clear = sata_fsl_irq_clear,
-       .irq_on = ata_dummy_irq_on,
-       .irq_ack = ata_dummy_irq_ack,
 
        .scr_read = sata_fsl_scr_read,
        .scr_write = sata_fsl_scr_write,
@@ -1348,6 +1337,7 @@ static const struct ata_port_operations sata_fsl_ops = {
 static const struct ata_port_info sata_fsl_port_info[] = {
        {
         .flags = SATA_FSL_HOST_FLAGS,
+        .link_flags = SATA_FSL_HOST_LFLAGS,
         .pio_mask = 0x1f,      /* pio 0-4 */
         .udma_mask = 0x7f,     /* udma 0-6 */
         .port_ops = &sata_fsl_ops,
@@ -1398,6 +1388,7 @@ static int sata_fsl_probe(struct of_device *ofdev,
                dev_printk(KERN_ERR, &ofdev->dev, "invalid irq from platform\n");
                goto error_exit_with_cleanup;
        }
+       host_priv->irq = irq;
 
        /* allocate host structure */
        host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_FSL_MAX_PORTS);
@@ -1444,7 +1435,7 @@ static int sata_fsl_remove(struct of_device *ofdev)
 
        dev_set_drvdata(&ofdev->dev, NULL);
 
-       irq_dispose_mapping(host->irq);
+       irq_dispose_mapping(host_priv->irq);
        iounmap(host_priv->hcr_base);
        kfree(host_priv);