diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-24 16:20:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-24 16:20:33 -0400 |
commit | 0519359784328bfa92bf0931bf0cff3b58c16932 (patch) | |
tree | 71ab4638b4f0bf86c76eb2b12de01303f6b1f5bf /drivers | |
parent | 596766102a3a37ba20c4d9a4130a8a4b42b34646 (diff) | |
parent | 2d17f460c5d79fa9fc794e813377f3276acf81ce (diff) |
Merge branch 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata updates from Tejun Heo:
"Nothing too interesting. Mostly ahci and ahci_platform changes, many
around power management"
* 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (22 commits)
ata: ahci_platform: enable to get and control reset
ata: libahci_platform: add reset control support
ata: add an extra argument to ahci_platform_get_resources()
ata: sata_rcar: Add r8a77965 support
ata: sata_rcar: exclude setting of PHY registers in Gen3
ata: sata_rcar: really mask all interrupts on Gen2 and later
Revert "ata: ahci_platform: allow disabling of hotplug to save power"
ata: libahci: Allow reconfigure of DEVSLP register
ata: libahci: Correct setting of DEVSLP register
ata: ahci: Enable DEVSLP by default on x86 with SLP_S0
ata: ahci: Support state with min power but Partial low power state
Revert "ata: ahci_platform: convert kcalloc to devm_kcalloc"
ata: sata_rcar: Add rudimentary Runtime PM support
ata: sata_rcar: Provide a short-hand for &pdev->dev
ata: Only output sg element mapped number in verbose debug
ata: Guard ata_scsi_dump_cdb() by ATA_VERBOSE_DEBUG
ata: ahci_platform: convert kcalloc to devm_kcalloc
ata: ahci_platform: convert kzallloc to kcalloc
ata: ahci_platform: correct parameter documentation for ahci_platform_shutdown
libata: remove ata_sff_data_xfer_noirq()
...
Diffstat (limited to 'drivers')
30 files changed, 158 insertions, 120 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index b2b9eba1d214..021ce46e2e57 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -610,7 +610,7 @@ static int marvell_enable = 1; | |||
610 | module_param(marvell_enable, int, 0644); | 610 | module_param(marvell_enable, int, 0644); |
611 | MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)"); | 611 | MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)"); |
612 | 612 | ||
613 | static int mobile_lpm_policy = CONFIG_SATA_MOBILE_LPM_POLICY; | 613 | static int mobile_lpm_policy = -1; |
614 | module_param(mobile_lpm_policy, int, 0644); | 614 | module_param(mobile_lpm_policy, int, 0644); |
615 | MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets"); | 615 | MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets"); |
616 | 616 | ||
@@ -1604,6 +1604,37 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports, | |||
1604 | return pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX); | 1604 | return pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX); |
1605 | } | 1605 | } |
1606 | 1606 | ||
1607 | static void ahci_update_initial_lpm_policy(struct ata_port *ap, | ||
1608 | struct ahci_host_priv *hpriv) | ||
1609 | { | ||
1610 | int policy = CONFIG_SATA_MOBILE_LPM_POLICY; | ||
1611 | |||
1612 | |||
1613 | /* Ignore processing for non mobile platforms */ | ||
1614 | if (!(hpriv->flags & AHCI_HFLAG_IS_MOBILE)) | ||
1615 | return; | ||
1616 | |||
1617 | /* user modified policy via module param */ | ||
1618 | if (mobile_lpm_policy != -1) { | ||
1619 | policy = mobile_lpm_policy; | ||
1620 | goto update_policy; | ||
1621 | } | ||
1622 | |||
1623 | #ifdef CONFIG_ACPI | ||
1624 | if (policy > ATA_LPM_MED_POWER && | ||
1625 | (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)) { | ||
1626 | if (hpriv->cap & HOST_CAP_PART) | ||
1627 | policy = ATA_LPM_MIN_POWER_WITH_PARTIAL; | ||
1628 | else if (hpriv->cap & HOST_CAP_SSC) | ||
1629 | policy = ATA_LPM_MIN_POWER; | ||
1630 | } | ||
1631 | #endif | ||
1632 | |||
1633 | update_policy: | ||
1634 | if (policy >= ATA_LPM_UNKNOWN && policy <= ATA_LPM_MIN_POWER) | ||
1635 | ap->target_lpm_policy = policy; | ||
1636 | } | ||
1637 | |||
1607 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 1638 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
1608 | { | 1639 | { |
1609 | unsigned int board_id = ent->driver_data; | 1640 | unsigned int board_id = ent->driver_data; |
@@ -1807,10 +1838,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1807 | if (ap->flags & ATA_FLAG_EM) | 1838 | if (ap->flags & ATA_FLAG_EM) |
1808 | ap->em_message_type = hpriv->em_msg_type; | 1839 | ap->em_message_type = hpriv->em_msg_type; |
1809 | 1840 | ||
1810 | if ((hpriv->flags & AHCI_HFLAG_IS_MOBILE) && | 1841 | ahci_update_initial_lpm_policy(ap, hpriv); |
1811 | mobile_lpm_policy >= ATA_LPM_UNKNOWN && | ||
1812 | mobile_lpm_policy <= ATA_LPM_MIN_POWER) | ||
1813 | ap->target_lpm_policy = mobile_lpm_policy; | ||
1814 | 1842 | ||
1815 | /* disabled/not-implemented port */ | 1843 | /* disabled/not-implemented port */ |
1816 | if (!(hpriv->port_map & (1 << i))) | 1844 | if (!(hpriv->port_map & (1 << i))) |
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 1609ebab4e23..6a1515f0da40 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h | |||
@@ -350,6 +350,7 @@ struct ahci_host_priv { | |||
350 | u32 em_msg_type; /* EM message type */ | 350 | u32 em_msg_type; /* EM message type */ |
351 | bool got_runtime_pm; /* Did we do pm_runtime_get? */ | 351 | bool got_runtime_pm; /* Did we do pm_runtime_get? */ |
352 | struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ | 352 | struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ |
353 | struct reset_control *rsts; /* Optional */ | ||
353 | struct regulator **target_pwrs; /* Optional */ | 354 | struct regulator **target_pwrs; /* Optional */ |
354 | /* | 355 | /* |
355 | * If platform uses PHYs. There is a 1:1 relation between the port number and | 356 | * If platform uses PHYs. There is a 1:1 relation between the port number and |
diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c index ea430819c80b..f3d557777d82 100644 --- a/drivers/ata/ahci_brcm.c +++ b/drivers/ata/ahci_brcm.c | |||
@@ -425,7 +425,7 @@ static int brcm_ahci_probe(struct platform_device *pdev) | |||
425 | 425 | ||
426 | brcm_sata_phys_enable(priv); | 426 | brcm_sata_phys_enable(priv); |
427 | 427 | ||
428 | hpriv = ahci_platform_get_resources(pdev); | 428 | hpriv = ahci_platform_get_resources(pdev, 0); |
429 | if (IS_ERR(hpriv)) | 429 | if (IS_ERR(hpriv)) |
430 | return PTR_ERR(hpriv); | 430 | return PTR_ERR(hpriv); |
431 | hpriv->plat_data = priv; | 431 | hpriv->plat_data = priv; |
diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c index 5ecc9d46cb54..dc78c98cb9f1 100644 --- a/drivers/ata/ahci_ceva.c +++ b/drivers/ata/ahci_ceva.c | |||
@@ -213,7 +213,7 @@ static int ceva_ahci_probe(struct platform_device *pdev) | |||
213 | 213 | ||
214 | cevapriv->ahci_pdev = pdev; | 214 | cevapriv->ahci_pdev = pdev; |
215 | 215 | ||
216 | hpriv = ahci_platform_get_resources(pdev); | 216 | hpriv = ahci_platform_get_resources(pdev, 0); |
217 | if (IS_ERR(hpriv)) | 217 | if (IS_ERR(hpriv)) |
218 | return PTR_ERR(hpriv); | 218 | return PTR_ERR(hpriv); |
219 | 219 | ||
diff --git a/drivers/ata/ahci_da850.c b/drivers/ata/ahci_da850.c index 9b34dff64536..ebaa657f28c4 100644 --- a/drivers/ata/ahci_da850.c +++ b/drivers/ata/ahci_da850.c | |||
@@ -171,7 +171,7 @@ static int ahci_da850_probe(struct platform_device *pdev) | |||
171 | u32 mpy; | 171 | u32 mpy; |
172 | int rc; | 172 | int rc; |
173 | 173 | ||
174 | hpriv = ahci_platform_get_resources(pdev); | 174 | hpriv = ahci_platform_get_resources(pdev, 0); |
175 | if (IS_ERR(hpriv)) | 175 | if (IS_ERR(hpriv)) |
176 | return PTR_ERR(hpriv); | 176 | return PTR_ERR(hpriv); |
177 | 177 | ||
diff --git a/drivers/ata/ahci_dm816.c b/drivers/ata/ahci_dm816.c index fbd827c3a75c..89509c3efb01 100644 --- a/drivers/ata/ahci_dm816.c +++ b/drivers/ata/ahci_dm816.c | |||
@@ -148,7 +148,7 @@ static int ahci_dm816_probe(struct platform_device *pdev) | |||
148 | struct ahci_host_priv *hpriv; | 148 | struct ahci_host_priv *hpriv; |
149 | int rc; | 149 | int rc; |
150 | 150 | ||
151 | hpriv = ahci_platform_get_resources(pdev); | 151 | hpriv = ahci_platform_get_resources(pdev, 0); |
152 | if (IS_ERR(hpriv)) | 152 | if (IS_ERR(hpriv)) |
153 | return PTR_ERR(hpriv); | 153 | return PTR_ERR(hpriv); |
154 | 154 | ||
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c index 6822e2f33f7e..b00799d208f5 100644 --- a/drivers/ata/ahci_imx.c +++ b/drivers/ata/ahci_imx.c | |||
@@ -1127,7 +1127,7 @@ static int imx_ahci_probe(struct platform_device *pdev) | |||
1127 | return ret; | 1127 | return ret; |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | hpriv = ahci_platform_get_resources(pdev); | 1130 | hpriv = ahci_platform_get_resources(pdev, 0); |
1131 | if (IS_ERR(hpriv)) | 1131 | if (IS_ERR(hpriv)) |
1132 | return PTR_ERR(hpriv); | 1132 | return PTR_ERR(hpriv); |
1133 | 1133 | ||
diff --git a/drivers/ata/ahci_mtk.c b/drivers/ata/ahci_mtk.c index 0ae6971c2a4c..8bc1a26ffc31 100644 --- a/drivers/ata/ahci_mtk.c +++ b/drivers/ata/ahci_mtk.c | |||
@@ -142,7 +142,7 @@ static int mtk_ahci_probe(struct platform_device *pdev) | |||
142 | if (!plat) | 142 | if (!plat) |
143 | return -ENOMEM; | 143 | return -ENOMEM; |
144 | 144 | ||
145 | hpriv = ahci_platform_get_resources(pdev); | 145 | hpriv = ahci_platform_get_resources(pdev, 0); |
146 | if (IS_ERR(hpriv)) | 146 | if (IS_ERR(hpriv)) |
147 | return PTR_ERR(hpriv); | 147 | return PTR_ERR(hpriv); |
148 | 148 | ||
diff --git a/drivers/ata/ahci_mvebu.c b/drivers/ata/ahci_mvebu.c index 72d90b4c3aae..f9cb51be38eb 100644 --- a/drivers/ata/ahci_mvebu.c +++ b/drivers/ata/ahci_mvebu.c | |||
@@ -158,7 +158,7 @@ static int ahci_mvebu_probe(struct platform_device *pdev) | |||
158 | const struct mbus_dram_target_info *dram; | 158 | const struct mbus_dram_target_info *dram; |
159 | int rc; | 159 | int rc; |
160 | 160 | ||
161 | hpriv = ahci_platform_get_resources(pdev); | 161 | hpriv = ahci_platform_get_resources(pdev, 0); |
162 | if (IS_ERR(hpriv)) | 162 | if (IS_ERR(hpriv)) |
163 | return PTR_ERR(hpriv); | 163 | return PTR_ERR(hpriv); |
164 | 164 | ||
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 564570ea3e27..46f0bd75eff7 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c | |||
@@ -43,7 +43,8 @@ static int ahci_probe(struct platform_device *pdev) | |||
43 | struct ahci_host_priv *hpriv; | 43 | struct ahci_host_priv *hpriv; |
44 | int rc; | 44 | int rc; |
45 | 45 | ||
46 | hpriv = ahci_platform_get_resources(pdev); | 46 | hpriv = ahci_platform_get_resources(pdev, |
47 | AHCI_PLATFORM_GET_RESETS); | ||
47 | if (IS_ERR(hpriv)) | 48 | if (IS_ERR(hpriv)) |
48 | return PTR_ERR(hpriv); | 49 | return PTR_ERR(hpriv); |
49 | 50 | ||
diff --git a/drivers/ata/ahci_qoriq.c b/drivers/ata/ahci_qoriq.c index cfdef4d44ae9..ce59253ec158 100644 --- a/drivers/ata/ahci_qoriq.c +++ b/drivers/ata/ahci_qoriq.c | |||
@@ -250,7 +250,7 @@ static int ahci_qoriq_probe(struct platform_device *pdev) | |||
250 | struct resource *res; | 250 | struct resource *res; |
251 | int rc; | 251 | int rc; |
252 | 252 | ||
253 | hpriv = ahci_platform_get_resources(pdev); | 253 | hpriv = ahci_platform_get_resources(pdev, 0); |
254 | if (IS_ERR(hpriv)) | 254 | if (IS_ERR(hpriv)) |
255 | return PTR_ERR(hpriv); | 255 | return PTR_ERR(hpriv); |
256 | 256 | ||
diff --git a/drivers/ata/ahci_seattle.c b/drivers/ata/ahci_seattle.c index 1d31c0c0fc20..e57b6f92c288 100644 --- a/drivers/ata/ahci_seattle.c +++ b/drivers/ata/ahci_seattle.c | |||
@@ -164,7 +164,7 @@ static int ahci_seattle_probe(struct platform_device *pdev) | |||
164 | int rc; | 164 | int rc; |
165 | struct ahci_host_priv *hpriv; | 165 | struct ahci_host_priv *hpriv; |
166 | 166 | ||
167 | hpriv = ahci_platform_get_resources(pdev); | 167 | hpriv = ahci_platform_get_resources(pdev, 0); |
168 | if (IS_ERR(hpriv)) | 168 | if (IS_ERR(hpriv)) |
169 | return PTR_ERR(hpriv); | 169 | return PTR_ERR(hpriv); |
170 | 170 | ||
diff --git a/drivers/ata/ahci_st.c b/drivers/ata/ahci_st.c index bc345f249555..21c5c44832ef 100644 --- a/drivers/ata/ahci_st.c +++ b/drivers/ata/ahci_st.c | |||
@@ -156,7 +156,7 @@ static int st_ahci_probe(struct platform_device *pdev) | |||
156 | if (!drv_data) | 156 | if (!drv_data) |
157 | return -ENOMEM; | 157 | return -ENOMEM; |
158 | 158 | ||
159 | hpriv = ahci_platform_get_resources(pdev); | 159 | hpriv = ahci_platform_get_resources(pdev, 0); |
160 | if (IS_ERR(hpriv)) | 160 | if (IS_ERR(hpriv)) |
161 | return PTR_ERR(hpriv); | 161 | return PTR_ERR(hpriv); |
162 | hpriv->plat_data = drv_data; | 162 | hpriv->plat_data = drv_data; |
diff --git a/drivers/ata/ahci_sunxi.c b/drivers/ata/ahci_sunxi.c index b26437430163..631610b72aa5 100644 --- a/drivers/ata/ahci_sunxi.c +++ b/drivers/ata/ahci_sunxi.c | |||
@@ -181,7 +181,7 @@ static int ahci_sunxi_probe(struct platform_device *pdev) | |||
181 | struct ahci_host_priv *hpriv; | 181 | struct ahci_host_priv *hpriv; |
182 | int rc; | 182 | int rc; |
183 | 183 | ||
184 | hpriv = ahci_platform_get_resources(pdev); | 184 | hpriv = ahci_platform_get_resources(pdev, 0); |
185 | if (IS_ERR(hpriv)) | 185 | if (IS_ERR(hpriv)) |
186 | return PTR_ERR(hpriv); | 186 | return PTR_ERR(hpriv); |
187 | 187 | ||
diff --git a/drivers/ata/ahci_tegra.c b/drivers/ata/ahci_tegra.c index 64d848409fe2..004f2608818e 100644 --- a/drivers/ata/ahci_tegra.c +++ b/drivers/ata/ahci_tegra.c | |||
@@ -494,7 +494,7 @@ static int tegra_ahci_probe(struct platform_device *pdev) | |||
494 | int ret; | 494 | int ret; |
495 | unsigned int i; | 495 | unsigned int i; |
496 | 496 | ||
497 | hpriv = ahci_platform_get_resources(pdev); | 497 | hpriv = ahci_platform_get_resources(pdev, 0); |
498 | if (IS_ERR(hpriv)) | 498 | if (IS_ERR(hpriv)) |
499 | return PTR_ERR(hpriv); | 499 | return PTR_ERR(hpriv); |
500 | 500 | ||
diff --git a/drivers/ata/ahci_xgene.c b/drivers/ata/ahci_xgene.c index ad58da7c9aff..7e157e1bf65e 100644 --- a/drivers/ata/ahci_xgene.c +++ b/drivers/ata/ahci_xgene.c | |||
@@ -759,7 +759,7 @@ static int xgene_ahci_probe(struct platform_device *pdev) | |||
759 | &xgene_ahci_v2_port_info }; | 759 | &xgene_ahci_v2_port_info }; |
760 | int rc; | 760 | int rc; |
761 | 761 | ||
762 | hpriv = ahci_platform_get_resources(pdev); | 762 | hpriv = ahci_platform_get_resources(pdev, 0); |
763 | if (IS_ERR(hpriv)) | 763 | if (IS_ERR(hpriv)) |
764 | return PTR_ERR(hpriv); | 764 | return PTR_ERR(hpriv); |
765 | 765 | ||
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 09620c2ffa0f..b5f57c69c487 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c | |||
@@ -801,6 +801,8 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, | |||
801 | cmd |= PORT_CMD_ALPE; | 801 | cmd |= PORT_CMD_ALPE; |
802 | if (policy == ATA_LPM_MIN_POWER) | 802 | if (policy == ATA_LPM_MIN_POWER) |
803 | cmd |= PORT_CMD_ASP; | 803 | cmd |= PORT_CMD_ASP; |
804 | else if (policy == ATA_LPM_MIN_POWER_WITH_PARTIAL) | ||
805 | cmd &= ~PORT_CMD_ASP; | ||
804 | 806 | ||
805 | /* write out new cmd value */ | 807 | /* write out new cmd value */ |
806 | writel(cmd, port_mmio + PORT_CMD); | 808 | writel(cmd, port_mmio + PORT_CMD); |
@@ -811,7 +813,8 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, | |||
811 | if ((hpriv->cap2 & HOST_CAP2_SDS) && | 813 | if ((hpriv->cap2 & HOST_CAP2_SDS) && |
812 | (hpriv->cap2 & HOST_CAP2_SADM) && | 814 | (hpriv->cap2 & HOST_CAP2_SADM) && |
813 | (link->device->flags & ATA_DFLAG_DEVSLP)) { | 815 | (link->device->flags & ATA_DFLAG_DEVSLP)) { |
814 | if (policy == ATA_LPM_MIN_POWER) | 816 | if (policy == ATA_LPM_MIN_POWER || |
817 | policy == ATA_LPM_MIN_POWER_WITH_PARTIAL) | ||
815 | ahci_set_aggressive_devslp(ap, true); | 818 | ahci_set_aggressive_devslp(ap, true); |
816 | else | 819 | else |
817 | ahci_set_aggressive_devslp(ap, false); | 820 | ahci_set_aggressive_devslp(ap, false); |
@@ -2107,7 +2110,7 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) | |||
2107 | struct ahci_host_priv *hpriv = ap->host->private_data; | 2110 | struct ahci_host_priv *hpriv = ap->host->private_data; |
2108 | void __iomem *port_mmio = ahci_port_base(ap); | 2111 | void __iomem *port_mmio = ahci_port_base(ap); |
2109 | struct ata_device *dev = ap->link.device; | 2112 | struct ata_device *dev = ap->link.device; |
2110 | u32 devslp, dm, dito, mdat, deto; | 2113 | u32 devslp, dm, dito, mdat, deto, dito_conf; |
2111 | int rc; | 2114 | int rc; |
2112 | unsigned int err_mask; | 2115 | unsigned int err_mask; |
2113 | 2116 | ||
@@ -2131,8 +2134,15 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) | |||
2131 | return; | 2134 | return; |
2132 | } | 2135 | } |
2133 | 2136 | ||
2134 | /* device sleep was already enabled */ | 2137 | dm = (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET; |
2135 | if (devslp & PORT_DEVSLP_ADSE) | 2138 | dito = devslp_idle_timeout / (dm + 1); |
2139 | if (dito > 0x3ff) | ||
2140 | dito = 0x3ff; | ||
2141 | |||
2142 | dito_conf = (devslp >> PORT_DEVSLP_DITO_OFFSET) & 0x3FF; | ||
2143 | |||
2144 | /* device sleep was already enabled and same dito */ | ||
2145 | if ((devslp & PORT_DEVSLP_ADSE) && (dito_conf == dito)) | ||
2136 | return; | 2146 | return; |
2137 | 2147 | ||
2138 | /* set DITO, MDAT, DETO and enable DevSlp, need to stop engine first */ | 2148 | /* set DITO, MDAT, DETO and enable DevSlp, need to stop engine first */ |
@@ -2140,11 +2150,6 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) | |||
2140 | if (rc) | 2150 | if (rc) |
2141 | return; | 2151 | return; |
2142 | 2152 | ||
2143 | dm = (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET; | ||
2144 | dito = devslp_idle_timeout / (dm + 1); | ||
2145 | if (dito > 0x3ff) | ||
2146 | dito = 0x3ff; | ||
2147 | |||
2148 | /* Use the nominal value 10 ms if the read MDAT is zero, | 2153 | /* Use the nominal value 10 ms if the read MDAT is zero, |
2149 | * the nominal value of DETO is 20 ms. | 2154 | * the nominal value of DETO is 20 ms. |
2150 | */ | 2155 | */ |
@@ -2162,6 +2167,8 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) | |||
2162 | deto = 20; | 2167 | deto = 20; |
2163 | } | 2168 | } |
2164 | 2169 | ||
2170 | /* Make dito, mdat, deto bits to 0s */ | ||
2171 | devslp &= ~GENMASK_ULL(24, 2); | ||
2165 | devslp |= ((dito << PORT_DEVSLP_DITO_OFFSET) | | 2172 | devslp |= ((dito << PORT_DEVSLP_DITO_OFFSET) | |
2166 | (mdat << PORT_DEVSLP_MDAT_OFFSET) | | 2173 | (mdat << PORT_DEVSLP_MDAT_OFFSET) | |
2167 | (deto << PORT_DEVSLP_DETO_OFFSET) | | 2174 | (deto << PORT_DEVSLP_DETO_OFFSET) | |
@@ -2439,6 +2446,8 @@ static void ahci_port_stop(struct ata_port *ap) | |||
2439 | * re-enabling INTx. | 2446 | * re-enabling INTx. |
2440 | */ | 2447 | */ |
2441 | writel(1 << ap->port_no, host_mmio + HOST_IRQ_STAT); | 2448 | writel(1 << ap->port_no, host_mmio + HOST_IRQ_STAT); |
2449 | |||
2450 | ahci_rpm_put_port(ap); | ||
2442 | } | 2451 | } |
2443 | 2452 | ||
2444 | void ahci_print_info(struct ata_host *host, const char *scc_s) | 2453 | void ahci_print_info(struct ata_host *host, const char *scc_s) |
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 30cc8f1a31e1..c92c10d55374 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/phy/phy.h> | 25 | #include <linux/phy/phy.h> |
26 | #include <linux/pm_runtime.h> | 26 | #include <linux/pm_runtime.h> |
27 | #include <linux/of_platform.h> | 27 | #include <linux/of_platform.h> |
28 | #include <linux/reset.h> | ||
28 | #include "ahci.h" | 29 | #include "ahci.h" |
29 | 30 | ||
30 | static void ahci_host_stop(struct ata_host *host); | 31 | static void ahci_host_stop(struct ata_host *host); |
@@ -195,7 +196,8 @@ EXPORT_SYMBOL_GPL(ahci_platform_disable_regulators); | |||
195 | * following order: | 196 | * following order: |
196 | * 1) Regulator | 197 | * 1) Regulator |
197 | * 2) Clocks (through ahci_platform_enable_clks) | 198 | * 2) Clocks (through ahci_platform_enable_clks) |
198 | * 3) Phys | 199 | * 3) Resets |
200 | * 4) Phys | ||
199 | * | 201 | * |
200 | * If resource enabling fails at any point the previous enabled resources | 202 | * If resource enabling fails at any point the previous enabled resources |
201 | * are disabled in reverse order. | 203 | * are disabled in reverse order. |
@@ -215,12 +217,19 @@ int ahci_platform_enable_resources(struct ahci_host_priv *hpriv) | |||
215 | if (rc) | 217 | if (rc) |
216 | goto disable_regulator; | 218 | goto disable_regulator; |
217 | 219 | ||
218 | rc = ahci_platform_enable_phys(hpriv); | 220 | rc = reset_control_deassert(hpriv->rsts); |
219 | if (rc) | 221 | if (rc) |
220 | goto disable_clks; | 222 | goto disable_clks; |
221 | 223 | ||
224 | rc = ahci_platform_enable_phys(hpriv); | ||
225 | if (rc) | ||
226 | goto disable_resets; | ||
227 | |||
222 | return 0; | 228 | return 0; |
223 | 229 | ||
230 | disable_resets: | ||
231 | reset_control_assert(hpriv->rsts); | ||
232 | |||
224 | disable_clks: | 233 | disable_clks: |
225 | ahci_platform_disable_clks(hpriv); | 234 | ahci_platform_disable_clks(hpriv); |
226 | 235 | ||
@@ -238,13 +247,16 @@ EXPORT_SYMBOL_GPL(ahci_platform_enable_resources); | |||
238 | * This function disables all ahci_platform managed resources in the | 247 | * This function disables all ahci_platform managed resources in the |
239 | * following order: | 248 | * following order: |
240 | * 1) Phys | 249 | * 1) Phys |
241 | * 2) Clocks (through ahci_platform_disable_clks) | 250 | * 2) Resets |
242 | * 3) Regulator | 251 | * 3) Clocks (through ahci_platform_disable_clks) |
252 | * 4) Regulator | ||
243 | */ | 253 | */ |
244 | void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) | 254 | void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) |
245 | { | 255 | { |
246 | ahci_platform_disable_phys(hpriv); | 256 | ahci_platform_disable_phys(hpriv); |
247 | 257 | ||
258 | reset_control_assert(hpriv->rsts); | ||
259 | |||
248 | ahci_platform_disable_clks(hpriv); | 260 | ahci_platform_disable_clks(hpriv); |
249 | 261 | ||
250 | ahci_platform_disable_regulators(hpriv); | 262 | ahci_platform_disable_regulators(hpriv); |
@@ -332,6 +344,7 @@ static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port, | |||
332 | /** | 344 | /** |
333 | * ahci_platform_get_resources - Get platform resources | 345 | * ahci_platform_get_resources - Get platform resources |
334 | * @pdev: platform device to get resources for | 346 | * @pdev: platform device to get resources for |
347 | * @flags: bitmap representing the resource to get | ||
335 | * | 348 | * |
336 | * This function allocates an ahci_host_priv struct, and gets the following | 349 | * This function allocates an ahci_host_priv struct, and gets the following |
337 | * resources, storing a reference to them inside the returned struct: | 350 | * resources, storing a reference to them inside the returned struct: |
@@ -340,18 +353,20 @@ static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port, | |||
340 | * 2) regulator for controlling the targets power (optional) | 353 | * 2) regulator for controlling the targets power (optional) |
341 | * 3) 0 - AHCI_MAX_CLKS clocks, as specified in the devs devicetree node, | 354 | * 3) 0 - AHCI_MAX_CLKS clocks, as specified in the devs devicetree node, |
342 | * or for non devicetree enabled platforms a single clock | 355 | * or for non devicetree enabled platforms a single clock |
343 | * 4) phys (optional) | 356 | * 4) resets, if flags has AHCI_PLATFORM_GET_RESETS (optional) |
357 | * 5) phys (optional) | ||
344 | * | 358 | * |
345 | * RETURNS: | 359 | * RETURNS: |
346 | * The allocated ahci_host_priv on success, otherwise an ERR_PTR value | 360 | * The allocated ahci_host_priv on success, otherwise an ERR_PTR value |
347 | */ | 361 | */ |
348 | struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) | 362 | struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, |
363 | unsigned int flags) | ||
349 | { | 364 | { |
350 | struct device *dev = &pdev->dev; | 365 | struct device *dev = &pdev->dev; |
351 | struct ahci_host_priv *hpriv; | 366 | struct ahci_host_priv *hpriv; |
352 | struct clk *clk; | 367 | struct clk *clk; |
353 | struct device_node *child; | 368 | struct device_node *child; |
354 | int i, sz, enabled_ports = 0, rc = -ENOMEM, child_nodes; | 369 | int i, enabled_ports = 0, rc = -ENOMEM, child_nodes; |
355 | u32 mask_port_map = 0; | 370 | u32 mask_port_map = 0; |
356 | 371 | ||
357 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) | 372 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) |
@@ -393,6 +408,14 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) | |||
393 | hpriv->clks[i] = clk; | 408 | hpriv->clks[i] = clk; |
394 | } | 409 | } |
395 | 410 | ||
411 | if (flags & AHCI_PLATFORM_GET_RESETS) { | ||
412 | hpriv->rsts = devm_reset_control_array_get_optional_shared(dev); | ||
413 | if (IS_ERR(hpriv->rsts)) { | ||
414 | rc = PTR_ERR(hpriv->rsts); | ||
415 | goto err_out; | ||
416 | } | ||
417 | } | ||
418 | |||
396 | hpriv->nports = child_nodes = of_get_child_count(dev->of_node); | 419 | hpriv->nports = child_nodes = of_get_child_count(dev->of_node); |
397 | 420 | ||
398 | /* | 421 | /* |
@@ -403,14 +426,16 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) | |||
403 | if (!child_nodes) | 426 | if (!child_nodes) |
404 | hpriv->nports = 1; | 427 | hpriv->nports = 1; |
405 | 428 | ||
406 | sz = hpriv->nports * sizeof(*hpriv->phys); | 429 | hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), GFP_KERNEL); |
407 | hpriv->phys = devm_kzalloc(dev, sz, GFP_KERNEL); | ||
408 | if (!hpriv->phys) { | 430 | if (!hpriv->phys) { |
409 | rc = -ENOMEM; | 431 | rc = -ENOMEM; |
410 | goto err_out; | 432 | goto err_out; |
411 | } | 433 | } |
412 | sz = hpriv->nports * sizeof(*hpriv->target_pwrs); | 434 | /* |
413 | hpriv->target_pwrs = kzalloc(sz, GFP_KERNEL); | 435 | * We cannot use devm_ here, since ahci_platform_put_resources() uses |
436 | * target_pwrs after devm_ have freed memory | ||
437 | */ | ||
438 | hpriv->target_pwrs = kcalloc(hpriv->nports, sizeof(*hpriv->target_pwrs), GFP_KERNEL); | ||
414 | if (!hpriv->target_pwrs) { | 439 | if (!hpriv->target_pwrs) { |
415 | rc = -ENOMEM; | 440 | rc = -ENOMEM; |
416 | goto err_out; | 441 | goto err_out; |
@@ -605,7 +630,7 @@ static void ahci_host_stop(struct ata_host *host) | |||
605 | 630 | ||
606 | /** | 631 | /** |
607 | * ahci_platform_shutdown - Disable interrupts and stop DMA for host ports | 632 | * ahci_platform_shutdown - Disable interrupts and stop DMA for host ports |
608 | * @dev: platform device pointer for the host | 633 | * @pdev: platform device pointer for the host |
609 | * | 634 | * |
610 | * This function is called during system shutdown and performs the minimal | 635 | * This function is called during system shutdown and performs the minimal |
611 | * deconfiguration required to ensure that an ahci_platform host cannot | 636 | * deconfiguration required to ensure that an ahci_platform host cannot |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 984b37647b2f..172e32840256 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -3970,6 +3970,7 @@ int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy, | |||
3970 | scontrol |= (0x6 << 8); | 3970 | scontrol |= (0x6 << 8); |
3971 | break; | 3971 | break; |
3972 | case ATA_LPM_MED_POWER_WITH_DIPM: | 3972 | case ATA_LPM_MED_POWER_WITH_DIPM: |
3973 | case ATA_LPM_MIN_POWER_WITH_PARTIAL: | ||
3973 | case ATA_LPM_MIN_POWER: | 3974 | case ATA_LPM_MIN_POWER: |
3974 | if (ata_link_nr_enabled(link) > 0) | 3975 | if (ata_link_nr_enabled(link) > 0) |
3975 | /* no restrictions on LPM transitions */ | 3976 | /* no restrictions on LPM transitions */ |
@@ -5066,7 +5067,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
5066 | if (n_elem < 1) | 5067 | if (n_elem < 1) |
5067 | return -1; | 5068 | return -1; |
5068 | 5069 | ||
5069 | DPRINTK("%d sg elements mapped\n", n_elem); | 5070 | VPRINTK("%d sg elements mapped\n", n_elem); |
5070 | qc->orig_n_elem = qc->n_elem; | 5071 | qc->orig_n_elem = qc->n_elem; |
5071 | qc->n_elem = n_elem; | 5072 | qc->n_elem = n_elem; |
5072 | qc->flags |= ATA_QCFLAG_DMAMAP; | 5073 | qc->flags |= ATA_QCFLAG_DMAMAP; |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 8e270962b2f3..1984fc78c750 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -110,6 +110,7 @@ static const char *ata_lpm_policy_names[] = { | |||
110 | [ATA_LPM_MAX_POWER] = "max_performance", | 110 | [ATA_LPM_MAX_POWER] = "max_performance", |
111 | [ATA_LPM_MED_POWER] = "medium_power", | 111 | [ATA_LPM_MED_POWER] = "medium_power", |
112 | [ATA_LPM_MED_POWER_WITH_DIPM] = "med_power_with_dipm", | 112 | [ATA_LPM_MED_POWER_WITH_DIPM] = "med_power_with_dipm", |
113 | [ATA_LPM_MIN_POWER_WITH_PARTIAL] = "min_power_with_partial", | ||
113 | [ATA_LPM_MIN_POWER] = "min_power", | 114 | [ATA_LPM_MIN_POWER] = "min_power", |
114 | }; | 115 | }; |
115 | 116 | ||
@@ -4288,10 +4289,10 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd) | |||
4288 | static inline void ata_scsi_dump_cdb(struct ata_port *ap, | 4289 | static inline void ata_scsi_dump_cdb(struct ata_port *ap, |
4289 | struct scsi_cmnd *cmd) | 4290 | struct scsi_cmnd *cmd) |
4290 | { | 4291 | { |
4291 | #ifdef ATA_DEBUG | 4292 | #ifdef ATA_VERBOSE_DEBUG |
4292 | struct scsi_device *scsidev = cmd->device; | 4293 | struct scsi_device *scsidev = cmd->device; |
4293 | 4294 | ||
4294 | DPRINTK("CDB (%u:%d,%d,%lld) %9ph\n", | 4295 | VPRINTK("CDB (%u:%d,%d,%lld) %9ph\n", |
4295 | ap->print_id, | 4296 | ap->print_id, |
4296 | scsidev->channel, scsidev->id, scsidev->lun, | 4297 | scsidev->channel, scsidev->id, scsidev->lun, |
4297 | cmd->cmnd); | 4298 | cmd->cmnd); |
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index cc2f2e35f4c2..c5ea0fc635e5 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -658,36 +658,6 @@ unsigned int ata_sff_data_xfer32(struct ata_queued_cmd *qc, unsigned char *buf, | |||
658 | EXPORT_SYMBOL_GPL(ata_sff_data_xfer32); | 658 | EXPORT_SYMBOL_GPL(ata_sff_data_xfer32); |
659 | 659 | ||
660 | /** | 660 | /** |
661 | * ata_sff_data_xfer_noirq - Transfer data by PIO | ||
662 | * @qc: queued command | ||
663 | * @buf: data buffer | ||
664 | * @buflen: buffer length | ||
665 | * @rw: read/write | ||
666 | * | ||
667 | * Transfer data from/to the device data register by PIO. Do the | ||
668 | * transfer with interrupts disabled. | ||
669 | * | ||
670 | * LOCKING: | ||
671 | * Inherited from caller. | ||
672 | * | ||
673 | * RETURNS: | ||
674 | * Bytes consumed. | ||
675 | */ | ||
676 | unsigned int ata_sff_data_xfer_noirq(struct ata_queued_cmd *qc, unsigned char *buf, | ||
677 | unsigned int buflen, int rw) | ||
678 | { | ||
679 | unsigned long flags; | ||
680 | unsigned int consumed; | ||
681 | |||
682 | local_irq_save(flags); | ||
683 | consumed = ata_sff_data_xfer32(qc, buf, buflen, rw); | ||
684 | local_irq_restore(flags); | ||
685 | |||
686 | return consumed; | ||
687 | } | ||
688 | EXPORT_SYMBOL_GPL(ata_sff_data_xfer_noirq); | ||
689 | |||
690 | /** | ||
691 | * ata_pio_sector - Transfer a sector of data. | 661 | * ata_pio_sector - Transfer a sector of data. |
692 | * @qc: Command on going | 662 | * @qc: Command on going |
693 | * | 663 | * |
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c index c47caa807fa9..e3532eda7b05 100644 --- a/drivers/ata/pata_cmd640.c +++ b/drivers/ata/pata_cmd640.c | |||
@@ -178,7 +178,7 @@ static struct scsi_host_template cmd640_sht = { | |||
178 | static struct ata_port_operations cmd640_port_ops = { | 178 | static struct ata_port_operations cmd640_port_ops = { |
179 | .inherits = &ata_sff_port_ops, | 179 | .inherits = &ata_sff_port_ops, |
180 | /* In theory xfer_noirq is not needed once we kill the prefetcher */ | 180 | /* In theory xfer_noirq is not needed once we kill the prefetcher */ |
181 | .sff_data_xfer = ata_sff_data_xfer_noirq, | 181 | .sff_data_xfer = ata_sff_data_xfer32, |
182 | .sff_irq_check = cmd640_sff_irq_check, | 182 | .sff_irq_check = cmd640_sff_irq_check, |
183 | .qc_issue = cmd640_qc_issue, | 183 | .qc_issue = cmd640_qc_issue, |
184 | .cable_detect = ata_cable_40wire, | 184 | .cable_detect = ata_cable_40wire, |
diff --git a/drivers/ata/pata_icside.c b/drivers/ata/pata_icside.c index 188f2f2eb21f..c272f2cbb47c 100644 --- a/drivers/ata/pata_icside.c +++ b/drivers/ata/pata_icside.c | |||
@@ -324,7 +324,7 @@ static struct ata_port_operations pata_icside_port_ops = { | |||
324 | .inherits = &ata_bmdma_port_ops, | 324 | .inherits = &ata_bmdma_port_ops, |
325 | /* no need to build any PRD tables for DMA */ | 325 | /* no need to build any PRD tables for DMA */ |
326 | .qc_prep = ata_noop_qc_prep, | 326 | .qc_prep = ata_noop_qc_prep, |
327 | .sff_data_xfer = ata_sff_data_xfer_noirq, | 327 | .sff_data_xfer = ata_sff_data_xfer32, |
328 | .bmdma_setup = pata_icside_bmdma_setup, | 328 | .bmdma_setup = pata_icside_bmdma_setup, |
329 | .bmdma_start = pata_icside_bmdma_start, | 329 | .bmdma_start = pata_icside_bmdma_start, |
330 | .bmdma_stop = pata_icside_bmdma_stop, | 330 | .bmdma_stop = pata_icside_bmdma_stop, |
diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c index 6f0534047c6d..2e538726802b 100644 --- a/drivers/ata/pata_imx.c +++ b/drivers/ata/pata_imx.c | |||
@@ -103,7 +103,7 @@ static struct scsi_host_template pata_imx_sht = { | |||
103 | 103 | ||
104 | static struct ata_port_operations pata_imx_port_ops = { | 104 | static struct ata_port_operations pata_imx_port_ops = { |
105 | .inherits = &ata_sff_port_ops, | 105 | .inherits = &ata_sff_port_ops, |
106 | .sff_data_xfer = ata_sff_data_xfer_noirq, | 106 | .sff_data_xfer = ata_sff_data_xfer32, |
107 | .cable_detect = ata_cable_unknown, | 107 | .cable_detect = ata_cable_unknown, |
108 | .set_piomode = pata_imx_set_piomode, | 108 | .set_piomode = pata_imx_set_piomode, |
109 | }; | 109 | }; |
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index 53828b6c3044..8ea4b8431fc8 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c | |||
@@ -246,12 +246,12 @@ static const struct ata_port_operations legacy_base_port_ops = { | |||
246 | 246 | ||
247 | static struct ata_port_operations simple_port_ops = { | 247 | static struct ata_port_operations simple_port_ops = { |
248 | .inherits = &legacy_base_port_ops, | 248 | .inherits = &legacy_base_port_ops, |
249 | .sff_data_xfer = ata_sff_data_xfer_noirq, | 249 | .sff_data_xfer = ata_sff_data_xfer32, |
250 | }; | 250 | }; |
251 | 251 | ||
252 | static struct ata_port_operations legacy_port_ops = { | 252 | static struct ata_port_operations legacy_port_ops = { |
253 | .inherits = &legacy_base_port_ops, | 253 | .inherits = &legacy_base_port_ops, |
254 | .sff_data_xfer = ata_sff_data_xfer_noirq, | 254 | .sff_data_xfer = ata_sff_data_xfer32, |
255 | .set_mode = legacy_set_mode, | 255 | .set_mode = legacy_set_mode, |
256 | }; | 256 | }; |
257 | 257 | ||
@@ -341,7 +341,7 @@ static unsigned int pdc_data_xfer_vlb(struct ata_queued_cmd *qc, | |||
341 | } | 341 | } |
342 | local_irq_restore(flags); | 342 | local_irq_restore(flags); |
343 | } else | 343 | } else |
344 | buflen = ata_sff_data_xfer_noirq(qc, buf, buflen, rw); | 344 | buflen = ata_sff_data_xfer32(qc, buf, buflen, rw); |
345 | 345 | ||
346 | return buflen; | 346 | return buflen; |
347 | } | 347 | } |
diff --git a/drivers/ata/pata_palmld.c b/drivers/ata/pata_palmld.c index 8c0d7d736b7a..d071ab6864a8 100644 --- a/drivers/ata/pata_palmld.c +++ b/drivers/ata/pata_palmld.c | |||
@@ -44,7 +44,7 @@ static struct scsi_host_template palmld_sht = { | |||
44 | 44 | ||
45 | static struct ata_port_operations palmld_port_ops = { | 45 | static struct ata_port_operations palmld_port_ops = { |
46 | .inherits = &ata_sff_port_ops, | 46 | .inherits = &ata_sff_port_ops, |
47 | .sff_data_xfer = ata_sff_data_xfer_noirq, | 47 | .sff_data_xfer = ata_sff_data_xfer32, |
48 | .cable_detect = ata_cable_40wire, | 48 | .cable_detect = ata_cable_40wire, |
49 | }; | 49 | }; |
50 | 50 | ||
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index a541eacc5e95..9b0e6c72e3f9 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -151,7 +151,7 @@ static struct scsi_host_template pcmcia_sht = { | |||
151 | 151 | ||
152 | static struct ata_port_operations pcmcia_port_ops = { | 152 | static struct ata_port_operations pcmcia_port_ops = { |
153 | .inherits = &ata_sff_port_ops, | 153 | .inherits = &ata_sff_port_ops, |
154 | .sff_data_xfer = ata_sff_data_xfer_noirq, | 154 | .sff_data_xfer = ata_sff_data_xfer32, |
155 | .cable_detect = ata_cable_40wire, | 155 | .cable_detect = ata_cable_40wire, |
156 | .set_mode = pcmcia_set_mode, | 156 | .set_mode = pcmcia_set_mode, |
157 | }; | 157 | }; |
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index c503ded87bb8..d6f8f5406442 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c | |||
@@ -49,7 +49,7 @@ static struct scsi_host_template pata_platform_sht = { | |||
49 | 49 | ||
50 | static struct ata_port_operations pata_platform_port_ops = { | 50 | static struct ata_port_operations pata_platform_port_ops = { |
51 | .inherits = &ata_sff_port_ops, | 51 | .inherits = &ata_sff_port_ops, |
52 | .sff_data_xfer = ata_sff_data_xfer_noirq, | 52 | .sff_data_xfer = ata_sff_data_xfer32, |
53 | .cable_detect = ata_cable_unknown, | 53 | .cable_detect = ata_cable_unknown, |
54 | .set_mode = pata_platform_set_mode, | 54 | .set_mode = pata_platform_set_mode, |
55 | }; | 55 | }; |
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index 1ca6bcab369f..fd19f1ce83aa 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c | |||
@@ -471,7 +471,7 @@ static struct ata_port_operations via_port_ops = { | |||
471 | 471 | ||
472 | static struct ata_port_operations via_port_ops_noirq = { | 472 | static struct ata_port_operations via_port_ops_noirq = { |
473 | .inherits = &via_port_ops, | 473 | .inherits = &via_port_ops, |
474 | .sff_data_xfer = ata_sff_data_xfer_noirq, | 474 | .sff_data_xfer = ata_sff_data_xfer32, |
475 | }; | 475 | }; |
476 | 476 | ||
477 | /** | 477 | /** |
diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index 6456e07db72a..10ecb232245d 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/libata.h> | 17 | #include <linux/libata.h> |
18 | #include <linux/of_device.h> | 18 | #include <linux/of_device.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/clk.h> | 20 | #include <linux/pm_runtime.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | 22 | ||
23 | #define DRV_NAME "sata_rcar" | 23 | #define DRV_NAME "sata_rcar" |
@@ -109,6 +109,8 @@ | |||
109 | #define SATAINTMASK_ERRMSK BIT(2) | 109 | #define SATAINTMASK_ERRMSK BIT(2) |
110 | #define SATAINTMASK_ERRCRTMSK BIT(1) | 110 | #define SATAINTMASK_ERRCRTMSK BIT(1) |
111 | #define SATAINTMASK_ATAMSK BIT(0) | 111 | #define SATAINTMASK_ATAMSK BIT(0) |
112 | #define SATAINTMASK_ALL_GEN1 0x7ff | ||
113 | #define SATAINTMASK_ALL_GEN2 0xfff | ||
112 | 114 | ||
113 | #define SATA_RCAR_INT_MASK (SATAINTMASK_SERRMSK | \ | 115 | #define SATA_RCAR_INT_MASK (SATAINTMASK_SERRMSK | \ |
114 | SATAINTMASK_ATAMSK) | 116 | SATAINTMASK_ATAMSK) |
@@ -152,7 +154,7 @@ enum sata_rcar_type { | |||
152 | 154 | ||
153 | struct sata_rcar_priv { | 155 | struct sata_rcar_priv { |
154 | void __iomem *base; | 156 | void __iomem *base; |
155 | struct clk *clk; | 157 | u32 sataint_mask; |
156 | enum sata_rcar_type type; | 158 | enum sata_rcar_type type; |
157 | }; | 159 | }; |
158 | 160 | ||
@@ -226,7 +228,7 @@ static void sata_rcar_freeze(struct ata_port *ap) | |||
226 | struct sata_rcar_priv *priv = ap->host->private_data; | 228 | struct sata_rcar_priv *priv = ap->host->private_data; |
227 | 229 | ||
228 | /* mask */ | 230 | /* mask */ |
229 | iowrite32(0x7ff, priv->base + SATAINTMASK_REG); | 231 | iowrite32(priv->sataint_mask, priv->base + SATAINTMASK_REG); |
230 | 232 | ||
231 | ata_sff_freeze(ap); | 233 | ata_sff_freeze(ap); |
232 | } | 234 | } |
@@ -242,7 +244,7 @@ static void sata_rcar_thaw(struct ata_port *ap) | |||
242 | ata_sff_thaw(ap); | 244 | ata_sff_thaw(ap); |
243 | 245 | ||
244 | /* unmask */ | 246 | /* unmask */ |
245 | iowrite32(0x7ff & ~SATA_RCAR_INT_MASK, base + SATAINTMASK_REG); | 247 | iowrite32(priv->sataint_mask & ~SATA_RCAR_INT_MASK, base + SATAINTMASK_REG); |
246 | } | 248 | } |
247 | 249 | ||
248 | static void sata_rcar_ioread16_rep(void __iomem *reg, void *buffer, int count) | 250 | static void sata_rcar_ioread16_rep(void __iomem *reg, void *buffer, int count) |
@@ -736,7 +738,7 @@ static irqreturn_t sata_rcar_interrupt(int irq, void *dev_instance) | |||
736 | if (!sataintstat) | 738 | if (!sataintstat) |
737 | goto done; | 739 | goto done; |
738 | /* ack */ | 740 | /* ack */ |
739 | iowrite32(~sataintstat & 0x7ff, base + SATAINTSTAT_REG); | 741 | iowrite32(~sataintstat & priv->sataint_mask, base + SATAINTSTAT_REG); |
740 | 742 | ||
741 | ap = host->ports[0]; | 743 | ap = host->ports[0]; |
742 | 744 | ||
@@ -809,7 +811,7 @@ static void sata_rcar_init_module(struct sata_rcar_priv *priv) | |||
809 | 811 | ||
810 | /* ack and mask */ | 812 | /* ack and mask */ |
811 | iowrite32(0, base + SATAINTSTAT_REG); | 813 | iowrite32(0, base + SATAINTSTAT_REG); |
812 | iowrite32(0x7ff, base + SATAINTMASK_REG); | 814 | iowrite32(priv->sataint_mask, base + SATAINTMASK_REG); |
813 | 815 | ||
814 | /* enable interrupts */ | 816 | /* enable interrupts */ |
815 | iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG); | 817 | iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG); |
@@ -819,16 +821,20 @@ static void sata_rcar_init_controller(struct ata_host *host) | |||
819 | { | 821 | { |
820 | struct sata_rcar_priv *priv = host->private_data; | 822 | struct sata_rcar_priv *priv = host->private_data; |
821 | 823 | ||
824 | priv->sataint_mask = SATAINTMASK_ALL_GEN2; | ||
825 | |||
822 | /* reset and setup phy */ | 826 | /* reset and setup phy */ |
823 | switch (priv->type) { | 827 | switch (priv->type) { |
824 | case RCAR_GEN1_SATA: | 828 | case RCAR_GEN1_SATA: |
829 | priv->sataint_mask = SATAINTMASK_ALL_GEN1; | ||
825 | sata_rcar_gen1_phy_init(priv); | 830 | sata_rcar_gen1_phy_init(priv); |
826 | break; | 831 | break; |
827 | case RCAR_GEN2_SATA: | 832 | case RCAR_GEN2_SATA: |
828 | case RCAR_GEN3_SATA: | ||
829 | case RCAR_R8A7790_ES1_SATA: | 833 | case RCAR_R8A7790_ES1_SATA: |
830 | sata_rcar_gen2_phy_init(priv); | 834 | sata_rcar_gen2_phy_init(priv); |
831 | break; | 835 | break; |
836 | case RCAR_GEN3_SATA: | ||
837 | break; | ||
832 | default: | 838 | default: |
833 | dev_warn(host->dev, "SATA phy is not initialized\n"); | 839 | dev_warn(host->dev, "SATA phy is not initialized\n"); |
834 | break; | 840 | break; |
@@ -881,6 +887,7 @@ MODULE_DEVICE_TABLE(of, sata_rcar_match); | |||
881 | 887 | ||
882 | static int sata_rcar_probe(struct platform_device *pdev) | 888 | static int sata_rcar_probe(struct platform_device *pdev) |
883 | { | 889 | { |
890 | struct device *dev = &pdev->dev; | ||
884 | struct ata_host *host; | 891 | struct ata_host *host; |
885 | struct sata_rcar_priv *priv; | 892 | struct sata_rcar_priv *priv; |
886 | struct resource *mem; | 893 | struct resource *mem; |
@@ -891,36 +898,31 @@ static int sata_rcar_probe(struct platform_device *pdev) | |||
891 | if (irq <= 0) | 898 | if (irq <= 0) |
892 | return -EINVAL; | 899 | return -EINVAL; |
893 | 900 | ||
894 | priv = devm_kzalloc(&pdev->dev, sizeof(struct sata_rcar_priv), | 901 | priv = devm_kzalloc(dev, sizeof(struct sata_rcar_priv), GFP_KERNEL); |
895 | GFP_KERNEL); | ||
896 | if (!priv) | 902 | if (!priv) |
897 | return -ENOMEM; | 903 | return -ENOMEM; |
898 | 904 | ||
899 | priv->type = (enum sata_rcar_type)of_device_get_match_data(&pdev->dev); | 905 | priv->type = (enum sata_rcar_type)of_device_get_match_data(dev); |
900 | priv->clk = devm_clk_get(&pdev->dev, NULL); | ||
901 | if (IS_ERR(priv->clk)) { | ||
902 | dev_err(&pdev->dev, "failed to get access to sata clock\n"); | ||
903 | return PTR_ERR(priv->clk); | ||
904 | } | ||
905 | 906 | ||
906 | ret = clk_prepare_enable(priv->clk); | 907 | pm_runtime_enable(dev); |
907 | if (ret) | 908 | ret = pm_runtime_get_sync(dev); |
908 | return ret; | 909 | if (ret < 0) |
910 | goto err_pm_disable; | ||
909 | 911 | ||
910 | host = ata_host_alloc(&pdev->dev, 1); | 912 | host = ata_host_alloc(dev, 1); |
911 | if (!host) { | 913 | if (!host) { |
912 | dev_err(&pdev->dev, "ata_host_alloc failed\n"); | 914 | dev_err(dev, "ata_host_alloc failed\n"); |
913 | ret = -ENOMEM; | 915 | ret = -ENOMEM; |
914 | goto cleanup; | 916 | goto err_pm_put; |
915 | } | 917 | } |
916 | 918 | ||
917 | host->private_data = priv; | 919 | host->private_data = priv; |
918 | 920 | ||
919 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 921 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
920 | priv->base = devm_ioremap_resource(&pdev->dev, mem); | 922 | priv->base = devm_ioremap_resource(dev, mem); |
921 | if (IS_ERR(priv->base)) { | 923 | if (IS_ERR(priv->base)) { |
922 | ret = PTR_ERR(priv->base); | 924 | ret = PTR_ERR(priv->base); |
923 | goto cleanup; | 925 | goto err_pm_put; |
924 | } | 926 | } |
925 | 927 | ||
926 | /* setup port */ | 928 | /* setup port */ |
@@ -934,9 +936,10 @@ static int sata_rcar_probe(struct platform_device *pdev) | |||
934 | if (!ret) | 936 | if (!ret) |
935 | return 0; | 937 | return 0; |
936 | 938 | ||
937 | cleanup: | 939 | err_pm_put: |
938 | clk_disable_unprepare(priv->clk); | 940 | pm_runtime_put(dev); |
939 | 941 | err_pm_disable: | |
942 | pm_runtime_disable(dev); | ||
940 | return ret; | 943 | return ret; |
941 | } | 944 | } |
942 | 945 | ||
@@ -952,9 +955,10 @@ static int sata_rcar_remove(struct platform_device *pdev) | |||
952 | iowrite32(0, base + ATAPI_INT_ENABLE_REG); | 955 | iowrite32(0, base + ATAPI_INT_ENABLE_REG); |
953 | /* ack and mask */ | 956 | /* ack and mask */ |
954 | iowrite32(0, base + SATAINTSTAT_REG); | 957 | iowrite32(0, base + SATAINTSTAT_REG); |
955 | iowrite32(0x7ff, base + SATAINTMASK_REG); | 958 | iowrite32(priv->sataint_mask, base + SATAINTMASK_REG); |
956 | 959 | ||
957 | clk_disable_unprepare(priv->clk); | 960 | pm_runtime_put(&pdev->dev); |
961 | pm_runtime_disable(&pdev->dev); | ||
958 | 962 | ||
959 | return 0; | 963 | return 0; |
960 | } | 964 | } |
@@ -972,9 +976,9 @@ static int sata_rcar_suspend(struct device *dev) | |||
972 | /* disable interrupts */ | 976 | /* disable interrupts */ |
973 | iowrite32(0, base + ATAPI_INT_ENABLE_REG); | 977 | iowrite32(0, base + ATAPI_INT_ENABLE_REG); |
974 | /* mask */ | 978 | /* mask */ |
975 | iowrite32(0x7ff, base + SATAINTMASK_REG); | 979 | iowrite32(priv->sataint_mask, base + SATAINTMASK_REG); |
976 | 980 | ||
977 | clk_disable_unprepare(priv->clk); | 981 | pm_runtime_put(dev); |
978 | } | 982 | } |
979 | 983 | ||
980 | return ret; | 984 | return ret; |
@@ -987,17 +991,16 @@ static int sata_rcar_resume(struct device *dev) | |||
987 | void __iomem *base = priv->base; | 991 | void __iomem *base = priv->base; |
988 | int ret; | 992 | int ret; |
989 | 993 | ||
990 | ret = clk_prepare_enable(priv->clk); | 994 | ret = pm_runtime_get_sync(dev); |
991 | if (ret) | 995 | if (ret < 0) |
992 | return ret; | 996 | return ret; |
993 | 997 | ||
994 | if (priv->type == RCAR_GEN3_SATA) { | 998 | if (priv->type == RCAR_GEN3_SATA) { |
995 | sata_rcar_gen2_phy_init(priv); | ||
996 | sata_rcar_init_module(priv); | 999 | sata_rcar_init_module(priv); |
997 | } else { | 1000 | } else { |
998 | /* ack and mask */ | 1001 | /* ack and mask */ |
999 | iowrite32(0, base + SATAINTSTAT_REG); | 1002 | iowrite32(0, base + SATAINTSTAT_REG); |
1000 | iowrite32(0x7ff, base + SATAINTMASK_REG); | 1003 | iowrite32(priv->sataint_mask, base + SATAINTMASK_REG); |
1001 | 1004 | ||
1002 | /* enable interrupts */ | 1005 | /* enable interrupts */ |
1003 | iowrite32(ATAPI_INT_ENABLE_SATAINT, | 1006 | iowrite32(ATAPI_INT_ENABLE_SATAINT, |
@@ -1012,11 +1015,10 @@ static int sata_rcar_resume(struct device *dev) | |||
1012 | static int sata_rcar_restore(struct device *dev) | 1015 | static int sata_rcar_restore(struct device *dev) |
1013 | { | 1016 | { |
1014 | struct ata_host *host = dev_get_drvdata(dev); | 1017 | struct ata_host *host = dev_get_drvdata(dev); |
1015 | struct sata_rcar_priv *priv = host->private_data; | ||
1016 | int ret; | 1018 | int ret; |
1017 | 1019 | ||
1018 | ret = clk_prepare_enable(priv->clk); | 1020 | ret = pm_runtime_get_sync(dev); |
1019 | if (ret) | 1021 | if (ret < 0) |
1020 | return ret; | 1022 | return ret; |
1021 | 1023 | ||
1022 | sata_rcar_setup_port(host); | 1024 | sata_rcar_setup_port(host); |