~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/ata/sata_fsl.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Author: Ashish Kalra <ashish.kalra@freescale.com>
7
7
 * Li Yang <leoli@freescale.com>
8
8
 *
9
 
 * Copyright (c) 2006-2007 Freescale Semiconductor, Inc.
 
9
 * Copyright (c) 2006-2007, 2011 Freescale Semiconductor, Inc.
10
10
 *
11
11
 * This program is free software; you can redistribute  it and/or modify it
12
12
 * under  the terms of  the GNU General  Public License as published by the
33
33
        SATA_FSL_MAX_PRD_USABLE = SATA_FSL_MAX_PRD - 1,
34
34
        SATA_FSL_MAX_PRD_DIRECT = 16,   /* Direct PRDT entries */
35
35
 
36
 
        SATA_FSL_HOST_FLAGS     = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
37
 
                                ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
 
36
        SATA_FSL_HOST_FLAGS     = (ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
38
37
                                ATA_FLAG_PMP | ATA_FLAG_NCQ | ATA_FLAG_AN),
39
38
 
40
39
        SATA_FSL_MAX_CMDS       = SATA_FSL_QUEUE_DEPTH,
43
42
 
44
43
        /*
45
44
         * SATA-FSL host controller supports a max. of (15+1) direct PRDEs, and
46
 
         * chained indirect PRDEs upto a max count of 63.
 
45
         * chained indirect PRDEs up to a max count of 63.
47
46
         * We are allocating an array of 63 PRDEs contiguously, but PRDE#15 will
48
47
         * be setup as an indirect descriptor, pointing to it's next
49
48
         * (contiguous) PRDE. Though chained indirect PRDE arrays are
158
157
            IE_ON_SINGL_DEVICE_ERR | IE_ON_CMD_COMPLETE,
159
158
 
160
159
        EXT_INDIRECT_SEG_PRD_FLAG = (1 << 31),
161
 
        DATA_SNOOP_ENABLE = (1 << 22),
 
160
        DATA_SNOOP_ENABLE_V1 = (1 << 22),
 
161
        DATA_SNOOP_ENABLE_V2 = (1 << 28),
162
162
};
163
163
 
164
164
/*
186
186
        COMMANDSTAT = 0x20,
187
187
};
188
188
 
 
189
/* TRANSCFG (transport-layer) configuration control */
 
190
enum {
 
191
        TRANSCFG_RX_WATER_MARK = (1 << 4),
 
192
};
 
193
 
189
194
/* PHY (link-layer) configuration control */
190
195
enum {
191
196
        PHY_BIST_ENABLE = 0x01,
256
261
        void __iomem *ssr_base;
257
262
        void __iomem *csr_base;
258
263
        int irq;
 
264
        int data_snoop;
259
265
};
260
266
 
261
267
static inline unsigned int sata_fsl_tag(unsigned int tag,
308
314
}
309
315
 
310
316
static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc,
311
 
                                     u32 *ttl, dma_addr_t cmd_desc_paddr)
 
317
                                     u32 *ttl, dma_addr_t cmd_desc_paddr,
 
318
                                     int data_snoop)
312
319
{
313
320
        struct scatterlist *sg;
314
321
        unsigned int num_prde = 0;
358
365
 
359
366
                ttl_dwords += sg_len;
360
367
                prd->dba = cpu_to_le32(sg_addr);
361
 
                prd->ddc_and_ext =
362
 
                    cpu_to_le32(DATA_SNOOP_ENABLE | (sg_len & ~0x03));
 
368
                prd->ddc_and_ext = cpu_to_le32(data_snoop | (sg_len & ~0x03));
363
369
 
364
370
                VPRINTK("sg_fill, ttl=%d, dba=0x%x, ddc=0x%x\n",
365
371
                        ttl_dwords, prd->dba, prd->ddc_and_ext);
374
380
                /* set indirect extension flag along with indirect ext. size */
375
381
                prd_ptr_to_indirect_ext->ddc_and_ext =
376
382
                    cpu_to_le32((EXT_INDIRECT_SEG_PRD_FLAG |
377
 
                                 DATA_SNOOP_ENABLE |
 
383
                                 data_snoop |
378
384
                                 (indirect_ext_segment_sz & ~0x03)));
379
385
        }
380
386
 
417
423
 
418
424
        if (qc->flags & ATA_QCFLAG_DMAMAP)
419
425
                num_prde = sata_fsl_fill_sg(qc, (void *)cd,
420
 
                                            &ttl_dwords, cd_paddr);
 
426
                                            &ttl_dwords, cd_paddr,
 
427
                                            host_priv->data_snoop);
421
428
 
422
429
        if (qc->tf.protocol == ATA_PROT_NCQ)
423
430
                desc_info |= FPDMA_QUEUED_CMD;
900
907
        ata_msleep(ap, 1);
901
908
 
902
909
        /*
903
 
         * SATA device enters reset state after receving a Control register
 
910
         * SATA device enters reset state after receiving a Control register
904
911
         * FIS with SRST bit asserted and it awaits another H2D Control reg.
905
912
         * FIS with SRST bit cleared, then the device does internal diags &
906
913
         * initialization, followed by indicating it's initialization status
1040
1047
 
1041
1048
                /* find out the offending link and qc */
1042
1049
                if (ap->nr_pmp_links) {
 
1050
                        unsigned int dev_num;
 
1051
 
1043
1052
                        dereg = ioread32(hcr_base + DE);
1044
1053
                        iowrite32(dereg, hcr_base + DE);
1045
1054
                        iowrite32(cereg, hcr_base + CE);
1046
1055
 
1047
 
                        if (dereg < ap->nr_pmp_links) {
1048
 
                                link = &ap->pmp_link[dereg];
 
1056
                        dev_num = ffs(dereg) - 1;
 
1057
                        if (dev_num < ap->nr_pmp_links && dereg != 0) {
 
1058
                                link = &ap->pmp_link[dev_num];
1049
1059
                                ehi = &link->eh_info;
1050
1060
                                qc = ata_qc_from_tag(ap, link->active_tag);
1051
1061
                                /*
1293
1303
         },
1294
1304
};
1295
1305
 
1296
 
static int sata_fsl_probe(struct platform_device *ofdev,
1297
 
                        const struct of_device_id *match)
 
1306
static int sata_fsl_probe(struct platform_device *ofdev)
1298
1307
{
1299
1308
        int retval = -ENXIO;
1300
1309
        void __iomem *hcr_base = NULL;
1303
1312
        struct sata_fsl_host_priv *host_priv = NULL;
1304
1313
        int irq;
1305
1314
        struct ata_host *host;
 
1315
        u32 temp;
1306
1316
 
1307
1317
        struct ata_port_info pi = sata_fsl_port_info[0];
1308
1318
        const struct ata_port_info *ppi[] = { &pi, NULL };
1317
1327
        ssr_base = hcr_base + 0x100;
1318
1328
        csr_base = hcr_base + 0x140;
1319
1329
 
 
1330
        if (!of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc8315-sata")) {
 
1331
                temp = ioread32(csr_base + TRANSCFG);
 
1332
                temp = temp & 0xffffffe0;
 
1333
                iowrite32(temp | TRANSCFG_RX_WATER_MARK, csr_base + TRANSCFG);
 
1334
        }
 
1335
 
1320
1336
        DPRINTK("@reset i/o = 0x%x\n", ioread32(csr_base + TRANSCFG));
1321
1337
        DPRINTK("sizeof(cmd_desc) = %d\n", sizeof(struct command_desc));
1322
1338
        DPRINTK("sizeof(#define cmd_desc) = %d\n", SATA_FSL_CMD_DESC_SIZE);
1336
1352
        }
1337
1353
        host_priv->irq = irq;
1338
1354
 
 
1355
        if (of_device_is_compatible(ofdev->dev.of_node, "fsl,pq-sata-v2"))
 
1356
                host_priv->data_snoop = DATA_SNOOP_ENABLE_V2;
 
1357
        else
 
1358
                host_priv->data_snoop = DATA_SNOOP_ENABLE_V1;
 
1359
 
1339
1360
        /* allocate host structure */
1340
1361
        host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_FSL_MAX_PORTS);
1341
1362
 
1418
1439
        {
1419
1440
                .compatible = "fsl,pq-sata",
1420
1441
        },
 
1442
        {
 
1443
                .compatible = "fsl,pq-sata-v2",
 
1444
        },
1421
1445
        {},
1422
1446
};
1423
1447
 
1424
1448
MODULE_DEVICE_TABLE(of, fsl_sata_match);
1425
1449
 
1426
 
static struct of_platform_driver fsl_sata_driver = {
 
1450
static struct platform_driver fsl_sata_driver = {
1427
1451
        .driver = {
1428
1452
                .name = "fsl-sata",
1429
1453
                .owner = THIS_MODULE,
1439
1463
 
1440
1464
static int __init sata_fsl_init(void)
1441
1465
{
1442
 
        of_register_platform_driver(&fsl_sata_driver);
 
1466
        platform_driver_register(&fsl_sata_driver);
1443
1467
        return 0;
1444
1468
}
1445
1469
 
1446
1470
static void __exit sata_fsl_exit(void)
1447
1471
{
1448
 
        of_unregister_platform_driver(&fsl_sata_driver);
 
1472
        platform_driver_unregister(&fsl_sata_driver);
1449
1473
}
1450
1474
 
1451
1475
MODULE_LICENSE("GPL");