Merge branch 'rmobile-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / ata / sata_fsl.c
index ef3ce26..35a71d8 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
@@ -42,7 +42,7 @@ enum {
 
        /*
         * SATA-FSL host controller supports a max. of (15+1) direct PRDEs, and
-        * chained indirect PRDEs upto a max count of 63.
+        * chained indirect PRDEs up to a max count of 63.
         * We are allocating an array of 63 PRDEs contiguously, but PRDE#15 will
         * be setup as an indirect descriptor, pointing to it's next
         * (contiguous) PRDE. Though chained indirect PRDE arrays are
@@ -157,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),
 };
 
 /*
@@ -260,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,
@@ -312,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;
@@ -362,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);
@@ -378,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)));
        }
 
@@ -421,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;
@@ -904,7 +907,7 @@ static int sata_fsl_softreset(struct ata_link *link, unsigned int *class,
        ata_msleep(ap, 1);
 
        /*
-        * SATA device enters reset state after receving a Control register
+        * SATA device enters reset state after receiving a Control register
         * FIS with SRST bit asserted and it awaits another H2D Control reg.
         * FIS with SRST bit cleared, then the device does internal diags &
         * initialization, followed by indicating it's initialization status
@@ -1349,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);
 
@@ -1431,6 +1439,9 @@ static struct of_device_id fsl_sata_match[] = {
        {
                .compatible = "fsl,pq-sata",
        },
+       {
+               .compatible = "fsl,pq-sata-v2",
+       },
        {},
 };