]> Pileus Git - ~andy/linux/blobdiff - drivers/ata/sata_fsl.c
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
[~andy/linux] / drivers / ata / sata_fsl.c
index b0214d00d50bb469de76b40fb8a4f81f70cbb161..0f91e583892e19a4578501407d0b816584bac83e 100644 (file)
@@ -6,7 +6,7 @@
  * Author: Ashish Kalra <ashish.kalra@freescale.com>
  * Li Yang <leoli@freescale.com>
  *
- * Copyright (c) 2006-2007 Freescale Semiconductor, Inc.
+ * Copyright (c) 2006-2007, 2011 Freescale Semiconductor, Inc.
  *
  * This program is free software; you can redistribute  it and/or modify it
  * under  the terms of  the GNU General  Public License as published by the
@@ -33,8 +33,7 @@ enum {
        SATA_FSL_MAX_PRD_USABLE = SATA_FSL_MAX_PRD - 1,
        SATA_FSL_MAX_PRD_DIRECT = 16,   /* Direct PRDT entries */
 
-       SATA_FSL_HOST_FLAGS     = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
-                               ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
+       SATA_FSL_HOST_FLAGS     = (ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
                                ATA_FLAG_PMP | ATA_FLAG_NCQ | ATA_FLAG_AN),
 
        SATA_FSL_MAX_CMDS       = SATA_FSL_QUEUE_DEPTH,
@@ -158,7 +157,8 @@ enum {
            IE_ON_SINGL_DEVICE_ERR | IE_ON_CMD_COMPLETE,
 
        EXT_INDIRECT_SEG_PRD_FLAG = (1 << 31),
-       DATA_SNOOP_ENABLE = (1 << 22),
+       DATA_SNOOP_ENABLE_V1 = (1 << 22),
+       DATA_SNOOP_ENABLE_V2 = (1 << 28),
 };
 
 /*
@@ -186,6 +186,11 @@ enum {
        COMMANDSTAT = 0x20,
 };
 
+/* TRANSCFG (transport-layer) configuration control */
+enum {
+       TRANSCFG_RX_WATER_MARK = (1 << 4),
+};
+
 /* PHY (link-layer) configuration control */
 enum {
        PHY_BIST_ENABLE = 0x01,
@@ -256,6 +261,7 @@ struct sata_fsl_host_priv {
        void __iomem *ssr_base;
        void __iomem *csr_base;
        int irq;
+       int data_snoop;
 };
 
 static inline unsigned int sata_fsl_tag(unsigned int tag,
@@ -308,7 +314,8 @@ static void sata_fsl_setup_cmd_hdr_entry(struct sata_fsl_port_priv *pp,
 }
 
 static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc,
-                                    u32 *ttl, dma_addr_t cmd_desc_paddr)
+                                    u32 *ttl, dma_addr_t cmd_desc_paddr,
+                                    int data_snoop)
 {
        struct scatterlist *sg;
        unsigned int num_prde = 0;
@@ -358,8 +365,7 @@ static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc,
 
                ttl_dwords += sg_len;
                prd->dba = cpu_to_le32(sg_addr);
-               prd->ddc_and_ext =
-                   cpu_to_le32(DATA_SNOOP_ENABLE | (sg_len & ~0x03));
+               prd->ddc_and_ext = cpu_to_le32(data_snoop | (sg_len & ~0x03));
 
                VPRINTK("sg_fill, ttl=%d, dba=0x%x, ddc=0x%x\n",
                        ttl_dwords, prd->dba, prd->ddc_and_ext);
@@ -374,7 +380,7 @@ static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc,
                /* set indirect extension flag along with indirect ext. size */
                prd_ptr_to_indirect_ext->ddc_and_ext =
                    cpu_to_le32((EXT_INDIRECT_SEG_PRD_FLAG |
-                                DATA_SNOOP_ENABLE |
+                                data_snoop |
                                 (indirect_ext_segment_sz & ~0x03)));
        }
 
@@ -417,7 +423,8 @@ static void sata_fsl_qc_prep(struct ata_queued_cmd *qc)
 
        if (qc->flags & ATA_QCFLAG_DMAMAP)
                num_prde = sata_fsl_fill_sg(qc, (void *)cd,
-                                           &ttl_dwords, cd_paddr);
+                                           &ttl_dwords, cd_paddr,
+                                           host_priv->data_snoop);
 
        if (qc->tf.protocol == ATA_PROT_NCQ)
                desc_info |= FPDMA_QUEUED_CMD;
@@ -1040,12 +1047,15 @@ static void sata_fsl_error_intr(struct ata_port *ap)
 
                /* find out the offending link and qc */
                if (ap->nr_pmp_links) {
+                       unsigned int dev_num;
+
                        dereg = ioread32(hcr_base + DE);
                        iowrite32(dereg, hcr_base + DE);
                        iowrite32(cereg, hcr_base + CE);
 
-                       if (dereg < ap->nr_pmp_links) {
-                               link = &ap->pmp_link[dereg];
+                       dev_num = ffs(dereg) - 1;
+                       if (dev_num < ap->nr_pmp_links && dereg != 0) {
+                               link = &ap->pmp_link[dev_num];
                                ehi = &link->eh_info;
                                qc = ata_qc_from_tag(ap, link->active_tag);
                                /*
@@ -1293,8 +1303,7 @@ static const struct ata_port_info sata_fsl_port_info[] = {
         },
 };
 
-static int sata_fsl_probe(struct platform_device *ofdev,
-                       const struct of_device_id *match)
+static int sata_fsl_probe(struct platform_device *ofdev)
 {
        int retval = -ENXIO;
        void __iomem *hcr_base = NULL;
@@ -1303,6 +1312,7 @@ static int sata_fsl_probe(struct platform_device *ofdev,
        struct sata_fsl_host_priv *host_priv = NULL;
        int irq;
        struct ata_host *host;
+       u32 temp;
 
        struct ata_port_info pi = sata_fsl_port_info[0];
        const struct ata_port_info *ppi[] = { &pi, NULL };
@@ -1317,6 +1327,12 @@ static int sata_fsl_probe(struct platform_device *ofdev,
        ssr_base = hcr_base + 0x100;
        csr_base = hcr_base + 0x140;
 
+       if (!of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc8315-sata")) {
+               temp = ioread32(csr_base + TRANSCFG);
+               temp = temp & 0xffffffe0;
+               iowrite32(temp | TRANSCFG_RX_WATER_MARK, csr_base + TRANSCFG);
+       }
+
        DPRINTK("@reset i/o = 0x%x\n", ioread32(csr_base + TRANSCFG));
        DPRINTK("sizeof(cmd_desc) = %d\n", sizeof(struct command_desc));
        DPRINTK("sizeof(#define cmd_desc) = %d\n", SATA_FSL_CMD_DESC_SIZE);
@@ -1336,6 +1352,11 @@ static int sata_fsl_probe(struct platform_device *ofdev,
        }
        host_priv->irq = irq;
 
+       if (of_device_is_compatible(ofdev->dev.of_node, "fsl,pq-sata-v2"))
+               host_priv->data_snoop = DATA_SNOOP_ENABLE_V2;
+       else
+               host_priv->data_snoop = DATA_SNOOP_ENABLE_V1;
+
        /* allocate host structure */
        host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_FSL_MAX_PORTS);
 
@@ -1418,12 +1439,15 @@ static struct of_device_id fsl_sata_match[] = {
        {
                .compatible = "fsl,pq-sata",
        },
+       {
+               .compatible = "fsl,pq-sata-v2",
+       },
        {},
 };
 
 MODULE_DEVICE_TABLE(of, fsl_sata_match);
 
-static struct of_platform_driver fsl_sata_driver = {
+static struct platform_driver fsl_sata_driver = {
        .driver = {
                .name = "fsl-sata",
                .owner = THIS_MODULE,
@@ -1439,13 +1463,13 @@ static struct of_platform_driver fsl_sata_driver = {
 
 static int __init sata_fsl_init(void)
 {
-       of_register_platform_driver(&fsl_sata_driver);
+       platform_driver_register(&fsl_sata_driver);
        return 0;
 }
 
 static void __exit sata_fsl_exit(void)
 {
-       of_unregister_platform_driver(&fsl_sata_driver);
+       platform_driver_unregister(&fsl_sata_driver);
 }
 
 MODULE_LICENSE("GPL");