diff options
author | Tejun Heo <htejun@gmail.com> | 2008-04-07 09:47:22 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-17 15:44:25 -0400 |
commit | 071f44b1d2c051641b62a3571223314737ccbe59 (patch) | |
tree | a07794c8109e5d82a78223ae0159eadbf862c463 /drivers/ata/sata_sil24.c | |
parent | 48515f6c006c2a9d7b624ee8ad068018c2d3fe0e (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/sata_sil24.c')
-rw-r--r-- | drivers/ata/sata_sil24.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index 6039614e956c..068789361895 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -354,8 +354,6 @@ static int sil24_softreset(struct ata_link *link, unsigned int *class, | |||
354 | unsigned long deadline); | 354 | unsigned long deadline); |
355 | static int sil24_hardreset(struct ata_link *link, unsigned int *class, | 355 | static int sil24_hardreset(struct ata_link *link, unsigned int *class, |
356 | unsigned long deadline); | 356 | unsigned long deadline); |
357 | static int sil24_pmp_softreset(struct ata_link *link, unsigned int *class, | ||
358 | unsigned long deadline); | ||
359 | static int sil24_pmp_hardreset(struct ata_link *link, unsigned int *class, | 357 | static int sil24_pmp_hardreset(struct ata_link *link, unsigned int *class, |
360 | unsigned long deadline); | 358 | unsigned long deadline); |
361 | static void sil24_error_handler(struct ata_port *ap); | 359 | static void sil24_error_handler(struct ata_port *ap); |
@@ -408,7 +406,7 @@ static struct ata_port_operations sil24_ops = { | |||
408 | .thaw = sil24_thaw, | 406 | .thaw = sil24_thaw, |
409 | .softreset = sil24_softreset, | 407 | .softreset = sil24_softreset, |
410 | .hardreset = sil24_hardreset, | 408 | .hardreset = sil24_hardreset, |
411 | .pmp_softreset = sil24_pmp_softreset, | 409 | .pmp_softreset = sil24_softreset, |
412 | .pmp_hardreset = sil24_pmp_hardreset, | 410 | .pmp_hardreset = sil24_pmp_hardreset, |
413 | .error_handler = sil24_error_handler, | 411 | .error_handler = sil24_error_handler, |
414 | .post_internal_cmd = sil24_post_internal_cmd, | 412 | .post_internal_cmd = sil24_post_internal_cmd, |
@@ -588,7 +586,7 @@ static int sil24_init_port(struct ata_port *ap) | |||
588 | u32 tmp; | 586 | u32 tmp; |
589 | 587 | ||
590 | /* clear PMP error status */ | 588 | /* clear PMP error status */ |
591 | if (ap->nr_pmp_links) | 589 | if (sata_pmp_attached(ap)) |
592 | sil24_clear_pmp(ap); | 590 | sil24_clear_pmp(ap); |
593 | 591 | ||
594 | writel(PORT_CS_INIT, port + PORT_CTRL_STAT); | 592 | writel(PORT_CS_INIT, port + PORT_CTRL_STAT); |
@@ -653,10 +651,11 @@ static int sil24_exec_polled_cmd(struct ata_port *ap, int pmp, | |||
653 | return rc; | 651 | return rc; |
654 | } | 652 | } |
655 | 653 | ||
656 | static int sil24_do_softreset(struct ata_link *link, unsigned int *class, | 654 | static int sil24_softreset(struct ata_link *link, unsigned int *class, |
657 | int pmp, unsigned long deadline) | 655 | unsigned long deadline) |
658 | { | 656 | { |
659 | struct ata_port *ap = link->ap; | 657 | struct ata_port *ap = link->ap; |
658 | int pmp = sata_srst_pmp(link); | ||
660 | unsigned long timeout_msec = 0; | 659 | unsigned long timeout_msec = 0; |
661 | struct ata_taskfile tf; | 660 | struct ata_taskfile tf; |
662 | const char *reason; | 661 | const char *reason; |
@@ -706,12 +705,6 @@ static int sil24_do_softreset(struct ata_link *link, unsigned int *class, | |||
706 | return -EIO; | 705 | return -EIO; |
707 | } | 706 | } |
708 | 707 | ||
709 | static int sil24_softreset(struct ata_link *link, unsigned int *class, | ||
710 | unsigned long deadline) | ||
711 | { | ||
712 | return sil24_do_softreset(link, class, SATA_PMP_CTRL_PORT, deadline); | ||
713 | } | ||
714 | |||
715 | static int sil24_hardreset(struct ata_link *link, unsigned int *class, | 708 | static int sil24_hardreset(struct ata_link *link, unsigned int *class, |
716 | unsigned long deadline) | 709 | unsigned long deadline) |
717 | { | 710 | { |
@@ -926,12 +919,6 @@ static void sil24_pmp_detach(struct ata_port *ap) | |||
926 | sil24_config_pmp(ap, 0); | 919 | sil24_config_pmp(ap, 0); |
927 | } | 920 | } |
928 | 921 | ||
929 | static int sil24_pmp_softreset(struct ata_link *link, unsigned int *class, | ||
930 | unsigned long deadline) | ||
931 | { | ||
932 | return sil24_do_softreset(link, class, link->pmp, deadline); | ||
933 | } | ||
934 | |||
935 | static int sil24_pmp_hardreset(struct ata_link *link, unsigned int *class, | 922 | static int sil24_pmp_hardreset(struct ata_link *link, unsigned int *class, |
936 | unsigned long deadline) | 923 | unsigned long deadline) |
937 | { | 924 | { |
@@ -1034,7 +1021,7 @@ static void sil24_error_intr(struct ata_port *ap) | |||
1034 | } | 1021 | } |
1035 | 1022 | ||
1036 | /* find out the offending link and qc */ | 1023 | /* find out the offending link and qc */ |
1037 | if (ap->nr_pmp_links) { | 1024 | if (sata_pmp_attached(ap)) { |
1038 | context = readl(port + PORT_CONTEXT); | 1025 | context = readl(port + PORT_CONTEXT); |
1039 | pmp = (context >> 5) & 0xf; | 1026 | pmp = (context >> 5) & 0xf; |
1040 | 1027 | ||
@@ -1082,7 +1069,7 @@ static void sil24_error_intr(struct ata_port *ap) | |||
1082 | ehi->action |= action; | 1069 | ehi->action |= action; |
1083 | 1070 | ||
1084 | /* if PMP, resume */ | 1071 | /* if PMP, resume */ |
1085 | if (ap->nr_pmp_links) | 1072 | if (sata_pmp_attached(ap)) |
1086 | writel(PORT_CS_PMP_RESUME, port + PORT_CTRL_STAT); | 1073 | writel(PORT_CS_PMP_RESUME, port + PORT_CTRL_STAT); |
1087 | } | 1074 | } |
1088 | 1075 | ||