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

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

Pull libata updates from Tejun Heo:
"Support for some new embedded controllers.

A couple late (<= a week) fixes have stable cc'd and one patch ("SATA:
MV: Add support for the optional PHYs") got committed yesterday
because otherwise the resulting kernel would fail boot on an embedded
board due to interdependent changes in its platform tree.

Other than that, nothing too noteworthy"

* 'for-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata:
SATA: MV: Add support for the optional PHYs
sata-highbank: Remove unnecessary ahci_platform.h include
libata: disable LPM for some WD SATA-I devices
ARM: mvebu: update the SATA compatible string for Armada 370/XP
ata: sata_mv: fix disk hotplug for Armada 370/XP SoCs
ata: sata_mv: introduce compatible string "marvell, armada-370-sata"
ata: pata_samsung_cf: Remove unused macros
ata: pata_samsung_cf: Use devm_ioremap_resource()
ata: pata_samsung_cf: Merge pata_samsung_cf.h into pata_samsung_cf.c
ata: pata_samsung_cf: Move plat/regs-ata.h to drivers/ata
drivers: ata: Mark the function as static in libahci.c
drivers: ata: Mark the function ahci_init_interrupts() as static in ahci.c
ahci: imx: fix the error handling in imx_ahci_probe()
ahci: imx: ahci_imx_softreset() can be static
ahci: imx: Add i.MX53 support
ahci: imx: Pull out the clock enable/disable calls
libata, dt: Document sata_rcar bindings
sata_rcar: Add R-Car Gen2 SATA PHY support
ahci: mcp89: enter AHCI mode under Apple BIOS emulation
ata: libata-eh: Remove unnecessary snprintf arithmetic

+458 -201
+1 -1
Documentation/devicetree/bindings/ata/marvell.txt
··· 1 1 * Marvell Orion SATA 2 2 3 3 Required Properties: 4 - - compatibility : "marvell,orion-sata" 4 + - compatibility : "marvell,orion-sata" or "marvell,armada-370-sata" 5 5 - reg : Address range of controller 6 6 - interrupts : Interrupt controller is using 7 7 - nr-ports : Number of SATA ports in use.
+18
Documentation/devicetree/bindings/ata/sata_rcar.txt
··· 1 + * Renesas R-Car SATA 2 + 3 + Required properties: 4 + - compatible : should contain one of the following: 5 + - "renesas,sata-r8a7779" for R-Car H1 6 + - "renesas,sata-r8a7790" for R-Car H2 7 + - "renesas,sata-r8a7791" for R-Car M2 8 + - reg : address and length of the SATA registers; 9 + - interrupts : must consist of one interrupt specifier. 10 + 11 + Example: 12 + 13 + sata: sata@fc600000 { 14 + compatible = "renesas,sata-r8a7779"; 15 + reg = <0xfc600000 0x2000>; 16 + interrupt-parent = <&gic>; 17 + interrupts = <0 100 IRQ_TYPE_LEVEL_HIGH>; 18 + };
+1 -1
arch/arm/boot/dts/armada-370-xp.dtsi
··· 152 152 }; 153 153 154 154 sata@a0000 { 155 - compatible = "marvell,orion-sata"; 155 + compatible = "marvell,armada-370-sata"; 156 156 reg = <0xa0000 0x5000>; 157 157 interrupts = <55>; 158 158 clocks = <&gateclk 15>, <&gateclk 30>;
-56
arch/arm/plat-samsung/include/plat/regs-ata.h
··· 1 - /* linux/arch/arm/plat-samsung/include/plat/regs-ata.h 2 - * 3 - * Copyright (c) 2010 Samsung Electronics Co., Ltd. 4 - * http://www.samsung.com 5 - * 6 - * Samsung CF-ATA register definitions 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License version 2 as 10 - * published by the Free Software Foundation. 11 - */ 12 - 13 - #ifndef __ASM_PLAT_REGS_ATA_H 14 - #define __ASM_PLAT_REGS_ATA_H __FILE__ 15 - 16 - #define S3C_CFATA_REG(x) (x) 17 - 18 - #define S3C_CFATA_MUX S3C_CFATA_REG(0x0) 19 - 20 - #define S3C_ATA_CTRL S3C_CFATA_REG(0x0) 21 - #define S3C_ATA_STATUS S3C_CFATA_REG(0x4) 22 - #define S3C_ATA_CMD S3C_CFATA_REG(0x8) 23 - #define S3C_ATA_SWRST S3C_CFATA_REG(0xc) 24 - #define S3C_ATA_IRQ S3C_CFATA_REG(0x10) 25 - #define S3C_ATA_IRQ_MSK S3C_CFATA_REG(0x14) 26 - #define S3C_ATA_CFG S3C_CFATA_REG(0x18) 27 - 28 - #define S3C_ATA_MDMA_TIME S3C_CFATA_REG(0x28) 29 - #define S3C_ATA_PIO_TIME S3C_CFATA_REG(0x2c) 30 - #define S3C_ATA_UDMA_TIME S3C_CFATA_REG(0x30) 31 - #define S3C_ATA_XFR_NUM S3C_CFATA_REG(0x34) 32 - #define S3C_ATA_XFR_CNT S3C_CFATA_REG(0x38) 33 - #define S3C_ATA_TBUF_START S3C_CFATA_REG(0x3c) 34 - #define S3C_ATA_TBUF_SIZE S3C_CFATA_REG(0x40) 35 - #define S3C_ATA_SBUF_START S3C_CFATA_REG(0x44) 36 - #define S3C_ATA_SBUF_SIZE S3C_CFATA_REG(0x48) 37 - #define S3C_ATA_CADR_TBUF S3C_CFATA_REG(0x4c) 38 - #define S3C_ATA_CADR_SBUF S3C_CFATA_REG(0x50) 39 - #define S3C_ATA_PIO_DTR S3C_CFATA_REG(0x54) 40 - #define S3C_ATA_PIO_FED S3C_CFATA_REG(0x58) 41 - #define S3C_ATA_PIO_SCR S3C_CFATA_REG(0x5c) 42 - #define S3C_ATA_PIO_LLR S3C_CFATA_REG(0x60) 43 - #define S3C_ATA_PIO_LMR S3C_CFATA_REG(0x64) 44 - #define S3C_ATA_PIO_LHR S3C_CFATA_REG(0x68) 45 - #define S3C_ATA_PIO_DVR S3C_CFATA_REG(0x6c) 46 - #define S3C_ATA_PIO_CSD S3C_CFATA_REG(0x70) 47 - #define S3C_ATA_PIO_DAD S3C_CFATA_REG(0x74) 48 - #define S3C_ATA_PIO_READY S3C_CFATA_REG(0x78) 49 - #define S3C_ATA_PIO_RDATA S3C_CFATA_REG(0x7c) 50 - 51 - #define S3C_CFATA_MUX_TRUEIDE 0x01 52 - 53 - #define S3C_ATA_CFG_SWAP 0x40 54 - #define S3C_ATA_CFG_IORDYEN 0x02 55 - 56 - #endif /* __ASM_PLAT_REGS_ATA_H */
+52 -10
drivers/ata/ahci.c
··· 83 83 static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 84 84 static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, 85 85 unsigned long deadline); 86 + static void ahci_mcp89_apple_enable(struct pci_dev *pdev); 87 + static bool is_mcp89_apple(struct pci_dev *pdev); 86 88 static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class, 87 89 unsigned long deadline); 88 90 #ifdef CONFIG_PM ··· 666 664 if (rc) 667 665 return rc; 668 666 667 + /* Apple BIOS helpfully mangles the registers on resume */ 668 + if (is_mcp89_apple(pdev)) 669 + ahci_mcp89_apple_enable(pdev); 670 + 669 671 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { 670 672 rc = ahci_pci_reset_controller(host); 671 673 if (rc) ··· 784 778 ap->ops = &ahci_p5wdh_ops; 785 779 ap->link.flags |= ATA_LFLAG_NO_SRST | ATA_LFLAG_ASSUME_ATA; 786 780 } 781 + } 782 + 783 + /* 784 + * Macbook7,1 firmware forcibly disables MCP89 AHCI and changes PCI ID when 785 + * booting in BIOS compatibility mode. We restore the registers but not ID. 786 + */ 787 + static void ahci_mcp89_apple_enable(struct pci_dev *pdev) 788 + { 789 + u32 val; 790 + 791 + printk(KERN_INFO "ahci: enabling MCP89 AHCI mode\n"); 792 + 793 + pci_read_config_dword(pdev, 0xf8, &val); 794 + val |= 1 << 0x1b; 795 + /* the following changes the device ID, but appears not to affect function */ 796 + /* val = (val & ~0xf0000000) | 0x80000000; */ 797 + pci_write_config_dword(pdev, 0xf8, val); 798 + 799 + pci_read_config_dword(pdev, 0x54c, &val); 800 + val |= 1 << 0xc; 801 + pci_write_config_dword(pdev, 0x54c, val); 802 + 803 + pci_read_config_dword(pdev, 0x4a4, &val); 804 + val &= 0xff; 805 + val |= 0x01060100; 806 + pci_write_config_dword(pdev, 0x4a4, val); 807 + 808 + pci_read_config_dword(pdev, 0x54c, &val); 809 + val &= ~(1 << 0xc); 810 + pci_write_config_dword(pdev, 0x54c, val); 811 + 812 + pci_read_config_dword(pdev, 0xf8, &val); 813 + val &= ~(1 << 0x1b); 814 + pci_write_config_dword(pdev, 0xf8, val); 815 + } 816 + 817 + static bool is_mcp89_apple(struct pci_dev *pdev) 818 + { 819 + return pdev->vendor == PCI_VENDOR_ID_NVIDIA && 820 + pdev->device == PCI_DEVICE_ID_NVIDIA_NFORCE_MCP89_SATA && 821 + pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE && 822 + pdev->subsystem_device == 0xcb89; 787 823 } 788 824 789 825 /* only some SB600 ahci controllers can do 64bit DMA */ ··· 1148 1100 {} 1149 1101 #endif 1150 1102 1151 - int ahci_init_interrupts(struct pci_dev *pdev, struct ahci_host_priv *hpriv) 1103 + static int ahci_init_interrupts(struct pci_dev *pdev, struct ahci_host_priv *hpriv) 1152 1104 { 1153 1105 int rc; 1154 1106 unsigned int maxvec; ··· 1260 1212 if (pdev->vendor == PCI_VENDOR_ID_MARVELL && !marvell_enable) 1261 1213 return -ENODEV; 1262 1214 1263 - /* 1264 - * For some reason, MCP89 on MacBook 7,1 doesn't work with 1265 - * ahci, use ata_generic instead. 1266 - */ 1267 - if (pdev->vendor == PCI_VENDOR_ID_NVIDIA && 1268 - pdev->device == PCI_DEVICE_ID_NVIDIA_NFORCE_MCP89_SATA && 1269 - pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE && 1270 - pdev->subsystem_device == 0xcb89) 1271 - return -ENODEV; 1215 + /* Apple BIOS on MCP89 prevents us using AHCI */ 1216 + if (is_mcp89_apple(pdev)) 1217 + ahci_mcp89_apple_enable(pdev); 1272 1218 1273 1219 /* Promise's PDC42819 is a SAS/SATA controller that has an AHCI mode. 1274 1220 * At the moment, we can only use the AHCI mode. Let the users know
+157 -85
drivers/ata/ahci_imx.c
··· 34 34 HOST_TIMER1MS = 0xe0, /* Timer 1-ms */ 35 35 }; 36 36 37 + enum ahci_imx_type { 38 + AHCI_IMX53, 39 + AHCI_IMX6Q, 40 + }; 41 + 37 42 struct imx_ahci_priv { 38 43 struct platform_device *ahci_pdev; 44 + enum ahci_imx_type type; 45 + 46 + /* i.MX53 clock */ 47 + struct clk *sata_gate_clk; 48 + /* Common clock */ 39 49 struct clk *sata_ref_clk; 40 50 struct clk *ahb_clk; 51 + 41 52 struct regmap *gpr; 42 53 bool no_device; 43 54 bool first_time; ··· 57 46 static int ahci_imx_hotplug; 58 47 module_param_named(hotplug, ahci_imx_hotplug, int, 0644); 59 48 MODULE_PARM_DESC(hotplug, "AHCI IMX hot-plug support (0=Don't support, 1=support)"); 49 + 50 + static int imx_sata_clock_enable(struct device *dev) 51 + { 52 + struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); 53 + int ret; 54 + 55 + if (imxpriv->type == AHCI_IMX53) { 56 + ret = clk_prepare_enable(imxpriv->sata_gate_clk); 57 + if (ret < 0) { 58 + dev_err(dev, "prepare-enable sata_gate clock err:%d\n", 59 + ret); 60 + return ret; 61 + } 62 + } 63 + 64 + ret = clk_prepare_enable(imxpriv->sata_ref_clk); 65 + if (ret < 0) { 66 + dev_err(dev, "prepare-enable sata_ref clock err:%d\n", 67 + ret); 68 + goto clk_err; 69 + } 70 + 71 + if (imxpriv->type == AHCI_IMX6Q) { 72 + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 73 + IMX6Q_GPR13_SATA_MPLL_CLK_EN, 74 + IMX6Q_GPR13_SATA_MPLL_CLK_EN); 75 + } 76 + 77 + usleep_range(1000, 2000); 78 + 79 + return 0; 80 + 81 + clk_err: 82 + if (imxpriv->type == AHCI_IMX53) 83 + clk_disable_unprepare(imxpriv->sata_gate_clk); 84 + return ret; 85 + } 86 + 87 + static void imx_sata_clock_disable(struct device *dev) 88 + { 89 + struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); 90 + 91 + if (imxpriv->type == AHCI_IMX6Q) { 92 + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 93 + IMX6Q_GPR13_SATA_MPLL_CLK_EN, 94 + !IMX6Q_GPR13_SATA_MPLL_CLK_EN); 95 + } 96 + 97 + clk_disable_unprepare(imxpriv->sata_ref_clk); 98 + 99 + if (imxpriv->type == AHCI_IMX53) 100 + clk_disable_unprepare(imxpriv->sata_gate_clk); 101 + } 60 102 61 103 static void ahci_imx_error_handler(struct ata_port *ap) 62 104 { ··· 136 72 */ 137 73 reg_val = readl(mmio + PORT_PHY_CTL); 138 74 writel(reg_val | PORT_PHY_CTL_PDDQ_LOC, mmio + PORT_PHY_CTL); 139 - regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 140 - IMX6Q_GPR13_SATA_MPLL_CLK_EN, 141 - !IMX6Q_GPR13_SATA_MPLL_CLK_EN); 142 - clk_disable_unprepare(imxpriv->sata_ref_clk); 75 + imx_sata_clock_disable(ap->dev); 143 76 imxpriv->no_device = true; 77 + } 78 + 79 + static int ahci_imx_softreset(struct ata_link *link, unsigned int *class, 80 + unsigned long deadline) 81 + { 82 + struct ata_port *ap = link->ap; 83 + struct imx_ahci_priv *imxpriv = dev_get_drvdata(ap->dev->parent); 84 + int ret = -EIO; 85 + 86 + if (imxpriv->type == AHCI_IMX53) 87 + ret = ahci_pmp_retry_srst_ops.softreset(link, class, deadline); 88 + else if (imxpriv->type == AHCI_IMX6Q) 89 + ret = ahci_ops.softreset(link, class, deadline); 90 + 91 + return ret; 144 92 } 145 93 146 94 static struct ata_port_operations ahci_imx_ops = { 147 95 .inherits = &ahci_platform_ops, 148 96 .error_handler = ahci_imx_error_handler, 97 + .softreset = ahci_imx_softreset, 149 98 }; 150 99 151 100 static const struct ata_port_info ahci_imx_port_info = { ··· 168 91 .port_ops = &ahci_imx_ops, 169 92 }; 170 93 171 - static int imx6q_sata_init(struct device *dev, void __iomem *mmio) 94 + static int imx_sata_init(struct device *dev, void __iomem *mmio) 172 95 { 173 96 int ret = 0; 174 97 unsigned int reg_val; 175 98 struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); 176 99 177 - imxpriv->gpr = 178 - syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr"); 179 - if (IS_ERR(imxpriv->gpr)) { 180 - dev_err(dev, "failed to find fsl,imx6q-iomux-gpr regmap\n"); 181 - return PTR_ERR(imxpriv->gpr); 182 - } 183 - 184 - ret = clk_prepare_enable(imxpriv->sata_ref_clk); 185 - if (ret < 0) { 186 - dev_err(dev, "prepare-enable sata_ref clock err:%d\n", ret); 100 + ret = imx_sata_clock_enable(dev); 101 + if (ret < 0) 187 102 return ret; 188 - } 189 - 190 - /* 191 - * set PHY Paremeters, two steps to configure the GPR13, 192 - * one write for rest of parameters, mask of first write 193 - * is 0x07ffffff, and the other one write for setting 194 - * the mpll_clk_en. 195 - */ 196 - regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK 197 - | IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK 198 - | IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK 199 - | IMX6Q_GPR13_SATA_SPD_MODE_MASK 200 - | IMX6Q_GPR13_SATA_MPLL_SS_EN 201 - | IMX6Q_GPR13_SATA_TX_ATTEN_MASK 202 - | IMX6Q_GPR13_SATA_TX_BOOST_MASK 203 - | IMX6Q_GPR13_SATA_TX_LVL_MASK 204 - | IMX6Q_GPR13_SATA_MPLL_CLK_EN 205 - | IMX6Q_GPR13_SATA_TX_EDGE_RATE 206 - , IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB 207 - | IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M 208 - | IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F 209 - | IMX6Q_GPR13_SATA_SPD_MODE_3P0G 210 - | IMX6Q_GPR13_SATA_MPLL_SS_EN 211 - | IMX6Q_GPR13_SATA_TX_ATTEN_9_16 212 - | IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB 213 - | IMX6Q_GPR13_SATA_TX_LVL_1_025_V); 214 - regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_MPLL_CLK_EN, 215 - IMX6Q_GPR13_SATA_MPLL_CLK_EN); 216 - usleep_range(100, 200); 217 103 218 104 /* 219 105 * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, ··· 202 162 return 0; 203 163 } 204 164 205 - static void imx6q_sata_exit(struct device *dev) 165 + static void imx_sata_exit(struct device *dev) 206 166 { 207 - struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); 208 - 209 - regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_MPLL_CLK_EN, 210 - !IMX6Q_GPR13_SATA_MPLL_CLK_EN); 211 - clk_disable_unprepare(imxpriv->sata_ref_clk); 167 + imx_sata_clock_disable(dev); 212 168 } 213 169 214 170 static int imx_ahci_suspend(struct device *dev) ··· 215 179 * If no_device is set, The CLKs had been gated off in the 216 180 * initialization so don't do it again here. 217 181 */ 218 - if (!imxpriv->no_device) { 219 - regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 220 - IMX6Q_GPR13_SATA_MPLL_CLK_EN, 221 - !IMX6Q_GPR13_SATA_MPLL_CLK_EN); 222 - clk_disable_unprepare(imxpriv->sata_ref_clk); 223 - } 182 + if (!imxpriv->no_device) 183 + imx_sata_clock_disable(dev); 224 184 225 185 return 0; 226 186 } ··· 224 192 static int imx_ahci_resume(struct device *dev) 225 193 { 226 194 struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); 227 - int ret; 195 + int ret = 0; 228 196 229 - if (!imxpriv->no_device) { 230 - ret = clk_prepare_enable(imxpriv->sata_ref_clk); 231 - if (ret < 0) { 232 - dev_err(dev, "pre-enable sata_ref clock err:%d\n", ret); 233 - return ret; 234 - } 197 + if (!imxpriv->no_device) 198 + ret = imx_sata_clock_enable(dev); 235 199 236 - regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 237 - IMX6Q_GPR13_SATA_MPLL_CLK_EN, 238 - IMX6Q_GPR13_SATA_MPLL_CLK_EN); 239 - usleep_range(1000, 2000); 240 - } 241 - 242 - return 0; 200 + return ret; 243 201 } 244 202 245 - static struct ahci_platform_data imx6q_sata_pdata = { 246 - .init = imx6q_sata_init, 247 - .exit = imx6q_sata_exit, 248 - .ata_port_info = &ahci_imx_port_info, 249 - .suspend = imx_ahci_suspend, 250 - .resume = imx_ahci_resume, 203 + static struct ahci_platform_data imx_sata_pdata = { 204 + .init = imx_sata_init, 205 + .exit = imx_sata_exit, 206 + .ata_port_info = &ahci_imx_port_info, 207 + .suspend = imx_ahci_suspend, 208 + .resume = imx_ahci_resume, 209 + 251 210 }; 252 211 253 212 static const struct of_device_id imx_ahci_of_match[] = { 254 - { .compatible = "fsl,imx6q-ahci", .data = &imx6q_sata_pdata}, 213 + { .compatible = "fsl,imx53-ahci", .data = (void *)AHCI_IMX53 }, 214 + { .compatible = "fsl,imx6q-ahci", .data = (void *)AHCI_IMX6Q }, 255 215 {}, 256 216 }; 257 217 MODULE_DEVICE_TABLE(of, imx_ahci_of_match); ··· 253 229 struct device *dev = &pdev->dev; 254 230 struct resource *mem, *irq, res[2]; 255 231 const struct of_device_id *of_id; 232 + enum ahci_imx_type type; 256 233 const struct ahci_platform_data *pdata = NULL; 257 234 struct imx_ahci_priv *imxpriv; 258 235 struct device *ahci_dev; 259 236 struct platform_device *ahci_pdev; 260 237 int ret; 238 + 239 + of_id = of_match_device(imx_ahci_of_match, dev); 240 + if (!of_id) 241 + return -EINVAL; 242 + 243 + type = (enum ahci_imx_type)of_id->data; 244 + pdata = &imx_sata_pdata; 261 245 262 246 imxpriv = devm_kzalloc(dev, sizeof(*imxpriv), GFP_KERNEL); 263 247 if (!imxpriv) { ··· 282 250 283 251 imxpriv->no_device = false; 284 252 imxpriv->first_time = true; 253 + imxpriv->type = type; 254 + 285 255 imxpriv->ahb_clk = devm_clk_get(dev, "ahb"); 286 256 if (IS_ERR(imxpriv->ahb_clk)) { 287 257 dev_err(dev, "can't get ahb clock.\n"); 288 258 ret = PTR_ERR(imxpriv->ahb_clk); 289 259 goto err_out; 260 + } 261 + 262 + if (type == AHCI_IMX53) { 263 + imxpriv->sata_gate_clk = devm_clk_get(dev, "sata_gate"); 264 + if (IS_ERR(imxpriv->sata_gate_clk)) { 265 + dev_err(dev, "can't get sata_gate clock.\n"); 266 + ret = PTR_ERR(imxpriv->sata_gate_clk); 267 + goto err_out; 268 + } 290 269 } 291 270 292 271 imxpriv->sata_ref_clk = devm_clk_get(dev, "sata_ref"); ··· 309 266 310 267 imxpriv->ahci_pdev = ahci_pdev; 311 268 platform_set_drvdata(pdev, imxpriv); 312 - 313 - of_id = of_match_device(imx_ahci_of_match, dev); 314 - if (of_id) { 315 - pdata = of_id->data; 316 - } else { 317 - ret = -EINVAL; 318 - goto err_out; 319 - } 320 269 321 270 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 322 271 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); ··· 324 289 ahci_dev->coherent_dma_mask = DMA_BIT_MASK(32); 325 290 ahci_dev->dma_mask = &ahci_dev->coherent_dma_mask; 326 291 ahci_dev->of_node = dev->of_node; 292 + 293 + if (type == AHCI_IMX6Q) { 294 + imxpriv->gpr = syscon_regmap_lookup_by_compatible( 295 + "fsl,imx6q-iomuxc-gpr"); 296 + if (IS_ERR(imxpriv->gpr)) { 297 + dev_err(dev, 298 + "failed to find fsl,imx6q-iomux-gpr regmap\n"); 299 + ret = PTR_ERR(imxpriv->gpr); 300 + goto err_out; 301 + } 302 + 303 + /* 304 + * Set PHY Paremeters, two steps to configure the GPR13, 305 + * one write for rest of parameters, mask of first write 306 + * is 0x07fffffe, and the other one write for setting 307 + * the mpll_clk_en happens in imx_sata_clock_enable(). 308 + */ 309 + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 310 + IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK | 311 + IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK | 312 + IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK | 313 + IMX6Q_GPR13_SATA_SPD_MODE_MASK | 314 + IMX6Q_GPR13_SATA_MPLL_SS_EN | 315 + IMX6Q_GPR13_SATA_TX_ATTEN_MASK | 316 + IMX6Q_GPR13_SATA_TX_BOOST_MASK | 317 + IMX6Q_GPR13_SATA_TX_LVL_MASK | 318 + IMX6Q_GPR13_SATA_MPLL_CLK_EN | 319 + IMX6Q_GPR13_SATA_TX_EDGE_RATE, 320 + IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB | 321 + IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M | 322 + IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F | 323 + IMX6Q_GPR13_SATA_SPD_MODE_3P0G | 324 + IMX6Q_GPR13_SATA_MPLL_SS_EN | 325 + IMX6Q_GPR13_SATA_TX_ATTEN_9_16 | 326 + IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB | 327 + IMX6Q_GPR13_SATA_TX_LVL_1_025_V); 328 + } 327 329 328 330 ret = platform_device_add_resources(ahci_pdev, res, 2); 329 331 if (ret)
-7
drivers/ata/ata_generic.c
··· 221 221 { PCI_DEVICE(PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558), }, 222 222 { PCI_DEVICE(PCI_VENDOR_ID_CENATEK,PCI_DEVICE_ID_CENATEK_IDE), 223 223 .driver_data = ATA_GEN_FORCE_DMA }, 224 - /* 225 - * For some reason, MCP89 on MacBook 7,1 doesn't work with 226 - * ahci, use ata_generic instead. 227 - */ 228 - { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP89_SATA, 229 - PCI_VENDOR_ID_APPLE, 0xcb89, 230 - .driver_data = ATA_GEN_FORCE_DMA }, 231 224 #if !defined(CONFIG_PATA_TOSHIBA) && !defined(CONFIG_PATA_TOSHIBA_MODULE) 232 225 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), }, 233 226 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), },
+2 -2
drivers/ata/libahci.c
··· 1764 1764 } 1765 1765 } 1766 1766 1767 - void ahci_port_intr(struct ata_port *ap) 1767 + static void ahci_port_intr(struct ata_port *ap) 1768 1768 { 1769 1769 void __iomem *port_mmio = ahci_port_base(ap); 1770 1770 u32 status; ··· 1797 1797 } 1798 1798 EXPORT_SYMBOL_GPL(ahci_thread_fn); 1799 1799 1800 - void ahci_hw_port_interrupt(struct ata_port *ap) 1800 + static void ahci_hw_port_interrupt(struct ata_port *ap) 1801 1801 { 1802 1802 void __iomem *port_mmio = ahci_port_base(ap); 1803 1803 struct ahci_port_priv *pp = ap->private_data;
+27
drivers/ata/libata-core.c
··· 2222 2222 if (rc) 2223 2223 return rc; 2224 2224 2225 + /* some WD SATA-1 drives have issues with LPM, turn on NOLPM for them */ 2226 + if ((dev->horkage & ATA_HORKAGE_WD_BROKEN_LPM) && 2227 + (id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2) 2228 + dev->horkage |= ATA_HORKAGE_NOLPM; 2229 + 2230 + if (dev->horkage & ATA_HORKAGE_NOLPM) { 2231 + ata_dev_warn(dev, "LPM support broken, forcing max_power\n"); 2232 + dev->link->ap->target_lpm_policy = ATA_LPM_MAX_POWER; 2233 + } 2234 + 2225 2235 /* let ACPI work its magic */ 2226 2236 rc = ata_acpi_on_devcfg(dev); 2227 2237 if (rc) ··· 4225 4215 /* devices that don't properly handle queued TRIM commands */ 4226 4216 { "Micron_M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, 4227 4217 { "Crucial_CT???M500SSD1", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, 4218 + 4219 + /* 4220 + * Some WD SATA-I drives spin up and down erratically when the link 4221 + * is put into the slumber mode. We don't have full list of the 4222 + * affected devices. Disable LPM if the device matches one of the 4223 + * known prefixes and is SATA-1. As a side effect LPM partial is 4224 + * lost too. 4225 + * 4226 + * https://bugzilla.kernel.org/show_bug.cgi?id=57211 4227 + */ 4228 + { "WDC WD800JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM }, 4229 + { "WDC WD1200JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM }, 4230 + { "WDC WD1600JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM }, 4231 + { "WDC WD2000JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM }, 4232 + { "WDC WD2500JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM }, 4233 + { "WDC WD3000JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM }, 4234 + { "WDC WD3200JD-*", NULL, ATA_HORKAGE_WD_BROKEN_LPM }, 4228 4235 4229 4236 /* End Marker */ 4230 4237 { }
+2 -3
drivers/ata/libata-eh.c
··· 2402 2402 struct ata_port *ap = link->ap; 2403 2403 struct ata_eh_context *ehc = &link->eh_context; 2404 2404 const char *frozen, *desc; 2405 - char tries_buf[6]; 2405 + char tries_buf[6] = ""; 2406 2406 int tag, nr_failed = 0; 2407 2407 2408 2408 if (ehc->i.flags & ATA_EHI_QUIET) ··· 2433 2433 if (ap->pflags & ATA_PFLAG_FROZEN) 2434 2434 frozen = " frozen"; 2435 2435 2436 - memset(tries_buf, 0, sizeof(tries_buf)); 2437 2436 if (ap->eh_tries < ATA_EH_MAX_TRIES) 2438 - snprintf(tries_buf, sizeof(tries_buf) - 1, " t%d", 2437 + snprintf(tries_buf, sizeof(tries_buf), " t%d", 2439 2438 ap->eh_tries); 2440 2439 2441 2440 if (ehc->i.dev) {
+15 -3
drivers/ata/libata-scsi.c
··· 111 111 [ATA_LPM_MIN_POWER] = "min_power", 112 112 }; 113 113 114 - static ssize_t ata_scsi_lpm_store(struct device *dev, 114 + static ssize_t ata_scsi_lpm_store(struct device *device, 115 115 struct device_attribute *attr, 116 116 const char *buf, size_t count) 117 117 { 118 - struct Scsi_Host *shost = class_to_shost(dev); 118 + struct Scsi_Host *shost = class_to_shost(device); 119 119 struct ata_port *ap = ata_shost_to_port(shost); 120 + struct ata_link *link; 121 + struct ata_device *dev; 120 122 enum ata_lpm_policy policy; 121 123 unsigned long flags; 122 124 ··· 134 132 return -EINVAL; 135 133 136 134 spin_lock_irqsave(ap->lock, flags); 135 + 136 + ata_for_each_link(link, ap, EDGE) { 137 + ata_for_each_dev(dev, &ap->link, ENABLED) { 138 + if (dev->horkage & ATA_HORKAGE_NOLPM) { 139 + count = -EOPNOTSUPP; 140 + goto out_unlock; 141 + } 142 + } 143 + } 144 + 137 145 ap->target_lpm_policy = policy; 138 146 ata_port_schedule_eh(ap); 147 + out_unlock: 139 148 spin_unlock_irqrestore(ap->lock, flags); 140 - 141 149 return count; 142 150 } 143 151
+27 -16
drivers/ata/pata_samsung_cf.c
··· 24 24 #include <linux/slab.h> 25 25 26 26 #include <linux/platform_data/ata-samsung_cf.h> 27 - #include <plat/regs-ata.h> 28 27 29 28 #define DRV_NAME "pata_samsung_cf" 30 29 #define DRV_VERSION "0.1" 30 + 31 + #define S3C_CFATA_REG(x) (x) 32 + #define S3C_CFATA_MUX S3C_CFATA_REG(0x0) 33 + #define S3C_ATA_CTRL S3C_CFATA_REG(0x0) 34 + #define S3C_ATA_CMD S3C_CFATA_REG(0x8) 35 + #define S3C_ATA_IRQ S3C_CFATA_REG(0x10) 36 + #define S3C_ATA_IRQ_MSK S3C_CFATA_REG(0x14) 37 + #define S3C_ATA_CFG S3C_CFATA_REG(0x18) 38 + 39 + #define S3C_ATA_PIO_TIME S3C_CFATA_REG(0x2c) 40 + #define S3C_ATA_PIO_DTR S3C_CFATA_REG(0x54) 41 + #define S3C_ATA_PIO_FED S3C_CFATA_REG(0x58) 42 + #define S3C_ATA_PIO_SCR S3C_CFATA_REG(0x5c) 43 + #define S3C_ATA_PIO_LLR S3C_CFATA_REG(0x60) 44 + #define S3C_ATA_PIO_LMR S3C_CFATA_REG(0x64) 45 + #define S3C_ATA_PIO_LHR S3C_CFATA_REG(0x68) 46 + #define S3C_ATA_PIO_DVR S3C_CFATA_REG(0x6c) 47 + #define S3C_ATA_PIO_CSD S3C_CFATA_REG(0x70) 48 + #define S3C_ATA_PIO_DAD S3C_CFATA_REG(0x74) 49 + #define S3C_ATA_PIO_RDATA S3C_CFATA_REG(0x7c) 50 + 51 + #define S3C_CFATA_MUX_TRUEIDE 0x01 52 + #define S3C_ATA_CFG_SWAP 0x40 53 + #define S3C_ATA_CFG_IORDYEN 0x02 31 54 32 55 enum s3c_cpu_type { 33 56 TYPE_S3C64XX, ··· 518 495 info->irq = platform_get_irq(pdev, 0); 519 496 520 497 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 521 - if (res == NULL) { 522 - dev_err(dev, "failed to get mem resource\n"); 523 - return -EINVAL; 524 - } 525 498 526 - if (!devm_request_mem_region(dev, res->start, 527 - resource_size(res), DRV_NAME)) { 528 - dev_err(dev, "error requesting register region\n"); 529 - return -EBUSY; 530 - } 531 - 532 - info->ide_addr = devm_ioremap(dev, res->start, resource_size(res)); 533 - if (!info->ide_addr) { 534 - dev_err(dev, "failed to map IO base address\n"); 535 - return -ENOMEM; 536 - } 499 + info->ide_addr = devm_ioremap_resource(dev, res); 500 + if (IS_ERR(info->ide_addr)) 501 + return PTR_ERR(info->ide_addr); 537 502 538 503 info->clk = devm_clk_get(&pdev->dev, "cfcon"); 539 504 if (IS_ERR(info->clk)) {
-1
drivers/ata/sata_highbank.c
··· 29 29 #include <linux/of_address.h> 30 30 #include <linux/platform_device.h> 31 31 #include <linux/libata.h> 32 - #include <linux/ahci_platform.h> 33 32 #include <linux/interrupt.h> 34 33 #include <linux/delay.h> 35 34 #include <linux/export.h>
+52
drivers/ata/sata_mv.c
··· 60 60 #include <linux/dma-mapping.h> 61 61 #include <linux/device.h> 62 62 #include <linux/clk.h> 63 + #include <linux/phy/phy.h> 63 64 #include <linux/platform_device.h> 64 65 #include <linux/ata_platform.h> 65 66 #include <linux/mbus.h> ··· 305 304 MV5_LTMODE = 0x30, 306 305 MV5_PHY_CTL = 0x0C, 307 306 SATA_IFCFG = 0x050, 307 + LP_PHY_CTL = 0x058, 308 308 309 309 MV_M2_PREAMP_MASK = 0x7e0, 310 310 ··· 433 431 MV_HP_CUT_THROUGH = (1 << 10), /* can use EDMA cut-through */ 434 432 MV_HP_FLAG_SOC = (1 << 11), /* SystemOnChip, no PCI */ 435 433 MV_HP_QUIRK_LED_BLINK_EN = (1 << 12), /* is led blinking enabled? */ 434 + MV_HP_FIX_LP_PHY_CTL = (1 << 13), /* fix speed in LP_PHY_CTL ? */ 436 435 437 436 /* Port private flags (pp_flags) */ 438 437 MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */ ··· 565 562 */ 566 563 struct clk *clk; 567 564 struct clk **port_clks; 565 + /* 566 + * Some devices have a SATA PHY which can be enabled/disabled 567 + * in order to save power. These are optional: if the platform 568 + * devices does not have any phy, they won't be used. 569 + */ 570 + struct phy **port_phys; 568 571 /* 569 572 * These consistent DMA memory pools give us guaranteed 570 573 * alignment for hardware-accessed data structures, ··· 1367 1358 1368 1359 if (ofs != 0xffffffffU) { 1369 1360 void __iomem *addr = mv_ap_base(link->ap) + ofs; 1361 + struct mv_host_priv *hpriv = link->ap->host->private_data; 1370 1362 if (sc_reg_in == SCR_CONTROL) { 1371 1363 /* 1372 1364 * Workaround for 88SX60x1 FEr SATA#26: ··· 1384 1374 */ 1385 1375 if ((val & 0xf) == 1 || (readl(addr) & 0xf) == 1) 1386 1376 val |= 0xf000; 1377 + 1378 + if (hpriv->hp_flags & MV_HP_FIX_LP_PHY_CTL) { 1379 + void __iomem *lp_phy_addr = 1380 + mv_ap_base(link->ap) + LP_PHY_CTL; 1381 + /* 1382 + * Set PHY speed according to SControl speed. 1383 + */ 1384 + if ((val & 0xf0) == 0x10) 1385 + writelfl(0x7, lp_phy_addr); 1386 + else 1387 + writelfl(0x227, lp_phy_addr); 1388 + } 1387 1389 } 1388 1390 writelfl(val, addr); 1389 1391 return 0; ··· 4098 4076 GFP_KERNEL); 4099 4077 if (!hpriv->port_clks) 4100 4078 return -ENOMEM; 4079 + hpriv->port_phys = devm_kzalloc(&pdev->dev, 4080 + sizeof(struct phy *) * n_ports, 4081 + GFP_KERNEL); 4082 + if (!hpriv->port_phys) 4083 + return -ENOMEM; 4101 4084 host->private_data = hpriv; 4102 4085 hpriv->n_ports = n_ports; 4103 4086 hpriv->board_idx = chip_soc; ··· 4124 4097 hpriv->port_clks[port] = clk_get(&pdev->dev, port_number); 4125 4098 if (!IS_ERR(hpriv->port_clks[port])) 4126 4099 clk_prepare_enable(hpriv->port_clks[port]); 4100 + 4101 + sprintf(port_number, "port%d", port); 4102 + hpriv->port_phys[port] = devm_phy_get(&pdev->dev, port_number); 4103 + if (IS_ERR(hpriv->port_phys[port])) { 4104 + rc = PTR_ERR(hpriv->port_phys[port]); 4105 + hpriv->port_phys[port] = NULL; 4106 + if ((rc != -EPROBE_DEFER) && (rc != -ENODEV)) 4107 + dev_warn(&pdev->dev, "error getting phy"); 4108 + goto err; 4109 + } else 4110 + phy_power_on(hpriv->port_phys[port]); 4127 4111 } 4128 4112 4129 4113 /* ··· 4147 4109 rc = mv_create_dma_pools(hpriv, &pdev->dev); 4148 4110 if (rc) 4149 4111 goto err; 4112 + 4113 + /* 4114 + * To allow disk hotplug on Armada 370/XP SoCs, the PHY speed must be 4115 + * updated in the LP_PHY_CTL register. 4116 + */ 4117 + if (pdev->dev.of_node && 4118 + of_device_is_compatible(pdev->dev.of_node, 4119 + "marvell,armada-370-sata")) 4120 + hpriv->hp_flags |= MV_HP_FIX_LP_PHY_CTL; 4150 4121 4151 4122 /* initialize adapter */ 4152 4123 rc = mv_init_host(host); ··· 4179 4132 clk_disable_unprepare(hpriv->port_clks[port]); 4180 4133 clk_put(hpriv->port_clks[port]); 4181 4134 } 4135 + if (hpriv->port_phys[port]) 4136 + phy_power_off(hpriv->port_phys[port]); 4182 4137 } 4183 4138 4184 4139 return rc; ··· 4210 4161 clk_disable_unprepare(hpriv->port_clks[port]); 4211 4162 clk_put(hpriv->port_clks[port]); 4212 4163 } 4164 + if (hpriv->port_phys[port]) 4165 + phy_power_off(hpriv->port_phys[port]); 4213 4166 } 4214 4167 return 0; 4215 4168 } ··· 4260 4209 4261 4210 #ifdef CONFIG_OF 4262 4211 static struct of_device_id mv_sata_dt_ids[] = { 4212 + { .compatible = "marvell,armada-370-sata", }, 4263 4213 { .compatible = "marvell,orion-sata", }, 4264 4214 {}, 4265 4215 };
+102 -16
drivers/ata/sata_rcar.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/ata.h> 17 17 #include <linux/libata.h> 18 + #include <linux/of_device.h> 18 19 #include <linux/platform_device.h> 19 20 #include <linux/clk.h> 20 21 #include <linux/err.h> ··· 124 123 125 124 #define SATA_RCAR_DMA_BOUNDARY 0x1FFFFFFEUL 126 125 126 + /* Gen2 Physical Layer Control Registers */ 127 + #define RCAR_GEN2_PHY_CTL1_REG 0x1704 128 + #define RCAR_GEN2_PHY_CTL1 0x34180002 129 + #define RCAR_GEN2_PHY_CTL1_SS 0xC180 /* Spread Spectrum */ 130 + 131 + #define RCAR_GEN2_PHY_CTL2_REG 0x170C 132 + #define RCAR_GEN2_PHY_CTL2 0x00002303 133 + 134 + #define RCAR_GEN2_PHY_CTL3_REG 0x171C 135 + #define RCAR_GEN2_PHY_CTL3 0x000B0194 136 + 137 + #define RCAR_GEN2_PHY_CTL4_REG 0x1724 138 + #define RCAR_GEN2_PHY_CTL4 0x00030994 139 + 140 + #define RCAR_GEN2_PHY_CTL5_REG 0x1740 141 + #define RCAR_GEN2_PHY_CTL5 0x03004001 142 + #define RCAR_GEN2_PHY_CTL5_DC BIT(1) /* DC connection */ 143 + #define RCAR_GEN2_PHY_CTL5_TR BIT(2) /* Termination Resistor */ 144 + 145 + enum sata_rcar_type { 146 + RCAR_GEN1_SATA, 147 + RCAR_GEN2_SATA, 148 + }; 149 + 127 150 struct sata_rcar_priv { 128 151 void __iomem *base; 129 152 struct clk *clk; 153 + enum sata_rcar_type type; 130 154 }; 131 155 132 - static void sata_rcar_phy_initialize(struct sata_rcar_priv *priv) 156 + static void sata_rcar_gen1_phy_preinit(struct sata_rcar_priv *priv) 133 157 { 134 158 void __iomem *base = priv->base; 135 159 ··· 167 141 iowrite32(0, base + SATAPHYRESET_REG); 168 142 } 169 143 170 - static void sata_rcar_phy_write(struct sata_rcar_priv *priv, u16 reg, u32 val, 171 - int group) 144 + static void sata_rcar_gen1_phy_write(struct sata_rcar_priv *priv, u16 reg, 145 + u32 val, int group) 172 146 { 173 147 void __iomem *base = priv->base; 174 148 int timeout; ··· 194 168 pr_err("%s timeout\n", __func__); 195 169 /* idle state */ 196 170 iowrite32(0, base + SATAPHYADDR_REG); 171 + } 172 + 173 + static void sata_rcar_gen1_phy_init(struct sata_rcar_priv *priv) 174 + { 175 + sata_rcar_gen1_phy_preinit(priv); 176 + sata_rcar_gen1_phy_write(priv, SATAPCTLR1_REG, 0x00200188, 0); 177 + sata_rcar_gen1_phy_write(priv, SATAPCTLR1_REG, 0x00200188, 1); 178 + sata_rcar_gen1_phy_write(priv, SATAPCTLR3_REG, 0x0000A061, 0); 179 + sata_rcar_gen1_phy_write(priv, SATAPCTLR2_REG, 0x20000000, 0); 180 + sata_rcar_gen1_phy_write(priv, SATAPCTLR2_REG, 0x20000000, 1); 181 + sata_rcar_gen1_phy_write(priv, SATAPCTLR4_REG, 0x28E80000, 0); 182 + } 183 + 184 + static void sata_rcar_gen2_phy_init(struct sata_rcar_priv *priv) 185 + { 186 + void __iomem *base = priv->base; 187 + 188 + iowrite32(RCAR_GEN2_PHY_CTL1, base + RCAR_GEN2_PHY_CTL1_REG); 189 + iowrite32(RCAR_GEN2_PHY_CTL2, base + RCAR_GEN2_PHY_CTL2_REG); 190 + iowrite32(RCAR_GEN2_PHY_CTL3, base + RCAR_GEN2_PHY_CTL3_REG); 191 + iowrite32(RCAR_GEN2_PHY_CTL4, base + RCAR_GEN2_PHY_CTL4_REG); 192 + iowrite32(RCAR_GEN2_PHY_CTL5 | RCAR_GEN2_PHY_CTL5_DC | 193 + RCAR_GEN2_PHY_CTL5_TR, base + RCAR_GEN2_PHY_CTL5_REG); 197 194 } 198 195 199 196 static void sata_rcar_freeze(struct ata_port *ap) ··· 787 738 u32 val; 788 739 789 740 /* reset and setup phy */ 790 - sata_rcar_phy_initialize(priv); 791 - sata_rcar_phy_write(priv, SATAPCTLR1_REG, 0x00200188, 0); 792 - sata_rcar_phy_write(priv, SATAPCTLR1_REG, 0x00200188, 1); 793 - sata_rcar_phy_write(priv, SATAPCTLR3_REG, 0x0000A061, 0); 794 - sata_rcar_phy_write(priv, SATAPCTLR2_REG, 0x20000000, 0); 795 - sata_rcar_phy_write(priv, SATAPCTLR2_REG, 0x20000000, 1); 796 - sata_rcar_phy_write(priv, SATAPCTLR4_REG, 0x28E80000, 0); 741 + switch (priv->type) { 742 + case RCAR_GEN1_SATA: 743 + sata_rcar_gen1_phy_init(priv); 744 + break; 745 + case RCAR_GEN2_SATA: 746 + sata_rcar_gen2_phy_init(priv); 747 + break; 748 + default: 749 + dev_warn(host->dev, "SATA phy is not initialized\n"); 750 + break; 751 + } 797 752 798 753 /* SATA-IP reset state */ 799 754 val = ioread32(base + ATAPI_CONTROL1_REG); ··· 823 770 iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG); 824 771 } 825 772 773 + static struct of_device_id sata_rcar_match[] = { 774 + { 775 + /* Deprecated by "renesas,sata-r8a7779" */ 776 + .compatible = "renesas,rcar-sata", 777 + .data = (void *)RCAR_GEN1_SATA, 778 + }, 779 + { 780 + .compatible = "renesas,sata-r8a7779", 781 + .data = (void *)RCAR_GEN1_SATA, 782 + }, 783 + { 784 + .compatible = "renesas,sata-r8a7790", 785 + .data = (void *)RCAR_GEN2_SATA 786 + }, 787 + { 788 + .compatible = "renesas,sata-r8a7791", 789 + .data = (void *)RCAR_GEN2_SATA 790 + }, 791 + { }, 792 + }; 793 + MODULE_DEVICE_TABLE(of, sata_rcar_match); 794 + 795 + static const struct platform_device_id sata_rcar_id_table[] = { 796 + { "sata_rcar", RCAR_GEN1_SATA }, /* Deprecated by "sata-r8a7779" */ 797 + { "sata-r8a7779", RCAR_GEN1_SATA }, 798 + { "sata-r8a7790", RCAR_GEN2_SATA }, 799 + { "sata-r8a7791", RCAR_GEN2_SATA }, 800 + { }, 801 + }; 802 + MODULE_DEVICE_TABLE(platform, sata_rcar_id_table); 803 + 826 804 static int sata_rcar_probe(struct platform_device *pdev) 827 805 { 806 + const struct of_device_id *of_id; 828 807 struct ata_host *host; 829 808 struct sata_rcar_priv *priv; 830 809 struct resource *mem; ··· 871 786 GFP_KERNEL); 872 787 if (!priv) 873 788 return -ENOMEM; 789 + 790 + of_id = of_match_device(sata_rcar_match, &pdev->dev); 791 + if (of_id) 792 + priv->type = (enum sata_rcar_type)of_id->data; 793 + else 794 + priv->type = platform_get_device_id(pdev)->driver_data; 874 795 875 796 priv->clk = devm_clk_get(&pdev->dev, NULL); 876 797 if (IS_ERR(priv->clk)) { ··· 983 892 }; 984 893 #endif 985 894 986 - static struct of_device_id sata_rcar_match[] = { 987 - { .compatible = "renesas,rcar-sata", }, 988 - {}, 989 - }; 990 - MODULE_DEVICE_TABLE(of, sata_rcar_match); 991 - 992 895 static struct platform_driver sata_rcar_driver = { 993 896 .probe = sata_rcar_probe, 994 897 .remove = sata_rcar_remove, 898 + .id_table = sata_rcar_id_table, 995 899 .driver = { 996 900 .name = DRV_NAME, 997 901 .owner = THIS_MODULE,
+2
include/linux/libata.h
··· 419 419 ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17), /* Set max sects to 65535 */ 420 420 ATA_HORKAGE_ATAPI_DMADIR = (1 << 18), /* device requires dmadir */ 421 421 ATA_HORKAGE_NO_NCQ_TRIM = (1 << 19), /* don't use queued TRIM */ 422 + ATA_HORKAGE_NOLPM = (1 << 20), /* don't use LPM */ 423 + ATA_HORKAGE_WD_BROKEN_LPM = (1 << 21), /* some WDs have broken LPM */ 422 424 423 425 /* DMA mask for user DMA control: User visible values; DO NOT 424 426 renumber */