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

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

Pull libata changes from Tejun Heo:
"Except for a few, all the changes are for ahci platform drivers for
the arm devices. Nothing too interesting or dangerous. There's one
merge from libata/for-3.16-fixes to pull in dependent changes"

* 'for-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (23 commits)
ata: libahci: Silence compiler warning on 64-bit
Documentation: bindings: document the sub-nodes AHCI bindings
ata: ahci_platform: add a generic AHCI compatible
ata: libahci: allow to use multiple PHYs
ata: libahci_platform: move port_map parameters into the AHCI structure
ahci: imx: add missing clk_disable_unprepare() on error in imx_sata_enable()
ahci_xgene: Use correct OOB tunning parameters for APM X-Gene SoC AHCI SATA Host controller driver.
ahci_xgene: Fix the watermark threshold for the APM X-Gene SATA host controller driver.
ahci: st: Make of_device_id array const
sata_sil24: Identify which card suffered IRQ status error
ahci: st: Provide DT bindings for ST's SATA implementation
ata: Add support for the Tegra124 SATA controller
ata: ahci_platform: Increase AHCI_MAX_CLKS to 4
of: Add NVIDIA Tegra SATA controller binding
dt-bindings: ata: document ability to disable spread-spectrum clock
ata: ahci_imx: add disable for spread-spectrum
dt-bindings: ata: add ahci_imx electrical properties
ata: ahci_imx: allow hardware parameters to be specified in DT
dt-bindings: ata: create bindings for imx sata controller
ata: pata_samsung_cf: removes s5pc100 related ata codes
...

+917 -141
+40 -5
Documentation/devicetree/bindings/ata/ahci-platform.txt
··· 3 3 SATA nodes are defined to describe on-chip Serial ATA controllers. 4 4 Each SATA controller should have its own node. 5 5 6 + It is possible, but not required, to represent each port as a sub-node. 7 + It allows to enable each port independently when dealing with multiple 8 + PHYs. 9 + 6 10 Required properties: 7 11 - compatible : compatible string, one of: 8 12 - "allwinner,sun4i-a10-ahci" 9 - - "fsl,imx53-ahci" 10 - - "fsl,imx6q-ahci" 11 13 - "hisilicon,hisi-ahci" 12 14 - "ibm,476gtr-ahci" 13 15 - "marvell,armada-380-ahci" 14 16 - "snps,dwc-ahci" 15 17 - "snps,exynos5440-ahci" 16 18 - "snps,spear-ahci" 19 + - "generic-ahci" 17 20 - interrupts : <interrupt mapping for SATA IRQ> 18 21 - reg : <registers mapping> 22 + 23 + Please note that when using "generic-ahci" you must also specify a SoC specific 24 + compatible: 25 + compatible = "manufacturer,soc-model-ahci", "generic-ahci"; 19 26 20 27 Optional properties: 21 28 - dma-coherent : Present if dma operations are coherent 22 29 - clocks : a list of phandle + clock specifier pairs 23 30 - target-supply : regulator for SATA target power 31 + - phys : reference to the SATA PHY node 32 + - phy-names : must be "sata-phy" 24 33 25 - "fsl,imx53-ahci", "fsl,imx6q-ahci" required properties: 26 - - clocks : must contain the sata, sata_ref and ahb clocks 27 - - clock-names : must contain "ahb" for the ahb clock 34 + Required properties when using sub-nodes: 35 + - #address-cells : number of cells to encode an address 36 + - #size-cells : number of cells representing the size of an address 37 + 38 + 39 + Sub-nodes required properties: 40 + - reg : the port number 41 + - phys : reference to the SATA PHY node 42 + 28 43 29 44 Examples: 30 45 sata@ffe08000 { ··· 54 39 interrupts = <56>; 55 40 clocks = <&pll6 0>, <&ahb_gates 25>; 56 41 target-supply = <&reg_ahci_5v>; 42 + }; 43 + 44 + With sub-nodes: 45 + sata@f7e90000 { 46 + compatible = "marvell,berlin2q-achi", "generic-ahci"; 47 + reg = <0xe90000 0x1000>; 48 + interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; 49 + clocks = <&chip CLKID_SATA>; 50 + #address-cells = <1>; 51 + #size-cells = <0>; 52 + 53 + sata0: sata-port@0 { 54 + reg = <0>; 55 + phys = <&sata_phy 0>; 56 + }; 57 + 58 + sata1: sata-port@1 { 59 + reg = <1>; 60 + phys = <&sata_phy 1>; 61 + }; 57 62 };
+31
Documentation/devicetree/bindings/ata/ahci-st.txt
··· 1 + STMicroelectronics STi SATA controller 2 + 3 + This binding describes a SATA device. 4 + 5 + Required properties: 6 + - compatible : Must be "st,sti-ahci" 7 + - reg : Physical base addresses and length of register sets 8 + - interrupts : Interrupt associated with the SATA device 9 + - interrupt-names : Associated name must be; "hostc" 10 + - resets : The power-down and soft-reset lines of SATA IP 11 + - reset-names : Associated names must be; "pwr-dwn" and "sw-rst" 12 + - clocks : The phandle for the clock 13 + - clock-names : Associated name must be; "ahci_clk" 14 + - phys : The phandle for the PHY device 15 + - phy-names : Associated name must be; "ahci_phy" 16 + 17 + Example: 18 + 19 + sata0: sata@fe380000 { 20 + compatible = "st,sti-ahci"; 21 + reg = <0xfe380000 0x1000>; 22 + interrupts = <GIC_SPI 157 IRQ_TYPE_NONE>; 23 + interrupt-names = "hostc"; 24 + phys = <&miphy365x_phy MIPHY_PORT_0 MIPHY_TYPE_SATA>; 25 + phy-names = "ahci_phy"; 26 + resets = <&powerdown STIH416_SATA0_POWERDOWN>, 27 + <&softreset STIH416_SATA0_SOFTRESET>; 28 + reset-names = "pwr-dwn", "sw-rst"; 29 + clocks = <&clk_s_a0_ls CLK_ICN_REG>; 30 + clock-names = "ahci_clk"; 31 + };
+36
Documentation/devicetree/bindings/ata/imx-sata.txt
··· 1 + * Freescale i.MX AHCI SATA Controller 2 + 3 + The Freescale i.MX SATA controller mostly conforms to the AHCI interface 4 + with some special extensions at integration level. 5 + 6 + Required properties: 7 + - compatible : should be one of the following: 8 + - "fsl,imx53-ahci" for i.MX53 SATA controller 9 + - "fsl,imx6q-ahci" for i.MX6Q SATA controller 10 + - interrupts : interrupt mapping for SATA IRQ 11 + - reg : registers mapping 12 + - clocks : list of clock specifiers, must contain an entry for each 13 + required entry in clock-names 14 + - clock-names : should include "sata", "sata_ref" and "ahb" entries 15 + 16 + Optional properties: 17 + - fsl,transmit-level-mV : transmit voltage level, in millivolts. 18 + - fsl,transmit-boost-mdB : transmit boost level, in milli-decibels 19 + - fsl,transmit-atten-16ths : transmit attenuation, in 16ths 20 + - fsl,receive-eq-mdB : receive equalisation, in milli-decibels 21 + Please refer to the technical documentation or the driver source code 22 + for the list of legal values for these options. 23 + - fsl,no-spread-spectrum : disable spread-spectrum clocking on the SATA 24 + link. 25 + 26 + Examples: 27 + 28 + sata@02200000 { 29 + compatible = "fsl,imx6q-ahci"; 30 + reg = <0x02200000 0x4000>; 31 + interrupts = <0 39 IRQ_TYPE_LEVEL_HIGH>; 32 + clocks = <&clks IMX6QDL_CLK_SATA>, 33 + <&clks IMX6QDL_CLK_SATA_REF_100M>, 34 + <&clks IMX6QDL_CLK_AHB>; 35 + clock-names = "sata", "sata_ref", "ahb"; 36 + };
+30
Documentation/devicetree/bindings/ata/tegra-sata.txt
··· 1 + Tegra124 SoC SATA AHCI controller 2 + 3 + Required properties : 4 + - compatible : "nvidia,tegra124-ahci". 5 + - reg : Should contain 2 entries: 6 + - AHCI register set (SATA BAR5) 7 + - SATA register set 8 + - interrupts : Defines the interrupt used by SATA 9 + - clocks : Must contain an entry for each entry in clock-names. 10 + See ../clocks/clock-bindings.txt for details. 11 + - clock-names : Must include the following entries: 12 + - sata 13 + - sata-oob 14 + - cml1 15 + - pll_e 16 + - resets : Must contain an entry for each entry in reset-names. 17 + See ../reset/reset.txt for details. 18 + - reset-names : Must include the following entries: 19 + - sata 20 + - sata-oob 21 + - sata-cold 22 + - phys : Must contain an entry for each entry in phy-names. 23 + See ../phy/phy-bindings.txt for details. 24 + - phy-names : Must include the following entries: 25 + - sata-phy : XUSB PADCTL SATA PHY 26 + - hvdd-supply : Defines the SATA HVDD regulator 27 + - vddio-supply : Defines the SATA VDDIO regulator 28 + - avdd-supply : Defines the SATA AVDD regulator 29 + - target-5v-supply : Defines the SATA 5V power regulator 30 + - target-12v-supply : Defines the SATA 12V power regulator
+9
drivers/ata/Kconfig
··· 141 141 142 142 If unsure, say N. 143 143 144 + config AHCI_TEGRA 145 + tristate "NVIDIA Tegra124 AHCI SATA support" 146 + depends on ARCH_TEGRA 147 + help 148 + This option enables support for the NVIDIA Tegra124 SoC's 149 + onboard AHCI SATA. 150 + 151 + If unsure, say N. 152 + 144 153 config AHCI_XGENE 145 154 tristate "APM X-Gene 6.0Gbps AHCI SATA host controller support" 146 155 depends on PHY_XGENE
+1
drivers/ata/Makefile
··· 15 15 obj-$(CONFIG_AHCI_MVEBU) += ahci_mvebu.o libahci.o libahci_platform.o 16 16 obj-$(CONFIG_AHCI_SUNXI) += ahci_sunxi.o libahci.o libahci_platform.o 17 17 obj-$(CONFIG_AHCI_ST) += ahci_st.o libahci.o libahci_platform.o 18 + obj-$(CONFIG_AHCI_TEGRA) += ahci_tegra.o libahci.o libahci_platform.o 18 19 obj-$(CONFIG_AHCI_XGENE) += ahci_xgene.o libahci.o libahci_platform.o 19 20 20 21 # SFF w/ custom DMA
+1 -1
drivers/ata/acard-ahci.c
··· 441 441 hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; 442 442 443 443 /* save initial config */ 444 - ahci_save_initial_config(&pdev->dev, hpriv, 0, 0); 444 + ahci_save_initial_config(&pdev->dev, hpriv); 445 445 446 446 /* prepare host */ 447 447 if (hpriv->cap & HOST_CAP_NCQ)
+1 -2
drivers/ata/ahci.c
··· 526 526 "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n"); 527 527 } 528 528 529 - ahci_save_initial_config(&pdev->dev, hpriv, force_port_map, 530 - mask_port_map); 529 + ahci_save_initial_config(&pdev->dev, hpriv); 531 530 } 532 531 533 532 static int ahci_pci_reset_controller(struct ata_host *host)
+13 -6
drivers/ata/ahci.h
··· 53 53 54 54 enum { 55 55 AHCI_MAX_PORTS = 32, 56 - AHCI_MAX_CLKS = 3, 56 + AHCI_MAX_CLKS = 4, 57 57 AHCI_MAX_SG = 168, /* hardware max is 64K */ 58 58 AHCI_DMA_BOUNDARY = 0xffffffff, 59 59 AHCI_MAX_CMDS = 32, ··· 316 316 }; 317 317 318 318 struct ahci_host_priv { 319 - void __iomem * mmio; /* bus-independent mem map */ 319 + /* Input fields */ 320 320 unsigned int flags; /* AHCI_HFLAG_* */ 321 + u32 force_port_map; /* force port map */ 322 + u32 mask_port_map; /* mask out particular bits */ 323 + 324 + void __iomem * mmio; /* bus-independent mem map */ 321 325 u32 cap; /* cap to use */ 322 326 u32 cap2; /* cap2 to use */ 323 327 u32 port_map; /* port map to use */ ··· 334 330 bool got_runtime_pm; /* Did we do pm_runtime_get? */ 335 331 struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ 336 332 struct regulator *target_pwr; /* Optional */ 337 - struct phy *phy; /* If platform uses phy */ 333 + /* 334 + * If platform uses PHYs. There is a 1:1 relation between the port number and 335 + * the PHY position in this array. 336 + */ 337 + struct phy **phys; 338 + unsigned nports; /* Number of ports */ 338 339 void *plat_data; /* Other platform data */ 339 340 /* 340 341 * Optional ahci_start_engine override, if not set this gets set to the ··· 370 361 void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, 371 362 u32 opts); 372 363 void ahci_save_initial_config(struct device *dev, 373 - struct ahci_host_priv *hpriv, 374 - unsigned int force_port_map, 375 - unsigned int mask_port_map); 364 + struct ahci_host_priv *hpriv); 376 365 void ahci_init_controller(struct ata_host *host); 377 366 int ahci_reset_controller(struct ata_host *host); 378 367
+1 -2
drivers/ata/ahci_da850.c
··· 85 85 86 86 da850_sata_init(dev, pwrdn_reg, hpriv->mmio); 87 87 88 - rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info, 89 - 0, 0, 0); 88 + rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info); 90 89 if (rc) 91 90 goto disable_resources; 92 91
+176 -11
drivers/ata/ahci_imx.c
··· 64 64 struct regmap *gpr; 65 65 bool no_device; 66 66 bool first_time; 67 + u32 phy_params; 67 68 }; 68 69 69 70 static int ahci_imx_hotplug; ··· 249 248 IMX6Q_GPR13_SATA_TX_LVL_MASK | 250 249 IMX6Q_GPR13_SATA_MPLL_CLK_EN | 251 250 IMX6Q_GPR13_SATA_TX_EDGE_RATE, 252 - IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB | 253 - IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M | 254 - IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F | 255 - IMX6Q_GPR13_SATA_SPD_MODE_3P0G | 256 - IMX6Q_GPR13_SATA_MPLL_SS_EN | 257 - IMX6Q_GPR13_SATA_TX_ATTEN_9_16 | 258 - IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB | 259 - IMX6Q_GPR13_SATA_TX_LVL_1_025_V); 251 + imxpriv->phy_params); 260 252 regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 261 253 IMX6Q_GPR13_SATA_MPLL_CLK_EN, 262 254 IMX6Q_GPR13_SATA_MPLL_CLK_EN); ··· 259 265 ret = imx_sata_phy_reset(hpriv); 260 266 if (ret) { 261 267 dev_err(dev, "failed to reset phy: %d\n", ret); 262 - goto disable_regulator; 268 + goto disable_clk; 263 269 } 264 270 } 265 271 ··· 267 273 268 274 return 0; 269 275 276 + disable_clk: 277 + clk_disable_unprepare(imxpriv->sata_ref_clk); 270 278 disable_regulator: 271 279 if (hpriv->target_pwr) 272 280 regulator_disable(hpriv->target_pwr); ··· 365 369 }; 366 370 MODULE_DEVICE_TABLE(of, imx_ahci_of_match); 367 371 372 + struct reg_value { 373 + u32 of_value; 374 + u32 reg_value; 375 + }; 376 + 377 + struct reg_property { 378 + const char *name; 379 + const struct reg_value *values; 380 + size_t num_values; 381 + u32 def_value; 382 + u32 set_value; 383 + }; 384 + 385 + static const struct reg_value gpr13_tx_level[] = { 386 + { 937, IMX6Q_GPR13_SATA_TX_LVL_0_937_V }, 387 + { 947, IMX6Q_GPR13_SATA_TX_LVL_0_947_V }, 388 + { 957, IMX6Q_GPR13_SATA_TX_LVL_0_957_V }, 389 + { 966, IMX6Q_GPR13_SATA_TX_LVL_0_966_V }, 390 + { 976, IMX6Q_GPR13_SATA_TX_LVL_0_976_V }, 391 + { 986, IMX6Q_GPR13_SATA_TX_LVL_0_986_V }, 392 + { 996, IMX6Q_GPR13_SATA_TX_LVL_0_996_V }, 393 + { 1005, IMX6Q_GPR13_SATA_TX_LVL_1_005_V }, 394 + { 1015, IMX6Q_GPR13_SATA_TX_LVL_1_015_V }, 395 + { 1025, IMX6Q_GPR13_SATA_TX_LVL_1_025_V }, 396 + { 1035, IMX6Q_GPR13_SATA_TX_LVL_1_035_V }, 397 + { 1045, IMX6Q_GPR13_SATA_TX_LVL_1_045_V }, 398 + { 1054, IMX6Q_GPR13_SATA_TX_LVL_1_054_V }, 399 + { 1064, IMX6Q_GPR13_SATA_TX_LVL_1_064_V }, 400 + { 1074, IMX6Q_GPR13_SATA_TX_LVL_1_074_V }, 401 + { 1084, IMX6Q_GPR13_SATA_TX_LVL_1_084_V }, 402 + { 1094, IMX6Q_GPR13_SATA_TX_LVL_1_094_V }, 403 + { 1104, IMX6Q_GPR13_SATA_TX_LVL_1_104_V }, 404 + { 1113, IMX6Q_GPR13_SATA_TX_LVL_1_113_V }, 405 + { 1123, IMX6Q_GPR13_SATA_TX_LVL_1_123_V }, 406 + { 1133, IMX6Q_GPR13_SATA_TX_LVL_1_133_V }, 407 + { 1143, IMX6Q_GPR13_SATA_TX_LVL_1_143_V }, 408 + { 1152, IMX6Q_GPR13_SATA_TX_LVL_1_152_V }, 409 + { 1162, IMX6Q_GPR13_SATA_TX_LVL_1_162_V }, 410 + { 1172, IMX6Q_GPR13_SATA_TX_LVL_1_172_V }, 411 + { 1182, IMX6Q_GPR13_SATA_TX_LVL_1_182_V }, 412 + { 1191, IMX6Q_GPR13_SATA_TX_LVL_1_191_V }, 413 + { 1201, IMX6Q_GPR13_SATA_TX_LVL_1_201_V }, 414 + { 1211, IMX6Q_GPR13_SATA_TX_LVL_1_211_V }, 415 + { 1221, IMX6Q_GPR13_SATA_TX_LVL_1_221_V }, 416 + { 1230, IMX6Q_GPR13_SATA_TX_LVL_1_230_V }, 417 + { 1240, IMX6Q_GPR13_SATA_TX_LVL_1_240_V } 418 + }; 419 + 420 + static const struct reg_value gpr13_tx_boost[] = { 421 + { 0, IMX6Q_GPR13_SATA_TX_BOOST_0_00_DB }, 422 + { 370, IMX6Q_GPR13_SATA_TX_BOOST_0_37_DB }, 423 + { 740, IMX6Q_GPR13_SATA_TX_BOOST_0_74_DB }, 424 + { 1110, IMX6Q_GPR13_SATA_TX_BOOST_1_11_DB }, 425 + { 1480, IMX6Q_GPR13_SATA_TX_BOOST_1_48_DB }, 426 + { 1850, IMX6Q_GPR13_SATA_TX_BOOST_1_85_DB }, 427 + { 2220, IMX6Q_GPR13_SATA_TX_BOOST_2_22_DB }, 428 + { 2590, IMX6Q_GPR13_SATA_TX_BOOST_2_59_DB }, 429 + { 2960, IMX6Q_GPR13_SATA_TX_BOOST_2_96_DB }, 430 + { 3330, IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB }, 431 + { 3700, IMX6Q_GPR13_SATA_TX_BOOST_3_70_DB }, 432 + { 4070, IMX6Q_GPR13_SATA_TX_BOOST_4_07_DB }, 433 + { 4440, IMX6Q_GPR13_SATA_TX_BOOST_4_44_DB }, 434 + { 4810, IMX6Q_GPR13_SATA_TX_BOOST_4_81_DB }, 435 + { 5280, IMX6Q_GPR13_SATA_TX_BOOST_5_28_DB }, 436 + { 5750, IMX6Q_GPR13_SATA_TX_BOOST_5_75_DB } 437 + }; 438 + 439 + static const struct reg_value gpr13_tx_atten[] = { 440 + { 8, IMX6Q_GPR13_SATA_TX_ATTEN_8_16 }, 441 + { 9, IMX6Q_GPR13_SATA_TX_ATTEN_9_16 }, 442 + { 10, IMX6Q_GPR13_SATA_TX_ATTEN_10_16 }, 443 + { 12, IMX6Q_GPR13_SATA_TX_ATTEN_12_16 }, 444 + { 14, IMX6Q_GPR13_SATA_TX_ATTEN_14_16 }, 445 + { 16, IMX6Q_GPR13_SATA_TX_ATTEN_16_16 }, 446 + }; 447 + 448 + static const struct reg_value gpr13_rx_eq[] = { 449 + { 500, IMX6Q_GPR13_SATA_RX_EQ_VAL_0_5_DB }, 450 + { 1000, IMX6Q_GPR13_SATA_RX_EQ_VAL_1_0_DB }, 451 + { 1500, IMX6Q_GPR13_SATA_RX_EQ_VAL_1_5_DB }, 452 + { 2000, IMX6Q_GPR13_SATA_RX_EQ_VAL_2_0_DB }, 453 + { 2500, IMX6Q_GPR13_SATA_RX_EQ_VAL_2_5_DB }, 454 + { 3000, IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB }, 455 + { 3500, IMX6Q_GPR13_SATA_RX_EQ_VAL_3_5_DB }, 456 + { 4000, IMX6Q_GPR13_SATA_RX_EQ_VAL_4_0_DB }, 457 + }; 458 + 459 + static const struct reg_property gpr13_props[] = { 460 + { 461 + .name = "fsl,transmit-level-mV", 462 + .values = gpr13_tx_level, 463 + .num_values = ARRAY_SIZE(gpr13_tx_level), 464 + .def_value = IMX6Q_GPR13_SATA_TX_LVL_1_025_V, 465 + }, { 466 + .name = "fsl,transmit-boost-mdB", 467 + .values = gpr13_tx_boost, 468 + .num_values = ARRAY_SIZE(gpr13_tx_boost), 469 + .def_value = IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB, 470 + }, { 471 + .name = "fsl,transmit-atten-16ths", 472 + .values = gpr13_tx_atten, 473 + .num_values = ARRAY_SIZE(gpr13_tx_atten), 474 + .def_value = IMX6Q_GPR13_SATA_TX_ATTEN_9_16, 475 + }, { 476 + .name = "fsl,receive-eq-mdB", 477 + .values = gpr13_rx_eq, 478 + .num_values = ARRAY_SIZE(gpr13_rx_eq), 479 + .def_value = IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB, 480 + }, { 481 + .name = "fsl,no-spread-spectrum", 482 + .def_value = IMX6Q_GPR13_SATA_MPLL_SS_EN, 483 + .set_value = 0, 484 + }, 485 + }; 486 + 487 + static u32 imx_ahci_parse_props(struct device *dev, 488 + const struct reg_property *prop, size_t num) 489 + { 490 + struct device_node *np = dev->of_node; 491 + u32 reg_value = 0; 492 + int i, j; 493 + 494 + for (i = 0; i < num; i++, prop++) { 495 + u32 of_val; 496 + 497 + if (prop->num_values == 0) { 498 + if (of_property_read_bool(np, prop->name)) 499 + reg_value |= prop->set_value; 500 + else 501 + reg_value |= prop->def_value; 502 + continue; 503 + } 504 + 505 + if (of_property_read_u32(np, prop->name, &of_val)) { 506 + dev_info(dev, "%s not specified, using %08x\n", 507 + prop->name, prop->def_value); 508 + reg_value |= prop->def_value; 509 + continue; 510 + } 511 + 512 + for (j = 0; j < prop->num_values; j++) { 513 + if (prop->values[j].of_value == of_val) { 514 + dev_info(dev, "%s value %u, using %08x\n", 515 + prop->name, of_val, prop->values[j].reg_value); 516 + reg_value |= prop->values[j].reg_value; 517 + break; 518 + } 519 + } 520 + 521 + if (j == prop->num_values) { 522 + dev_err(dev, "DT property %s is not a valid value\n", 523 + prop->name); 524 + reg_value |= prop->def_value; 525 + } 526 + } 527 + 528 + return reg_value; 529 + } 530 + 368 531 static int imx_ahci_probe(struct platform_device *pdev) 369 532 { 370 533 struct device *dev = &pdev->dev; ··· 565 410 } 566 411 567 412 if (imxpriv->type == AHCI_IMX6Q) { 413 + u32 reg_value; 414 + 568 415 imxpriv->gpr = syscon_regmap_lookup_by_compatible( 569 416 "fsl,imx6q-iomuxc-gpr"); 570 417 if (IS_ERR(imxpriv->gpr)) { ··· 574 417 "failed to find fsl,imx6q-iomux-gpr regmap\n"); 575 418 return PTR_ERR(imxpriv->gpr); 576 419 } 420 + 421 + reg_value = imx_ahci_parse_props(dev, gpr13_props, 422 + ARRAY_SIZE(gpr13_props)); 423 + 424 + imxpriv->phy_params = 425 + IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M | 426 + IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F | 427 + IMX6Q_GPR13_SATA_SPD_MODE_3P0G | 428 + reg_value; 577 429 } 578 430 579 431 hpriv = ahci_platform_get_resources(pdev); ··· 620 454 reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; 621 455 writel(reg_val, hpriv->mmio + IMX_TIMER1MS); 622 456 623 - ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, 624 - 0, 0, 0); 457 + ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info); 625 458 if (ret) 626 459 goto disable_sata; 627 460
+1 -2
drivers/ata/ahci_mvebu.c
··· 88 88 ahci_mvebu_mbus_config(hpriv, dram); 89 89 ahci_mvebu_regret_option(hpriv); 90 90 91 - rc = ahci_platform_init_host(pdev, hpriv, &ahci_mvebu_port_info, 92 - 0, 0, 0); 91 + rc = ahci_platform_init_host(pdev, hpriv, &ahci_mvebu_port_info); 93 92 if (rc) 94 93 goto disable_resources; 95 94
+4 -4
drivers/ata/ahci_platform.c
··· 34 34 struct device *dev = &pdev->dev; 35 35 struct ahci_platform_data *pdata = dev_get_platdata(dev); 36 36 struct ahci_host_priv *hpriv; 37 - unsigned long hflags = 0; 38 37 int rc; 39 38 40 39 hpriv = ahci_platform_get_resources(pdev); ··· 57 58 } 58 59 59 60 if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) 60 - hflags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; 61 + hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; 61 62 62 - rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info, 63 - hflags, 0, 0); 63 + rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info); 64 64 if (rc) 65 65 goto pdata_exit; 66 66 ··· 76 78 ahci_platform_resume); 77 79 78 80 static const struct of_device_id ahci_of_match[] = { 81 + { .compatible = "generic-ahci", }, 82 + /* Keep the following compatibles for device tree compatibility */ 79 83 { .compatible = "snps,spear-ahci", }, 80 84 { .compatible = "snps,exynos5440-ahci", }, 81 85 { .compatible = "ibm,476gtr-ahci", },
+2 -2
drivers/ata/ahci_st.c
··· 166 166 if (err) 167 167 return err; 168 168 169 - err = ahci_platform_init_host(pdev, hpriv, &st_ahci_port_info, 0, 0, 0); 169 + err = ahci_platform_init_host(pdev, hpriv, &st_ahci_port_info); 170 170 if (err) { 171 171 ahci_platform_disable_resources(hpriv); 172 172 return err; ··· 221 221 222 222 static SIMPLE_DEV_PM_OPS(st_ahci_pm_ops, st_ahci_suspend, st_ahci_resume); 223 223 224 - static struct of_device_id st_ahci_match[] = { 224 + static const struct of_device_id st_ahci_match[] = { 225 225 { .compatible = "st,ahci", }, 226 226 {}, 227 227 };
+3 -5
drivers/ata/ahci_sunxi.c
··· 167 167 { 168 168 struct device *dev = &pdev->dev; 169 169 struct ahci_host_priv *hpriv; 170 - unsigned long hflags; 171 170 int rc; 172 171 173 172 hpriv = ahci_platform_get_resources(pdev); ··· 183 184 if (rc) 184 185 goto disable_resources; 185 186 186 - hflags = AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI | 187 - AHCI_HFLAG_NO_PMP | AHCI_HFLAG_YES_NCQ; 187 + hpriv->flags = AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI | 188 + AHCI_HFLAG_NO_PMP | AHCI_HFLAG_YES_NCQ; 188 189 189 - rc = ahci_platform_init_host(pdev, hpriv, &ahci_sunxi_port_info, 190 - hflags, 0, 0); 190 + rc = ahci_platform_init_host(pdev, hpriv, &ahci_sunxi_port_info); 191 191 if (rc) 192 192 goto disable_resources; 193 193
+376
drivers/ata/ahci_tegra.c
··· 1 + /* 2 + * drivers/ata/ahci_tegra.c 3 + * 4 + * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. 5 + * 6 + * Author: 7 + * Mikko Perttunen <mperttunen@nvidia.com> 8 + * 9 + * This software is licensed under the terms of the GNU General Public 10 + * License version 2, as published by the Free Software Foundation, and 11 + * may be copied, distributed, and modified under those terms. 12 + * 13 + * This program is distributed in the hope that it will be useful, 14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + * GNU General Public License for more details. 17 + * 18 + */ 19 + 20 + #include <linux/ahci_platform.h> 21 + #include <linux/reset.h> 22 + #include <linux/errno.h> 23 + #include <linux/kernel.h> 24 + #include <linux/module.h> 25 + #include <linux/of_device.h> 26 + #include <linux/platform_device.h> 27 + #include <linux/tegra-powergate.h> 28 + #include <linux/regulator/consumer.h> 29 + #include "ahci.h" 30 + 31 + #define SATA_CONFIGURATION_0 0x180 32 + #define SATA_CONFIGURATION_EN_FPCI BIT(0) 33 + 34 + #define SCFG_OFFSET 0x1000 35 + 36 + #define T_SATA0_CFG_1 0x04 37 + #define T_SATA0_CFG_1_IO_SPACE BIT(0) 38 + #define T_SATA0_CFG_1_MEMORY_SPACE BIT(1) 39 + #define T_SATA0_CFG_1_BUS_MASTER BIT(2) 40 + #define T_SATA0_CFG_1_SERR BIT(8) 41 + 42 + #define T_SATA0_CFG_9 0x24 43 + #define T_SATA0_CFG_9_BASE_ADDRESS_SHIFT 13 44 + 45 + #define SATA_FPCI_BAR5 0x94 46 + #define SATA_FPCI_BAR5_START_SHIFT 4 47 + 48 + #define SATA_INTR_MASK 0x188 49 + #define SATA_INTR_MASK_IP_INT_MASK BIT(16) 50 + 51 + #define T_SATA0_AHCI_HBA_CAP_BKDR 0x300 52 + 53 + #define T_SATA0_BKDOOR_CC 0x4a4 54 + 55 + #define T_SATA0_CFG_SATA 0x54c 56 + #define T_SATA0_CFG_SATA_BACKDOOR_PROG_IF_EN BIT(12) 57 + 58 + #define T_SATA0_CFG_MISC 0x550 59 + 60 + #define T_SATA0_INDEX 0x680 61 + 62 + #define T_SATA0_CHX_PHY_CTRL1_GEN1 0x690 63 + #define T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_MASK 0xff 64 + #define T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_SHIFT 0 65 + #define T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_MASK (0xff << 8) 66 + #define T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_SHIFT 8 67 + 68 + #define T_SATA0_CHX_PHY_CTRL1_GEN2 0x694 69 + #define T_SATA0_CHX_PHY_CTRL1_GEN2_TX_AMP_MASK 0xff 70 + #define T_SATA0_CHX_PHY_CTRL1_GEN2_TX_AMP_SHIFT 0 71 + #define T_SATA0_CHX_PHY_CTRL1_GEN2_TX_PEAK_MASK (0xff << 12) 72 + #define T_SATA0_CHX_PHY_CTRL1_GEN2_TX_PEAK_SHIFT 12 73 + 74 + #define T_SATA0_CHX_PHY_CTRL2 0x69c 75 + #define T_SATA0_CHX_PHY_CTRL2_CDR_CNTL_GEN1 0x23 76 + 77 + #define T_SATA0_CHX_PHY_CTRL11 0x6d0 78 + #define T_SATA0_CHX_PHY_CTRL11_GEN2_RX_EQ (0x2800 << 16) 79 + 80 + #define FUSE_SATA_CALIB 0x124 81 + #define FUSE_SATA_CALIB_MASK 0x3 82 + 83 + struct sata_pad_calibration { 84 + u8 gen1_tx_amp; 85 + u8 gen1_tx_peak; 86 + u8 gen2_tx_amp; 87 + u8 gen2_tx_peak; 88 + }; 89 + 90 + static const struct sata_pad_calibration tegra124_pad_calibration[] = { 91 + {0x18, 0x04, 0x18, 0x0a}, 92 + {0x0e, 0x04, 0x14, 0x0a}, 93 + {0x0e, 0x07, 0x1a, 0x0e}, 94 + {0x14, 0x0e, 0x1a, 0x0e}, 95 + }; 96 + 97 + struct tegra_ahci_priv { 98 + struct platform_device *pdev; 99 + void __iomem *sata_regs; 100 + struct reset_control *sata_rst; 101 + struct reset_control *sata_oob_rst; 102 + struct reset_control *sata_cold_rst; 103 + /* Needs special handling, cannot use ahci_platform */ 104 + struct clk *sata_clk; 105 + struct regulator_bulk_data supplies[5]; 106 + }; 107 + 108 + static int tegra_ahci_power_on(struct ahci_host_priv *hpriv) 109 + { 110 + struct tegra_ahci_priv *tegra = hpriv->plat_data; 111 + int ret; 112 + 113 + ret = regulator_bulk_enable(ARRAY_SIZE(tegra->supplies), 114 + tegra->supplies); 115 + if (ret) 116 + return ret; 117 + 118 + ret = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_SATA, 119 + tegra->sata_clk, 120 + tegra->sata_rst); 121 + if (ret) 122 + goto disable_regulators; 123 + 124 + reset_control_assert(tegra->sata_oob_rst); 125 + reset_control_assert(tegra->sata_cold_rst); 126 + 127 + ret = ahci_platform_enable_resources(hpriv); 128 + if (ret) 129 + goto disable_power; 130 + 131 + reset_control_deassert(tegra->sata_cold_rst); 132 + reset_control_deassert(tegra->sata_oob_rst); 133 + 134 + return 0; 135 + 136 + disable_power: 137 + clk_disable_unprepare(tegra->sata_clk); 138 + 139 + tegra_powergate_power_off(TEGRA_POWERGATE_SATA); 140 + 141 + disable_regulators: 142 + regulator_bulk_disable(ARRAY_SIZE(tegra->supplies), tegra->supplies); 143 + 144 + return ret; 145 + } 146 + 147 + static void tegra_ahci_power_off(struct ahci_host_priv *hpriv) 148 + { 149 + struct tegra_ahci_priv *tegra = hpriv->plat_data; 150 + 151 + ahci_platform_disable_resources(hpriv); 152 + 153 + reset_control_assert(tegra->sata_rst); 154 + reset_control_assert(tegra->sata_oob_rst); 155 + reset_control_assert(tegra->sata_cold_rst); 156 + 157 + clk_disable_unprepare(tegra->sata_clk); 158 + tegra_powergate_power_off(TEGRA_POWERGATE_SATA); 159 + 160 + regulator_bulk_disable(ARRAY_SIZE(tegra->supplies), tegra->supplies); 161 + } 162 + 163 + static int tegra_ahci_controller_init(struct ahci_host_priv *hpriv) 164 + { 165 + struct tegra_ahci_priv *tegra = hpriv->plat_data; 166 + int ret; 167 + unsigned int val; 168 + struct sata_pad_calibration calib; 169 + 170 + ret = tegra_ahci_power_on(hpriv); 171 + if (ret) { 172 + dev_err(&tegra->pdev->dev, 173 + "failed to power on AHCI controller: %d\n", ret); 174 + return ret; 175 + } 176 + 177 + val = readl(tegra->sata_regs + SATA_CONFIGURATION_0); 178 + val |= SATA_CONFIGURATION_EN_FPCI; 179 + writel(val, tegra->sata_regs + SATA_CONFIGURATION_0); 180 + 181 + /* Pad calibration */ 182 + 183 + /* FIXME Always use calibration 0. Change this to read the calibration 184 + * fuse once the fuse driver has landed. */ 185 + val = 0; 186 + 187 + calib = tegra124_pad_calibration[val & FUSE_SATA_CALIB_MASK]; 188 + 189 + writel(BIT(0), tegra->sata_regs + SCFG_OFFSET + T_SATA0_INDEX); 190 + 191 + val = readl(tegra->sata_regs + 192 + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL1_GEN1); 193 + val &= ~T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_MASK; 194 + val &= ~T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_MASK; 195 + val |= calib.gen1_tx_amp << 196 + T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_SHIFT; 197 + val |= calib.gen1_tx_peak << 198 + T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_SHIFT; 199 + writel(val, tegra->sata_regs + SCFG_OFFSET + 200 + T_SATA0_CHX_PHY_CTRL1_GEN1); 201 + 202 + val = readl(tegra->sata_regs + 203 + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL1_GEN2); 204 + val &= ~T_SATA0_CHX_PHY_CTRL1_GEN2_TX_AMP_MASK; 205 + val &= ~T_SATA0_CHX_PHY_CTRL1_GEN2_TX_PEAK_MASK; 206 + val |= calib.gen2_tx_amp << 207 + T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_SHIFT; 208 + val |= calib.gen2_tx_peak << 209 + T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_SHIFT; 210 + writel(val, tegra->sata_regs + SCFG_OFFSET + 211 + T_SATA0_CHX_PHY_CTRL1_GEN2); 212 + 213 + writel(T_SATA0_CHX_PHY_CTRL11_GEN2_RX_EQ, 214 + tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL11); 215 + writel(T_SATA0_CHX_PHY_CTRL2_CDR_CNTL_GEN1, 216 + tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL2); 217 + 218 + writel(0, tegra->sata_regs + SCFG_OFFSET + T_SATA0_INDEX); 219 + 220 + /* Program controller device ID */ 221 + 222 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_SATA); 223 + val |= T_SATA0_CFG_SATA_BACKDOOR_PROG_IF_EN; 224 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_SATA); 225 + 226 + writel(0x01060100, tegra->sata_regs + SCFG_OFFSET + T_SATA0_BKDOOR_CC); 227 + 228 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_SATA); 229 + val &= ~T_SATA0_CFG_SATA_BACKDOOR_PROG_IF_EN; 230 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_SATA); 231 + 232 + /* Enable IO & memory access, bus master mode */ 233 + 234 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_1); 235 + val |= T_SATA0_CFG_1_IO_SPACE | T_SATA0_CFG_1_MEMORY_SPACE | 236 + T_SATA0_CFG_1_BUS_MASTER | T_SATA0_CFG_1_SERR; 237 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_1); 238 + 239 + /* Program SATA MMIO */ 240 + 241 + writel(0x10000 << SATA_FPCI_BAR5_START_SHIFT, 242 + tegra->sata_regs + SATA_FPCI_BAR5); 243 + 244 + writel(0x08000 << T_SATA0_CFG_9_BASE_ADDRESS_SHIFT, 245 + tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_9); 246 + 247 + /* Unmask SATA interrupts */ 248 + 249 + val = readl(tegra->sata_regs + SATA_INTR_MASK); 250 + val |= SATA_INTR_MASK_IP_INT_MASK; 251 + writel(val, tegra->sata_regs + SATA_INTR_MASK); 252 + 253 + return 0; 254 + } 255 + 256 + static void tegra_ahci_controller_deinit(struct ahci_host_priv *hpriv) 257 + { 258 + tegra_ahci_power_off(hpriv); 259 + } 260 + 261 + static void tegra_ahci_host_stop(struct ata_host *host) 262 + { 263 + struct ahci_host_priv *hpriv = host->private_data; 264 + 265 + tegra_ahci_controller_deinit(hpriv); 266 + } 267 + 268 + static struct ata_port_operations ahci_tegra_port_ops = { 269 + .inherits = &ahci_ops, 270 + .host_stop = tegra_ahci_host_stop, 271 + }; 272 + 273 + static const struct ata_port_info ahci_tegra_port_info = { 274 + .flags = AHCI_FLAG_COMMON, 275 + .pio_mask = ATA_PIO4, 276 + .udma_mask = ATA_UDMA6, 277 + .port_ops = &ahci_tegra_port_ops, 278 + }; 279 + 280 + static const struct of_device_id tegra_ahci_of_match[] = { 281 + { .compatible = "nvidia,tegra124-ahci" }, 282 + {} 283 + }; 284 + MODULE_DEVICE_TABLE(of, tegra_ahci_of_match); 285 + 286 + static int tegra_ahci_probe(struct platform_device *pdev) 287 + { 288 + struct ahci_host_priv *hpriv; 289 + struct tegra_ahci_priv *tegra; 290 + struct resource *res; 291 + int ret; 292 + 293 + hpriv = ahci_platform_get_resources(pdev); 294 + if (IS_ERR(hpriv)) 295 + return PTR_ERR(hpriv); 296 + 297 + tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); 298 + if (!tegra) 299 + return -ENOMEM; 300 + 301 + hpriv->plat_data = tegra; 302 + 303 + tegra->pdev = pdev; 304 + 305 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 306 + tegra->sata_regs = devm_ioremap_resource(&pdev->dev, res); 307 + if (IS_ERR(tegra->sata_regs)) 308 + return PTR_ERR(tegra->sata_regs); 309 + 310 + tegra->sata_rst = devm_reset_control_get(&pdev->dev, "sata"); 311 + if (IS_ERR(tegra->sata_rst)) { 312 + dev_err(&pdev->dev, "Failed to get sata reset\n"); 313 + return PTR_ERR(tegra->sata_rst); 314 + } 315 + 316 + tegra->sata_oob_rst = devm_reset_control_get(&pdev->dev, "sata-oob"); 317 + if (IS_ERR(tegra->sata_oob_rst)) { 318 + dev_err(&pdev->dev, "Failed to get sata-oob reset\n"); 319 + return PTR_ERR(tegra->sata_oob_rst); 320 + } 321 + 322 + tegra->sata_cold_rst = devm_reset_control_get(&pdev->dev, "sata-cold"); 323 + if (IS_ERR(tegra->sata_cold_rst)) { 324 + dev_err(&pdev->dev, "Failed to get sata-cold reset\n"); 325 + return PTR_ERR(tegra->sata_cold_rst); 326 + } 327 + 328 + tegra->sata_clk = devm_clk_get(&pdev->dev, "sata"); 329 + if (IS_ERR(tegra->sata_clk)) { 330 + dev_err(&pdev->dev, "Failed to get sata clock\n"); 331 + return PTR_ERR(tegra->sata_clk); 332 + } 333 + 334 + tegra->supplies[0].supply = "avdd"; 335 + tegra->supplies[1].supply = "hvdd"; 336 + tegra->supplies[2].supply = "vddio"; 337 + tegra->supplies[3].supply = "target-5v"; 338 + tegra->supplies[4].supply = "target-12v"; 339 + 340 + ret = devm_regulator_bulk_get(&pdev->dev, ARRAY_SIZE(tegra->supplies), 341 + tegra->supplies); 342 + if (ret) { 343 + dev_err(&pdev->dev, "Failed to get regulators\n"); 344 + return ret; 345 + } 346 + 347 + ret = tegra_ahci_controller_init(hpriv); 348 + if (ret) 349 + return ret; 350 + 351 + ret = ahci_platform_init_host(pdev, hpriv, &ahci_tegra_port_info); 352 + if (ret) 353 + goto deinit_controller; 354 + 355 + return 0; 356 + 357 + deinit_controller: 358 + tegra_ahci_controller_deinit(hpriv); 359 + 360 + return ret; 361 + }; 362 + 363 + static struct platform_driver tegra_ahci_driver = { 364 + .probe = tegra_ahci_probe, 365 + .remove = ata_platform_remove_one, 366 + .driver = { 367 + .name = "tegra-ahci", 368 + .of_match_table = tegra_ahci_of_match, 369 + }, 370 + /* LP0 suspend support not implemented */ 371 + }; 372 + module_platform_driver(tegra_ahci_driver); 373 + 374 + MODULE_AUTHOR("Mikko Perttunen <mperttunen@nvidia.com>"); 375 + MODULE_DESCRIPTION("Tegra124 AHCI SATA driver"); 376 + MODULE_LICENSE("GPL v2");
+12 -17
drivers/ata/ahci_xgene.c
··· 67 67 #define PORTAXICFG 0x000000bc 68 68 #define PORTAXICFG_OUTTRANS_SET(dst, src) \ 69 69 (((dst) & ~0x00f00000) | (((u32)(src) << 0x14) & 0x00f00000)) 70 + #define PORTRANSCFG 0x000000c8 71 + #define PORTRANSCFG_RXWM_SET(dst, src) \ 72 + (((dst) & ~0x0000007f) | (((u32)(src)) & 0x0000007f)) 70 73 71 74 /* SATA host controller AXI CSR */ 72 75 #define INT_SLV_TMOMASK 0x00000010 ··· 196 193 /* Disable fix rate */ 197 194 writel(0x0001fffe, mmio + PORTPHY1CFG); 198 195 readl(mmio + PORTPHY1CFG); /* Force a barrier */ 199 - writel(0x5018461c, mmio + PORTPHY2CFG); 196 + writel(0x28183219, mmio + PORTPHY2CFG); 200 197 readl(mmio + PORTPHY2CFG); /* Force a barrier */ 201 - writel(0x1c081907, mmio + PORTPHY3CFG); 198 + writel(0x13081008, mmio + PORTPHY3CFG); 202 199 readl(mmio + PORTPHY3CFG); /* Force a barrier */ 203 - writel(0x1c080815, mmio + PORTPHY4CFG); 200 + writel(0x00480815, mmio + PORTPHY4CFG); 204 201 readl(mmio + PORTPHY4CFG); /* Force a barrier */ 205 202 /* Set window negotiation */ 206 203 val = readl(mmio + PORTPHY5CFG); ··· 212 209 val = PORTAXICFG_OUTTRANS_SET(val, 0xe); /* Set outstanding */ 213 210 writel(val, mmio + PORTAXICFG); 214 211 readl(mmio + PORTAXICFG); /* Force a barrier */ 212 + /* Set the watermark threshold of the receive FIFO */ 213 + val = readl(mmio + PORTRANSCFG); 214 + val = PORTRANSCFG_RXWM_SET(val, 0x30); 215 + writel(val, mmio + PORTRANSCFG); 215 216 } 216 217 217 218 /** ··· 422 415 struct ahci_host_priv *hpriv; 423 416 struct xgene_ahci_context *ctx; 424 417 struct resource *res; 425 - unsigned long hflags; 426 418 int rc; 427 419 428 420 hpriv = ahci_platform_get_resources(pdev); ··· 480 474 /* Configure the host controller */ 481 475 xgene_ahci_hw_init(hpriv); 482 476 483 - /* 484 - * Setup DMA mask. This is preliminary until the DMA range is sorted 485 - * out. 486 - */ 487 - rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); 488 - if (rc) { 489 - dev_err(dev, "Unable to set dma mask\n"); 490 - goto disable_resources; 491 - } 477 + hpriv->flags = AHCI_HFLAG_NO_PMP | AHCI_HFLAG_YES_NCQ; 492 478 493 - hflags = AHCI_HFLAG_NO_PMP | AHCI_HFLAG_YES_NCQ; 494 - 495 - rc = ahci_platform_init_host(pdev, hpriv, &xgene_ahci_port_info, 496 - hflags, 0, 0); 479 + rc = ahci_platform_init_host(pdev, hpriv, &xgene_ahci_port_info); 497 480 if (rc) 498 481 goto disable_resources; 499 482
+7 -12
drivers/ata/libahci.c
··· 382 382 * ahci_save_initial_config - Save and fixup initial config values 383 383 * @dev: target AHCI device 384 384 * @hpriv: host private area to store config values 385 - * @force_port_map: force port map to a specified value 386 - * @mask_port_map: mask out particular bits from port map 387 385 * 388 386 * Some registers containing configuration info might be setup by 389 387 * BIOS and might be cleared on reset. This function saves the ··· 396 398 * LOCKING: 397 399 * None. 398 400 */ 399 - void ahci_save_initial_config(struct device *dev, 400 - struct ahci_host_priv *hpriv, 401 - unsigned int force_port_map, 402 - unsigned int mask_port_map) 401 + void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv) 403 402 { 404 403 void __iomem *mmio = hpriv->mmio; 405 404 u32 cap, cap2, vers, port_map; ··· 463 468 cap &= ~HOST_CAP_FBS; 464 469 } 465 470 466 - if (force_port_map && port_map != force_port_map) { 471 + if (hpriv->force_port_map && port_map != hpriv->force_port_map) { 467 472 dev_info(dev, "forcing port_map 0x%x -> 0x%x\n", 468 - port_map, force_port_map); 469 - port_map = force_port_map; 473 + port_map, hpriv->force_port_map); 474 + port_map = hpriv->force_port_map; 470 475 } 471 476 472 - if (mask_port_map) { 477 + if (hpriv->mask_port_map) { 473 478 dev_warn(dev, "masking port_map 0x%x -> 0x%x\n", 474 479 port_map, 475 - port_map & mask_port_map); 476 - port_map &= mask_port_map; 480 + port_map & hpriv->mask_port_map); 481 + port_map &= hpriv->mask_port_map; 477 482 } 478 483 479 484 /* cross check port_map and cap.n_ports */
+167 -48
drivers/ata/libahci_platform.c
··· 39 39 }; 40 40 41 41 /** 42 + * ahci_platform_enable_phys - Enable PHYs 43 + * @hpriv: host private area to store config values 44 + * 45 + * This function enables all the PHYs found in hpriv->phys, if any. 46 + * If a PHY fails to be enabled, it disables all the PHYs already 47 + * enabled in reverse order and returns an error. 48 + * 49 + * RETURNS: 50 + * 0 on success otherwise a negative error code 51 + */ 52 + int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) 53 + { 54 + int rc, i; 55 + 56 + for (i = 0; i < hpriv->nports; i++) { 57 + if (!hpriv->phys[i]) 58 + continue; 59 + 60 + rc = phy_init(hpriv->phys[i]); 61 + if (rc) 62 + goto disable_phys; 63 + 64 + rc = phy_power_on(hpriv->phys[i]); 65 + if (rc) { 66 + phy_exit(hpriv->phys[i]); 67 + goto disable_phys; 68 + } 69 + } 70 + 71 + return 0; 72 + 73 + disable_phys: 74 + while (--i >= 0) { 75 + phy_power_off(hpriv->phys[i]); 76 + phy_exit(hpriv->phys[i]); 77 + } 78 + return rc; 79 + } 80 + EXPORT_SYMBOL_GPL(ahci_platform_enable_phys); 81 + 82 + /** 83 + * ahci_platform_disable_phys - Disable PHYs 84 + * @hpriv: host private area to store config values 85 + * 86 + * This function disables all PHYs found in hpriv->phys. 87 + */ 88 + void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) 89 + { 90 + int i; 91 + 92 + for (i = 0; i < hpriv->nports; i++) { 93 + if (!hpriv->phys[i]) 94 + continue; 95 + 96 + phy_power_off(hpriv->phys[i]); 97 + phy_exit(hpriv->phys[i]); 98 + } 99 + } 100 + EXPORT_SYMBOL_GPL(ahci_platform_disable_phys); 101 + 102 + /** 42 103 * ahci_platform_enable_clks - Enable platform clocks 43 104 * @hpriv: host private area to store config values 44 105 * ··· 153 92 * following order: 154 93 * 1) Regulator 155 94 * 2) Clocks (through ahci_platform_enable_clks) 156 - * 3) Phy 95 + * 3) Phys 157 96 * 158 97 * If resource enabling fails at any point the previous enabled resources 159 98 * are disabled in reverse order. ··· 175 114 if (rc) 176 115 goto disable_regulator; 177 116 178 - if (hpriv->phy) { 179 - rc = phy_init(hpriv->phy); 180 - if (rc) 181 - goto disable_clks; 182 - 183 - rc = phy_power_on(hpriv->phy); 184 - if (rc) { 185 - phy_exit(hpriv->phy); 186 - goto disable_clks; 187 - } 188 - } 117 + rc = ahci_platform_enable_phys(hpriv); 118 + if (rc) 119 + goto disable_clks; 189 120 190 121 return 0; 191 122 ··· 197 144 * 198 145 * This function disables all ahci_platform managed resources in the 199 146 * following order: 200 - * 1) Phy 147 + * 1) Phys 201 148 * 2) Clocks (through ahci_platform_disable_clks) 202 149 * 3) Regulator 203 150 */ 204 151 void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) 205 152 { 206 - if (hpriv->phy) { 207 - phy_power_off(hpriv->phy); 208 - phy_exit(hpriv->phy); 209 - } 153 + ahci_platform_disable_phys(hpriv); 210 154 211 155 ahci_platform_disable_clks(hpriv); 212 156 ··· 237 187 * 2) regulator for controlling the targets power (optional) 238 188 * 3) 0 - AHCI_MAX_CLKS clocks, as specified in the devs devicetree node, 239 189 * or for non devicetree enabled platforms a single clock 240 - * 4) phy (optional) 190 + * 4) phys (optional) 241 191 * 242 192 * RETURNS: 243 193 * The allocated ahci_host_priv on success, otherwise an ERR_PTR value ··· 247 197 struct device *dev = &pdev->dev; 248 198 struct ahci_host_priv *hpriv; 249 199 struct clk *clk; 250 - int i, rc = -ENOMEM; 200 + struct device_node *child; 201 + int i, enabled_ports = 0, rc = -ENOMEM; 202 + u32 mask_port_map = 0; 251 203 252 204 if (!devres_open_group(dev, NULL, GFP_KERNEL)) 253 205 return ERR_PTR(-ENOMEM); ··· 298 246 hpriv->clks[i] = clk; 299 247 } 300 248 301 - hpriv->phy = devm_phy_get(dev, "sata-phy"); 302 - if (IS_ERR(hpriv->phy)) { 303 - rc = PTR_ERR(hpriv->phy); 304 - switch (rc) { 305 - case -ENOSYS: 306 - /* No PHY support. Check if PHY is required. */ 307 - if (of_find_property(dev->of_node, "phys", NULL)) { 308 - dev_err(dev, "couldn't get sata-phy: ENOSYS\n"); 249 + hpriv->nports = of_get_child_count(dev->of_node); 250 + 251 + if (hpriv->nports) { 252 + hpriv->phys = devm_kzalloc(dev, 253 + hpriv->nports * sizeof(*hpriv->phys), 254 + GFP_KERNEL); 255 + if (!hpriv->phys) { 256 + rc = -ENOMEM; 257 + goto err_out; 258 + } 259 + 260 + for_each_child_of_node(dev->of_node, child) { 261 + u32 port; 262 + 263 + if (!of_device_is_available(child)) 264 + continue; 265 + 266 + if (of_property_read_u32(child, "reg", &port)) { 267 + rc = -EINVAL; 309 268 goto err_out; 310 269 } 311 - case -ENODEV: 312 - /* continue normally */ 313 - hpriv->phy = NULL; 314 - break; 315 270 316 - case -EPROBE_DEFER: 317 - goto err_out; 271 + if (port >= hpriv->nports) { 272 + dev_warn(dev, "invalid port number %d\n", port); 273 + continue; 274 + } 318 275 319 - default: 320 - dev_err(dev, "couldn't get sata-phy\n"); 276 + mask_port_map |= BIT(port); 277 + 278 + hpriv->phys[port] = devm_of_phy_get(dev, child, NULL); 279 + if (IS_ERR(hpriv->phys[port])) { 280 + rc = PTR_ERR(hpriv->phys[port]); 281 + dev_err(dev, 282 + "couldn't get PHY in node %s: %d\n", 283 + child->name, rc); 284 + goto err_out; 285 + } 286 + 287 + enabled_ports++; 288 + } 289 + if (!enabled_ports) { 290 + dev_warn(dev, "No port enabled\n"); 291 + rc = -ENODEV; 321 292 goto err_out; 293 + } 294 + 295 + if (!hpriv->mask_port_map) 296 + hpriv->mask_port_map = mask_port_map; 297 + } else { 298 + /* 299 + * If no sub-node was found, keep this for device tree 300 + * compatibility 301 + */ 302 + struct phy *phy = devm_phy_get(dev, "sata-phy"); 303 + if (!IS_ERR(phy)) { 304 + hpriv->phys = devm_kzalloc(dev, sizeof(*hpriv->phys), 305 + GFP_KERNEL); 306 + if (!hpriv->phys) { 307 + rc = -ENOMEM; 308 + goto err_out; 309 + } 310 + 311 + hpriv->phys[0] = phy; 312 + hpriv->nports = 1; 313 + } else { 314 + rc = PTR_ERR(phy); 315 + switch (rc) { 316 + case -ENOSYS: 317 + /* No PHY support. Check if PHY is required. */ 318 + if (of_find_property(dev->of_node, "phys", NULL)) { 319 + dev_err(dev, "couldn't get sata-phy: ENOSYS\n"); 320 + goto err_out; 321 + } 322 + case -ENODEV: 323 + /* continue normally */ 324 + hpriv->phys = NULL; 325 + break; 326 + 327 + default: 328 + goto err_out; 329 + 330 + } 322 331 } 323 332 } 324 333 ··· 401 288 * @pdev: platform device pointer for the host 402 289 * @hpriv: ahci-host private data for the host 403 290 * @pi_template: template for the ata_port_info to use 404 - * @host_flags: ahci host flags used in ahci_host_priv 405 - * @force_port_map: param passed to ahci_save_initial_config 406 - * @mask_port_map: param passed to ahci_save_initial_config 407 291 * 408 292 * This function does all the usual steps needed to bring up an 409 - * ahci-platform host, note any necessary resources (ie clks, phy, etc.) 293 + * ahci-platform host, note any necessary resources (ie clks, phys, etc.) 410 294 * must be initialized / enabled before calling this. 411 295 * 412 296 * RETURNS: ··· 411 301 */ 412 302 int ahci_platform_init_host(struct platform_device *pdev, 413 303 struct ahci_host_priv *hpriv, 414 - const struct ata_port_info *pi_template, 415 - unsigned long host_flags, 416 - unsigned int force_port_map, 417 - unsigned int mask_port_map) 304 + const struct ata_port_info *pi_template) 418 305 { 419 306 struct device *dev = &pdev->dev; 420 307 struct ata_port_info pi = *pi_template; ··· 426 319 } 427 320 428 321 /* prepare host */ 429 - pi.private_data = (void *)host_flags; 430 - hpriv->flags |= host_flags; 322 + pi.private_data = (void *)(unsigned long)hpriv->flags; 431 323 432 - ahci_save_initial_config(dev, hpriv, force_port_map, mask_port_map); 324 + ahci_save_initial_config(dev, hpriv); 433 325 434 326 if (hpriv->cap & HOST_CAP_NCQ) 435 327 pi.flags |= ATA_FLAG_NCQ; ··· 475 369 ap->ops = &ata_dummy_port_ops; 476 370 } 477 371 372 + if (hpriv->cap & HOST_CAP_64) { 373 + rc = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64)); 374 + if (rc) { 375 + rc = dma_coerce_mask_and_coherent(dev, 376 + DMA_BIT_MASK(32)); 377 + if (rc) { 378 + dev_err(dev, "Failed to enable 64-bit DMA.\n"); 379 + return rc; 380 + } 381 + dev_warn(dev, "Enable 32-bit DMA instead of 64-bit.\n"); 382 + } 383 + } 384 + 478 385 rc = ahci_reset_controller(host); 479 386 if (rc) 480 387 return rc; ··· 518 399 * @dev: device pointer for the host 519 400 * 520 401 * This function does all the usual steps needed to suspend an 521 - * ahci-platform host, note any necessary resources (ie clks, phy, etc.) 402 + * ahci-platform host, note any necessary resources (ie clks, phys, etc.) 522 403 * must be disabled after calling this. 523 404 * 524 405 * RETURNS: ··· 555 436 * @dev: device pointer for the host 556 437 * 557 438 * This function does all the usual steps needed to resume an ahci-platform 558 - * host, note any necessary resources (ie clks, phy, etc.) must be 439 + * host, note any necessary resources (ie clks, phys, etc.) must be 559 440 * initialized / enabled before calling this. 560 441 * 561 442 * RETURNS:
-13
drivers/ata/pata_samsung_cf.c
··· 54 54 55 55 enum s3c_cpu_type { 56 56 TYPE_S3C64XX, 57 - TYPE_S5PC100, 58 57 TYPE_S5PV210, 59 58 }; 60 59 ··· 475 476 writel(0x1b, info->ide_addr + S3C_ATA_IRQ_MSK); 476 477 break; 477 478 478 - case TYPE_S5PC100: 479 - pata_s3c_cfg_mode(info->sfr_addr); 480 - /* FALLTHROUGH */ 481 - 482 479 case TYPE_S5PV210: 483 480 /* Configure as little endian */ 484 481 pata_s3c_set_endian(info->ide_addr, 0); ··· 544 549 info->sfr_addr = info->ide_addr + 0x1800; 545 550 info->ide_addr += 0x1900; 546 551 info->fifo_status_reg = 0x94; 547 - } else if (cpu_type == TYPE_S5PC100) { 548 - ap->ops = &pata_s5p_port_ops; 549 - info->sfr_addr = info->ide_addr + 0x1800; 550 - info->ide_addr += 0x1900; 551 - info->fifo_status_reg = 0x84; 552 552 } else { 553 553 ap->ops = &pata_s5p_port_ops; 554 554 info->fifo_status_reg = 0x84; ··· 642 652 { 643 653 .name = "s3c64xx-pata", 644 654 .driver_data = TYPE_S3C64XX, 645 - }, { 646 - .name = "s5pc100-pata", 647 - .driver_data = TYPE_S5PC100, 648 655 }, { 649 656 .name = "s5pv210-pata", 650 657 .driver_data = TYPE_S5PV210,
+2 -3
drivers/ata/sata_fsl.c
··· 734 734 if (!pp) 735 735 return -ENOMEM; 736 736 737 - mem = dma_alloc_coherent(dev, SATA_FSL_PORT_PRIV_DMA_SZ, &mem_dma, 738 - GFP_KERNEL); 737 + mem = dma_zalloc_coherent(dev, SATA_FSL_PORT_PRIV_DMA_SZ, &mem_dma, 738 + GFP_KERNEL); 739 739 if (!mem) { 740 740 kfree(pp); 741 741 return -ENOMEM; 742 742 } 743 - memset(mem, 0, SATA_FSL_PORT_PRIV_DMA_SZ); 744 743 745 744 pp->cmdslot = mem; 746 745 pp->cmdslot_paddr = mem_dma;
+1 -1
drivers/ata/sata_highbank.c
··· 512 512 return rc; 513 513 514 514 515 - ahci_save_initial_config(dev, hpriv, 0, 0); 515 + ahci_save_initial_config(dev, hpriv); 516 516 517 517 /* prepare host */ 518 518 if (hpriv->cap & HOST_CAP_NCQ)
+2 -2
drivers/ata/sata_sil24.c
··· 1154 1154 status = readl(host_base + HOST_IRQ_STAT); 1155 1155 1156 1156 if (status == 0xffffffff) { 1157 - printk(KERN_ERR DRV_NAME ": IRQ status == 0xffffffff, " 1158 - "PCI fault or device removal?\n"); 1157 + dev_err(host->dev, "IRQ status == 0xffffffff, " 1158 + "PCI fault or device removal?\n"); 1159 1159 goto out; 1160 1160 } 1161 1161
+1 -4
include/linux/ahci_platform.h
··· 43 43 struct platform_device *pdev); 44 44 int ahci_platform_init_host(struct platform_device *pdev, 45 45 struct ahci_host_priv *hpriv, 46 - const struct ata_port_info *pi_template, 47 - unsigned long host_flags, 48 - unsigned int force_port_map, 49 - unsigned int mask_port_map); 46 + const struct ata_port_info *pi_template); 50 47 51 48 int ahci_platform_suspend_host(struct device *dev); 52 49 int ahci_platform_resume_host(struct device *dev);
-1
include/linux/platform_data/ata-samsung_cf.h
··· 29 29 30 30 /* architecture-specific IDE configuration */ 31 31 extern void s3c64xx_ide_setup_gpio(void); 32 - extern void s5pc100_ide_setup_gpio(void); 33 32 extern void s5pv210_ide_setup_gpio(void); 34 33 35 34 #endif /*__ATA_SAMSUNG_CF_H */