Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
ahci: change the Device IDs of nvidia MCP7B AHCI controller in ahci.c
[libata] sata_fsl: Fix broken driver, add port multiplier (PMP) support
libata: SRST can't be trusted on PMP sil3726
libata: fix libata-scsi kernel-doc notation
ata: Convert to static DEFINE_SPINLOCK(lock)
ata_piix: fix macbook ich8m problems
sata_mv: implement SoC guideline SATA_S11
sata_mv: workaround for 60x1 errata sata13
sata_mv: nuke unreleased GenIIe revisions
sata_mv: PHY_MODEx errata fixes
sata_mv: move SOC_FLAG to hpriv

+214 -114
+4 -4
drivers/ata/ahci.c
··· 502 502 { PCI_VDEVICE(NVIDIA, 0x0bcd), board_ahci }, /* MCP7B */ 503 503 { PCI_VDEVICE(NVIDIA, 0x0bce), board_ahci }, /* MCP7B */ 504 504 { PCI_VDEVICE(NVIDIA, 0x0bcf), board_ahci }, /* MCP7B */ 505 - { PCI_VDEVICE(NVIDIA, 0x0bd0), board_ahci }, /* MCP7B */ 506 - { PCI_VDEVICE(NVIDIA, 0x0bd1), board_ahci }, /* MCP7B */ 507 - { PCI_VDEVICE(NVIDIA, 0x0bd2), board_ahci }, /* MCP7B */ 508 - { PCI_VDEVICE(NVIDIA, 0x0bd3), board_ahci }, /* MCP7B */ 505 + { PCI_VDEVICE(NVIDIA, 0x0bc4), board_ahci }, /* MCP7B */ 506 + { PCI_VDEVICE(NVIDIA, 0x0bc5), board_ahci }, /* MCP7B */ 507 + { PCI_VDEVICE(NVIDIA, 0x0bc6), board_ahci }, /* MCP7B */ 508 + { PCI_VDEVICE(NVIDIA, 0x0bc7), board_ahci }, /* MCP7B */ 509 509 510 510 /* SiS */ 511 511 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
+4 -3
drivers/ata/ata_piix.c
··· 247 247 { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 248 248 /* SATA Controller 2 IDE (ICH8) */ 249 249 { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, 250 - /* Mobile SATA Controller IDE (ICH8M) */ 251 - { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 252 250 /* Mobile SATA Controller IDE (ICH8M), Apple */ 253 251 { 0x8086, 0x2828, 0x106b, 0x00a0, 0, 0, ich8m_apple_sata }, 252 + { 0x8086, 0x2828, 0x106b, 0x00a1, 0, 0, ich8m_apple_sata }, 253 + /* Mobile SATA Controller IDE (ICH8M) */ 254 + { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 254 255 /* SATA Controller IDE (ICH9) */ 255 256 { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 256 257 /* SATA Controller IDE (ICH9) */ ··· 527 526 528 527 [ich8m_apple_sata] = 529 528 { 530 - .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR, 529 + .flags = PIIX_SATA_FLAGS, 531 530 .pio_mask = 0x1f, /* pio0-4 */ 532 531 .mwdma_mask = 0x07, /* mwdma0-2 */ 533 532 .udma_mask = ATA_UDMA6,
+1 -1
drivers/ata/libata-core.c
··· 5403 5403 */ 5404 5404 static void ata_finalize_port_ops(struct ata_port_operations *ops) 5405 5405 { 5406 - static spinlock_t lock = SPIN_LOCK_UNLOCKED; 5406 + static DEFINE_SPINLOCK(lock); 5407 5407 const struct ata_port_operations *cur; 5408 5408 void **begin = (void **)ops; 5409 5409 void **end = (void **)&ops->inherits;
+5 -2
drivers/ata/libata-pmp.c
··· 322 322 if (vendor == 0x1095 && devid == 0x3726) { 323 323 /* sil3726 quirks */ 324 324 ata_port_for_each_link(link, ap) { 325 - /* class code report is unreliable */ 325 + /* Class code report is unreliable and SRST 326 + * times out under certain configurations. 327 + */ 326 328 if (link->pmp < 5) 327 - link->flags |= ATA_LFLAG_ASSUME_ATA; 329 + link->flags |= ATA_LFLAG_NO_SRST | 330 + ATA_LFLAG_ASSUME_ATA; 328 331 329 332 /* port 5 is for SEMB device and it doesn't like SRST */ 330 333 if (link->pmp == 5)
+2 -1
drivers/ata/libata-scsi.c
··· 1637 1637 1638 1638 /** 1639 1639 * ata_scsi_rbuf_get - Map response buffer. 1640 + * @cmd: SCSI command containing buffer to be mapped. 1640 1641 * @flags: unsigned long variable to store irq enable status 1641 1642 * @copy_in: copy in from user buffer 1642 1643 * ··· 1955 1954 1956 1955 /** 1957 1956 * ata_msense_rw_recovery - Simulate MODE SENSE r/w error recovery page 1958 - * @bufp: output buffer 1957 + * @buf: output buffer 1959 1958 * 1960 1959 * Generate a generic MODE SENSE r/w error recovery page. 1961 1960 *
+160 -58
drivers/ata/sata_fsl.c
··· 34 34 35 35 SATA_FSL_HOST_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 36 36 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 37 - ATA_FLAG_NCQ), 37 + ATA_FLAG_PMP | ATA_FLAG_NCQ), 38 38 39 39 SATA_FSL_MAX_CMDS = SATA_FSL_QUEUE_DEPTH, 40 40 SATA_FSL_CMD_HDR_SIZE = 16, /* 4 DWORDS */ ··· 395 395 cd = (struct command_desc *)pp->cmdentry + tag; 396 396 cd_paddr = pp->cmdentry_paddr + tag * SATA_FSL_CMD_DESC_SIZE; 397 397 398 - ata_tf_to_fis(&qc->tf, 0, 1, (u8 *) &cd->cfis); 398 + ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, (u8 *) &cd->cfis); 399 399 400 400 VPRINTK("Dumping cfis : 0x%x, 0x%x, 0x%x\n", 401 401 cd->cfis[0], cd->cfis[1], cd->cfis[2]); ··· 437 437 ioread32(CQ + hcr_base), 438 438 ioread32(CA + hcr_base), 439 439 ioread32(CE + hcr_base), ioread32(CC + hcr_base)); 440 + 441 + iowrite32(qc->dev->link->pmp, CQPMP + hcr_base); 440 442 441 443 /* Simply queue command to the controller/device */ 442 444 iowrite32(1 << tag, CQ + hcr_base); ··· 560 558 ioread32(hcr_base + HCONTROL), ioread32(hcr_base + HSTATUS)); 561 559 } 562 560 561 + static void sata_fsl_pmp_attach(struct ata_port *ap) 562 + { 563 + struct sata_fsl_host_priv *host_priv = ap->host->private_data; 564 + void __iomem *hcr_base = host_priv->hcr_base; 565 + u32 temp; 566 + 567 + temp = ioread32(hcr_base + HCONTROL); 568 + iowrite32((temp | HCONTROL_PMP_ATTACHED), hcr_base + HCONTROL); 569 + } 570 + 571 + static void sata_fsl_pmp_detach(struct ata_port *ap) 572 + { 573 + struct sata_fsl_host_priv *host_priv = ap->host->private_data; 574 + void __iomem *hcr_base = host_priv->hcr_base; 575 + u32 temp; 576 + 577 + temp = ioread32(hcr_base + HCONTROL); 578 + temp &= ~HCONTROL_PMP_ATTACHED; 579 + iowrite32(temp, hcr_base + HCONTROL); 580 + 581 + /* enable interrupts on the controller/port */ 582 + temp = ioread32(hcr_base + HCONTROL); 583 + iowrite32((temp | DEFAULT_PORT_IRQ_ENABLE_MASK), hcr_base + HCONTROL); 584 + 585 + } 586 + 563 587 static int sata_fsl_port_start(struct ata_port *ap) 564 588 { 565 589 struct device *dev = ap->host->dev; 566 590 struct sata_fsl_port_priv *pp; 567 - int retval; 568 591 void *mem; 569 592 dma_addr_t mem_dma; 570 593 struct sata_fsl_host_priv *host_priv = ap->host->private_data; ··· 715 688 } 716 689 717 690 static int sata_fsl_softreset(struct ata_link *link, unsigned int *class, 718 - unsigned long deadline) 691 + unsigned long deadline) 719 692 { 720 693 struct ata_port *ap = link->ap; 721 694 struct sata_fsl_port_priv *pp = ap->private_data; 722 695 struct sata_fsl_host_priv *host_priv = ap->host->private_data; 723 696 void __iomem *hcr_base = host_priv->hcr_base; 697 + int pmp = sata_srst_pmp(link); 724 698 u32 temp; 725 699 struct ata_taskfile tf; 726 700 u8 *cfis; ··· 730 702 unsigned long start_jiffies; 731 703 732 704 DPRINTK("in xx_softreset\n"); 705 + 706 + if (pmp != SATA_PMP_CTRL_PORT) 707 + goto issue_srst; 733 708 734 709 try_offline_again: 735 710 /* ··· 777 746 778 747 temp = ioread32(hcr_base + HCONTROL); 779 748 temp |= (HCONTROL_ONLINE_PHY_RST | HCONTROL_SNOOP_ENABLE); 749 + temp |= HCONTROL_PMP_ATTACHED; 780 750 iowrite32(temp, hcr_base + HCONTROL); 781 751 782 752 temp = ata_wait_register(hcr_base + HSTATUS, ONLINE, 0, 1, 500); ··· 803 771 ata_port_printk(ap, KERN_WARNING, 804 772 "No Device OR PHYRDY change,Hstatus = 0x%x\n", 805 773 ioread32(hcr_base + HSTATUS)); 806 - goto err; 774 + *class = ATA_DEV_NONE; 775 + goto out; 807 776 } 808 777 809 778 /* ··· 816 783 817 784 if ((temp & 0xFF) != 0x18) { 818 785 ata_port_printk(ap, KERN_WARNING, "No Signature Update\n"); 819 - goto err; 786 + *class = ATA_DEV_NONE; 787 + goto out; 820 788 } else { 821 789 ata_port_printk(ap, KERN_INFO, 822 790 "Signature Update detected @ %d msecs\n", ··· 832 798 * reached here, we can send a command to the target device 833 799 */ 834 800 801 + issue_srst: 835 802 DPRINTK("Sending SRST/device reset\n"); 836 803 837 804 ata_tf_init(link->device, &tf); ··· 843 808 SRST_CMD | CMD_DESC_SNOOP_ENABLE, 0, 0, 5); 844 809 845 810 tf.ctl |= ATA_SRST; /* setup SRST bit in taskfile control reg */ 846 - ata_tf_to_fis(&tf, 0, 0, cfis); 811 + ata_tf_to_fis(&tf, pmp, 0, cfis); 847 812 848 813 DPRINTK("Dumping cfis : 0x%x, 0x%x, 0x%x, 0x%x\n", 849 814 cfis[0], cfis[1], cfis[2], cfis[3]); ··· 889 854 sata_fsl_setup_cmd_hdr_entry(pp, 0, CMD_DESC_SNOOP_ENABLE, 0, 0, 5); 890 855 891 856 tf.ctl &= ~ATA_SRST; /* 2nd H2D Ctl. register FIS */ 892 - ata_tf_to_fis(&tf, 0, 0, cfis); 857 + ata_tf_to_fis(&tf, pmp, 0, cfis); 893 858 859 + if (pmp != SATA_PMP_CTRL_PORT) 860 + iowrite32(pmp, CQPMP + hcr_base); 894 861 iowrite32(1, CQ + hcr_base); 895 862 msleep(150); /* ?? */ 896 863 ··· 923 886 VPRINTK("cereg = 0x%x\n", ioread32(hcr_base + CE)); 924 887 } 925 888 889 + out: 926 890 return 0; 927 891 928 892 err: 929 893 return -EIO; 894 + } 895 + 896 + static void sata_fsl_error_handler(struct ata_port *ap) 897 + { 898 + 899 + DPRINTK("in xx_error_handler\n"); 900 + sata_pmp_error_handler(ap); 901 + 930 902 } 931 903 932 904 static void sata_fsl_post_internal_cmd(struct ata_queued_cmd *qc) ··· 951 905 952 906 static void sata_fsl_error_intr(struct ata_port *ap) 953 907 { 954 - struct ata_link *link = &ap->link; 955 - struct ata_eh_info *ehi = &link->eh_info; 956 908 struct sata_fsl_host_priv *host_priv = ap->host->private_data; 957 909 void __iomem *hcr_base = host_priv->hcr_base; 958 - u32 hstatus, dereg, cereg = 0, SError = 0; 910 + u32 hstatus, dereg=0, cereg = 0, SError = 0; 959 911 unsigned int err_mask = 0, action = 0; 960 - struct ata_queued_cmd *qc; 961 - int freeze = 0; 912 + int freeze = 0, abort=0; 913 + struct ata_link *link = NULL; 914 + struct ata_queued_cmd *qc = NULL; 915 + struct ata_eh_info *ehi; 962 916 963 917 hstatus = ioread32(hcr_base + HSTATUS); 964 918 cereg = ioread32(hcr_base + CE); 965 919 920 + /* first, analyze and record host port events */ 921 + link = &ap->link; 922 + ehi = &link->eh_info; 966 923 ata_ehi_clear_desc(ehi); 967 924 968 925 /* ··· 975 926 sata_fsl_scr_read(ap, SCR_ERROR, &SError); 976 927 if (unlikely(SError & 0xFFFF0000)) { 977 928 sata_fsl_scr_write(ap, SCR_ERROR, SError); 978 - err_mask |= AC_ERR_ATA_BUS; 979 929 } 980 930 981 931 DPRINTK("error_intr,hStat=0x%x,CE=0x%x,DE =0x%x,SErr=0x%x\n", 982 932 hstatus, cereg, ioread32(hcr_base + DE), SError); 933 + 934 + /* handle fatal errors */ 935 + if (hstatus & FATAL_ERROR_DECODE) { 936 + ehi->err_mask |= AC_ERR_ATA_BUS; 937 + ehi->action |= ATA_EH_SOFTRESET; 938 + 939 + /* 940 + * Ignore serror in case of fatal errors as we always want 941 + * to do a soft-reset of the FSL SATA controller. Analyzing 942 + * serror may cause libata to schedule a hard-reset action, 943 + * and hard-reset currently does not do controller 944 + * offline/online, causing command timeouts and leads to an 945 + * un-recoverable state, hence make libATA ignore 946 + * autopsy in case of fatal errors. 947 + */ 948 + 949 + ehi->flags |= ATA_EHI_NO_AUTOPSY; 950 + 951 + freeze = 1; 952 + } 953 + 954 + /* Handle PHYRDY change notification */ 955 + if (hstatus & INT_ON_PHYRDY_CHG) { 956 + DPRINTK("SATA FSL: PHYRDY change indication\n"); 957 + 958 + /* Setup a soft-reset EH action */ 959 + ata_ehi_hotplugged(ehi); 960 + ata_ehi_push_desc(ehi, "%s", "PHY RDY changed"); 961 + freeze = 1; 962 + } 983 963 984 964 /* handle single device errors */ 985 965 if (cereg) { ··· 1021 943 * clearing the device error, we can issue commands to the 1022 944 * device to interrogate it to find the source of the error. 1023 945 */ 1024 - dereg = ioread32(hcr_base + DE); 1025 - iowrite32(dereg, hcr_base + DE); 1026 - iowrite32(cereg, hcr_base + CE); 946 + abort = 1; 1027 947 1028 948 DPRINTK("single device error, CE=0x%x, DE=0x%x\n", 1029 949 ioread32(hcr_base + CE), ioread32(hcr_base + DE)); 1030 - /* 1031 - * We should consider this as non fatal error, and TF must 1032 - * be updated as done below. 1033 - */ 1034 950 1035 - err_mask |= AC_ERR_DEV; 1036 - } 951 + /* find out the offending link and qc */ 952 + if (ap->nr_pmp_links) { 953 + dereg = ioread32(hcr_base + DE); 954 + iowrite32(dereg, hcr_base + DE); 955 + iowrite32(cereg, hcr_base + CE); 1037 956 1038 - /* handle fatal errors */ 1039 - if (hstatus & FATAL_ERROR_DECODE) { 1040 - err_mask |= AC_ERR_ATA_BUS; 1041 - action |= ATA_EH_RESET; 1042 - /* how will fatal error interrupts be completed ?? */ 1043 - freeze = 1; 1044 - } 957 + if (dereg < ap->nr_pmp_links) { 958 + link = &ap->pmp_link[dereg]; 959 + ehi = &link->eh_info; 960 + qc = ata_qc_from_tag(ap, link->active_tag); 961 + /* 962 + * We should consider this as non fatal error, 963 + * and TF must be updated as done below. 964 + */ 1045 965 1046 - /* Handle PHYRDY change notification */ 1047 - if (hstatus & INT_ON_PHYRDY_CHG) { 1048 - DPRINTK("SATA FSL: PHYRDY change indication\n"); 966 + err_mask |= AC_ERR_DEV; 1049 967 1050 - /* Setup a soft-reset EH action */ 1051 - ata_ehi_hotplugged(ehi); 1052 - freeze = 1; 968 + } else { 969 + err_mask |= AC_ERR_HSM; 970 + action |= ATA_EH_HARDRESET; 971 + freeze = 1; 972 + } 973 + } else { 974 + dereg = ioread32(hcr_base + DE); 975 + iowrite32(dereg, hcr_base + DE); 976 + iowrite32(cereg, hcr_base + CE); 977 + 978 + qc = ata_qc_from_tag(ap, link->active_tag); 979 + /* 980 + * We should consider this as non fatal error, 981 + * and TF must be updated as done below. 982 + */ 983 + err_mask |= AC_ERR_DEV; 984 + } 1053 985 } 1054 986 1055 987 /* record error info */ 1056 - qc = ata_qc_from_tag(ap, link->active_tag); 1057 - 1058 - if (qc) 988 + if (qc) { 1059 989 qc->err_mask |= err_mask; 1060 - else 990 + } else 1061 991 ehi->err_mask |= err_mask; 1062 992 1063 993 ehi->action |= action; 1064 - ehi->serror |= SError; 1065 994 1066 995 /* freeze or abort */ 1067 996 if (freeze) 1068 997 ata_port_freeze(ap); 1069 - else 1070 - ata_port_abort(ap); 998 + else if (abort) { 999 + if (qc) 1000 + ata_link_abort(qc->dev->link); 1001 + else 1002 + ata_port_abort(ap); 1003 + } 1071 1004 } 1072 1005 1073 1006 static void sata_fsl_host_intr(struct ata_port *ap) 1074 1007 { 1075 - struct ata_link *link = &ap->link; 1076 1008 struct sata_fsl_host_priv *host_priv = ap->host->private_data; 1077 1009 void __iomem *hcr_base = host_priv->hcr_base; 1078 1010 u32 hstatus, qc_active = 0; ··· 1105 1017 return; 1106 1018 } 1107 1019 1108 - if (link->sactive) { /* only true for NCQ commands */ 1020 + /* Read command completed register */ 1021 + qc_active = ioread32(hcr_base + CC); 1022 + 1023 + VPRINTK("Status of all queues :\n"); 1024 + VPRINTK("qc_active/CC = 0x%x, CA = 0x%x, CE=0x%x,CQ=0x%x,apqa=0x%x\n", 1025 + qc_active, 1026 + ioread32(hcr_base + CA), 1027 + ioread32(hcr_base + CE), 1028 + ioread32(hcr_base + CQ), 1029 + ap->qc_active); 1030 + 1031 + if (qc_active & ap->qc_active) { 1109 1032 int i; 1110 - /* Read command completed register */ 1111 - qc_active = ioread32(hcr_base + CC); 1112 1033 /* clear CC bit, this will also complete the interrupt */ 1113 1034 iowrite32(qc_active, hcr_base + CC); 1114 1035 ··· 1129 1032 for (i = 0; i < SATA_FSL_QUEUE_DEPTH; i++) { 1130 1033 if (qc_active & (1 << i)) { 1131 1034 qc = ata_qc_from_tag(ap, i); 1132 - if (qc) 1035 + if (qc) { 1133 1036 ata_qc_complete(qc); 1037 + } 1134 1038 DPRINTK 1135 1039 ("completing ncq cmd,tag=%d,CC=0x%x,CA=0x%x\n", 1136 1040 i, ioread32(hcr_base + CC), ··· 1140 1042 } 1141 1043 return; 1142 1044 1143 - } else if (ap->qc_active) { 1045 + } else if ((ap->qc_active & (1 << ATA_TAG_INTERNAL))) { 1144 1046 iowrite32(1, hcr_base + CC); 1145 - qc = ata_qc_from_tag(ap, link->active_tag); 1047 + qc = ata_qc_from_tag(ap, ATA_TAG_INTERNAL); 1146 1048 1147 - DPRINTK("completing non-ncq cmd, tag=%d,CC=0x%x\n", 1148 - link->active_tag, ioread32(hcr_base + CC)); 1049 + DPRINTK("completing non-ncq cmd, CC=0x%x\n", 1050 + ioread32(hcr_base + CC)); 1149 1051 1150 - if (qc) 1052 + if (qc) { 1151 1053 ata_qc_complete(qc); 1054 + } 1152 1055 } else { 1153 1056 /* Spurious Interrupt!! */ 1154 1057 DPRINTK("spurious interrupt!!, CC = 0x%x\n", 1155 1058 ioread32(hcr_base + CC)); 1059 + iowrite32(qc_active, hcr_base + CC); 1156 1060 return; 1157 1061 } 1158 1062 } ··· 1230 1130 iowrite32(0x00000FFFF, hcr_base + CE); 1231 1131 iowrite32(0x00000FFFF, hcr_base + DE); 1232 1132 1233 - /* initially assuming no Port multiplier, set CQPMP to 0 */ 1234 - iowrite32(0x0, hcr_base + CQPMP); 1235 - 1236 1133 /* 1237 1134 * host controller will be brought on-line, during xx_port_start() 1238 1135 * callback, that should also initiate the OOB, COMINIT sequence ··· 1251 1154 .dma_boundary = ATA_DMA_BOUNDARY, 1252 1155 }; 1253 1156 1254 - static const struct ata_port_operations sata_fsl_ops = { 1255 - .inherits = &sata_port_ops, 1157 + static struct ata_port_operations sata_fsl_ops = { 1158 + .inherits = &sata_pmp_port_ops, 1256 1159 1257 1160 .qc_prep = sata_fsl_qc_prep, 1258 1161 .qc_issue = sata_fsl_qc_issue, ··· 1265 1168 .thaw = sata_fsl_thaw, 1266 1169 .prereset = sata_fsl_prereset, 1267 1170 .softreset = sata_fsl_softreset, 1171 + .pmp_softreset = sata_fsl_softreset, 1172 + .error_handler = sata_fsl_error_handler, 1268 1173 .post_internal_cmd = sata_fsl_post_internal_cmd, 1269 1174 1270 1175 .port_start = sata_fsl_port_start, 1271 1176 .port_stop = sata_fsl_port_stop, 1177 + 1178 + .pmp_attach = sata_fsl_pmp_attach, 1179 + .pmp_detach = sata_fsl_pmp_detach, 1272 1180 }; 1273 1181 1274 1182 static const struct ata_port_info sata_fsl_port_info[] = {
+38 -45
drivers/ata/sata_mv.c
··· 72 72 #include <linux/libata.h> 73 73 74 74 #define DRV_NAME "sata_mv" 75 - #define DRV_VERSION "1.21" 75 + #define DRV_VERSION "1.24" 76 76 77 77 enum { 78 78 /* BAR's are enumerated in terms of pci_resource_start() terms */ ··· 122 122 /* Host Flags */ 123 123 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ 124 124 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */ 125 - /* SoC integrated controllers, no PCI interface */ 126 - MV_FLAG_SOC = (1 << 28), 127 125 128 126 MV_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 129 127 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI | ··· 354 356 MV_HP_ERRATA_50XXB2 = (1 << 2), 355 357 MV_HP_ERRATA_60X1B2 = (1 << 3), 356 358 MV_HP_ERRATA_60X1C0 = (1 << 4), 357 - MV_HP_ERRATA_XX42A0 = (1 << 5), 358 359 MV_HP_GEN_I = (1 << 6), /* Generation I: 50xx */ 359 360 MV_HP_GEN_II = (1 << 7), /* Generation II: 60xx */ 360 361 MV_HP_GEN_IIE = (1 << 8), /* Generation IIE: 6042/7042 */ 361 362 MV_HP_PCIE = (1 << 9), /* PCIe bus/regs: 7042 */ 362 363 MV_HP_CUT_THROUGH = (1 << 10), /* can use EDMA cut-through */ 364 + MV_HP_FLAG_SOC = (1 << 11), /* SystemOnChip, no PCI */ 363 365 364 366 /* Port private flags (pp_flags) */ 365 367 MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */ ··· 372 374 #define IS_GEN_II(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_II) 373 375 #define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE) 374 376 #define IS_PCIE(hpriv) ((hpriv)->hp_flags & MV_HP_PCIE) 375 - #define HAS_PCI(host) (!((host)->ports[0]->flags & MV_FLAG_SOC)) 377 + #define IS_SOC(hpriv) ((hpriv)->hp_flags & MV_HP_FLAG_SOC) 376 378 377 379 #define WINDOW_CTRL(i) (0x20030 + ((i) << 4)) 378 380 #define WINDOW_BASE(i) (0x20034 + ((i) << 4)) ··· 650 652 .port_ops = &mv_iie_ops, 651 653 }, 652 654 { /* chip_soc */ 653 - .flags = MV_GENIIE_FLAGS | MV_FLAG_SOC, 655 + .flags = MV_GENIIE_FLAGS, 654 656 .pio_mask = 0x1f, /* pio0-4 */ 655 657 .udma_mask = ATA_UDMA6, 656 658 .port_ops = &mv_iie_ops, ··· 810 812 writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS); 811 813 writelfl((pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK) | index, 812 814 port_mmio + EDMA_REQ_Q_IN_PTR_OFS); 813 - 814 - if (hpriv->hp_flags & MV_HP_ERRATA_XX42A0) 815 - writelfl((pp->crqb_dma & 0xffffffff) | index, 816 - port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); 817 - else 818 - writelfl(index, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); 815 + writelfl(index, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); 819 816 820 817 /* 821 818 * initialize response queue ··· 820 827 821 828 WARN_ON(pp->crpb_dma & 0xff); 822 829 writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS); 823 - 824 - if (hpriv->hp_flags & MV_HP_ERRATA_XX42A0) 825 - writelfl((pp->crpb_dma & 0xffffffff) | index, 826 - port_mmio + EDMA_RSP_Q_IN_PTR_OFS); 827 - else 828 - writelfl(index, port_mmio + EDMA_RSP_Q_IN_PTR_OFS); 829 - 830 + writelfl(index, port_mmio + EDMA_RSP_Q_IN_PTR_OFS); 830 831 writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) | index, 831 832 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 832 833 } ··· 1241 1254 1242 1255 cfg |= (1 << 23); /* do not mask PM field in rx'd FIS */ 1243 1256 cfg |= (1 << 22); /* enab 4-entry host queue cache */ 1244 - if (HAS_PCI(ap->host)) 1257 + if (!IS_SOC(hpriv)) 1245 1258 cfg |= (1 << 18); /* enab early completion */ 1246 1259 if (hpriv->hp_flags & MV_HP_CUT_THROUGH) 1247 1260 cfg |= (1 << 17); /* enab cut-thru (dis stor&forwrd) */ ··· 2212 2225 * a bogus register value which can indicate HW removal or PCI fault. 2213 2226 */ 2214 2227 if (pending_irqs && main_irq_cause != 0xffffffffU) { 2215 - if (unlikely((pending_irqs & PCI_ERR) && HAS_PCI(host))) 2228 + if (unlikely((pending_irqs & PCI_ERR) && !IS_SOC(hpriv))) 2216 2229 handled = mv_pci_error(host, hpriv->base); 2217 2230 else 2218 2231 handled = mv_host_intr(host, pending_irqs); ··· 2534 2547 hp_flags & (MV_HP_ERRATA_60X1B2 | MV_HP_ERRATA_60X1C0); 2535 2548 int fix_phy_mode4 = 2536 2549 hp_flags & (MV_HP_ERRATA_60X1B2 | MV_HP_ERRATA_60X1C0); 2537 - u32 m2, tmp; 2550 + u32 m2, m3; 2538 2551 2539 2552 if (fix_phy_mode2) { 2540 2553 m2 = readl(port_mmio + PHY_MODE2); ··· 2551 2564 udelay(200); 2552 2565 } 2553 2566 2554 - /* who knows what this magic does */ 2555 - tmp = readl(port_mmio + PHY_MODE3); 2556 - tmp &= ~0x7F800000; 2557 - tmp |= 0x2A800000; 2558 - writel(tmp, port_mmio + PHY_MODE3); 2567 + /* 2568 + * Gen-II/IIe PHY_MODE3 errata RM#2: 2569 + * Achieves better receiver noise performance than the h/w default: 2570 + */ 2571 + m3 = readl(port_mmio + PHY_MODE3); 2572 + m3 = (m3 & 0x1f) | (0x5555601 << 5); 2573 + 2574 + /* Guideline 88F5182 (GL# SATA-S11) */ 2575 + if (IS_SOC(hpriv)) 2576 + m3 &= ~0x1c; 2559 2577 2560 2578 if (fix_phy_mode4) { 2561 2579 u32 m4; 2562 2580 2563 2581 m4 = readl(port_mmio + PHY_MODE4); 2564 2582 2565 - if (hp_flags & MV_HP_ERRATA_60X1B2) 2566 - tmp = readl(port_mmio + PHY_MODE3); 2567 - 2568 2583 /* workaround for errata FEr SATA#10 (part 1) */ 2569 2584 m4 = (m4 & ~(1 << 1)) | (1 << 0); 2570 2585 2571 - writel(m4, port_mmio + PHY_MODE4); 2586 + /* enforce bit restrictions on GenIIe devices */ 2587 + if (IS_GEN_IIE(hpriv)) 2588 + m4 = (m4 & ~0x5DE3FFFC) | (1 << 2); 2572 2589 2573 - if (hp_flags & MV_HP_ERRATA_60X1B2) 2574 - writel(tmp, port_mmio + PHY_MODE3); 2590 + writel(m4, port_mmio + PHY_MODE4); 2575 2591 } 2592 + /* 2593 + * Workaround for 60x1-B2 errata SATA#13: 2594 + * Any write to PHY_MODE4 (above) may corrupt PHY_MODE3, 2595 + * so we must always rewrite PHY_MODE3 after PHY_MODE4. 2596 + */ 2597 + writel(m3, port_mmio + PHY_MODE3); 2576 2598 2577 2599 /* Revert values of pre-emphasis and signal amps to the saved ones */ 2578 2600 m2 = readl(port_mmio + PHY_MODE2); ··· 2872 2876 void __iomem *mmio = hpriv->base; 2873 2877 u32 reg; 2874 2878 2875 - if (!HAS_PCI(host) || !IS_PCIE(hpriv)) 2879 + if (IS_SOC(hpriv) || !IS_PCIE(hpriv)) 2876 2880 return 0; /* not PCI-X capable */ 2877 2881 reg = readl(mmio + MV_PCI_MODE_OFS); 2878 2882 if ((reg & MV_PCI_MODE_MASK) == 0) ··· 2999 3003 hp_flags |= MV_HP_CUT_THROUGH; 3000 3004 3001 3005 switch (pdev->revision) { 3002 - case 0x0: 3003 - hp_flags |= MV_HP_ERRATA_XX42A0; 3004 - break; 3005 - case 0x1: 3006 + case 0x2: /* Rev.B0: the first/only public release */ 3006 3007 hp_flags |= MV_HP_ERRATA_60X1C0; 3007 3008 break; 3008 3009 default: ··· 3011 3018 break; 3012 3019 case chip_soc: 3013 3020 hpriv->ops = &mv_soc_ops; 3014 - hp_flags |= MV_HP_ERRATA_60X1C0; 3021 + hp_flags |= MV_HP_FLAG_SOC | MV_HP_ERRATA_60X1C0; 3015 3022 break; 3016 3023 3017 3024 default: ··· 3055 3062 if (rc) 3056 3063 goto done; 3057 3064 3058 - if (HAS_PCI(host)) { 3059 - hpriv->main_irq_cause_addr = mmio + PCI_HC_MAIN_IRQ_CAUSE_OFS; 3060 - hpriv->main_irq_mask_addr = mmio + PCI_HC_MAIN_IRQ_MASK_OFS; 3061 - } else { 3065 + if (IS_SOC(hpriv)) { 3062 3066 hpriv->main_irq_cause_addr = mmio + SOC_HC_MAIN_IRQ_CAUSE_OFS; 3063 3067 hpriv->main_irq_mask_addr = mmio + SOC_HC_MAIN_IRQ_MASK_OFS; 3068 + } else { 3069 + hpriv->main_irq_cause_addr = mmio + PCI_HC_MAIN_IRQ_CAUSE_OFS; 3070 + hpriv->main_irq_mask_addr = mmio + PCI_HC_MAIN_IRQ_MASK_OFS; 3064 3071 } 3065 3072 3066 3073 /* global interrupt mask: 0 == mask everything */ ··· 3086 3093 mv_port_init(&ap->ioaddr, port_mmio); 3087 3094 3088 3095 #ifdef CONFIG_PCI 3089 - if (HAS_PCI(host)) { 3096 + if (!IS_SOC(hpriv)) { 3090 3097 unsigned int offset = port_mmio - mmio; 3091 3098 ata_port_pbar_desc(ap, MV_PRIMARY_BAR, -1, "mmio"); 3092 3099 ata_port_pbar_desc(ap, MV_PRIMARY_BAR, offset, "port"); ··· 3106 3113 writelfl(0, hc_mmio + HC_IRQ_CAUSE_OFS); 3107 3114 } 3108 3115 3109 - if (HAS_PCI(host)) { 3116 + if (!IS_SOC(hpriv)) { 3110 3117 /* Clear any currently outstanding host interrupt conditions */ 3111 3118 writelfl(0, mmio + hpriv->irq_cause_ofs); 3112 3119