aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 17:39:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 17:39:40 -0400
commit75a442efb1ca613f8d1cc71a32c2c9b0aefae4a5 (patch)
tree6161c21803db3f03bcbd26715761e2d310246bb8 /drivers
parentb55b048718c8c833186c87ceeea86b78346cda2e (diff)
parent737bee9308c457090711684b976e0fe02785a094 (diff)
Merge branch 'for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata updates from Tejun Heo: "libata saw quite a bit of activities in this cycle: - SMR drive support still being worked on - bug fixes and improvements to misc SCSI command emulation - some low level driver updates" * 'for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (39 commits) libata-scsi: better style in ata_msense_*() AHCI: Clear GHC.IS to prevent unexpectly asserting INTx ata: sata_dwc_460ex: remove redundant dev_err call ata: define ATA_PROT_* in terms of ATA_PROT_FLAG_* libata: remove ATA_PROT_FLAG_DATA libata: remove ata_is_nodata ata: make lba_{28,48}_ok() use ATA_MAX_SECTORS{,_LBA48} libata-scsi: minor cleanup for ata_scsi_zbc_out_xlat libata-scsi: Fix ZBC management out command translation libata-scsi: Fix translation of REPORT ZONES command ata: Handle ATA NCQ NO-DATA commands correctly libata-eh: decode all taskfile protocols ata: fixup ATA_PROT_NODATA libsas: use ata_is_ncq() and ata_has_dma() accessors libata: use ata_is_ncq() accessors libata: return boolean values from ata_is_* libata-scsi: avoid repeated calculation of number of TRIM ranges libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit libata-scsi: rename ata_msense_ctl_mode() to ata_msense_control() libata-scsi: fix D_SENSE bit relection in control mode page ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/Kconfig8
-rw-r--r--drivers/ata/Makefile2
-rw-r--r--drivers/ata/ahci.c2
-rw-r--r--drivers/ata/ahci_brcm.c (renamed from drivers/ata/ahci_brcmstb.c)46
-rw-r--r--drivers/ata/libahci.c10
-rw-r--r--drivers/ata/libata-core.c14
-rw-r--r--drivers/ata/libata-eh.c8
-rw-r--r--drivers/ata/libata-scsi.c82
-rw-r--r--drivers/ata/libata-transport.c9
-rw-r--r--drivers/ata/pata_arasan_cf.c2
-rw-r--r--drivers/ata/pata_atiixp.c4
-rw-r--r--drivers/ata/pata_hpt366.c2
-rw-r--r--drivers/ata/pata_marvell.c2
-rw-r--r--drivers/ata/sata_dwc_460ex.c14
-rw-r--r--drivers/phy/phy-brcm-sata.c81
-rw-r--r--drivers/scsi/libsas/sas_ata.c11
16 files changed, 212 insertions, 85 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index e2dc4c045146..2c8be74f401d 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -98,12 +98,12 @@ config SATA_AHCI_PLATFORM
98 98
99 If unsure, say N. 99 If unsure, say N.
100 100
101config AHCI_BRCMSTB 101config AHCI_BRCM
102 tristate "Broadcom STB AHCI SATA support" 102 tristate "Broadcom AHCI SATA support"
103 depends on ARCH_BRCMSTB || BMIPS_GENERIC 103 depends on ARCH_BRCMSTB || BMIPS_GENERIC || ARCH_BCM_NSP
104 help 104 help
105 This option enables support for the AHCI SATA3 controller found on 105 This option enables support for the AHCI SATA3 controller found on
106 STB SoC's. 106 Broadcom SoC's.
107 107
108 If unsure, say N. 108 If unsure, say N.
109 109
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 0b2afb7e5f35..a46e6b784bda 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -11,7 +11,7 @@ obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o
11obj-$(CONFIG_SATA_SIL24) += sata_sil24.o 11obj-$(CONFIG_SATA_SIL24) += sata_sil24.o
12obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o 12obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o
13obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o 13obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o
14obj-$(CONFIG_AHCI_BRCMSTB) += ahci_brcmstb.o libahci.o libahci_platform.o 14obj-$(CONFIG_AHCI_BRCM) += ahci_brcm.o libahci.o libahci_platform.o
15obj-$(CONFIG_AHCI_CEVA) += ahci_ceva.o libahci.o libahci_platform.o 15obj-$(CONFIG_AHCI_CEVA) += ahci_ceva.o libahci.o libahci_platform.o
16obj-$(CONFIG_AHCI_DA850) += ahci_da850.o libahci.o libahci_platform.o 16obj-$(CONFIG_AHCI_DA850) += ahci_da850.o libahci.o libahci_platform.o
17obj-$(CONFIG_AHCI_IMX) += ahci_imx.o libahci.o libahci_platform.o 17obj-$(CONFIG_AHCI_IMX) += ahci_imx.o libahci.o libahci_platform.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index a83bbcc58b4c..90eabaf81215 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -580,7 +580,7 @@ static struct pci_driver ahci_pci_driver = {
580 }, 580 },
581}; 581};
582 582
583#if defined(CONFIG_PATA_MARVELL) || defined(CONFIG_PATA_MARVELL_MODULE) 583#if IS_ENABLED(CONFIG_PATA_MARVELL)
584static int marvell_enable; 584static int marvell_enable;
585#else 585#else
586static int marvell_enable = 1; 586static int marvell_enable = 1;
diff --git a/drivers/ata/ahci_brcmstb.c b/drivers/ata/ahci_brcm.c
index e87bcec0fd7c..6f8a7341fa08 100644
--- a/drivers/ata/ahci_brcmstb.c
+++ b/drivers/ata/ahci_brcm.c
@@ -71,6 +71,12 @@
71 (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \ 71 (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \
72 (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT)) 72 (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT))
73 73
74enum brcm_ahci_version {
75 BRCM_SATA_BCM7425 = 1,
76 BRCM_SATA_BCM7445,
77 BRCM_SATA_NSP,
78};
79
74enum brcm_ahci_quirks { 80enum brcm_ahci_quirks {
75 BRCM_AHCI_QUIRK_NO_NCQ = BIT(0), 81 BRCM_AHCI_QUIRK_NO_NCQ = BIT(0),
76 BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1), 82 BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1),
@@ -81,6 +87,7 @@ struct brcm_ahci_priv {
81 void __iomem *top_ctrl; 87 void __iomem *top_ctrl;
82 u32 port_mask; 88 u32 port_mask;
83 u32 quirks; 89 u32 quirks;
90 enum brcm_ahci_version version;
84}; 91};
85 92
86static const struct ata_port_info ahci_brcm_port_info = { 93static const struct ata_port_info ahci_brcm_port_info = {
@@ -247,9 +254,19 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev,
247 254
248static void brcm_sata_init(struct brcm_ahci_priv *priv) 255static void brcm_sata_init(struct brcm_ahci_priv *priv)
249{ 256{
257 void __iomem *ctrl = priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL;
258
250 /* Configure endianness */ 259 /* Configure endianness */
251 brcm_sata_writereg(BUS_CTRL_ENDIAN_CONF, 260 if (priv->version == BRCM_SATA_NSP) {
252 priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL); 261 u32 data = brcm_sata_readreg(ctrl);
262
263 data &= ~((0x03 << DMADATA_ENDIAN_SHIFT) |
264 (0x03 << DMADESC_ENDIAN_SHIFT));
265 data |= (0x02 << DMADATA_ENDIAN_SHIFT) |
266 (0x02 << DMADESC_ENDIAN_SHIFT);
267 brcm_sata_writereg(data, ctrl);
268 } else
269 brcm_sata_writereg(BUS_CTRL_ENDIAN_CONF, ctrl);
253} 270}
254 271
255#ifdef CONFIG_PM_SLEEP 272#ifdef CONFIG_PM_SLEEP
@@ -282,8 +299,17 @@ static struct scsi_host_template ahci_platform_sht = {
282 AHCI_SHT(DRV_NAME), 299 AHCI_SHT(DRV_NAME),
283}; 300};
284 301
302static const struct of_device_id ahci_of_match[] = {
303 {.compatible = "brcm,bcm7425-ahci", .data = (void *)BRCM_SATA_BCM7425},
304 {.compatible = "brcm,bcm7445-ahci", .data = (void *)BRCM_SATA_BCM7445},
305 {.compatible = "brcm,bcm-nsp-ahci", .data = (void *)BRCM_SATA_NSP},
306 {},
307};
308MODULE_DEVICE_TABLE(of, ahci_of_match);
309
285static int brcm_ahci_probe(struct platform_device *pdev) 310static int brcm_ahci_probe(struct platform_device *pdev)
286{ 311{
312 const struct of_device_id *of_id;
287 struct device *dev = &pdev->dev; 313 struct device *dev = &pdev->dev;
288 struct brcm_ahci_priv *priv; 314 struct brcm_ahci_priv *priv;
289 struct ahci_host_priv *hpriv; 315 struct ahci_host_priv *hpriv;
@@ -293,6 +319,12 @@ static int brcm_ahci_probe(struct platform_device *pdev)
293 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 319 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
294 if (!priv) 320 if (!priv)
295 return -ENOMEM; 321 return -ENOMEM;
322
323 of_id = of_match_node(ahci_of_match, pdev->dev.of_node);
324 if (!of_id)
325 return -ENODEV;
326
327 priv->version = (enum brcm_ahci_version)of_id->data;
296 priv->dev = dev; 328 priv->dev = dev;
297 329
298 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "top-ctrl"); 330 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "top-ctrl");
@@ -300,7 +332,8 @@ static int brcm_ahci_probe(struct platform_device *pdev)
300 if (IS_ERR(priv->top_ctrl)) 332 if (IS_ERR(priv->top_ctrl))
301 return PTR_ERR(priv->top_ctrl); 333 return PTR_ERR(priv->top_ctrl);
302 334
303 if (of_device_is_compatible(dev->of_node, "brcm,bcm7425-ahci")) { 335 if ((priv->version == BRCM_SATA_BCM7425) ||
336 (priv->version == BRCM_SATA_NSP)) {
304 priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ; 337 priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ;
305 priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE; 338 priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE;
306 } 339 }
@@ -354,13 +387,6 @@ static int brcm_ahci_remove(struct platform_device *pdev)
354 return 0; 387 return 0;
355} 388}
356 389
357static const struct of_device_id ahci_of_match[] = {
358 {.compatible = "brcm,bcm7425-ahci"},
359 {.compatible = "brcm,bcm7445-ahci"},
360 {},
361};
362MODULE_DEVICE_TABLE(of, ahci_of_match);
363
364static SIMPLE_DEV_PM_OPS(ahci_brcm_pm_ops, brcm_ahci_suspend, brcm_ahci_resume); 390static SIMPLE_DEV_PM_OPS(ahci_brcm_pm_ops, brcm_ahci_suspend, brcm_ahci_resume);
365 391
366static struct platform_driver brcm_ahci_driver = { 392static struct platform_driver brcm_ahci_driver = {
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 71b07198e207..7461a587b39b 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1975,7 +1975,7 @@ unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
1975 */ 1975 */
1976 pp->active_link = qc->dev->link; 1976 pp->active_link = qc->dev->link;
1977 1977
1978 if (qc->tf.protocol == ATA_PROT_NCQ) 1978 if (ata_is_ncq(qc->tf.protocol))
1979 writel(1 << qc->tag, port_mmio + PORT_SCR_ACT); 1979 writel(1 << qc->tag, port_mmio + PORT_SCR_ACT);
1980 1980
1981 if (pp->fbs_enabled && pp->fbs_last_dev != qc->dev->link->pmp) { 1981 if (pp->fbs_enabled && pp->fbs_last_dev != qc->dev->link->pmp) {
@@ -2392,12 +2392,20 @@ static int ahci_port_start(struct ata_port *ap)
2392static void ahci_port_stop(struct ata_port *ap) 2392static void ahci_port_stop(struct ata_port *ap)
2393{ 2393{
2394 const char *emsg = NULL; 2394 const char *emsg = NULL;
2395 struct ahci_host_priv *hpriv = ap->host->private_data;
2396 void __iomem *host_mmio = hpriv->mmio;
2395 int rc; 2397 int rc;
2396 2398
2397 /* de-initialize port */ 2399 /* de-initialize port */
2398 rc = ahci_deinit_port(ap, &emsg); 2400 rc = ahci_deinit_port(ap, &emsg);
2399 if (rc) 2401 if (rc)
2400 ata_port_warn(ap, "%s (%d)\n", emsg, rc); 2402 ata_port_warn(ap, "%s (%d)\n", emsg, rc);
2403
2404 /*
2405 * Clear GHC.IS to prevent stuck INTx after disabling MSI and
2406 * re-enabling INTx.
2407 */
2408 writel(1 << ap->port_no, host_mmio + HOST_IRQ_STAT);
2401} 2409}
2402 2410
2403void ahci_print_info(struct ata_host *host, const char *scc_s) 2411void ahci_print_info(struct ata_host *host, const char *scc_s)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 31c183aed368..67339b4f92f1 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1238,7 +1238,7 @@ static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors)
1238 } else 1238 } else
1239 tf.command = ATA_CMD_READ_NATIVE_MAX; 1239 tf.command = ATA_CMD_READ_NATIVE_MAX;
1240 1240
1241 tf.protocol |= ATA_PROT_NODATA; 1241 tf.protocol = ATA_PROT_NODATA;
1242 tf.device |= ATA_LBA; 1242 tf.device |= ATA_LBA;
1243 1243
1244 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 1244 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
@@ -1297,7 +1297,7 @@ static int ata_set_max_sectors(struct ata_device *dev, u64 new_sectors)
1297 tf.device |= (new_sectors >> 24) & 0xf; 1297 tf.device |= (new_sectors >> 24) & 0xf;
1298 } 1298 }
1299 1299
1300 tf.protocol |= ATA_PROT_NODATA; 1300 tf.protocol = ATA_PROT_NODATA;
1301 tf.device |= ATA_LBA; 1301 tf.device |= ATA_LBA;
1302 1302
1303 tf.lbal = (new_sectors >> 0) & 0xff; 1303 tf.lbal = (new_sectors >> 0) & 0xff;
@@ -4848,7 +4848,7 @@ int ata_std_qc_defer(struct ata_queued_cmd *qc)
4848{ 4848{
4849 struct ata_link *link = qc->dev->link; 4849 struct ata_link *link = qc->dev->link;
4850 4850
4851 if (qc->tf.protocol == ATA_PROT_NCQ) { 4851 if (ata_is_ncq(qc->tf.protocol)) {
4852 if (!ata_tag_valid(link->active_tag)) 4852 if (!ata_tag_valid(link->active_tag))
4853 return 0; 4853 return 0;
4854 } else { 4854 } else {
@@ -5013,7 +5013,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
5013 ata_sg_clean(qc); 5013 ata_sg_clean(qc);
5014 5014
5015 /* command should be marked inactive atomically with qc completion */ 5015 /* command should be marked inactive atomically with qc completion */
5016 if (qc->tf.protocol == ATA_PROT_NCQ) { 5016 if (ata_is_ncq(qc->tf.protocol)) {
5017 link->sactive &= ~(1 << qc->tag); 5017 link->sactive &= ~(1 << qc->tag);
5018 if (!link->sactive) 5018 if (!link->sactive)
5019 ap->nr_active_links--; 5019 ap->nr_active_links--;
@@ -5050,7 +5050,7 @@ static void ata_verify_xfer(struct ata_queued_cmd *qc)
5050{ 5050{
5051 struct ata_device *dev = qc->dev; 5051 struct ata_device *dev = qc->dev;
5052 5052
5053 if (ata_is_nodata(qc->tf.protocol)) 5053 if (!ata_is_data(qc->tf.protocol))
5054 return; 5054 return;
5055 5055
5056 if ((dev->mwdma_mask || dev->udma_mask) && ata_is_pio(qc->tf.protocol)) 5056 if ((dev->mwdma_mask || dev->udma_mask) && ata_is_pio(qc->tf.protocol))
@@ -5133,7 +5133,9 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
5133 switch (qc->tf.command) { 5133 switch (qc->tf.command) {
5134 case ATA_CMD_SET_FEATURES: 5134 case ATA_CMD_SET_FEATURES:
5135 if (qc->tf.feature != SETFEATURES_WC_ON && 5135 if (qc->tf.feature != SETFEATURES_WC_ON &&
5136 qc->tf.feature != SETFEATURES_WC_OFF) 5136 qc->tf.feature != SETFEATURES_WC_OFF &&
5137 qc->tf.feature != SETFEATURES_RA_ON &&
5138 qc->tf.feature != SETFEATURES_RA_OFF)
5137 break; 5139 break;
5138 /* fall through */ 5140 /* fall through */
5139 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ 5141 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index c6f017458958..0e1ec37070d1 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2607,9 +2607,13 @@ static void ata_eh_link_report(struct ata_link *link)
2607 [DMA_FROM_DEVICE] = "in", 2607 [DMA_FROM_DEVICE] = "in",
2608 }; 2608 };
2609 static const char *prot_str[] = { 2609 static const char *prot_str[] = {
2610 [ATA_PROT_UNKNOWN] = "unknown",
2611 [ATA_PROT_NODATA] = "nodata",
2610 [ATA_PROT_PIO] = "pio", 2612 [ATA_PROT_PIO] = "pio",
2611 [ATA_PROT_DMA] = "dma", 2613 [ATA_PROT_DMA] = "dma",
2612 [ATA_PROT_NCQ] = "ncq", 2614 [ATA_PROT_NCQ] = "ncq dma",
2615 [ATA_PROT_NCQ_NODATA] = "ncq nodata",
2616 [ATAPI_PROT_NODATA] = "nodata",
2613 [ATAPI_PROT_PIO] = "pio", 2617 [ATAPI_PROT_PIO] = "pio",
2614 [ATAPI_PROT_DMA] = "dma", 2618 [ATAPI_PROT_DMA] = "dma",
2615 }; 2619 };
@@ -3177,7 +3181,7 @@ static void ata_eh_park_issue_cmd(struct ata_device *dev, int park)
3177 } 3181 }
3178 3182
3179 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; 3183 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
3180 tf.protocol |= ATA_PROT_NODATA; 3184 tf.protocol = ATA_PROT_NODATA;
3181 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 3185 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
3182 if (park && (err_mask || tf.lbal != 0xc4)) { 3186 if (park && (err_mask || tf.lbal != 0xc4)) {
3183 ata_dev_err(dev, "head unload failed!\n"); 3187 ata_dev_err(dev, "head unload failed!\n");
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66fb26e2..2bdb5dab922b 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -304,7 +304,7 @@ static void ata_scsi_set_invalid_field(struct ata_device *dev,
304 struct scsi_cmnd *cmd, u16 field, u8 bit) 304 struct scsi_cmnd *cmd, u16 field, u8 bit)
305{ 305{
306 ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x24, 0x0); 306 ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x24, 0x0);
307 /* "Invalid field in cbd" */ 307 /* "Invalid field in CDB" */
308 scsi_set_sense_field_pointer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, 308 scsi_set_sense_field_pointer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
309 field, bit, 1); 309 field, bit, 1);
310} 310}
@@ -2075,8 +2075,8 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
2075 0x03, 2075 0x03,
2076 0x20, /* SBC-2 (no version claimed) */ 2076 0x20, /* SBC-2 (no version claimed) */
2077 2077
2078 0x02, 2078 0x03,
2079 0x60 /* SPC-3 (no version claimed) */ 2079 0x00 /* SPC-3 (no version claimed) */
2080 }; 2080 };
2081 const u8 versions_zbc[] = { 2081 const u8 versions_zbc[] = {
2082 0x00, 2082 0x00,
@@ -2097,7 +2097,10 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
2097 0, 2097 0,
2098 0x5, /* claim SPC-3 version compatibility */ 2098 0x5, /* claim SPC-3 version compatibility */
2099 2, 2099 2,
2100 95 - 4 2100 95 - 4,
2101 0,
2102 0,
2103 2
2101 }; 2104 };
2102 2105
2103 VPRINTK("ENTER\n"); 2106 VPRINTK("ENTER\n");
@@ -2109,8 +2112,10 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
2109 (args->dev->link->ap->pflags & ATA_PFLAG_EXTERNAL)) 2112 (args->dev->link->ap->pflags & ATA_PFLAG_EXTERNAL))
2110 hdr[1] |= (1 << 7); 2113 hdr[1] |= (1 << 7);
2111 2114
2112 if (args->dev->class == ATA_DEV_ZAC) 2115 if (args->dev->class == ATA_DEV_ZAC) {
2113 hdr[0] = TYPE_ZBC; 2116 hdr[0] = TYPE_ZBC;
2117 hdr[2] = 0x7; /* claim SPC-5 version compatibility */
2118 }
2114 2119
2115 memcpy(rbuf, hdr, sizeof(hdr)); 2120 memcpy(rbuf, hdr, sizeof(hdr));
2116 memcpy(&rbuf[8], "ATA ", 8); 2121 memcpy(&rbuf[8], "ATA ", 8);
@@ -2314,7 +2319,7 @@ static unsigned int ata_scsiop_inq_b0(struct ata_scsi_args *args, u8 *rbuf)
2314 * with the unmap bit set. 2319 * with the unmap bit set.
2315 */ 2320 */
2316 if (ata_id_has_trim(args->id)) { 2321 if (ata_id_has_trim(args->id)) {
2317 put_unaligned_be64(65535 * 512 / 8, &rbuf[36]); 2322 put_unaligned_be64(65535 * ATA_MAX_TRIM_RNUM, &rbuf[36]);
2318 put_unaligned_be32(1, &rbuf[28]); 2323 put_unaligned_be32(1, &rbuf[28]);
2319 } 2324 }
2320 2325
@@ -2424,15 +2429,17 @@ static void modecpy(u8 *dest, const u8 *src, int n, bool changeable)
2424static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable) 2429static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
2425{ 2430{
2426 modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable); 2431 modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
2427 if (changeable || ata_id_wcache_enabled(id)) 2432 if (changeable) {
2428 buf[2] |= (1 << 2); /* write cache enable */ 2433 buf[2] |= (1 << 2); /* ata_mselect_caching() */
2429 if (!changeable && !ata_id_rahead_enabled(id)) 2434 } else {
2430 buf[12] |= (1 << 5); /* disable read ahead */ 2435 buf[2] |= (ata_id_wcache_enabled(id) << 2); /* write cache enable */
2436 buf[12] |= (!ata_id_rahead_enabled(id) << 5); /* disable read ahead */
2437 }
2431 return sizeof(def_cache_mpage); 2438 return sizeof(def_cache_mpage);
2432} 2439}
2433 2440
2434/** 2441/**
2435 * ata_msense_ctl_mode - Simulate MODE SENSE control mode page 2442 * ata_msense_control - Simulate MODE SENSE control mode page
2436 * @dev: ATA device of interest 2443 * @dev: ATA device of interest
2437 * @buf: output buffer 2444 * @buf: output buffer
2438 * @changeable: whether changeable parameters are requested 2445 * @changeable: whether changeable parameters are requested
@@ -2442,12 +2449,17 @@ static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
2442 * LOCKING: 2449 * LOCKING:
2443 * None. 2450 * None.
2444 */ 2451 */
2445static unsigned int ata_msense_ctl_mode(struct ata_device *dev, u8 *buf, 2452static unsigned int ata_msense_control(struct ata_device *dev, u8 *buf,
2446 bool changeable) 2453 bool changeable)
2447{ 2454{
2448 modecpy(buf, def_control_mpage, sizeof(def_control_mpage), changeable); 2455 modecpy(buf, def_control_mpage, sizeof(def_control_mpage), changeable);
2449 if (changeable && (dev->flags & ATA_DFLAG_D_SENSE)) 2456 if (changeable) {
2450 buf[2] |= (1 << 2); /* Descriptor sense requested */ 2457 buf[2] |= (1 << 2); /* ata_mselect_control() */
2458 } else {
2459 bool d_sense = (dev->flags & ATA_DFLAG_D_SENSE);
2460
2461 buf[2] |= (d_sense << 2); /* descriptor format sense data */
2462 }
2451 return sizeof(def_control_mpage); 2463 return sizeof(def_control_mpage);
2452} 2464}
2453 2465
@@ -2566,13 +2578,13 @@ static unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf)
2566 break; 2578 break;
2567 2579
2568 case CONTROL_MPAGE: 2580 case CONTROL_MPAGE:
2569 p += ata_msense_ctl_mode(args->dev, p, page_control == 1); 2581 p += ata_msense_control(args->dev, p, page_control == 1);
2570 break; 2582 break;
2571 2583
2572 case ALL_MPAGES: 2584 case ALL_MPAGES:
2573 p += ata_msense_rw_recovery(p, page_control == 1); 2585 p += ata_msense_rw_recovery(p, page_control == 1);
2574 p += ata_msense_caching(args->id, p, page_control == 1); 2586 p += ata_msense_caching(args->id, p, page_control == 1);
2575 p += ata_msense_ctl_mode(args->dev, p, page_control == 1); 2587 p += ata_msense_control(args->dev, p, page_control == 1);
2576 break; 2588 break;
2577 2589
2578 default: /* invalid page code */ 2590 default: /* invalid page code */
@@ -3077,6 +3089,9 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
3077 goto invalid_fld; 3089 goto invalid_fld;
3078 } 3090 }
3079 3091
3092 if (ata_is_ncq(tf->protocol) && (cdb[2] & 0x3) == 0)
3093 tf->protocol = ATA_PROT_NCQ_NODATA;
3094
3080 /* enable LBA */ 3095 /* enable LBA */
3081 tf->flags |= ATA_TFLAG_LBA; 3096 tf->flags |= ATA_TFLAG_LBA;
3082 3097
@@ -3125,8 +3140,8 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
3125 tf->command = cdb[9]; 3140 tf->command = cdb[9];
3126 } 3141 }
3127 3142
3128 /* For NCQ commands with FPDMA protocol, copy the tag value */ 3143 /* For NCQ commands copy the tag value */
3129 if (tf->protocol == ATA_PROT_NCQ) 3144 if (ata_is_ncq(tf->protocol))
3130 tf->nsect = qc->tag << 3; 3145 tf->nsect = qc->tag << 3;
3131 3146
3132 /* enforce correct master/slave bit */ 3147 /* enforce correct master/slave bit */
@@ -3305,7 +3320,13 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
3305 goto invalid_param_len; 3320 goto invalid_param_len;
3306 3321
3307 buf = page_address(sg_page(scsi_sglist(scmd))); 3322 buf = page_address(sg_page(scsi_sglist(scmd)));
3308 size = ata_set_lba_range_entries(buf, 512, block, n_block); 3323
3324 if (n_block <= 65535 * ATA_MAX_TRIM_RNUM) {
3325 size = ata_set_lba_range_entries(buf, ATA_MAX_TRIM_RNUM, block, n_block);
3326 } else {
3327 fp = 2;
3328 goto invalid_fld;
3329 }
3309 3330
3310 if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) { 3331 if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
3311 /* Newer devices support queued TRIM commands */ 3332 /* Newer devices support queued TRIM commands */
@@ -3454,7 +3475,7 @@ static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc)
3454 goto invalid_param_len; 3475 goto invalid_param_len;
3455 } 3476 }
3456 sect = n_block / 512; 3477 sect = n_block / 512;
3457 options = cdb[14]; 3478 options = cdb[14] & 0xbf;
3458 3479
3459 if (ata_ncq_enabled(qc->dev) && 3480 if (ata_ncq_enabled(qc->dev) &&
3460 ata_fpdma_zac_mgmt_in_supported(qc->dev)) { 3481 ata_fpdma_zac_mgmt_in_supported(qc->dev)) {
@@ -3464,7 +3485,7 @@ static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc)
3464 tf->nsect = qc->tag << 3; 3485 tf->nsect = qc->tag << 3;
3465 tf->feature = sect & 0xff; 3486 tf->feature = sect & 0xff;
3466 tf->hob_feature = (sect >> 8) & 0xff; 3487 tf->hob_feature = (sect >> 8) & 0xff;
3467 tf->auxiliary = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES; 3488 tf->auxiliary = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES | (options << 8);
3468 } else { 3489 } else {
3469 tf->command = ATA_CMD_ZAC_MGMT_IN; 3490 tf->command = ATA_CMD_ZAC_MGMT_IN;
3470 tf->feature = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES; 3491 tf->feature = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES;
@@ -3506,7 +3527,7 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
3506 struct scsi_cmnd *scmd = qc->scsicmd; 3527 struct scsi_cmnd *scmd = qc->scsicmd;
3507 struct ata_device *dev = qc->dev; 3528 struct ata_device *dev = qc->dev;
3508 const u8 *cdb = scmd->cmnd; 3529 const u8 *cdb = scmd->cmnd;
3509 u8 reset_all, sa; 3530 u8 all, sa;
3510 u64 block; 3531 u64 block;
3511 u32 n_block; 3532 u32 n_block;
3512 u16 fp = (u16)-1; 3533 u16 fp = (u16)-1;
@@ -3533,20 +3554,20 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
3533 if (block > dev->n_sectors) 3554 if (block > dev->n_sectors)
3534 goto out_of_range; 3555 goto out_of_range;
3535 3556
3536 reset_all = cdb[14] & 0x1; 3557 all = cdb[14] & 0x1;
3537 3558
3538 if (ata_ncq_enabled(qc->dev) && 3559 if (ata_ncq_enabled(qc->dev) &&
3539 ata_fpdma_zac_mgmt_out_supported(qc->dev)) { 3560 ata_fpdma_zac_mgmt_out_supported(qc->dev)) {
3540 tf->protocol = ATA_PROT_NCQ; 3561 tf->protocol = ATA_PROT_NCQ_NODATA;
3541 tf->command = ATA_CMD_NCQ_NON_DATA; 3562 tf->command = ATA_CMD_NCQ_NON_DATA;
3542 tf->hob_nsect = ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT; 3563 tf->feature = ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT;
3543 tf->nsect = qc->tag << 3; 3564 tf->nsect = qc->tag << 3;
3544 tf->auxiliary = sa | (reset_all & 0x1) << 8; 3565 tf->auxiliary = sa | ((u16)all << 8);
3545 } else { 3566 } else {
3546 tf->protocol = ATA_PROT_NODATA; 3567 tf->protocol = ATA_PROT_NODATA;
3547 tf->command = ATA_CMD_ZAC_MGMT_OUT; 3568 tf->command = ATA_CMD_ZAC_MGMT_OUT;
3548 tf->feature = sa; 3569 tf->feature = sa;
3549 tf->hob_feature = reset_all & 0x1; 3570 tf->hob_feature = all;
3550 } 3571 }
3551 tf->lbah = (block >> 16) & 0xff; 3572 tf->lbah = (block >> 16) & 0xff;
3552 tf->lbam = (block >> 8) & 0xff; 3573 tf->lbam = (block >> 8) & 0xff;
@@ -3667,7 +3688,7 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
3667 /* 3688 /*
3668 * Check that read-only bits are not modified. 3689 * Check that read-only bits are not modified.
3669 */ 3690 */
3670 ata_msense_ctl_mode(dev, mpage, false); 3691 ata_msense_control(dev, mpage, false);
3671 for (i = 0; i < CONTROL_MPAGE_LEN - 2; i++) { 3692 for (i = 0; i < CONTROL_MPAGE_LEN - 2; i++) {
3672 if (i == 0) 3693 if (i == 0)
3673 continue; 3694 continue;
@@ -4039,11 +4060,6 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
4039 args.done = cmd->scsi_done; 4060 args.done = cmd->scsi_done;
4040 4061
4041 switch(scsicmd[0]) { 4062 switch(scsicmd[0]) {
4042 /* TODO: worth improving? */
4043 case FORMAT_UNIT:
4044 ata_scsi_invalid_field(dev, cmd, 0);
4045 break;
4046
4047 case INQUIRY: 4063 case INQUIRY:
4048 if (scsicmd[1] & 2) /* is CmdDt set? */ 4064 if (scsicmd[1] & 2) /* is CmdDt set? */
4049 ata_scsi_invalid_field(dev, cmd, 1); 4065 ata_scsi_invalid_field(dev, cmd, 1);
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index e2d94972962d..7ef16c085058 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -495,12 +495,13 @@ struct ata_show_ering_arg {
495static int ata_show_ering(struct ata_ering_entry *ent, void *void_arg) 495static int ata_show_ering(struct ata_ering_entry *ent, void *void_arg)
496{ 496{
497 struct ata_show_ering_arg* arg = void_arg; 497 struct ata_show_ering_arg* arg = void_arg;
498 struct timespec time; 498 u64 seconds;
499 u32 rem;
499 500
500 jiffies_to_timespec(ent->timestamp,&time); 501 seconds = div_u64_rem(ent->timestamp, HZ, &rem);
501 arg->written += sprintf(arg->buf + arg->written, 502 arg->written += sprintf(arg->buf + arg->written,
502 "[%5lu.%06lu]", 503 "[%5llu.%09lu]", seconds,
503 time.tv_sec, time.tv_nsec); 504 rem * NSEC_PER_SEC / HZ);
504 arg->written += get_ata_err_names(ent->err_mask, 505 arg->written += get_ata_err_names(ent->err_mask,
505 arg->buf + arg->written); 506 arg->buf + arg->written);
506 return 0; 507 return 0;
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index 80fe0f6fed29..b4d54771c9fe 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -565,7 +565,7 @@ chan_request_fail:
565 qc->ap->hsm_task_state = HSM_ST_ERR; 565 qc->ap->hsm_task_state = HSM_ST_ERR;
566 566
567 cf_ctrl_reset(acdev); 567 cf_ctrl_reset(acdev);
568 spin_unlock_irqrestore(qc->ap->lock, flags); 568 spin_unlock_irqrestore(&acdev->host->lock, flags);
569sff_intr: 569sff_intr:
570 dma_complete(acdev); 570 dma_complete(acdev);
571} 571}
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 970f7767e5fd..49d705c9f0f7 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -183,8 +183,8 @@ static void atiixp_set_dmamode(struct ata_port *ap, struct ata_device *adev)
183 * We must now look at the PIO mode situation. We may need to 183 * We must now look at the PIO mode situation. We may need to
184 * adjust the PIO mode to keep the timings acceptable 184 * adjust the PIO mode to keep the timings acceptable
185 */ 185 */
186 if (adev->dma_mode >= XFER_MW_DMA_2) 186 if (adev->dma_mode >= XFER_MW_DMA_2)
187 wanted_pio = 4; 187 wanted_pio = 4;
188 else if (adev->dma_mode == XFER_MW_DMA_1) 188 else if (adev->dma_mode == XFER_MW_DMA_1)
189 wanted_pio = 3; 189 wanted_pio = 3;
190 else if (adev->dma_mode == XFER_MW_DMA_0) 190 else if (adev->dma_mode == XFER_MW_DMA_0)
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index e5fb7525a5df..a219a503c229 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -368,7 +368,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
368 368
369 /* PCI clocking determines the ATA timing values to use */ 369 /* PCI clocking determines the ATA timing values to use */
370 /* info_hpt366 is safe against re-entry so we can scribble on it */ 370 /* info_hpt366 is safe against re-entry so we can scribble on it */
371 switch ((reg1 & 0x700) >> 8) { 371 switch ((reg1 & 0xf00) >> 8) {
372 case 9: 372 case 9:
373 hpriv = &hpt366_40; 373 hpriv = &hpt366_40;
374 break; 374 break;
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index ae9feb1ba8f7..ff468a6fd8dd 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -146,7 +146,7 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
146 if (pdev->device == 0x6101) 146 if (pdev->device == 0x6101)
147 ppi[1] = &ata_dummy_port_info; 147 ppi[1] = &ata_dummy_port_info;
148 148
149#if defined(CONFIG_SATA_AHCI) || defined(CONFIG_SATA_AHCI_MODULE) 149#if IS_ENABLED(CONFIG_SATA_AHCI)
150 if (!marvell_pata_active(pdev)) { 150 if (!marvell_pata_active(pdev)) {
151 printk(KERN_INFO DRV_NAME ": PATA port not active, deferring to AHCI driver.\n"); 151 printk(KERN_INFO DRV_NAME ": PATA port not active, deferring to AHCI driver.\n");
152 return -ENODEV; 152 return -ENODEV;
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 00c2af1d211b..e0939bd5ea73 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -259,11 +259,8 @@ static int sata_dwc_dma_init_old(struct platform_device *pdev,
259 /* Get physical SATA DMA register base address */ 259 /* Get physical SATA DMA register base address */
260 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 260 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
261 hsdev->dma->regs = devm_ioremap_resource(&pdev->dev, res); 261 hsdev->dma->regs = devm_ioremap_resource(&pdev->dev, res);
262 if (IS_ERR(hsdev->dma->regs)) { 262 if (IS_ERR(hsdev->dma->regs))
263 dev_err(&pdev->dev,
264 "ioremap failed for AHBDMA register address\n");
265 return PTR_ERR(hsdev->dma->regs); 263 return PTR_ERR(hsdev->dma->regs);
266 }
267 264
268 /* Initialize AHB DMAC */ 265 /* Initialize AHB DMAC */
269 return dw_dma_probe(hsdev->dma); 266 return dw_dma_probe(hsdev->dma);
@@ -281,7 +278,7 @@ static void sata_dwc_dma_exit_old(struct sata_dwc_device *hsdev)
281 278
282static const char *get_prot_descript(u8 protocol) 279static const char *get_prot_descript(u8 protocol)
283{ 280{
284 switch ((enum ata_tf_protocols)protocol) { 281 switch (protocol) {
285 case ATA_PROT_NODATA: 282 case ATA_PROT_NODATA:
286 return "ATA no data"; 283 return "ATA no data";
287 case ATA_PROT_PIO: 284 case ATA_PROT_PIO:
@@ -290,6 +287,8 @@ static const char *get_prot_descript(u8 protocol)
290 return "ATA DMA"; 287 return "ATA DMA";
291 case ATA_PROT_NCQ: 288 case ATA_PROT_NCQ:
292 return "ATA NCQ"; 289 return "ATA NCQ";
290 case ATA_PROT_NCQ_NODATA:
291 return "ATA NCQ no data";
293 case ATAPI_PROT_NODATA: 292 case ATAPI_PROT_NODATA:
294 return "ATAPI no data"; 293 return "ATAPI no data";
295 case ATAPI_PROT_PIO: 294 case ATAPI_PROT_PIO:
@@ -1225,11 +1224,8 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1225 /* Ioremap SATA registers */ 1224 /* Ioremap SATA registers */
1226 res = platform_get_resource(ofdev, IORESOURCE_MEM, 0); 1225 res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
1227 base = devm_ioremap_resource(&ofdev->dev, res); 1226 base = devm_ioremap_resource(&ofdev->dev, res);
1228 if (IS_ERR(base)) { 1227 if (IS_ERR(base))
1229 dev_err(&ofdev->dev,
1230 "ioremap failed for SATA register address\n");
1231 return PTR_ERR(base); 1228 return PTR_ERR(base);
1232 }
1233 dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n"); 1229 dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n");
1234 1230
1235 /* Synopsys DWC SATA specific Registers */ 1231 /* Synopsys DWC SATA specific Registers */
diff --git a/drivers/phy/phy-brcm-sata.c b/drivers/phy/phy-brcm-sata.c
index 6c4c5cb791ca..18d662610075 100644
--- a/drivers/phy/phy-brcm-sata.c
+++ b/drivers/phy/phy-brcm-sata.c
@@ -45,6 +45,7 @@ enum brcm_sata_phy_version {
45 BRCM_SATA_PHY_STB_28NM, 45 BRCM_SATA_PHY_STB_28NM,
46 BRCM_SATA_PHY_STB_40NM, 46 BRCM_SATA_PHY_STB_40NM,
47 BRCM_SATA_PHY_IPROC_NS2, 47 BRCM_SATA_PHY_IPROC_NS2,
48 BRCM_SATA_PHY_IPROC_NSP,
48}; 49};
49 50
50struct brcm_sata_port { 51struct brcm_sata_port {
@@ -73,6 +74,13 @@ enum sata_phy_regs {
73 74
74 PLL_REG_BANK_0 = 0x050, 75 PLL_REG_BANK_0 = 0x050,
75 PLL_REG_BANK_0_PLLCONTROL_0 = 0x81, 76 PLL_REG_BANK_0_PLLCONTROL_0 = 0x81,
77 PLLCONTROL_0_FREQ_DET_RESTART = BIT(13),
78 PLLCONTROL_0_FREQ_MONITOR = BIT(12),
79 PLLCONTROL_0_SEQ_START = BIT(15),
80 PLL_CAP_CONTROL = 0x85,
81 PLL_ACTRL2 = 0x8b,
82 PLL_ACTRL2_SELDIV_MASK = 0x1f,
83 PLL_ACTRL2_SELDIV_SHIFT = 9,
76 84
77 PLL1_REG_BANK = 0x060, 85 PLL1_REG_BANK = 0x060,
78 PLL1_ACTRL2 = 0x82, 86 PLL1_ACTRL2 = 0x82,
@@ -80,6 +88,7 @@ enum sata_phy_regs {
80 PLL1_ACTRL4 = 0x84, 88 PLL1_ACTRL4 = 0x84,
81 89
82 OOB_REG_BANK = 0x150, 90 OOB_REG_BANK = 0x150,
91 OOB1_REG_BANK = 0x160,
83 OOB_CTRL1 = 0x80, 92 OOB_CTRL1 = 0x80,
84 OOB_CTRL1_BURST_MAX_MASK = 0xf, 93 OOB_CTRL1_BURST_MAX_MASK = 0xf,
85 OOB_CTRL1_BURST_MAX_SHIFT = 12, 94 OOB_CTRL1_BURST_MAX_SHIFT = 12,
@@ -271,6 +280,73 @@ static int brcm_ns2_sata_init(struct brcm_sata_port *port)
271 return 0; 280 return 0;
272} 281}
273 282
283static int brcm_nsp_sata_init(struct brcm_sata_port *port)
284{
285 struct brcm_sata_phy *priv = port->phy_priv;
286 struct device *dev = port->phy_priv->dev;
287 void __iomem *base = priv->phy_base;
288 unsigned int oob_bank;
289 unsigned int val, try;
290
291 /* Configure OOB control */
292 if (port->portnum == 0)
293 oob_bank = OOB_REG_BANK;
294 else if (port->portnum == 1)
295 oob_bank = OOB1_REG_BANK;
296 else
297 return -EINVAL;
298
299 val = 0x0;
300 val |= (0x0f << OOB_CTRL1_BURST_MAX_SHIFT);
301 val |= (0x06 << OOB_CTRL1_BURST_MIN_SHIFT);
302 val |= (0x0f << OOB_CTRL1_WAKE_IDLE_MAX_SHIFT);
303 val |= (0x06 << OOB_CTRL1_WAKE_IDLE_MIN_SHIFT);
304 brcm_sata_phy_wr(base, oob_bank, OOB_CTRL1, 0x0, val);
305
306 val = 0x0;
307 val |= (0x2e << OOB_CTRL2_RESET_IDLE_MAX_SHIFT);
308 val |= (0x02 << OOB_CTRL2_BURST_CNT_SHIFT);
309 val |= (0x16 << OOB_CTRL2_RESET_IDLE_MIN_SHIFT);
310 brcm_sata_phy_wr(base, oob_bank, OOB_CTRL2, 0x0, val);
311
312
313 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_ACTRL2,
314 ~(PLL_ACTRL2_SELDIV_MASK << PLL_ACTRL2_SELDIV_SHIFT),
315 0x0c << PLL_ACTRL2_SELDIV_SHIFT);
316
317 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_CAP_CONTROL,
318 0xff0, 0x4f0);
319
320 val = PLLCONTROL_0_FREQ_DET_RESTART | PLLCONTROL_0_FREQ_MONITOR;
321 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_REG_BANK_0_PLLCONTROL_0,
322 ~val, val);
323 val = PLLCONTROL_0_SEQ_START;
324 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_REG_BANK_0_PLLCONTROL_0,
325 ~val, 0);
326 mdelay(10);
327 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_REG_BANK_0_PLLCONTROL_0,
328 ~val, val);
329
330 /* Wait for pll_seq_done bit */
331 try = 50;
332 while (try--) {
333 val = brcm_sata_phy_rd(base, BLOCK0_REG_BANK,
334 BLOCK0_XGXSSTATUS);
335 if (val & BLOCK0_XGXSSTATUS_PLL_LOCK)
336 break;
337 msleep(20);
338 }
339 if (!try) {
340 /* PLL did not lock; give up */
341 dev_err(dev, "port%d PLL did not lock\n", port->portnum);
342 return -ETIMEDOUT;
343 }
344
345 dev_dbg(dev, "port%d initialized\n", port->portnum);
346
347 return 0;
348}
349
274static int brcm_sata_phy_init(struct phy *phy) 350static int brcm_sata_phy_init(struct phy *phy)
275{ 351{
276 int rc; 352 int rc;
@@ -284,6 +360,9 @@ static int brcm_sata_phy_init(struct phy *phy)
284 case BRCM_SATA_PHY_IPROC_NS2: 360 case BRCM_SATA_PHY_IPROC_NS2:
285 rc = brcm_ns2_sata_init(port); 361 rc = brcm_ns2_sata_init(port);
286 break; 362 break;
363 case BRCM_SATA_PHY_IPROC_NSP:
364 rc = brcm_nsp_sata_init(port);
365 break;
287 default: 366 default:
288 rc = -ENODEV; 367 rc = -ENODEV;
289 }; 368 };
@@ -303,6 +382,8 @@ static const struct of_device_id brcm_sata_phy_of_match[] = {
303 .data = (void *)BRCM_SATA_PHY_STB_40NM }, 382 .data = (void *)BRCM_SATA_PHY_STB_40NM },
304 { .compatible = "brcm,iproc-ns2-sata-phy", 383 { .compatible = "brcm,iproc-ns2-sata-phy",
305 .data = (void *)BRCM_SATA_PHY_IPROC_NS2 }, 384 .data = (void *)BRCM_SATA_PHY_IPROC_NS2 },
385 { .compatible = "brcm,iproc-nsp-sata-phy",
386 .data = (void *)BRCM_SATA_PHY_IPROC_NSP },
306 {}, 387 {},
307}; 388};
308MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match); 389MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match);
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 935c43095109..497bc1558377 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -233,15 +233,8 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
233 task->task_state_flags = SAS_TASK_STATE_PENDING; 233 task->task_state_flags = SAS_TASK_STATE_PENDING;
234 qc->lldd_task = task; 234 qc->lldd_task = task;
235 235
236 switch (qc->tf.protocol) { 236 task->ata_task.use_ncq = ata_is_ncq(qc->tf.protocol);
237 case ATA_PROT_NCQ: 237 task->ata_task.dma_xfer = ata_is_dma(qc->tf.protocol);
238 task->ata_task.use_ncq = 1;
239 /* fall through */
240 case ATAPI_PROT_DMA:
241 case ATA_PROT_DMA:
242 task->ata_task.dma_xfer = 1;
243 break;
244 }
245 238
246 if (qc->scsicmd) 239 if (qc->scsicmd)
247 ASSIGN_SAS_TASK(qc->scsicmd, task); 240 ASSIGN_SAS_TASK(qc->scsicmd, task);