diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/ata/sata_dwc_460ex.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/ata/sata_dwc_460ex.c')
-rw-r--r-- | drivers/ata/sata_dwc_460ex.c | 86 |
1 files changed, 61 insertions, 25 deletions
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c index 6cf57c5c2b5f..dc88a39e7db8 100644 --- a/drivers/ata/sata_dwc_460ex.c +++ b/drivers/ata/sata_dwc_460ex.c | |||
@@ -40,8 +40,11 @@ | |||
40 | #include <scsi/scsi_host.h> | 40 | #include <scsi/scsi_host.h> |
41 | #include <scsi/scsi_cmnd.h> | 41 | #include <scsi/scsi_cmnd.h> |
42 | 42 | ||
43 | /* These two are defined in "libata.h" */ | ||
44 | #undef DRV_NAME | ||
45 | #undef DRV_VERSION | ||
43 | #define DRV_NAME "sata-dwc" | 46 | #define DRV_NAME "sata-dwc" |
44 | #define DRV_VERSION "1.0" | 47 | #define DRV_VERSION "1.3" |
45 | 48 | ||
46 | /* SATA DMA driver Globals */ | 49 | /* SATA DMA driver Globals */ |
47 | #define DMA_NUM_CHANS 1 | 50 | #define DMA_NUM_CHANS 1 |
@@ -333,11 +336,47 @@ static int dma_dwc_xfer_setup(struct scatterlist *sg, int num_elems, | |||
333 | void __iomem *addr, int dir); | 336 | void __iomem *addr, int dir); |
334 | static void dma_dwc_xfer_start(int dma_ch); | 337 | static void dma_dwc_xfer_start(int dma_ch); |
335 | 338 | ||
339 | static const char *get_prot_descript(u8 protocol) | ||
340 | { | ||
341 | switch ((enum ata_tf_protocols)protocol) { | ||
342 | case ATA_PROT_NODATA: | ||
343 | return "ATA no data"; | ||
344 | case ATA_PROT_PIO: | ||
345 | return "ATA PIO"; | ||
346 | case ATA_PROT_DMA: | ||
347 | return "ATA DMA"; | ||
348 | case ATA_PROT_NCQ: | ||
349 | return "ATA NCQ"; | ||
350 | case ATAPI_PROT_NODATA: | ||
351 | return "ATAPI no data"; | ||
352 | case ATAPI_PROT_PIO: | ||
353 | return "ATAPI PIO"; | ||
354 | case ATAPI_PROT_DMA: | ||
355 | return "ATAPI DMA"; | ||
356 | default: | ||
357 | return "unknown"; | ||
358 | } | ||
359 | } | ||
360 | |||
361 | static const char *get_dma_dir_descript(int dma_dir) | ||
362 | { | ||
363 | switch ((enum dma_data_direction)dma_dir) { | ||
364 | case DMA_BIDIRECTIONAL: | ||
365 | return "bidirectional"; | ||
366 | case DMA_TO_DEVICE: | ||
367 | return "to device"; | ||
368 | case DMA_FROM_DEVICE: | ||
369 | return "from device"; | ||
370 | default: | ||
371 | return "none"; | ||
372 | } | ||
373 | } | ||
374 | |||
336 | static void sata_dwc_tf_dump(struct ata_taskfile *tf) | 375 | static void sata_dwc_tf_dump(struct ata_taskfile *tf) |
337 | { | 376 | { |
338 | dev_vdbg(host_pvt.dwc_dev, "taskfile cmd: 0x%02x protocol: %s flags:" | 377 | dev_vdbg(host_pvt.dwc_dev, "taskfile cmd: 0x%02x protocol: %s flags:" |
339 | "0x%lx device: %x\n", tf->command, ata_get_cmd_descript\ | 378 | "0x%lx device: %x\n", tf->command, |
340 | (tf->protocol), tf->flags, tf->device); | 379 | get_prot_descript(tf->protocol), tf->flags, tf->device); |
341 | dev_vdbg(host_pvt.dwc_dev, "feature: 0x%02x nsect: 0x%x lbal: 0x%x " | 380 | dev_vdbg(host_pvt.dwc_dev, "feature: 0x%02x nsect: 0x%x lbal: 0x%x " |
342 | "lbam: 0x%x lbah: 0x%x\n", tf->feature, tf->nsect, tf->lbal, | 381 | "lbam: 0x%x lbah: 0x%x\n", tf->feature, tf->nsect, tf->lbal, |
343 | tf->lbam, tf->lbah); | 382 | tf->lbam, tf->lbah); |
@@ -350,7 +389,7 @@ static void sata_dwc_tf_dump(struct ata_taskfile *tf) | |||
350 | /* | 389 | /* |
351 | * Function: get_burst_length_encode | 390 | * Function: get_burst_length_encode |
352 | * arguments: datalength: length in bytes of data | 391 | * arguments: datalength: length in bytes of data |
353 | * returns value to be programmed in register corrresponding to data length | 392 | * returns value to be programmed in register corresponding to data length |
354 | * This value is effectively the log(base 2) of the length | 393 | * This value is effectively the log(base 2) of the length |
355 | */ | 394 | */ |
356 | static int get_burst_length_encode(int datalength) | 395 | static int get_burst_length_encode(int datalength) |
@@ -715,7 +754,7 @@ static int dma_dwc_xfer_setup(struct scatterlist *sg, int num_elems, | |||
715 | /* Program the CTL register with src enable / dst enable */ | 754 | /* Program the CTL register with src enable / dst enable */ |
716 | out_le32(&(host_pvt.sata_dma_regs->chan_regs[dma_ch].ctl.low), | 755 | out_le32(&(host_pvt.sata_dma_regs->chan_regs[dma_ch].ctl.low), |
717 | DMA_CTL_LLP_SRCEN | DMA_CTL_LLP_DSTEN); | 756 | DMA_CTL_LLP_SRCEN | DMA_CTL_LLP_DSTEN); |
718 | return 0; | 757 | return dma_ch; |
719 | } | 758 | } |
720 | 759 | ||
721 | /* | 760 | /* |
@@ -967,7 +1006,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance) | |||
967 | } | 1006 | } |
968 | 1007 | ||
969 | dev_dbg(ap->dev, "%s non-NCQ cmd interrupt, protocol: %s\n", | 1008 | dev_dbg(ap->dev, "%s non-NCQ cmd interrupt, protocol: %s\n", |
970 | __func__, ata_get_cmd_descript(qc->tf.protocol)); | 1009 | __func__, get_prot_descript(qc->tf.protocol)); |
971 | DRVSTILLBUSY: | 1010 | DRVSTILLBUSY: |
972 | if (ata_is_dma(qc->tf.protocol)) { | 1011 | if (ata_is_dma(qc->tf.protocol)) { |
973 | /* | 1012 | /* |
@@ -1057,7 +1096,7 @@ DRVSTILLBUSY: | |||
1057 | 1096 | ||
1058 | /* Process completed command */ | 1097 | /* Process completed command */ |
1059 | dev_dbg(ap->dev, "%s NCQ command, protocol: %s\n", __func__, | 1098 | dev_dbg(ap->dev, "%s NCQ command, protocol: %s\n", __func__, |
1060 | ata_get_cmd_descript(qc->tf.protocol)); | 1099 | get_prot_descript(qc->tf.protocol)); |
1061 | if (ata_is_dma(qc->tf.protocol)) { | 1100 | if (ata_is_dma(qc->tf.protocol)) { |
1062 | host_pvt.dma_interrupt_count++; | 1101 | host_pvt.dma_interrupt_count++; |
1063 | if (hsdevp->dma_pending[tag] == \ | 1102 | if (hsdevp->dma_pending[tag] == \ |
@@ -1142,8 +1181,8 @@ static void sata_dwc_dma_xfer_complete(struct ata_port *ap, u32 check_status) | |||
1142 | if (tag > 0) { | 1181 | if (tag > 0) { |
1143 | dev_info(ap->dev, "%s tag=%u cmd=0x%02x dma dir=%s proto=%s " | 1182 | dev_info(ap->dev, "%s tag=%u cmd=0x%02x dma dir=%s proto=%s " |
1144 | "dmacr=0x%08x\n", __func__, qc->tag, qc->tf.command, | 1183 | "dmacr=0x%08x\n", __func__, qc->tag, qc->tf.command, |
1145 | ata_get_cmd_descript(qc->dma_dir), | 1184 | get_dma_dir_descript(qc->dma_dir), |
1146 | ata_get_cmd_descript(qc->tf.protocol), | 1185 | get_prot_descript(qc->tf.protocol), |
1147 | in_le32(&(hsdev->sata_dwc_regs->dmacr))); | 1186 | in_le32(&(hsdev->sata_dwc_regs->dmacr))); |
1148 | } | 1187 | } |
1149 | #endif | 1188 | #endif |
@@ -1354,7 +1393,7 @@ static void sata_dwc_exec_command_by_tag(struct ata_port *ap, | |||
1354 | struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap); | 1393 | struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap); |
1355 | 1394 | ||
1356 | dev_dbg(ap->dev, "%s cmd(0x%02x): %s tag=%d\n", __func__, tf->command, | 1395 | dev_dbg(ap->dev, "%s cmd(0x%02x): %s tag=%d\n", __func__, tf->command, |
1357 | ata_get_cmd_descript(tf), tag); | 1396 | ata_get_cmd_descript(tf->command), tag); |
1358 | 1397 | ||
1359 | spin_lock_irqsave(&ap->host->lock, flags); | 1398 | spin_lock_irqsave(&ap->host->lock, flags); |
1360 | hsdevp->cmd_issued[tag] = cmd_issued; | 1399 | hsdevp->cmd_issued[tag] = cmd_issued; |
@@ -1413,7 +1452,7 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag) | |||
1413 | 1452 | ||
1414 | dev_dbg(ap->dev, "%s qc=%p tag: %x cmd: 0x%02x dma_dir: %s " | 1453 | dev_dbg(ap->dev, "%s qc=%p tag: %x cmd: 0x%02x dma_dir: %s " |
1415 | "start_dma? %x\n", __func__, qc, tag, qc->tf.command, | 1454 | "start_dma? %x\n", __func__, qc, tag, qc->tf.command, |
1416 | ata_get_cmd_descript(qc->dma_dir), start_dma); | 1455 | get_dma_dir_descript(qc->dma_dir), start_dma); |
1417 | sata_dwc_tf_dump(&(qc->tf)); | 1456 | sata_dwc_tf_dump(&(qc->tf)); |
1418 | 1457 | ||
1419 | if (start_dma) { | 1458 | if (start_dma) { |
@@ -1462,10 +1501,9 @@ static void sata_dwc_qc_prep_by_tag(struct ata_queued_cmd *qc, u8 tag) | |||
1462 | int dma_chan; | 1501 | int dma_chan; |
1463 | struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap); | 1502 | struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap); |
1464 | struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap); | 1503 | struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap); |
1465 | int err; | ||
1466 | 1504 | ||
1467 | dev_dbg(ap->dev, "%s: port=%d dma dir=%s n_elem=%d\n", | 1505 | dev_dbg(ap->dev, "%s: port=%d dma dir=%s n_elem=%d\n", |
1468 | __func__, ap->port_no, ata_get_cmd_descript(qc->dma_dir), | 1506 | __func__, ap->port_no, get_dma_dir_descript(qc->dma_dir), |
1469 | qc->n_elem); | 1507 | qc->n_elem); |
1470 | 1508 | ||
1471 | dma_chan = dma_dwc_xfer_setup(sg, qc->n_elem, hsdevp->llit[tag], | 1509 | dma_chan = dma_dwc_xfer_setup(sg, qc->n_elem, hsdevp->llit[tag], |
@@ -1474,7 +1512,7 @@ static void sata_dwc_qc_prep_by_tag(struct ata_queued_cmd *qc, u8 tag) | |||
1474 | dmadr), qc->dma_dir); | 1512 | dmadr), qc->dma_dir); |
1475 | if (dma_chan < 0) { | 1513 | if (dma_chan < 0) { |
1476 | dev_err(ap->dev, "%s: dma_dwc_xfer_setup returns err %d\n", | 1514 | dev_err(ap->dev, "%s: dma_dwc_xfer_setup returns err %d\n", |
1477 | __func__, err); | 1515 | __func__, dma_chan); |
1478 | return; | 1516 | return; |
1479 | } | 1517 | } |
1480 | hsdevp->dma_chan[tag] = dma_chan; | 1518 | hsdevp->dma_chan[tag] = dma_chan; |
@@ -1491,8 +1529,8 @@ static unsigned int sata_dwc_qc_issue(struct ata_queued_cmd *qc) | |||
1491 | dev_info(ap->dev, "%s ap id=%d cmd(0x%02x)=%s qc tag=%d " | 1529 | dev_info(ap->dev, "%s ap id=%d cmd(0x%02x)=%s qc tag=%d " |
1492 | "prot=%s ap active_tag=0x%08x ap sactive=0x%08x\n", | 1530 | "prot=%s ap active_tag=0x%08x ap sactive=0x%08x\n", |
1493 | __func__, ap->print_id, qc->tf.command, | 1531 | __func__, ap->print_id, qc->tf.command, |
1494 | ata_get_cmd_descript(&qc->tf), | 1532 | ata_get_cmd_descript(qc->tf.command), |
1495 | qc->tag, ata_get_cmd_descript(qc->tf.protocol), | 1533 | qc->tag, get_prot_descript(qc->tf.protocol), |
1496 | ap->link.active_tag, ap->link.sactive); | 1534 | ap->link.active_tag, ap->link.sactive); |
1497 | #endif | 1535 | #endif |
1498 | 1536 | ||
@@ -1533,7 +1571,7 @@ static void sata_dwc_qc_prep(struct ata_queued_cmd *qc) | |||
1533 | #ifdef DEBUG_NCQ | 1571 | #ifdef DEBUG_NCQ |
1534 | if (qc->tag > 0) | 1572 | if (qc->tag > 0) |
1535 | dev_info(qc->ap->dev, "%s: qc->tag=%d ap->active_tag=0x%08x\n", | 1573 | dev_info(qc->ap->dev, "%s: qc->tag=%d ap->active_tag=0x%08x\n", |
1536 | __func__, tag, qc->ap->link.active_tag); | 1574 | __func__, qc->tag, qc->ap->link.active_tag); |
1537 | 1575 | ||
1538 | return ; | 1576 | return ; |
1539 | #endif | 1577 | #endif |
@@ -1580,16 +1618,14 @@ static struct ata_port_operations sata_dwc_ops = { | |||
1580 | 1618 | ||
1581 | static const struct ata_port_info sata_dwc_port_info[] = { | 1619 | static const struct ata_port_info sata_dwc_port_info[] = { |
1582 | { | 1620 | { |
1583 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 1621 | .flags = ATA_FLAG_SATA | ATA_FLAG_NCQ, |
1584 | ATA_FLAG_MMIO | ATA_FLAG_NCQ, | 1622 | .pio_mask = ATA_PIO4, |
1585 | .pio_mask = 0x1f, /* pio 0-4 */ | ||
1586 | .udma_mask = ATA_UDMA6, | 1623 | .udma_mask = ATA_UDMA6, |
1587 | .port_ops = &sata_dwc_ops, | 1624 | .port_ops = &sata_dwc_ops, |
1588 | }, | 1625 | }, |
1589 | }; | 1626 | }; |
1590 | 1627 | ||
1591 | static int sata_dwc_probe(struct platform_device *ofdev, | 1628 | static int sata_dwc_probe(struct platform_device *ofdev) |
1592 | const struct of_device_id *match) | ||
1593 | { | 1629 | { |
1594 | struct sata_dwc_device *hsdev; | 1630 | struct sata_dwc_device *hsdev; |
1595 | u32 idr, versionr; | 1631 | u32 idr, versionr; |
@@ -1727,7 +1763,7 @@ static const struct of_device_id sata_dwc_match[] = { | |||
1727 | }; | 1763 | }; |
1728 | MODULE_DEVICE_TABLE(of, sata_dwc_match); | 1764 | MODULE_DEVICE_TABLE(of, sata_dwc_match); |
1729 | 1765 | ||
1730 | static struct of_platform_driver sata_dwc_driver = { | 1766 | static struct platform_driver sata_dwc_driver = { |
1731 | .driver = { | 1767 | .driver = { |
1732 | .name = DRV_NAME, | 1768 | .name = DRV_NAME, |
1733 | .owner = THIS_MODULE, | 1769 | .owner = THIS_MODULE, |
@@ -1739,12 +1775,12 @@ static struct of_platform_driver sata_dwc_driver = { | |||
1739 | 1775 | ||
1740 | static int __init sata_dwc_init(void) | 1776 | static int __init sata_dwc_init(void) |
1741 | { | 1777 | { |
1742 | return of_register_platform_driver(&sata_dwc_driver); | 1778 | return platform_driver_register(&sata_dwc_driver); |
1743 | } | 1779 | } |
1744 | 1780 | ||
1745 | static void __exit sata_dwc_exit(void) | 1781 | static void __exit sata_dwc_exit(void) |
1746 | { | 1782 | { |
1747 | of_unregister_platform_driver(&sata_dwc_driver); | 1783 | platform_driver_unregister(&sata_dwc_driver); |
1748 | } | 1784 | } |
1749 | 1785 | ||
1750 | module_init(sata_dwc_init); | 1786 | module_init(sata_dwc_init); |