diff options
author | Jiang Yutang <b14898@freescale.com> | 2009-10-16 12:44:36 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2009-11-19 18:18:17 -0500 |
commit | a0a74d1ee2e38eb936a0437330da3a2fbc12b54e (patch) | |
tree | 3fe918157051e2f362ea4ecaf8cfef6d6d6ebe90 /drivers/ata | |
parent | 648f4e3e50c4793d9dbf9a09afa193631f76fa26 (diff) |
sata_fsl: Split hard and soft reset
Split sata_fsl_softreset() into hard and soft resets to make
error-handling more efficient & device and PMP detection more
reliable.
Also includes fix for PMP support, driver tested with Sil3726,
Sil4726 & Exar PMP controllers.
[AV: Also fixes resuming from deep sleep on MPC8315 CPUs]
Signed-off-by: Jiang Yutang <b14898@freescale.com>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/sata_fsl.c | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c index d344db42a002..172b57e6543f 100644 --- a/drivers/ata/sata_fsl.c +++ b/drivers/ata/sata_fsl.c | |||
@@ -707,34 +707,17 @@ static unsigned int sata_fsl_dev_classify(struct ata_port *ap) | |||
707 | return ata_dev_classify(&tf); | 707 | return ata_dev_classify(&tf); |
708 | } | 708 | } |
709 | 709 | ||
710 | static int sata_fsl_prereset(struct ata_link *link, unsigned long deadline) | 710 | static int sata_fsl_hardreset(struct ata_link *link, unsigned int *class, |
711 | { | ||
712 | /* FIXME: Never skip softreset, sata_fsl_softreset() is | ||
713 | * combination of soft and hard resets. sata_fsl_softreset() | ||
714 | * needs to be splitted into soft and hard resets. | ||
715 | */ | ||
716 | return 0; | ||
717 | } | ||
718 | |||
719 | static int sata_fsl_softreset(struct ata_link *link, unsigned int *class, | ||
720 | unsigned long deadline) | 711 | unsigned long deadline) |
721 | { | 712 | { |
722 | struct ata_port *ap = link->ap; | 713 | struct ata_port *ap = link->ap; |
723 | struct sata_fsl_port_priv *pp = ap->private_data; | ||
724 | struct sata_fsl_host_priv *host_priv = ap->host->private_data; | 714 | struct sata_fsl_host_priv *host_priv = ap->host->private_data; |
725 | void __iomem *hcr_base = host_priv->hcr_base; | 715 | void __iomem *hcr_base = host_priv->hcr_base; |
726 | int pmp = sata_srst_pmp(link); | ||
727 | u32 temp; | 716 | u32 temp; |
728 | struct ata_taskfile tf; | ||
729 | u8 *cfis; | ||
730 | u32 Serror; | ||
731 | int i = 0; | 717 | int i = 0; |
732 | unsigned long start_jiffies; | 718 | unsigned long start_jiffies; |
733 | 719 | ||
734 | DPRINTK("in xx_softreset\n"); | 720 | DPRINTK("in xx_hardreset\n"); |
735 | |||
736 | if (pmp != SATA_PMP_CTRL_PORT) | ||
737 | goto issue_srst; | ||
738 | 721 | ||
739 | try_offline_again: | 722 | try_offline_again: |
740 | /* | 723 | /* |
@@ -749,7 +732,7 @@ try_offline_again: | |||
749 | 732 | ||
750 | if (temp & ONLINE) { | 733 | if (temp & ONLINE) { |
751 | ata_port_printk(ap, KERN_ERR, | 734 | ata_port_printk(ap, KERN_ERR, |
752 | "Softreset failed, not off-lined %d\n", i); | 735 | "Hardreset failed, not off-lined %d\n", i); |
753 | 736 | ||
754 | /* | 737 | /* |
755 | * Try to offline controller atleast twice | 738 | * Try to offline controller atleast twice |
@@ -761,7 +744,7 @@ try_offline_again: | |||
761 | goto try_offline_again; | 744 | goto try_offline_again; |
762 | } | 745 | } |
763 | 746 | ||
764 | DPRINTK("softreset, controller off-lined\n"); | 747 | DPRINTK("hardreset, controller off-lined\n"); |
765 | VPRINTK("HStatus = 0x%x\n", ioread32(hcr_base + HSTATUS)); | 748 | VPRINTK("HStatus = 0x%x\n", ioread32(hcr_base + HSTATUS)); |
766 | VPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL)); | 749 | VPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL)); |
767 | 750 | ||
@@ -786,11 +769,11 @@ try_offline_again: | |||
786 | 769 | ||
787 | if (!(temp & ONLINE)) { | 770 | if (!(temp & ONLINE)) { |
788 | ata_port_printk(ap, KERN_ERR, | 771 | ata_port_printk(ap, KERN_ERR, |
789 | "Softreset failed, not on-lined\n"); | 772 | "Hardreset failed, not on-lined\n"); |
790 | goto err; | 773 | goto err; |
791 | } | 774 | } |
792 | 775 | ||
793 | DPRINTK("softreset, controller off-lined & on-lined\n"); | 776 | DPRINTK("hardreset, controller off-lined & on-lined\n"); |
794 | VPRINTK("HStatus = 0x%x\n", ioread32(hcr_base + HSTATUS)); | 777 | VPRINTK("HStatus = 0x%x\n", ioread32(hcr_base + HSTATUS)); |
795 | VPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL)); | 778 | VPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL)); |
796 | 779 | ||
@@ -806,7 +789,7 @@ try_offline_again: | |||
806 | "No Device OR PHYRDY change,Hstatus = 0x%x\n", | 789 | "No Device OR PHYRDY change,Hstatus = 0x%x\n", |
807 | ioread32(hcr_base + HSTATUS)); | 790 | ioread32(hcr_base + HSTATUS)); |
808 | *class = ATA_DEV_NONE; | 791 | *class = ATA_DEV_NONE; |
809 | goto out; | 792 | return 0; |
810 | } | 793 | } |
811 | 794 | ||
812 | /* | 795 | /* |
@@ -819,11 +802,44 @@ try_offline_again: | |||
819 | if ((temp & 0xFF) != 0x18) { | 802 | if ((temp & 0xFF) != 0x18) { |
820 | ata_port_printk(ap, KERN_WARNING, "No Signature Update\n"); | 803 | ata_port_printk(ap, KERN_WARNING, "No Signature Update\n"); |
821 | *class = ATA_DEV_NONE; | 804 | *class = ATA_DEV_NONE; |
822 | goto out; | 805 | goto do_followup_srst; |
823 | } else { | 806 | } else { |
824 | ata_port_printk(ap, KERN_INFO, | 807 | ata_port_printk(ap, KERN_INFO, |
825 | "Signature Update detected @ %d msecs\n", | 808 | "Signature Update detected @ %d msecs\n", |
826 | jiffies_to_msecs(jiffies - start_jiffies)); | 809 | jiffies_to_msecs(jiffies - start_jiffies)); |
810 | *class = sata_fsl_dev_classify(ap); | ||
811 | return 0; | ||
812 | } | ||
813 | |||
814 | do_followup_srst: | ||
815 | /* | ||
816 | * request libATA to perform follow-up softreset | ||
817 | */ | ||
818 | return -EAGAIN; | ||
819 | |||
820 | err: | ||
821 | return -EIO; | ||
822 | } | ||
823 | |||
824 | static int sata_fsl_softreset(struct ata_link *link, unsigned int *class, | ||
825 | unsigned long deadline) | ||
826 | { | ||
827 | struct ata_port *ap = link->ap; | ||
828 | struct sata_fsl_port_priv *pp = ap->private_data; | ||
829 | struct sata_fsl_host_priv *host_priv = ap->host->private_data; | ||
830 | void __iomem *hcr_base = host_priv->hcr_base; | ||
831 | int pmp = sata_srst_pmp(link); | ||
832 | u32 temp; | ||
833 | struct ata_taskfile tf; | ||
834 | u8 *cfis; | ||
835 | u32 Serror; | ||
836 | |||
837 | DPRINTK("in xx_softreset\n"); | ||
838 | |||
839 | if (ata_link_offline(link)) { | ||
840 | DPRINTK("PHY reports no device\n"); | ||
841 | *class = ATA_DEV_NONE; | ||
842 | return 0; | ||
827 | } | 843 | } |
828 | 844 | ||
829 | /* | 845 | /* |
@@ -834,7 +850,6 @@ try_offline_again: | |||
834 | * reached here, we can send a command to the target device | 850 | * reached here, we can send a command to the target device |
835 | */ | 851 | */ |
836 | 852 | ||
837 | issue_srst: | ||
838 | DPRINTK("Sending SRST/device reset\n"); | 853 | DPRINTK("Sending SRST/device reset\n"); |
839 | 854 | ||
840 | ata_tf_init(link->device, &tf); | 855 | ata_tf_init(link->device, &tf); |
@@ -860,6 +875,8 @@ issue_srst: | |||
860 | ioread32(CA + hcr_base), ioread32(CC + hcr_base)); | 875 | ioread32(CA + hcr_base), ioread32(CC + hcr_base)); |
861 | 876 | ||
862 | iowrite32(0xFFFF, CC + hcr_base); | 877 | iowrite32(0xFFFF, CC + hcr_base); |
878 | if (pmp != SATA_PMP_CTRL_PORT) | ||
879 | iowrite32(pmp, CQPMP + hcr_base); | ||
863 | iowrite32(1, CQ + hcr_base); | 880 | iowrite32(1, CQ + hcr_base); |
864 | 881 | ||
865 | temp = ata_wait_register(CQ + hcr_base, 0x1, 0x1, 1, 5000); | 882 | temp = ata_wait_register(CQ + hcr_base, 0x1, 0x1, 1, 5000); |
@@ -926,7 +943,6 @@ issue_srst: | |||
926 | VPRINTK("cereg = 0x%x\n", ioread32(hcr_base + CE)); | 943 | VPRINTK("cereg = 0x%x\n", ioread32(hcr_base + CE)); |
927 | } | 944 | } |
928 | 945 | ||
929 | out: | ||
930 | return 0; | 946 | return 0; |
931 | 947 | ||
932 | err: | 948 | err: |
@@ -988,18 +1004,6 @@ static void sata_fsl_error_intr(struct ata_port *ap) | |||
988 | ehi->err_mask |= AC_ERR_ATA_BUS; | 1004 | ehi->err_mask |= AC_ERR_ATA_BUS; |
989 | ehi->action |= ATA_EH_SOFTRESET; | 1005 | ehi->action |= ATA_EH_SOFTRESET; |
990 | 1006 | ||
991 | /* | ||
992 | * Ignore serror in case of fatal errors as we always want | ||
993 | * to do a soft-reset of the FSL SATA controller. Analyzing | ||
994 | * serror may cause libata to schedule a hard-reset action, | ||
995 | * and hard-reset currently does not do controller | ||
996 | * offline/online, causing command timeouts and leads to an | ||
997 | * un-recoverable state, hence make libATA ignore | ||
998 | * autopsy in case of fatal errors. | ||
999 | */ | ||
1000 | |||
1001 | ehi->flags |= ATA_EHI_NO_AUTOPSY; | ||
1002 | |||
1003 | freeze = 1; | 1007 | freeze = 1; |
1004 | } | 1008 | } |
1005 | 1009 | ||
@@ -1267,8 +1271,8 @@ static struct ata_port_operations sata_fsl_ops = { | |||
1267 | 1271 | ||
1268 | .freeze = sata_fsl_freeze, | 1272 | .freeze = sata_fsl_freeze, |
1269 | .thaw = sata_fsl_thaw, | 1273 | .thaw = sata_fsl_thaw, |
1270 | .prereset = sata_fsl_prereset, | ||
1271 | .softreset = sata_fsl_softreset, | 1274 | .softreset = sata_fsl_softreset, |
1275 | .hardreset = sata_fsl_hardreset, | ||
1272 | .pmp_softreset = sata_fsl_softreset, | 1276 | .pmp_softreset = sata_fsl_softreset, |
1273 | .error_handler = sata_fsl_error_handler, | 1277 | .error_handler = sata_fsl_error_handler, |
1274 | .post_internal_cmd = sata_fsl_post_internal_cmd, | 1278 | .post_internal_cmd = sata_fsl_post_internal_cmd, |