aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/ahci.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-04-07 09:47:22 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-17 15:44:25 -0400
commit071f44b1d2c051641b62a3571223314737ccbe59 (patch)
treea07794c8109e5d82a78223ae0159eadbf862c463 /drivers/ata/ahci.c
parent48515f6c006c2a9d7b624ee8ad068018c2d3fe0e (diff)
libata: implement PMP helpers
Implement helpers to test whether PMP is supported, attached and determine pmp number to use when issuing SRST to a link. While at it, move ata_is_host_link() so that it's together with the two new PMP helpers. This change simplifies LLDs and helps making PMP support optional. Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'drivers/ata/ahci.c')
-rw-r--r--drivers/ata/ahci.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 6281f7f9eae6..0de6432ee026 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -260,8 +260,6 @@ static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
260static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class, 260static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
261 unsigned long deadline); 261 unsigned long deadline);
262static void ahci_postreset(struct ata_link *link, unsigned int *class); 262static void ahci_postreset(struct ata_link *link, unsigned int *class);
263static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
264 unsigned long deadline);
265static void ahci_error_handler(struct ata_port *ap); 263static void ahci_error_handler(struct ata_port *ap);
266static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); 264static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
267static int ahci_port_resume(struct ata_port *ap); 265static int ahci_port_resume(struct ata_port *ap);
@@ -301,7 +299,7 @@ static struct ata_port_operations ahci_ops = {
301 .softreset = ahci_softreset, 299 .softreset = ahci_softreset,
302 .hardreset = ahci_hardreset, 300 .hardreset = ahci_hardreset,
303 .postreset = ahci_postreset, 301 .postreset = ahci_postreset,
304 .pmp_softreset = ahci_pmp_softreset, 302 .pmp_softreset = ahci_softreset,
305 .error_handler = ahci_error_handler, 303 .error_handler = ahci_error_handler,
306 .post_internal_cmd = ahci_post_internal_cmd, 304 .post_internal_cmd = ahci_post_internal_cmd,
307 .dev_config = ahci_dev_config, 305 .dev_config = ahci_dev_config,
@@ -1263,10 +1261,11 @@ static int ahci_check_ready(struct ata_link *link)
1263 return 0; 1261 return 0;
1264} 1262}
1265 1263
1266static int ahci_do_softreset(struct ata_link *link, unsigned int *class, 1264static int ahci_softreset(struct ata_link *link, unsigned int *class,
1267 int pmp, unsigned long deadline) 1265 unsigned long deadline)
1268{ 1266{
1269 struct ata_port *ap = link->ap; 1267 struct ata_port *ap = link->ap;
1268 int pmp = sata_srst_pmp(link);
1270 const char *reason = NULL; 1269 const char *reason = NULL;
1271 unsigned long now, msecs; 1270 unsigned long now, msecs;
1272 struct ata_taskfile tf; 1271 struct ata_taskfile tf;
@@ -1326,17 +1325,6 @@ static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
1326 return rc; 1325 return rc;
1327} 1326}
1328 1327
1329static int ahci_softreset(struct ata_link *link, unsigned int *class,
1330 unsigned long deadline)
1331{
1332 int pmp = 0;
1333
1334 if (link->ap->flags & ATA_FLAG_PMP)
1335 pmp = SATA_PMP_CTRL_PORT;
1336
1337 return ahci_do_softreset(link, class, pmp, deadline);
1338}
1339
1340static int ahci_hardreset(struct ata_link *link, unsigned int *class, 1328static int ahci_hardreset(struct ata_link *link, unsigned int *class,
1341 unsigned long deadline) 1329 unsigned long deadline)
1342{ 1330{
@@ -1457,12 +1445,6 @@ static void ahci_postreset(struct ata_link *link, unsigned int *class)
1457 } 1445 }
1458} 1446}
1459 1447
1460static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
1461 unsigned long deadline)
1462{
1463 return ahci_do_softreset(link, class, link->pmp, deadline);
1464}
1465
1466static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl) 1448static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl)
1467{ 1449{
1468 struct scatterlist *sg; 1450 struct scatterlist *sg;
@@ -1581,7 +1563,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
1581 unk[0], unk[1], unk[2], unk[3]); 1563 unk[0], unk[1], unk[2], unk[3]);
1582 } 1564 }
1583 1565
1584 if (ap->nr_pmp_links && (irq_stat & PORT_IRQ_BAD_PMP)) { 1566 if (sata_pmp_attached(ap) && (irq_stat & PORT_IRQ_BAD_PMP)) {
1585 active_ehi->err_mask |= AC_ERR_HSM; 1567 active_ehi->err_mask |= AC_ERR_HSM;
1586 active_ehi->action |= ATA_EH_RESET; 1568 active_ehi->action |= ATA_EH_RESET;
1587 ata_ehi_push_desc(active_ehi, "incorrect PMP"); 1569 ata_ehi_push_desc(active_ehi, "incorrect PMP");
@@ -1847,7 +1829,7 @@ static int ahci_port_resume(struct ata_port *ap)
1847 ahci_power_up(ap); 1829 ahci_power_up(ap);
1848 ahci_start_port(ap); 1830 ahci_start_port(ap);
1849 1831
1850 if (ap->nr_pmp_links) 1832 if (sata_pmp_attached(ap))
1851 ahci_pmp_attach(ap); 1833 ahci_pmp_attach(ap);
1852 else 1834 else
1853 ahci_pmp_detach(ap); 1835 ahci_pmp_detach(ap);