Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-3.15-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata

Pull libata fixes from Tejun Heo:
"Mostly device-specific fixes. The only thing which isn't is the fix
for zpodd oops-on-detach bug"

* 'for-3.15-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata:
ahci: imx: PLL clock needs 100us to settle down
ata: pata_at91 only works on sam9
libata: clean up ZPODD when a port is detached
ahci: imx: software workaround for phy reset issue in resume
ahci: imx: add namespace for register enums
ahci: disable DEVSLP for Intel Valleyview

+205 -8
+1 -1
drivers/ata/Kconfig
··· 815 815 816 816 config PATA_AT91 817 817 tristate "PATA support for AT91SAM9260" 818 - depends on ARM && ARCH_AT91 818 + depends on ARM && SOC_AT91SAM9 819 819 help 820 820 This option enables support for IDE devices on the Atmel AT91SAM9260 SoC. 821 821
+15
drivers/ata/ahci.c
··· 1115 1115 return pdev->bus->number == (val >> 8) && pdev->devfn == (val & 0xff); 1116 1116 } 1117 1117 1118 + static bool ahci_broken_devslp(struct pci_dev *pdev) 1119 + { 1120 + /* device with broken DEVSLP but still showing SDS capability */ 1121 + static const struct pci_device_id ids[] = { 1122 + { PCI_VDEVICE(INTEL, 0x0f23)}, /* Valleyview SoC */ 1123 + {} 1124 + }; 1125 + 1126 + return pci_match_id(ids, pdev); 1127 + } 1128 + 1118 1129 #ifdef CONFIG_ATA_ACPI 1119 1130 static void ahci_gtf_filter_workaround(struct ata_host *host) 1120 1131 { ··· 1374 1363 hpriv->flags &= ~AHCI_HFLAG_32BIT_ONLY; 1375 1364 1376 1365 hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar]; 1366 + 1367 + /* must set flag prior to save config in order to take effect */ 1368 + if (ahci_broken_devslp(pdev)) 1369 + hpriv->flags |= AHCI_HFLAG_NO_DEVSLP; 1377 1370 1378 1371 /* save initial config */ 1379 1372 ahci_pci_save_initial_config(pdev, hpriv);
+1
drivers/ata/ahci.h
··· 236 236 port start (wait until 237 237 error-handling stage) */ 238 238 AHCI_HFLAG_MULTI_MSI = (1 << 16), /* multiple PCI MSIs */ 239 + AHCI_HFLAG_NO_DEVSLP = (1 << 17), /* no device sleep */ 239 240 240 241 /* ap->flags bits */ 241 242
+172 -7
drivers/ata/ahci_imx.c
··· 29 29 #include "ahci.h" 30 30 31 31 enum { 32 - PORT_PHY_CTL = 0x178, /* Port0 PHY Control */ 33 - PORT_PHY_CTL_PDDQ_LOC = 0x100000, /* PORT_PHY_CTL bits */ 34 - HOST_TIMER1MS = 0xe0, /* Timer 1-ms */ 32 + /* Timer 1-ms Register */ 33 + IMX_TIMER1MS = 0x00e0, 34 + /* Port0 PHY Control Register */ 35 + IMX_P0PHYCR = 0x0178, 36 + IMX_P0PHYCR_TEST_PDDQ = 1 << 20, 37 + IMX_P0PHYCR_CR_READ = 1 << 19, 38 + IMX_P0PHYCR_CR_WRITE = 1 << 18, 39 + IMX_P0PHYCR_CR_CAP_DATA = 1 << 17, 40 + IMX_P0PHYCR_CR_CAP_ADDR = 1 << 16, 41 + /* Port0 PHY Status Register */ 42 + IMX_P0PHYSR = 0x017c, 43 + IMX_P0PHYSR_CR_ACK = 1 << 18, 44 + IMX_P0PHYSR_CR_DATA_OUT = 0xffff << 0, 45 + /* Lane0 Output Status Register */ 46 + IMX_LANE0_OUT_STAT = 0x2003, 47 + IMX_LANE0_OUT_STAT_RX_PLL_STATE = 1 << 1, 48 + /* Clock Reset Register */ 49 + IMX_CLOCK_RESET = 0x7f3f, 50 + IMX_CLOCK_RESET_RESET = 1 << 0, 35 51 }; 36 52 37 53 enum ahci_imx_type { ··· 70 54 71 55 static void ahci_imx_host_stop(struct ata_host *host); 72 56 57 + static int imx_phy_crbit_assert(void __iomem *mmio, u32 bit, bool assert) 58 + { 59 + int timeout = 10; 60 + u32 crval; 61 + u32 srval; 62 + 63 + /* Assert or deassert the bit */ 64 + crval = readl(mmio + IMX_P0PHYCR); 65 + if (assert) 66 + crval |= bit; 67 + else 68 + crval &= ~bit; 69 + writel(crval, mmio + IMX_P0PHYCR); 70 + 71 + /* Wait for the cr_ack signal */ 72 + do { 73 + srval = readl(mmio + IMX_P0PHYSR); 74 + if ((assert ? srval : ~srval) & IMX_P0PHYSR_CR_ACK) 75 + break; 76 + usleep_range(100, 200); 77 + } while (--timeout); 78 + 79 + return timeout ? 0 : -ETIMEDOUT; 80 + } 81 + 82 + static int imx_phy_reg_addressing(u16 addr, void __iomem *mmio) 83 + { 84 + u32 crval = addr; 85 + int ret; 86 + 87 + /* Supply the address on cr_data_in */ 88 + writel(crval, mmio + IMX_P0PHYCR); 89 + 90 + /* Assert the cr_cap_addr signal */ 91 + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, true); 92 + if (ret) 93 + return ret; 94 + 95 + /* Deassert cr_cap_addr */ 96 + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, false); 97 + if (ret) 98 + return ret; 99 + 100 + return 0; 101 + } 102 + 103 + static int imx_phy_reg_write(u16 val, void __iomem *mmio) 104 + { 105 + u32 crval = val; 106 + int ret; 107 + 108 + /* Supply the data on cr_data_in */ 109 + writel(crval, mmio + IMX_P0PHYCR); 110 + 111 + /* Assert the cr_cap_data signal */ 112 + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, true); 113 + if (ret) 114 + return ret; 115 + 116 + /* Deassert cr_cap_data */ 117 + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, false); 118 + if (ret) 119 + return ret; 120 + 121 + if (val & IMX_CLOCK_RESET_RESET) { 122 + /* 123 + * In case we're resetting the phy, it's unable to acknowledge, 124 + * so we return immediately here. 125 + */ 126 + crval |= IMX_P0PHYCR_CR_WRITE; 127 + writel(crval, mmio + IMX_P0PHYCR); 128 + goto out; 129 + } 130 + 131 + /* Assert the cr_write signal */ 132 + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_WRITE, true); 133 + if (ret) 134 + return ret; 135 + 136 + /* Deassert cr_write */ 137 + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_WRITE, false); 138 + if (ret) 139 + return ret; 140 + 141 + out: 142 + return 0; 143 + } 144 + 145 + static int imx_phy_reg_read(u16 *val, void __iomem *mmio) 146 + { 147 + int ret; 148 + 149 + /* Assert the cr_read signal */ 150 + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_READ, true); 151 + if (ret) 152 + return ret; 153 + 154 + /* Capture the data from cr_data_out[] */ 155 + *val = readl(mmio + IMX_P0PHYSR) & IMX_P0PHYSR_CR_DATA_OUT; 156 + 157 + /* Deassert cr_read */ 158 + ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_READ, false); 159 + if (ret) 160 + return ret; 161 + 162 + return 0; 163 + } 164 + 165 + static int imx_sata_phy_reset(struct ahci_host_priv *hpriv) 166 + { 167 + void __iomem *mmio = hpriv->mmio; 168 + int timeout = 10; 169 + u16 val; 170 + int ret; 171 + 172 + /* Reset SATA PHY by setting RESET bit of PHY register CLOCK_RESET */ 173 + ret = imx_phy_reg_addressing(IMX_CLOCK_RESET, mmio); 174 + if (ret) 175 + return ret; 176 + ret = imx_phy_reg_write(IMX_CLOCK_RESET_RESET, mmio); 177 + if (ret) 178 + return ret; 179 + 180 + /* Wait for PHY RX_PLL to be stable */ 181 + do { 182 + usleep_range(100, 200); 183 + ret = imx_phy_reg_addressing(IMX_LANE0_OUT_STAT, mmio); 184 + if (ret) 185 + return ret; 186 + ret = imx_phy_reg_read(&val, mmio); 187 + if (ret) 188 + return ret; 189 + if (val & IMX_LANE0_OUT_STAT_RX_PLL_STATE) 190 + break; 191 + } while (--timeout); 192 + 193 + return timeout ? 0 : -ETIMEDOUT; 194 + } 195 + 73 196 static int imx_sata_enable(struct ahci_host_priv *hpriv) 74 197 { 75 198 struct imx_ahci_priv *imxpriv = hpriv->plat_data; 199 + struct device *dev = &imxpriv->ahci_pdev->dev; 76 200 int ret; 77 201 78 202 if (imxpriv->no_device) ··· 257 101 regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 258 102 IMX6Q_GPR13_SATA_MPLL_CLK_EN, 259 103 IMX6Q_GPR13_SATA_MPLL_CLK_EN); 104 + 105 + usleep_range(100, 200); 106 + 107 + ret = imx_sata_phy_reset(hpriv); 108 + if (ret) { 109 + dev_err(dev, "failed to reset phy: %d\n", ret); 110 + goto disable_regulator; 111 + } 260 112 } 261 113 262 114 usleep_range(1000, 2000); ··· 320 156 * without full reset once the pddq mode is enabled making it 321 157 * impossible to use as part of libata LPM. 322 158 */ 323 - reg_val = readl(mmio + PORT_PHY_CTL); 324 - writel(reg_val | PORT_PHY_CTL_PDDQ_LOC, mmio + PORT_PHY_CTL); 159 + reg_val = readl(mmio + IMX_P0PHYCR); 160 + writel(reg_val | IMX_P0PHYCR_TEST_PDDQ, mmio + IMX_P0PHYCR); 325 161 imx_sata_disable(hpriv); 326 162 imxpriv->no_device = true; 327 163 } ··· 381 217 if (!imxpriv) 382 218 return -ENOMEM; 383 219 220 + imxpriv->ahci_pdev = pdev; 384 221 imxpriv->no_device = false; 385 222 imxpriv->first_time = true; 386 223 imxpriv->type = (enum ahci_imx_type)of_id->data; ··· 413 248 414 249 /* 415 250 * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, 416 - * and IP vendor specific register HOST_TIMER1MS. 251 + * and IP vendor specific register IMX_TIMER1MS. 417 252 * Configure CAP_SSS (support stagered spin up). 418 253 * Implement the port0. 419 254 * Get the ahb clock rate, and configure the TIMER1MS register. ··· 430 265 } 431 266 432 267 reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; 433 - writel(reg_val, hpriv->mmio + HOST_TIMER1MS); 268 + writel(reg_val, hpriv->mmio + IMX_TIMER1MS); 434 269 435 270 ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, 0, 0); 436 271 if (ret)
+7
drivers/ata/libahci.c
··· 452 452 cap &= ~HOST_CAP_SNTF; 453 453 } 454 454 455 + if ((cap2 & HOST_CAP2_SDS) && (hpriv->flags & AHCI_HFLAG_NO_DEVSLP)) { 456 + dev_info(dev, 457 + "controller can't do DEVSLP, turning off\n"); 458 + cap2 &= ~HOST_CAP2_SDS; 459 + cap2 &= ~HOST_CAP2_SADM; 460 + } 461 + 455 462 if (!(cap & HOST_CAP_FBS) && (hpriv->flags & AHCI_HFLAG_YES_FBS)) { 456 463 dev_info(dev, "controller can do FBS, turning on CAP_FBS\n"); 457 464 cap |= HOST_CAP_FBS;
+9
drivers/ata/libata-core.c
··· 6314 6314 static void ata_port_detach(struct ata_port *ap) 6315 6315 { 6316 6316 unsigned long flags; 6317 + struct ata_link *link; 6318 + struct ata_device *dev; 6317 6319 6318 6320 if (!ap->ops->error_handler) 6319 6321 goto skip_eh; ··· 6335 6333 cancel_delayed_work_sync(&ap->hotplug_task); 6336 6334 6337 6335 skip_eh: 6336 + /* clean up zpodd on port removal */ 6337 + ata_for_each_link(link, ap, HOST_FIRST) { 6338 + ata_for_each_dev(dev, link, ALL) { 6339 + if (zpodd_dev_enabled(dev)) 6340 + zpodd_exit(dev); 6341 + } 6342 + } 6338 6343 if (ap->pmp_link) { 6339 6344 int i; 6340 6345 for (i = 0; i < SATA_PMP_MAX_PORTS; i++)