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

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

Pull libata updates from Tejun Heo:
"Nothing too interesting.

The biggest change is refcnting fix for ata_host - the bug is recent
and can only be triggered on controller hotplug, so very few are
hitting it.

There also are a number of trivial license / error message changes and
some hardware specific changes"

* 'for-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (23 commits)
ahci: imx: add the imx8qm ahci sata support
libata: ensure host is free'd on error exit paths
ata: ahci-platform: add reset control support
ahci: imx: fix the build warning
ata: add Amiga Gayle PATA controller driver
ahci: imx: add the imx6qp ahci sata support
ata: change Tegra124 to Tegra
ata: ahci_tegra: Add AHCI support for Tegra210
ata: ahci_tegra: disable DIPM
ata: ahci_tegra: disable devslp for Tegra124
ata: ahci_tegra: initialize regulators from soc struct
ata: ahci_tegra: Update initialization sequence
dt-bindings: Tegra210: add binding documentation
libata: add refcounting to ata_host
pata_bk3710: clarify license version and use SPDX header
pata_falcon: clarify license version and use SPDX header
pata_it821x: Delete an error message for a failed memory allocation in it821x_firmware_command()
pata_macio: Delete an error message for a failed memory allocation in two functions
pata_mpc52xx: Delete an error message for a failed memory allocation in mpc52xx_ata_probe()
sata_dwc_460ex: Delete an error message for a failed memory allocation in sata_dwc_port_start()
...

+986 -126
+1
Documentation/devicetree/bindings/ata/ahci-platform.txt
··· 30 30 Optional properties: 31 31 - dma-coherent : Present if dma operations are coherent 32 32 - clocks : a list of phandle + clock specifier pairs 33 + - resets : a list of phandle + reset specifier pairs 33 34 - target-supply : regulator for SATA target power 34 35 - phys : reference to the SATA PHY node 35 36 - phy-names : must be "sata-phy"
+1
Documentation/devicetree/bindings/ata/imx-sata.txt
··· 7 7 - compatible : should be one of the following: 8 8 - "fsl,imx53-ahci" for i.MX53 SATA controller 9 9 - "fsl,imx6q-ahci" for i.MX6Q SATA controller 10 + - "fsl,imx6qp-ahci" for i.MX6QP SATA controller 10 11 - interrupts : interrupt mapping for SATA IRQ 11 12 - reg : registers mapping 12 13 - clocks : list of clock specifiers, must contain an entry for each
+24 -12
Documentation/devicetree/bindings/ata/nvidia,tegra124-ahci.txt
··· 1 - Tegra124 SoC SATA AHCI controller 1 + Tegra SoC SATA AHCI controller 2 2 3 3 Required properties : 4 - - compatible : For Tegra124, must contain "nvidia,tegra124-ahci". Otherwise, 5 - must contain '"nvidia,<chip>-ahci", "nvidia,tegra124-ahci"', where <chip> 6 - is tegra132. 4 + - compatible : Must be one of: 5 + - Tegra124 : "nvidia,tegra124-ahci" 6 + - Tegra132 : "nvidia,tegra132-ahci", "nvidia,tegra124-ahci" 7 + - Tegra210 : "nvidia,tegra210-ahci" 7 8 - reg : Should contain 2 entries: 8 9 - AHCI register set (SATA BAR5) 9 10 - SATA register set ··· 14 13 - clock-names : Must include the following entries: 15 14 - sata 16 15 - sata-oob 17 - - cml1 18 - - pll_e 19 16 - resets : Must contain an entry for each entry in reset-names. 20 17 See ../reset/reset.txt for details. 21 18 - reset-names : Must include the following entries: ··· 23 24 - phys : Must contain an entry for each entry in phy-names. 24 25 See ../phy/phy-bindings.txt for details. 25 26 - phy-names : Must include the following entries: 26 - - sata-phy : XUSB PADCTL SATA PHY 27 - - hvdd-supply : Defines the SATA HVDD regulator 28 - - vddio-supply : Defines the SATA VDDIO regulator 29 - - avdd-supply : Defines the SATA AVDD regulator 30 - - target-5v-supply : Defines the SATA 5V power regulator 31 - - target-12v-supply : Defines the SATA 12V power regulator 27 + - For Tegra124 and Tegra132: 28 + - sata-phy : XUSB PADCTL SATA PHY 29 + - For Tegra124 and Tegra132: 30 + - hvdd-supply : Defines the SATA HVDD regulator 31 + - vddio-supply : Defines the SATA VDDIO regulator 32 + - avdd-supply : Defines the SATA AVDD regulator 33 + - target-5v-supply : Defines the SATA 5V power regulator 34 + - target-12v-supply : Defines the SATA 12V power regulator 35 + 36 + Optional properties: 37 + - reg : 38 + - AUX register set 39 + - clock-names : 40 + - cml1 : 41 + cml1 clock should be defined here if the PHY driver 42 + doesn't manage them. If it does, they should not be. 43 + - phy-names : 44 + - For T210: 45 + - sata-phy
+14 -2
drivers/ata/Kconfig
··· 211 211 If unsure, say N. 212 212 213 213 config AHCI_TEGRA 214 - tristate "NVIDIA Tegra124 AHCI SATA support" 214 + tristate "NVIDIA Tegra AHCI SATA support" 215 215 depends on ARCH_TEGRA 216 216 help 217 - This option enables support for the NVIDIA Tegra124 SoC's 217 + This option enables support for the NVIDIA Tegra SoC's 218 218 onboard AHCI SATA. 219 219 220 220 If unsure, say N. ··· 951 951 help 952 952 This option enables support for the on-board IDE 953 953 interface on the Atari Falcon. 954 + 955 + If unsure, say N. 956 + 957 + config PATA_GAYLE 958 + tristate "Amiga Gayle PATA support" 959 + depends on M68K && AMIGA 960 + help 961 + This option enables support for the on-board IDE 962 + interfaces on some Amiga models (A600, A1200, 963 + A4000 and A4000T) and also for IDE interfaces on 964 + the Zorro expansion bus (M-Tech E-Matrix 530 965 + expansion card). 954 966 955 967 If unsure, say N. 956 968
+1
drivers/ata/Makefile
··· 97 97 # SFF PIO only 98 98 obj-$(CONFIG_PATA_CMD640_PCI) += pata_cmd640.o 99 99 obj-$(CONFIG_PATA_FALCON) += pata_falcon.o 100 + obj-$(CONFIG_PATA_GAYLE) += pata_gayle.o 100 101 obj-$(CONFIG_PATA_ISAPNP) += pata_isapnp.o 101 102 obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o 102 103 obj-$(CONFIG_PATA_MPIIX) += pata_mpiix.o
+1
drivers/ata/ahci.h
··· 350 350 u32 em_msg_type; /* EM message type */ 351 351 bool got_runtime_pm; /* Did we do pm_runtime_get? */ 352 352 struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ 353 + struct reset_control *rsts; /* Optional */ 353 354 struct regulator **target_pwrs; /* Optional */ 354 355 /* 355 356 * If platform uses PHYs. There is a 1:1 relation between the port number and
+367 -4
drivers/ata/ahci_imx.c
··· 23 23 #include <linux/regmap.h> 24 24 #include <linux/ahci_platform.h> 25 25 #include <linux/of_device.h> 26 + #include <linux/of_gpio.h> 26 27 #include <linux/mfd/syscon.h> 27 28 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> 28 29 #include <linux/libata.h> ··· 54 53 /* Clock Reset Register */ 55 54 IMX_CLOCK_RESET = 0x7f3f, 56 55 IMX_CLOCK_RESET_RESET = 1 << 0, 56 + /* IMX8QM HSIO AHCI definitions */ 57 + IMX8QM_SATA_PHY_RX_IMPED_RATIO_OFFSET = 0x03, 58 + IMX8QM_SATA_PHY_TX_IMPED_RATIO_OFFSET = 0x09, 59 + IMX8QM_SATA_PHY_IMPED_RATIO_85OHM = 0x6c, 60 + IMX8QM_LPCG_PHYX2_OFFSET = 0x00000, 61 + IMX8QM_CSR_PHYX2_OFFSET = 0x90000, 62 + IMX8QM_CSR_PHYX1_OFFSET = 0xa0000, 63 + IMX8QM_CSR_PHYX_STTS0_OFFSET = 0x4, 64 + IMX8QM_CSR_PCIEA_OFFSET = 0xb0000, 65 + IMX8QM_CSR_PCIEB_OFFSET = 0xc0000, 66 + IMX8QM_CSR_SATA_OFFSET = 0xd0000, 67 + IMX8QM_CSR_PCIE_CTRL2_OFFSET = 0x8, 68 + IMX8QM_CSR_MISC_OFFSET = 0xe0000, 69 + 70 + IMX8QM_LPCG_PHYX2_PCLK0_MASK = (0x3 << 16), 71 + IMX8QM_LPCG_PHYX2_PCLK1_MASK = (0x3 << 20), 72 + IMX8QM_PHY_APB_RSTN_0 = BIT(0), 73 + IMX8QM_PHY_MODE_SATA = BIT(19), 74 + IMX8QM_PHY_MODE_MASK = (0xf << 17), 75 + IMX8QM_PHY_PIPE_RSTN_0 = BIT(24), 76 + IMX8QM_PHY_PIPE_RSTN_OVERRIDE_0 = BIT(25), 77 + IMX8QM_PHY_PIPE_RSTN_1 = BIT(26), 78 + IMX8QM_PHY_PIPE_RSTN_OVERRIDE_1 = BIT(27), 79 + IMX8QM_STTS0_LANE0_TX_PLL_LOCK = BIT(4), 80 + IMX8QM_MISC_IOB_RXENA = BIT(0), 81 + IMX8QM_MISC_IOB_TXENA = BIT(1), 82 + IMX8QM_MISC_PHYX1_EPCS_SEL = BIT(12), 83 + IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_1 = BIT(24), 84 + IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_0 = BIT(25), 85 + IMX8QM_MISC_CLKREQN_IN_OVERRIDE_1 = BIT(28), 86 + IMX8QM_MISC_CLKREQN_IN_OVERRIDE_0 = BIT(29), 87 + IMX8QM_SATA_CTRL_RESET_N = BIT(12), 88 + IMX8QM_SATA_CTRL_EPCS_PHYRESET_N = BIT(7), 89 + IMX8QM_CTRL_BUTTON_RST_N = BIT(21), 90 + IMX8QM_CTRL_POWER_UP_RST_N = BIT(23), 91 + IMX8QM_CTRL_LTSSM_ENABLE = BIT(4), 57 92 }; 58 93 59 94 enum ahci_imx_type { 60 95 AHCI_IMX53, 61 96 AHCI_IMX6Q, 97 + AHCI_IMX6QP, 98 + AHCI_IMX8QM, 62 99 }; 63 100 64 101 struct imx_ahci_priv { ··· 105 66 struct clk *sata_clk; 106 67 struct clk *sata_ref_clk; 107 68 struct clk *ahb_clk; 69 + struct clk *epcs_tx_clk; 70 + struct clk *epcs_rx_clk; 71 + struct clk *phy_apbclk; 72 + struct clk *phy_pclk0; 73 + struct clk *phy_pclk1; 74 + void __iomem *phy_base; 75 + int clkreq_gpio; 108 76 struct regmap *gpr; 109 77 bool no_device; 110 78 bool first_time; 111 79 u32 phy_params; 80 + u32 imped_ratio; 112 81 }; 113 82 114 83 static int ahci_imx_hotplug; ··· 235 188 236 189 static int imx_sata_phy_reset(struct ahci_host_priv *hpriv) 237 190 { 191 + struct imx_ahci_priv *imxpriv = hpriv->plat_data; 238 192 void __iomem *mmio = hpriv->mmio; 239 193 int timeout = 10; 240 194 u16 val; 241 195 int ret; 196 + 197 + if (imxpriv->type == AHCI_IMX6QP) { 198 + /* 6qp adds the sata reset mechanism, use it for 6qp sata */ 199 + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR5, 200 + IMX6Q_GPR5_SATA_SW_PD, 0); 201 + 202 + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR5, 203 + IMX6Q_GPR5_SATA_SW_RST, 0); 204 + udelay(50); 205 + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR5, 206 + IMX6Q_GPR5_SATA_SW_RST, 207 + IMX6Q_GPR5_SATA_SW_RST); 208 + return 0; 209 + } 242 210 243 211 /* Reset SATA PHY by setting RESET bit of PHY register CLOCK_RESET */ 244 212 ret = imx_phy_reg_addressing(IMX_CLOCK_RESET, mmio); ··· 453 391 }; 454 392 ATTRIBUTE_GROUPS(fsl_sata_ahci); 455 393 394 + static int imx8_sata_enable(struct ahci_host_priv *hpriv) 395 + { 396 + u32 val, reg; 397 + int i, ret; 398 + struct imx_ahci_priv *imxpriv = hpriv->plat_data; 399 + struct device *dev = &imxpriv->ahci_pdev->dev; 400 + 401 + /* configure the hsio for sata */ 402 + ret = clk_prepare_enable(imxpriv->phy_pclk0); 403 + if (ret < 0) { 404 + dev_err(dev, "can't enable phy_pclk0.\n"); 405 + return ret; 406 + } 407 + ret = clk_prepare_enable(imxpriv->phy_pclk1); 408 + if (ret < 0) { 409 + dev_err(dev, "can't enable phy_pclk1.\n"); 410 + goto disable_phy_pclk0; 411 + } 412 + ret = clk_prepare_enable(imxpriv->epcs_tx_clk); 413 + if (ret < 0) { 414 + dev_err(dev, "can't enable epcs_tx_clk.\n"); 415 + goto disable_phy_pclk1; 416 + } 417 + ret = clk_prepare_enable(imxpriv->epcs_rx_clk); 418 + if (ret < 0) { 419 + dev_err(dev, "can't enable epcs_rx_clk.\n"); 420 + goto disable_epcs_tx_clk; 421 + } 422 + ret = clk_prepare_enable(imxpriv->phy_apbclk); 423 + if (ret < 0) { 424 + dev_err(dev, "can't enable phy_apbclk.\n"); 425 + goto disable_epcs_rx_clk; 426 + } 427 + /* Configure PHYx2 PIPE_RSTN */ 428 + regmap_read(imxpriv->gpr, IMX8QM_CSR_PCIEA_OFFSET + 429 + IMX8QM_CSR_PCIE_CTRL2_OFFSET, &val); 430 + if ((val & IMX8QM_CTRL_LTSSM_ENABLE) == 0) { 431 + /* The link of the PCIEA of HSIO is down */ 432 + regmap_update_bits(imxpriv->gpr, 433 + IMX8QM_CSR_PHYX2_OFFSET, 434 + IMX8QM_PHY_PIPE_RSTN_0 | 435 + IMX8QM_PHY_PIPE_RSTN_OVERRIDE_0, 436 + IMX8QM_PHY_PIPE_RSTN_0 | 437 + IMX8QM_PHY_PIPE_RSTN_OVERRIDE_0); 438 + } 439 + regmap_read(imxpriv->gpr, IMX8QM_CSR_PCIEB_OFFSET + 440 + IMX8QM_CSR_PCIE_CTRL2_OFFSET, &reg); 441 + if ((reg & IMX8QM_CTRL_LTSSM_ENABLE) == 0) { 442 + /* The link of the PCIEB of HSIO is down */ 443 + regmap_update_bits(imxpriv->gpr, 444 + IMX8QM_CSR_PHYX2_OFFSET, 445 + IMX8QM_PHY_PIPE_RSTN_1 | 446 + IMX8QM_PHY_PIPE_RSTN_OVERRIDE_1, 447 + IMX8QM_PHY_PIPE_RSTN_1 | 448 + IMX8QM_PHY_PIPE_RSTN_OVERRIDE_1); 449 + } 450 + if (((reg | val) & IMX8QM_CTRL_LTSSM_ENABLE) == 0) { 451 + /* The links of both PCIA and PCIEB of HSIO are down */ 452 + regmap_update_bits(imxpriv->gpr, 453 + IMX8QM_LPCG_PHYX2_OFFSET, 454 + IMX8QM_LPCG_PHYX2_PCLK0_MASK | 455 + IMX8QM_LPCG_PHYX2_PCLK1_MASK, 456 + 0); 457 + } 458 + 459 + /* set PWR_RST and BT_RST of csr_pciea */ 460 + val = IMX8QM_CSR_PCIEA_OFFSET + IMX8QM_CSR_PCIE_CTRL2_OFFSET; 461 + regmap_update_bits(imxpriv->gpr, 462 + val, 463 + IMX8QM_CTRL_BUTTON_RST_N, 464 + IMX8QM_CTRL_BUTTON_RST_N); 465 + regmap_update_bits(imxpriv->gpr, 466 + val, 467 + IMX8QM_CTRL_POWER_UP_RST_N, 468 + IMX8QM_CTRL_POWER_UP_RST_N); 469 + 470 + /* PHYX1_MODE to SATA */ 471 + regmap_update_bits(imxpriv->gpr, 472 + IMX8QM_CSR_PHYX1_OFFSET, 473 + IMX8QM_PHY_MODE_MASK, 474 + IMX8QM_PHY_MODE_SATA); 475 + 476 + /* 477 + * BIT0 RXENA 1, BIT1 TXENA 0 478 + * BIT12 PHY_X1_EPCS_SEL 1. 479 + */ 480 + regmap_update_bits(imxpriv->gpr, 481 + IMX8QM_CSR_MISC_OFFSET, 482 + IMX8QM_MISC_IOB_RXENA, 483 + IMX8QM_MISC_IOB_RXENA); 484 + regmap_update_bits(imxpriv->gpr, 485 + IMX8QM_CSR_MISC_OFFSET, 486 + IMX8QM_MISC_IOB_TXENA, 487 + 0); 488 + regmap_update_bits(imxpriv->gpr, 489 + IMX8QM_CSR_MISC_OFFSET, 490 + IMX8QM_MISC_PHYX1_EPCS_SEL, 491 + IMX8QM_MISC_PHYX1_EPCS_SEL); 492 + /* 493 + * It is possible, for PCIe and SATA are sharing 494 + * the same clock source, HPLL or external oscillator. 495 + * When PCIe is in low power modes (L1.X or L2 etc), 496 + * the clock source can be turned off. In this case, 497 + * if this clock source is required to be toggling by 498 + * SATA, then SATA functions will be abnormal. 499 + * Set the override here to avoid it. 500 + */ 501 + regmap_update_bits(imxpriv->gpr, 502 + IMX8QM_CSR_MISC_OFFSET, 503 + IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_1 | 504 + IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_0 | 505 + IMX8QM_MISC_CLKREQN_IN_OVERRIDE_1 | 506 + IMX8QM_MISC_CLKREQN_IN_OVERRIDE_0, 507 + IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_1 | 508 + IMX8QM_MISC_CLKREQN_OUT_OVERRIDE_0 | 509 + IMX8QM_MISC_CLKREQN_IN_OVERRIDE_1 | 510 + IMX8QM_MISC_CLKREQN_IN_OVERRIDE_0); 511 + 512 + /* clear PHY RST, then set it */ 513 + regmap_update_bits(imxpriv->gpr, 514 + IMX8QM_CSR_SATA_OFFSET, 515 + IMX8QM_SATA_CTRL_EPCS_PHYRESET_N, 516 + 0); 517 + 518 + regmap_update_bits(imxpriv->gpr, 519 + IMX8QM_CSR_SATA_OFFSET, 520 + IMX8QM_SATA_CTRL_EPCS_PHYRESET_N, 521 + IMX8QM_SATA_CTRL_EPCS_PHYRESET_N); 522 + 523 + /* CTRL RST: SET -> delay 1 us -> CLEAR -> SET */ 524 + regmap_update_bits(imxpriv->gpr, 525 + IMX8QM_CSR_SATA_OFFSET, 526 + IMX8QM_SATA_CTRL_RESET_N, 527 + IMX8QM_SATA_CTRL_RESET_N); 528 + udelay(1); 529 + regmap_update_bits(imxpriv->gpr, 530 + IMX8QM_CSR_SATA_OFFSET, 531 + IMX8QM_SATA_CTRL_RESET_N, 532 + 0); 533 + regmap_update_bits(imxpriv->gpr, 534 + IMX8QM_CSR_SATA_OFFSET, 535 + IMX8QM_SATA_CTRL_RESET_N, 536 + IMX8QM_SATA_CTRL_RESET_N); 537 + 538 + /* APB reset */ 539 + regmap_update_bits(imxpriv->gpr, 540 + IMX8QM_CSR_PHYX1_OFFSET, 541 + IMX8QM_PHY_APB_RSTN_0, 542 + IMX8QM_PHY_APB_RSTN_0); 543 + 544 + for (i = 0; i < 100; i++) { 545 + reg = IMX8QM_CSR_PHYX1_OFFSET + 546 + IMX8QM_CSR_PHYX_STTS0_OFFSET; 547 + regmap_read(imxpriv->gpr, reg, &val); 548 + val &= IMX8QM_STTS0_LANE0_TX_PLL_LOCK; 549 + if (val == IMX8QM_STTS0_LANE0_TX_PLL_LOCK) 550 + break; 551 + udelay(1); 552 + } 553 + 554 + if (val != IMX8QM_STTS0_LANE0_TX_PLL_LOCK) { 555 + dev_err(dev, "TX PLL of the PHY is not locked\n"); 556 + ret = -ENODEV; 557 + } else { 558 + writeb(imxpriv->imped_ratio, imxpriv->phy_base + 559 + IMX8QM_SATA_PHY_RX_IMPED_RATIO_OFFSET); 560 + writeb(imxpriv->imped_ratio, imxpriv->phy_base + 561 + IMX8QM_SATA_PHY_TX_IMPED_RATIO_OFFSET); 562 + reg = readb(imxpriv->phy_base + 563 + IMX8QM_SATA_PHY_RX_IMPED_RATIO_OFFSET); 564 + if (unlikely(reg != imxpriv->imped_ratio)) 565 + dev_info(dev, "Can't set PHY RX impedance ratio.\n"); 566 + reg = readb(imxpriv->phy_base + 567 + IMX8QM_SATA_PHY_TX_IMPED_RATIO_OFFSET); 568 + if (unlikely(reg != imxpriv->imped_ratio)) 569 + dev_info(dev, "Can't set PHY TX impedance ratio.\n"); 570 + usleep_range(50, 100); 571 + 572 + /* 573 + * To reduce the power consumption, gate off 574 + * the PHY clks 575 + */ 576 + clk_disable_unprepare(imxpriv->phy_apbclk); 577 + clk_disable_unprepare(imxpriv->phy_pclk1); 578 + clk_disable_unprepare(imxpriv->phy_pclk0); 579 + return ret; 580 + } 581 + 582 + clk_disable_unprepare(imxpriv->phy_apbclk); 583 + disable_epcs_rx_clk: 584 + clk_disable_unprepare(imxpriv->epcs_rx_clk); 585 + disable_epcs_tx_clk: 586 + clk_disable_unprepare(imxpriv->epcs_tx_clk); 587 + disable_phy_pclk1: 588 + clk_disable_unprepare(imxpriv->phy_pclk1); 589 + disable_phy_pclk0: 590 + clk_disable_unprepare(imxpriv->phy_pclk0); 591 + 592 + return ret; 593 + } 594 + 456 595 static int imx_sata_enable(struct ahci_host_priv *hpriv) 457 596 { 458 597 struct imx_ahci_priv *imxpriv = hpriv->plat_data; ··· 671 408 if (ret < 0) 672 409 goto disable_regulator; 673 410 674 - if (imxpriv->type == AHCI_IMX6Q) { 411 + if (imxpriv->type == AHCI_IMX6Q || imxpriv->type == AHCI_IMX6QP) { 675 412 /* 676 413 * set PHY Paremeters, two steps to configure the GPR13, 677 414 * one write for rest of parameters, mask of first write ··· 701 438 dev_err(dev, "failed to reset phy: %d\n", ret); 702 439 goto disable_clk; 703 440 } 441 + } else if (imxpriv->type == AHCI_IMX8QM) { 442 + ret = imx8_sata_enable(hpriv); 704 443 } 705 444 706 445 usleep_range(1000, 2000); ··· 724 459 if (imxpriv->no_device) 725 460 return; 726 461 727 - if (imxpriv->type == AHCI_IMX6Q) { 462 + switch (imxpriv->type) { 463 + case AHCI_IMX6QP: 464 + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR5, 465 + IMX6Q_GPR5_SATA_SW_PD, 466 + IMX6Q_GPR5_SATA_SW_PD); 728 467 regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 729 468 IMX6Q_GPR13_SATA_MPLL_CLK_EN, 730 469 !IMX6Q_GPR13_SATA_MPLL_CLK_EN); 470 + break; 471 + 472 + case AHCI_IMX6Q: 473 + regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 474 + IMX6Q_GPR13_SATA_MPLL_CLK_EN, 475 + !IMX6Q_GPR13_SATA_MPLL_CLK_EN); 476 + break; 477 + 478 + case AHCI_IMX8QM: 479 + clk_disable_unprepare(imxpriv->epcs_rx_clk); 480 + clk_disable_unprepare(imxpriv->epcs_tx_clk); 481 + break; 482 + 483 + default: 484 + break; 731 485 } 732 486 733 487 clk_disable_unprepare(imxpriv->sata_ref_clk); ··· 797 513 798 514 if (imxpriv->type == AHCI_IMX53) 799 515 ret = ahci_pmp_retry_srst_ops.softreset(link, class, deadline); 800 - else if (imxpriv->type == AHCI_IMX6Q) 516 + else 801 517 ret = ahci_ops.softreset(link, class, deadline); 802 518 803 519 return ret; ··· 820 536 static const struct of_device_id imx_ahci_of_match[] = { 821 537 { .compatible = "fsl,imx53-ahci", .data = (void *)AHCI_IMX53 }, 822 538 { .compatible = "fsl,imx6q-ahci", .data = (void *)AHCI_IMX6Q }, 539 + { .compatible = "fsl,imx6qp-ahci", .data = (void *)AHCI_IMX6QP }, 540 + { .compatible = "fsl,imx8qm-ahci", .data = (void *)AHCI_IMX8QM }, 823 541 {}, 824 542 }; 825 543 MODULE_DEVICE_TABLE(of, imx_ahci_of_match); ··· 989 703 AHCI_SHT(DRV_NAME), 990 704 }; 991 705 706 + static int imx8_sata_probe(struct device *dev, struct imx_ahci_priv *imxpriv) 707 + { 708 + int ret; 709 + struct resource *phy_res; 710 + struct platform_device *pdev = imxpriv->ahci_pdev; 711 + struct device_node *np = dev->of_node; 712 + 713 + if (of_property_read_u32(np, "fsl,phy-imp", &imxpriv->imped_ratio)) 714 + imxpriv->imped_ratio = IMX8QM_SATA_PHY_IMPED_RATIO_85OHM; 715 + phy_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); 716 + if (phy_res) { 717 + imxpriv->phy_base = devm_ioremap(dev, phy_res->start, 718 + resource_size(phy_res)); 719 + if (!imxpriv->phy_base) { 720 + dev_err(dev, "error with ioremap\n"); 721 + return -ENOMEM; 722 + } 723 + } else { 724 + dev_err(dev, "missing *phy* reg region.\n"); 725 + return -ENOMEM; 726 + } 727 + imxpriv->gpr = 728 + syscon_regmap_lookup_by_phandle(np, "hsio"); 729 + if (IS_ERR(imxpriv->gpr)) { 730 + dev_err(dev, "unable to find gpr registers\n"); 731 + return PTR_ERR(imxpriv->gpr); 732 + } 733 + 734 + imxpriv->epcs_tx_clk = devm_clk_get(dev, "epcs_tx"); 735 + if (IS_ERR(imxpriv->epcs_tx_clk)) { 736 + dev_err(dev, "can't get epcs_tx_clk clock.\n"); 737 + return PTR_ERR(imxpriv->epcs_tx_clk); 738 + } 739 + imxpriv->epcs_rx_clk = devm_clk_get(dev, "epcs_rx"); 740 + if (IS_ERR(imxpriv->epcs_rx_clk)) { 741 + dev_err(dev, "can't get epcs_rx_clk clock.\n"); 742 + return PTR_ERR(imxpriv->epcs_rx_clk); 743 + } 744 + imxpriv->phy_pclk0 = devm_clk_get(dev, "phy_pclk0"); 745 + if (IS_ERR(imxpriv->phy_pclk0)) { 746 + dev_err(dev, "can't get phy_pclk0 clock.\n"); 747 + return PTR_ERR(imxpriv->phy_pclk0); 748 + } 749 + imxpriv->phy_pclk1 = devm_clk_get(dev, "phy_pclk1"); 750 + if (IS_ERR(imxpriv->phy_pclk1)) { 751 + dev_err(dev, "can't get phy_pclk1 clock.\n"); 752 + return PTR_ERR(imxpriv->phy_pclk1); 753 + } 754 + imxpriv->phy_apbclk = devm_clk_get(dev, "phy_apbclk"); 755 + if (IS_ERR(imxpriv->phy_apbclk)) { 756 + dev_err(dev, "can't get phy_apbclk clock.\n"); 757 + return PTR_ERR(imxpriv->phy_apbclk); 758 + } 759 + 760 + /* Fetch GPIO, then enable the external OSC */ 761 + imxpriv->clkreq_gpio = of_get_named_gpio(np, "clkreq-gpio", 0); 762 + if (gpio_is_valid(imxpriv->clkreq_gpio)) { 763 + ret = devm_gpio_request_one(dev, imxpriv->clkreq_gpio, 764 + GPIOF_OUT_INIT_LOW, 765 + "SATA CLKREQ"); 766 + if (ret == -EBUSY) { 767 + dev_info(dev, "clkreq had been initialized.\n"); 768 + } else if (ret) { 769 + dev_err(dev, "%d unable to get clkreq.\n", ret); 770 + return ret; 771 + } 772 + } else if (imxpriv->clkreq_gpio == -EPROBE_DEFER) { 773 + return imxpriv->clkreq_gpio; 774 + } 775 + 776 + return 0; 777 + } 778 + 992 779 static int imx_ahci_probe(struct platform_device *pdev) 993 780 { 994 781 struct device *dev = &pdev->dev; ··· 1102 743 return PTR_ERR(imxpriv->ahb_clk); 1103 744 } 1104 745 1105 - if (imxpriv->type == AHCI_IMX6Q) { 746 + if (imxpriv->type == AHCI_IMX6Q || imxpriv->type == AHCI_IMX6QP) { 1106 747 u32 reg_value; 1107 748 1108 749 imxpriv->gpr = syscon_regmap_lookup_by_compatible( ··· 1121 762 IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F | 1122 763 IMX6Q_GPR13_SATA_SPD_MODE_3P0G | 1123 764 reg_value; 765 + } else if (imxpriv->type == AHCI_IMX8QM) { 766 + ret = imx8_sata_probe(dev, imxpriv); 767 + if (ret) 768 + return ret; 1124 769 } 1125 770 1126 771 hpriv = ahci_platform_get_resources(pdev);
+274 -67
drivers/ata/ahci_tegra.c
··· 34 34 #define DRV_NAME "tegra-ahci" 35 35 36 36 #define SATA_CONFIGURATION_0 0x180 37 - #define SATA_CONFIGURATION_EN_FPCI BIT(0) 37 + #define SATA_CONFIGURATION_0_EN_FPCI BIT(0) 38 + #define SATA_CONFIGURATION_0_CLK_OVERRIDE BIT(31) 38 39 39 40 #define SCFG_OFFSET 0x1000 40 41 ··· 46 45 #define T_SATA0_CFG_1_SERR BIT(8) 47 46 48 47 #define T_SATA0_CFG_9 0x24 49 - #define T_SATA0_CFG_9_BASE_ADDRESS_SHIFT 13 48 + #define T_SATA0_CFG_9_BASE_ADDRESS 0x40020000 50 49 51 50 #define SATA_FPCI_BAR5 0x94 52 - #define SATA_FPCI_BAR5_START_SHIFT 4 51 + #define SATA_FPCI_BAR5_START_MASK (0xfffffff << 4) 52 + #define SATA_FPCI_BAR5_START (0x0040020 << 4) 53 + #define SATA_FPCI_BAR5_ACCESS_TYPE (0x1) 53 54 54 55 #define SATA_INTR_MASK 0x188 55 56 #define SATA_INTR_MASK_IP_INT_MASK BIT(16) 56 57 58 + #define T_SATA0_CFG_35 0x94 59 + #define T_SATA0_CFG_35_IDP_INDEX_MASK (0x7ff << 2) 60 + #define T_SATA0_CFG_35_IDP_INDEX (0x2a << 2) 61 + 62 + #define T_SATA0_AHCI_IDP1 0x98 63 + #define T_SATA0_AHCI_IDP1_DATA (0x400040) 64 + 65 + #define T_SATA0_CFG_PHY_1 0x12c 66 + #define T_SATA0_CFG_PHY_1_PADS_IDDQ_EN BIT(23) 67 + #define T_SATA0_CFG_PHY_1_PAD_PLL_IDDQ_EN BIT(22) 68 + 69 + #define T_SATA0_NVOOB 0x114 70 + #define T_SATA0_NVOOB_COMMA_CNT_MASK (0xff << 16) 71 + #define T_SATA0_NVOOB_COMMA_CNT (0x07 << 16) 72 + #define T_SATA0_NVOOB_SQUELCH_FILTER_MODE_MASK (0x3 << 24) 73 + #define T_SATA0_NVOOB_SQUELCH_FILTER_MODE (0x1 << 24) 74 + #define T_SATA0_NVOOB_SQUELCH_FILTER_LENGTH_MASK (0x3 << 26) 75 + #define T_SATA0_NVOOB_SQUELCH_FILTER_LENGTH (0x3 << 26) 76 + 77 + #define T_SATA_CFG_PHY_0 0x120 78 + #define T_SATA_CFG_PHY_0_USE_7BIT_ALIGN_DET_FOR_SPD BIT(11) 79 + #define T_SATA_CFG_PHY_0_MASK_SQUELCH BIT(24) 80 + 81 + #define T_SATA0_CFG2NVOOB_2 0x134 82 + #define T_SATA0_CFG2NVOOB_2_COMWAKE_IDLE_CNT_LOW_MASK (0x1ff << 18) 83 + #define T_SATA0_CFG2NVOOB_2_COMWAKE_IDLE_CNT_LOW (0xc << 18) 84 + 57 85 #define T_SATA0_AHCI_HBA_CAP_BKDR 0x300 86 + #define T_SATA0_AHCI_HBA_CAP_BKDR_PARTIAL_ST_CAP BIT(13) 87 + #define T_SATA0_AHCI_HBA_CAP_BKDR_SLUMBER_ST_CAP BIT(14) 88 + #define T_SATA0_AHCI_HBA_CAP_BKDR_SALP BIT(26) 89 + #define T_SATA0_AHCI_HBA_CAP_BKDR_SUPP_PM BIT(17) 90 + #define T_SATA0_AHCI_HBA_CAP_BKDR_SNCQ BIT(30) 58 91 59 92 #define T_SATA0_BKDOOR_CC 0x4a4 93 + #define T_SATA0_BKDOOR_CC_CLASS_CODE_MASK (0xffff << 16) 94 + #define T_SATA0_BKDOOR_CC_CLASS_CODE (0x0106 << 16) 95 + #define T_SATA0_BKDOOR_CC_PROG_IF_MASK (0xff << 8) 96 + #define T_SATA0_BKDOOR_CC_PROG_IF (0x01 << 8) 60 97 61 98 #define T_SATA0_CFG_SATA 0x54c 62 99 #define T_SATA0_CFG_SATA_BACKDOOR_PROG_IF_EN BIT(12) ··· 121 82 #define T_SATA0_CHX_PHY_CTRL11 0x6d0 122 83 #define T_SATA0_CHX_PHY_CTRL11_GEN2_RX_EQ (0x2800 << 16) 123 84 85 + #define T_SATA0_CHX_PHY_CTRL17_0 0x6e8 86 + #define T_SATA0_CHX_PHY_CTRL17_0_RX_EQ_CTRL_L_GEN1 0x55010000 87 + #define T_SATA0_CHX_PHY_CTRL18_0 0x6ec 88 + #define T_SATA0_CHX_PHY_CTRL18_0_RX_EQ_CTRL_L_GEN2 0x55010000 89 + #define T_SATA0_CHX_PHY_CTRL20_0 0x6f4 90 + #define T_SATA0_CHX_PHY_CTRL20_0_RX_EQ_CTRL_H_GEN1 0x1 91 + #define T_SATA0_CHX_PHY_CTRL21_0 0x6f8 92 + #define T_SATA0_CHX_PHY_CTRL21_0_RX_EQ_CTRL_H_GEN2 0x1 93 + 94 + /* AUX Registers */ 95 + #define SATA_AUX_MISC_CNTL_1_0 0x8 96 + #define SATA_AUX_MISC_CNTL_1_0_DEVSLP_OVERRIDE BIT(17) 97 + #define SATA_AUX_MISC_CNTL_1_0_SDS_SUPPORT BIT(13) 98 + #define SATA_AUX_MISC_CNTL_1_0_DESO_SUPPORT BIT(15) 99 + 100 + #define SATA_AUX_RX_STAT_INT_0 0xc 101 + #define SATA_AUX_RX_STAT_INT_0_SATA_DEVSLP BIT(7) 102 + 103 + #define SATA_AUX_SPARE_CFG0_0 0x18 104 + #define SATA_AUX_SPARE_CFG0_0_MDAT_TIMER_AFTER_PG_VALID BIT(14) 105 + 124 106 #define FUSE_SATA_CALIB 0x124 125 107 #define FUSE_SATA_CALIB_MASK 0x3 126 108 ··· 159 99 {0x14, 0x0e, 0x1a, 0x0e}, 160 100 }; 161 101 102 + struct tegra_ahci_ops { 103 + int (*init)(struct ahci_host_priv *hpriv); 104 + }; 105 + 106 + struct tegra_ahci_soc { 107 + const char *const *supply_names; 108 + u32 num_supplies; 109 + bool supports_devslp; 110 + const struct tegra_ahci_ops *ops; 111 + }; 112 + 162 113 struct tegra_ahci_priv { 163 114 struct platform_device *pdev; 164 115 void __iomem *sata_regs; 116 + void __iomem *sata_aux_regs; 165 117 struct reset_control *sata_rst; 166 118 struct reset_control *sata_oob_rst; 167 119 struct reset_control *sata_cold_rst; 168 120 /* Needs special handling, cannot use ahci_platform */ 169 121 struct clk *sata_clk; 170 - struct regulator_bulk_data supplies[5]; 122 + struct regulator_bulk_data *supplies; 123 + const struct tegra_ahci_soc *soc; 171 124 }; 125 + 126 + static void tegra_ahci_handle_quirks(struct ahci_host_priv *hpriv) 127 + { 128 + struct tegra_ahci_priv *tegra = hpriv->plat_data; 129 + u32 val; 130 + 131 + if (tegra->sata_aux_regs && !tegra->soc->supports_devslp) { 132 + val = readl(tegra->sata_aux_regs + SATA_AUX_MISC_CNTL_1_0); 133 + val &= ~SATA_AUX_MISC_CNTL_1_0_SDS_SUPPORT; 134 + writel(val, tegra->sata_aux_regs + SATA_AUX_MISC_CNTL_1_0); 135 + } 136 + } 137 + 138 + static int tegra124_ahci_init(struct ahci_host_priv *hpriv) 139 + { 140 + struct tegra_ahci_priv *tegra = hpriv->plat_data; 141 + struct sata_pad_calibration calib; 142 + int ret; 143 + u32 val; 144 + 145 + /* Pad calibration */ 146 + ret = tegra_fuse_readl(FUSE_SATA_CALIB, &val); 147 + if (ret) 148 + return ret; 149 + 150 + calib = tegra124_pad_calibration[val & FUSE_SATA_CALIB_MASK]; 151 + 152 + writel(BIT(0), tegra->sata_regs + SCFG_OFFSET + T_SATA0_INDEX); 153 + 154 + val = readl(tegra->sata_regs + 155 + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL1_GEN1); 156 + val &= ~T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_MASK; 157 + val &= ~T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_MASK; 158 + val |= calib.gen1_tx_amp << T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_SHIFT; 159 + val |= calib.gen1_tx_peak << T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_SHIFT; 160 + writel(val, tegra->sata_regs + SCFG_OFFSET + 161 + T_SATA0_CHX_PHY_CTRL1_GEN1); 162 + 163 + val = readl(tegra->sata_regs + 164 + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL1_GEN2); 165 + val &= ~T_SATA0_CHX_PHY_CTRL1_GEN2_TX_AMP_MASK; 166 + val &= ~T_SATA0_CHX_PHY_CTRL1_GEN2_TX_PEAK_MASK; 167 + val |= calib.gen2_tx_amp << T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_SHIFT; 168 + val |= calib.gen2_tx_peak << T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_SHIFT; 169 + writel(val, tegra->sata_regs + SCFG_OFFSET + 170 + T_SATA0_CHX_PHY_CTRL1_GEN2); 171 + 172 + writel(T_SATA0_CHX_PHY_CTRL11_GEN2_RX_EQ, 173 + tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL11); 174 + writel(T_SATA0_CHX_PHY_CTRL2_CDR_CNTL_GEN1, 175 + tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL2); 176 + 177 + writel(0, tegra->sata_regs + SCFG_OFFSET + T_SATA0_INDEX); 178 + 179 + return 0; 180 + } 172 181 173 182 static int tegra_ahci_power_on(struct ahci_host_priv *hpriv) 174 183 { 175 184 struct tegra_ahci_priv *tegra = hpriv->plat_data; 176 185 int ret; 177 186 178 - ret = regulator_bulk_enable(ARRAY_SIZE(tegra->supplies), 187 + ret = regulator_bulk_enable(tegra->soc->num_supplies, 179 188 tegra->supplies); 180 189 if (ret) 181 190 return ret; ··· 273 144 tegra_powergate_power_off(TEGRA_POWERGATE_SATA); 274 145 275 146 disable_regulators: 276 - regulator_bulk_disable(ARRAY_SIZE(tegra->supplies), tegra->supplies); 147 + regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); 277 148 278 149 return ret; 279 150 } ··· 291 162 clk_disable_unprepare(tegra->sata_clk); 292 163 tegra_powergate_power_off(TEGRA_POWERGATE_SATA); 293 164 294 - regulator_bulk_disable(ARRAY_SIZE(tegra->supplies), tegra->supplies); 165 + regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); 295 166 } 296 167 297 168 static int tegra_ahci_controller_init(struct ahci_host_priv *hpriv) 298 169 { 299 170 struct tegra_ahci_priv *tegra = hpriv->plat_data; 300 171 int ret; 301 - unsigned int val; 302 - struct sata_pad_calibration calib; 172 + u32 val; 303 173 304 174 ret = tegra_ahci_power_on(hpriv); 305 175 if (ret) { ··· 307 179 return ret; 308 180 } 309 181 182 + /* 183 + * Program the following SATA IPFS registers to allow SW accesses to 184 + * SATA's MMIO register range. 185 + */ 186 + val = readl(tegra->sata_regs + SATA_FPCI_BAR5); 187 + val &= ~(SATA_FPCI_BAR5_START_MASK | SATA_FPCI_BAR5_ACCESS_TYPE); 188 + val |= SATA_FPCI_BAR5_START | SATA_FPCI_BAR5_ACCESS_TYPE; 189 + writel(val, tegra->sata_regs + SATA_FPCI_BAR5); 190 + 191 + /* Program the following SATA IPFS register to enable the SATA */ 310 192 val = readl(tegra->sata_regs + SATA_CONFIGURATION_0); 311 - val |= SATA_CONFIGURATION_EN_FPCI; 193 + val |= SATA_CONFIGURATION_0_EN_FPCI; 312 194 writel(val, tegra->sata_regs + SATA_CONFIGURATION_0); 313 195 314 - /* Pad calibration */ 196 + /* Electrical settings for better link stability */ 197 + val = T_SATA0_CHX_PHY_CTRL17_0_RX_EQ_CTRL_L_GEN1; 198 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL17_0); 199 + val = T_SATA0_CHX_PHY_CTRL18_0_RX_EQ_CTRL_L_GEN2; 200 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL18_0); 201 + val = T_SATA0_CHX_PHY_CTRL20_0_RX_EQ_CTRL_H_GEN1; 202 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL20_0); 203 + val = T_SATA0_CHX_PHY_CTRL21_0_RX_EQ_CTRL_H_GEN2; 204 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL21_0); 315 205 316 - ret = tegra_fuse_readl(FUSE_SATA_CALIB, &val); 317 - if (ret) { 318 - dev_err(&tegra->pdev->dev, 319 - "failed to read calibration fuse: %d\n", ret); 320 - return ret; 321 - } 206 + /* For SQUELCH Filter & Gen3 drive getting detected as Gen1 drive */ 322 207 323 - calib = tegra124_pad_calibration[val & FUSE_SATA_CALIB_MASK]; 208 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA_CFG_PHY_0); 209 + val |= T_SATA_CFG_PHY_0_MASK_SQUELCH; 210 + val &= ~T_SATA_CFG_PHY_0_USE_7BIT_ALIGN_DET_FOR_SPD; 211 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA_CFG_PHY_0); 324 212 325 - writel(BIT(0), tegra->sata_regs + SCFG_OFFSET + T_SATA0_INDEX); 213 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_NVOOB); 214 + val &= ~(T_SATA0_NVOOB_COMMA_CNT_MASK | 215 + T_SATA0_NVOOB_SQUELCH_FILTER_LENGTH_MASK | 216 + T_SATA0_NVOOB_SQUELCH_FILTER_MODE_MASK); 217 + val |= (T_SATA0_NVOOB_COMMA_CNT | 218 + T_SATA0_NVOOB_SQUELCH_FILTER_LENGTH | 219 + T_SATA0_NVOOB_SQUELCH_FILTER_MODE); 220 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_NVOOB); 326 221 327 - val = readl(tegra->sata_regs + 328 - SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL1_GEN1); 329 - val &= ~T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_MASK; 330 - val &= ~T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_MASK; 331 - val |= calib.gen1_tx_amp << 332 - T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_SHIFT; 333 - val |= calib.gen1_tx_peak << 334 - T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_SHIFT; 335 - writel(val, tegra->sata_regs + SCFG_OFFSET + 336 - T_SATA0_CHX_PHY_CTRL1_GEN1); 222 + /* 223 + * Change CFG2NVOOB_2_COMWAKE_IDLE_CNT_LOW from 83.3 ns to 58.8ns 224 + */ 225 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG2NVOOB_2); 226 + val &= ~T_SATA0_CFG2NVOOB_2_COMWAKE_IDLE_CNT_LOW_MASK; 227 + val |= T_SATA0_CFG2NVOOB_2_COMWAKE_IDLE_CNT_LOW; 228 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG2NVOOB_2); 337 229 338 - val = readl(tegra->sata_regs + 339 - SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL1_GEN2); 340 - val &= ~T_SATA0_CHX_PHY_CTRL1_GEN2_TX_AMP_MASK; 341 - val &= ~T_SATA0_CHX_PHY_CTRL1_GEN2_TX_PEAK_MASK; 342 - val |= calib.gen2_tx_amp << 343 - T_SATA0_CHX_PHY_CTRL1_GEN1_TX_AMP_SHIFT; 344 - val |= calib.gen2_tx_peak << 345 - T_SATA0_CHX_PHY_CTRL1_GEN1_TX_PEAK_SHIFT; 346 - writel(val, tegra->sata_regs + SCFG_OFFSET + 347 - T_SATA0_CHX_PHY_CTRL1_GEN2); 230 + if (tegra->soc->ops && tegra->soc->ops->init) 231 + tegra->soc->ops->init(hpriv); 348 232 349 - writel(T_SATA0_CHX_PHY_CTRL11_GEN2_RX_EQ, 350 - tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL11); 351 - writel(T_SATA0_CHX_PHY_CTRL2_CDR_CNTL_GEN1, 352 - tegra->sata_regs + SCFG_OFFSET + T_SATA0_CHX_PHY_CTRL2); 233 + /* 234 + * Program the following SATA configuration registers to 235 + * initialize SATA 236 + */ 237 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_1); 238 + val |= (T_SATA0_CFG_1_IO_SPACE | T_SATA0_CFG_1_MEMORY_SPACE | 239 + T_SATA0_CFG_1_BUS_MASTER | T_SATA0_CFG_1_SERR); 240 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_1); 241 + val = T_SATA0_CFG_9_BASE_ADDRESS; 242 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_9); 353 243 354 - writel(0, tegra->sata_regs + SCFG_OFFSET + T_SATA0_INDEX); 355 - 356 - /* Program controller device ID */ 357 - 244 + /* Program Class Code and Programming interface for SATA */ 358 245 val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_SATA); 359 246 val |= T_SATA0_CFG_SATA_BACKDOOR_PROG_IF_EN; 360 247 writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_SATA); 361 248 362 - writel(0x01060100, tegra->sata_regs + SCFG_OFFSET + T_SATA0_BKDOOR_CC); 249 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_BKDOOR_CC); 250 + val &= 251 + ~(T_SATA0_BKDOOR_CC_CLASS_CODE_MASK | 252 + T_SATA0_BKDOOR_CC_PROG_IF_MASK); 253 + val |= T_SATA0_BKDOOR_CC_CLASS_CODE | T_SATA0_BKDOOR_CC_PROG_IF; 254 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_BKDOOR_CC); 363 255 364 256 val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_SATA); 365 257 val &= ~T_SATA0_CFG_SATA_BACKDOOR_PROG_IF_EN; 366 258 writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_SATA); 367 259 368 - /* Enable IO & memory access, bus master mode */ 260 + /* Enabling LPM capabilities through Backdoor Programming */ 261 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_AHCI_HBA_CAP_BKDR); 262 + val |= (T_SATA0_AHCI_HBA_CAP_BKDR_PARTIAL_ST_CAP | 263 + T_SATA0_AHCI_HBA_CAP_BKDR_SLUMBER_ST_CAP | 264 + T_SATA0_AHCI_HBA_CAP_BKDR_SALP | 265 + T_SATA0_AHCI_HBA_CAP_BKDR_SUPP_PM); 266 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_AHCI_HBA_CAP_BKDR); 369 267 370 - val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_1); 371 - val |= T_SATA0_CFG_1_IO_SPACE | T_SATA0_CFG_1_MEMORY_SPACE | 372 - T_SATA0_CFG_1_BUS_MASTER | T_SATA0_CFG_1_SERR; 373 - writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_1); 268 + /* SATA Second Level Clock Gating configuration 269 + * Enabling Gating of Tx/Rx clocks and driving Pad IDDQ and Lane 270 + * IDDQ Signals 271 + */ 272 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_35); 273 + val &= ~T_SATA0_CFG_35_IDP_INDEX_MASK; 274 + val |= T_SATA0_CFG_35_IDP_INDEX; 275 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_35); 374 276 375 - /* Program SATA MMIO */ 277 + val = T_SATA0_AHCI_IDP1_DATA; 278 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_AHCI_IDP1); 376 279 377 - writel(0x10000 << SATA_FPCI_BAR5_START_SHIFT, 378 - tegra->sata_regs + SATA_FPCI_BAR5); 280 + val = readl(tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_PHY_1); 281 + val |= (T_SATA0_CFG_PHY_1_PADS_IDDQ_EN | 282 + T_SATA0_CFG_PHY_1_PAD_PLL_IDDQ_EN); 283 + writel(val, tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_PHY_1); 379 284 380 - writel(0x08000 << T_SATA0_CFG_9_BASE_ADDRESS_SHIFT, 381 - tegra->sata_regs + SCFG_OFFSET + T_SATA0_CFG_9); 285 + /* Enabling IPFS Clock Gating */ 286 + val = readl(tegra->sata_regs + SATA_CONFIGURATION_0); 287 + val &= ~SATA_CONFIGURATION_0_CLK_OVERRIDE; 288 + writel(val, tegra->sata_regs + SATA_CONFIGURATION_0); 289 + 290 + tegra_ahci_handle_quirks(hpriv); 382 291 383 292 /* Unmask SATA interrupts */ 384 293 ··· 444 279 }; 445 280 446 281 static const struct ata_port_info ahci_tegra_port_info = { 447 - .flags = AHCI_FLAG_COMMON, 282 + .flags = AHCI_FLAG_COMMON | ATA_FLAG_NO_DIPM, 448 283 .pio_mask = ATA_PIO4, 449 284 .udma_mask = ATA_UDMA6, 450 285 .port_ops = &ahci_tegra_port_ops, 451 286 }; 452 287 288 + static const char *const tegra124_supply_names[] = { 289 + "avdd", "hvdd", "vddio", "target-5v", "target-12v" 290 + }; 291 + 292 + static const struct tegra_ahci_ops tegra124_ahci_ops = { 293 + .init = tegra124_ahci_init, 294 + }; 295 + 296 + static const struct tegra_ahci_soc tegra124_ahci_soc = { 297 + .supply_names = tegra124_supply_names, 298 + .num_supplies = ARRAY_SIZE(tegra124_supply_names), 299 + .supports_devslp = false, 300 + .ops = &tegra124_ahci_ops, 301 + }; 302 + 303 + static const struct tegra_ahci_soc tegra210_ahci_soc = { 304 + .supports_devslp = false, 305 + }; 306 + 453 307 static const struct of_device_id tegra_ahci_of_match[] = { 454 - { .compatible = "nvidia,tegra124-ahci" }, 308 + { 309 + .compatible = "nvidia,tegra124-ahci", 310 + .data = &tegra124_ahci_soc 311 + }, 312 + { 313 + .compatible = "nvidia,tegra210-ahci", 314 + .data = &tegra210_ahci_soc 315 + }, 455 316 {} 456 317 }; 457 318 MODULE_DEVICE_TABLE(of, tegra_ahci_of_match); ··· 492 301 struct tegra_ahci_priv *tegra; 493 302 struct resource *res; 494 303 int ret; 304 + unsigned int i; 495 305 496 306 hpriv = ahci_platform_get_resources(pdev); 497 307 if (IS_ERR(hpriv)) ··· 505 313 hpriv->plat_data = tegra; 506 314 507 315 tegra->pdev = pdev; 316 + tegra->soc = of_device_get_match_data(&pdev->dev); 508 317 509 318 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 510 319 tegra->sata_regs = devm_ioremap_resource(&pdev->dev, res); 511 320 if (IS_ERR(tegra->sata_regs)) 512 321 return PTR_ERR(tegra->sata_regs); 322 + 323 + /* 324 + * AUX registers is optional. 325 + */ 326 + res = platform_get_resource(pdev, IORESOURCE_MEM, 2); 327 + if (res) { 328 + tegra->sata_aux_regs = devm_ioremap_resource(&pdev->dev, res); 329 + if (IS_ERR(tegra->sata_aux_regs)) 330 + return PTR_ERR(tegra->sata_aux_regs); 331 + } 513 332 514 333 tegra->sata_rst = devm_reset_control_get(&pdev->dev, "sata"); 515 334 if (IS_ERR(tegra->sata_rst)) { ··· 546 343 return PTR_ERR(tegra->sata_clk); 547 344 } 548 345 549 - tegra->supplies[0].supply = "avdd"; 550 - tegra->supplies[1].supply = "hvdd"; 551 - tegra->supplies[2].supply = "vddio"; 552 - tegra->supplies[3].supply = "target-5v"; 553 - tegra->supplies[4].supply = "target-12v"; 346 + tegra->supplies = devm_kcalloc(&pdev->dev, 347 + tegra->soc->num_supplies, 348 + sizeof(*tegra->supplies), GFP_KERNEL); 349 + if (!tegra->supplies) 350 + return -ENOMEM; 554 351 555 - ret = devm_regulator_bulk_get(&pdev->dev, ARRAY_SIZE(tegra->supplies), 352 + for (i = 0; i < tegra->soc->num_supplies; i++) 353 + tegra->supplies[i].supply = tegra->soc->supply_names[i]; 354 + 355 + ret = devm_regulator_bulk_get(&pdev->dev, 356 + tegra->soc->num_supplies, 556 357 tegra->supplies); 557 358 if (ret) { 558 359 dev_err(&pdev->dev, "Failed to get regulators\n"); ··· 592 385 module_platform_driver(tegra_ahci_driver); 593 386 594 387 MODULE_AUTHOR("Mikko Perttunen <mperttunen@nvidia.com>"); 595 - MODULE_DESCRIPTION("Tegra124 AHCI SATA driver"); 388 + MODULE_DESCRIPTION("Tegra AHCI SATA driver"); 596 389 MODULE_LICENSE("GPL v2");
+21 -3
drivers/ata/libahci_platform.c
··· 25 25 #include <linux/phy/phy.h> 26 26 #include <linux/pm_runtime.h> 27 27 #include <linux/of_platform.h> 28 + #include <linux/reset.h> 28 29 #include "ahci.h" 29 30 30 31 static void ahci_host_stop(struct ata_host *host); ··· 196 195 * following order: 197 196 * 1) Regulator 198 197 * 2) Clocks (through ahci_platform_enable_clks) 199 - * 3) Phys 198 + * 3) Resets 199 + * 4) Phys 200 200 * 201 201 * If resource enabling fails at any point the previous enabled resources 202 202 * are disabled in reverse order. ··· 217 215 if (rc) 218 216 goto disable_regulator; 219 217 220 - rc = ahci_platform_enable_phys(hpriv); 218 + rc = reset_control_deassert(hpriv->rsts); 221 219 if (rc) 222 220 goto disable_clks; 223 221 222 + rc = ahci_platform_enable_phys(hpriv); 223 + if (rc) 224 + goto disable_resets; 225 + 224 226 return 0; 227 + 228 + disable_resets: 229 + reset_control_assert(hpriv->rsts); 225 230 226 231 disable_clks: 227 232 ahci_platform_disable_clks(hpriv); ··· 248 239 * following order: 249 240 * 1) Phys 250 241 * 2) Clocks (through ahci_platform_disable_clks) 251 - * 3) Regulator 242 + * 3) Resets 243 + * 4) Regulator 252 244 */ 253 245 void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) 254 246 { 255 247 ahci_platform_disable_phys(hpriv); 248 + 249 + reset_control_assert(hpriv->rsts); 256 250 257 251 ahci_platform_disable_clks(hpriv); 258 252 ··· 403 391 break; 404 392 } 405 393 hpriv->clks[i] = clk; 394 + } 395 + 396 + hpriv->rsts = devm_reset_control_array_get_optional_shared(dev); 397 + if (IS_ERR(hpriv->rsts)) { 398 + rc = PTR_ERR(hpriv->rsts); 399 + goto err_out; 406 400 } 407 401 408 402 hpriv->nports = child_nodes = of_get_child_count(dev->of_node);
+38 -8
drivers/ata/libata-core.c
··· 6026 6026 return ap; 6027 6027 } 6028 6028 6029 - static void ata_host_release(struct device *gendev, void *res) 6029 + static void ata_devres_release(struct device *gendev, void *res) 6030 6030 { 6031 6031 struct ata_host *host = dev_get_drvdata(gendev); 6032 6032 int i; ··· 6040 6040 if (ap->scsi_host) 6041 6041 scsi_host_put(ap->scsi_host); 6042 6042 6043 + } 6044 + 6045 + dev_set_drvdata(gendev, NULL); 6046 + ata_host_put(host); 6047 + } 6048 + 6049 + static void ata_host_release(struct kref *kref) 6050 + { 6051 + struct ata_host *host = container_of(kref, struct ata_host, kref); 6052 + int i; 6053 + 6054 + for (i = 0; i < host->n_ports; i++) { 6055 + struct ata_port *ap = host->ports[i]; 6056 + 6043 6057 kfree(ap->pmp_link); 6044 6058 kfree(ap->slave_link); 6045 6059 kfree(ap); 6046 6060 host->ports[i] = NULL; 6047 6061 } 6062 + kfree(host); 6063 + } 6048 6064 6049 - dev_set_drvdata(gendev, NULL); 6065 + void ata_host_get(struct ata_host *host) 6066 + { 6067 + kref_get(&host->kref); 6068 + } 6069 + 6070 + void ata_host_put(struct ata_host *host) 6071 + { 6072 + kref_put(&host->kref, ata_host_release); 6050 6073 } 6051 6074 6052 6075 /** ··· 6097 6074 struct ata_host *host; 6098 6075 size_t sz; 6099 6076 int i; 6077 + void *dr; 6100 6078 6101 6079 DPRINTK("ENTER\n"); 6102 6080 6103 - if (!devres_open_group(dev, NULL, GFP_KERNEL)) 6104 - return NULL; 6105 - 6106 6081 /* alloc a container for our list of ATA ports (buses) */ 6107 6082 sz = sizeof(struct ata_host) + (max_ports + 1) * sizeof(void *); 6108 - /* alloc a container for our list of ATA ports (buses) */ 6109 - host = devres_alloc(ata_host_release, sz, GFP_KERNEL); 6083 + host = kzalloc(sz, GFP_KERNEL); 6110 6084 if (!host) 6085 + return NULL; 6086 + 6087 + if (!devres_open_group(dev, NULL, GFP_KERNEL)) 6088 + goto err_free; 6089 + 6090 + dr = devres_alloc(ata_devres_release, 0, GFP_KERNEL); 6091 + if (!dr) 6111 6092 goto err_out; 6112 6093 6113 - devres_add(dev, host); 6094 + devres_add(dev, dr); 6114 6095 dev_set_drvdata(dev, host); 6115 6096 6116 6097 spin_lock_init(&host->lock); 6117 6098 mutex_init(&host->eh_mutex); 6118 6099 host->dev = dev; 6119 6100 host->n_ports = max_ports; 6101 + kref_init(&host->kref); 6120 6102 6121 6103 /* allocate ports bound to this host */ 6122 6104 for (i = 0; i < max_ports; i++) { ··· 6140 6112 6141 6113 err_out: 6142 6114 devres_release_group(dev, NULL); 6115 + err_free: 6116 + kfree(host); 6143 6117 return NULL; 6144 6118 } 6145 6119
+4
drivers/ata/libata-transport.c
··· 224 224 225 225 static void ata_tport_release(struct device *dev) 226 226 { 227 + struct ata_port *ap = tdev_to_port(dev); 228 + ata_host_put(ap->host); 227 229 } 228 230 229 231 /** ··· 286 284 dev->type = &ata_port_type; 287 285 288 286 dev->parent = parent; 287 + ata_host_get(ap->host); 289 288 dev->release = ata_tport_release; 290 289 dev_set_name(dev, "ata%d", ap->print_id); 291 290 transport_setup_device(dev); ··· 317 314 tport_err: 318 315 transport_destroy_device(dev); 319 316 put_device(dev); 317 + ata_host_put(ap->host); 320 318 return error; 321 319 } 322 320
+2
drivers/ata/libata.h
··· 100 100 extern void __ata_port_probe(struct ata_port *ap); 101 101 extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log, 102 102 u8 page, void *buf, unsigned int sectors); 103 + extern void ata_host_get(struct ata_host *host); 104 + extern void ata_host_put(struct ata_host *host); 103 105 104 106 #define to_ata_port(d) container_of(d, struct ata_port, tdev) 105 107
+2 -4
drivers/ata/pata_arasan_cf.c
··· 796 796 struct resource *res; 797 797 u32 quirk; 798 798 irq_handler_t irq_handler = NULL; 799 - int ret = 0; 799 + int ret; 800 800 801 801 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 802 802 if (!res) ··· 809 809 } 810 810 811 811 acdev = devm_kzalloc(&pdev->dev, sizeof(*acdev), GFP_KERNEL); 812 - if (!acdev) { 813 - dev_warn(&pdev->dev, "kzalloc fail\n"); 812 + if (!acdev) 814 813 return -ENOMEM; 815 - } 816 814 817 815 if (pdata) 818 816 quirk = pdata->quirk;
+3 -5
drivers/ata/pata_bk3710.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 1 3 /* 2 4 * Palmchip BK3710 PATA controller driver 3 5 * ··· 10 8 * 11 9 * Copyright (C) 2006 Texas Instruments. 12 10 * Copyright (C) 2007 MontaVista Software, Inc., <source@mvista.com> 13 - * 14 - * This file is subject to the terms and conditions of the GNU General Public 15 - * License. See the file "COPYING" in the main directory of this archive 16 - * for more details. 17 11 */ 18 12 19 13 #include <linux/ata.h> ··· 377 379 } 378 380 379 381 module_init(pata_bk3710_init); 380 - MODULE_LICENSE("GPL"); 382 + MODULE_LICENSE("GPL v2");
+3 -5
drivers/ata/pata_falcon.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 1 3 /* 2 4 * Atari Falcon PATA controller driver 3 5 * ··· 9 7 * Based on falconide.c: 10 8 * 11 9 * Created 12 Jul 1997 by Geert Uytterhoeven 12 - * 13 - * This file is subject to the terms and conditions of the GNU General Public 14 - * License. See the file "COPYING" in the main directory of this archive 15 - * for more details. 16 10 */ 17 11 18 12 #include <linux/kernel.h> ··· 178 180 179 181 MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); 180 182 MODULE_DESCRIPTION("low-level driver for Atari Falcon PATA"); 181 - MODULE_LICENSE("GPL"); 183 + MODULE_LICENSE("GPL v2"); 182 184 MODULE_VERSION(DRV_VERSION);
+219
drivers/ata/pata_gayle.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + /* 4 + * Amiga Gayle PATA controller driver 5 + * 6 + * Copyright (c) 2018 Samsung Electronics Co., Ltd. 7 + * http://www.samsung.com 8 + * 9 + * Based on gayle.c: 10 + * 11 + * Created 12 Jul 1997 by Geert Uytterhoeven 12 + */ 13 + 14 + #include <linux/ata.h> 15 + #include <linux/blkdev.h> 16 + #include <linux/delay.h> 17 + #include <linux/interrupt.h> 18 + #include <linux/kernel.h> 19 + #include <linux/libata.h> 20 + #include <linux/mm.h> 21 + #include <linux/module.h> 22 + #include <linux/platform_device.h> 23 + #include <linux/zorro.h> 24 + #include <scsi/scsi_cmnd.h> 25 + #include <scsi/scsi_host.h> 26 + 27 + #include <asm/amigahw.h> 28 + #include <asm/amigaints.h> 29 + #include <asm/amigayle.h> 30 + #include <asm/ide.h> 31 + #include <asm/setup.h> 32 + 33 + #define DRV_NAME "pata_gayle" 34 + #define DRV_VERSION "0.1.0" 35 + 36 + #define GAYLE_CONTROL 0x101a 37 + 38 + static struct scsi_host_template pata_gayle_sht = { 39 + ATA_PIO_SHT(DRV_NAME), 40 + }; 41 + 42 + /* FIXME: is this needed? */ 43 + static unsigned int pata_gayle_data_xfer(struct ata_queued_cmd *qc, 44 + unsigned char *buf, 45 + unsigned int buflen, int rw) 46 + { 47 + struct ata_device *dev = qc->dev; 48 + struct ata_port *ap = dev->link->ap; 49 + void __iomem *data_addr = ap->ioaddr.data_addr; 50 + unsigned int words = buflen >> 1; 51 + 52 + /* Transfer multiple of 2 bytes */ 53 + if (rw == READ) 54 + raw_insw((u16 *)data_addr, (u16 *)buf, words); 55 + else 56 + raw_outsw((u16 *)data_addr, (u16 *)buf, words); 57 + 58 + /* Transfer trailing byte, if any. */ 59 + if (unlikely(buflen & 0x01)) { 60 + unsigned char pad[2] = { }; 61 + 62 + /* Point buf to the tail of buffer */ 63 + buf += buflen - 1; 64 + 65 + if (rw == READ) { 66 + raw_insw((u16 *)data_addr, (u16 *)pad, 1); 67 + *buf = pad[0]; 68 + } else { 69 + pad[0] = *buf; 70 + raw_outsw((u16 *)data_addr, (u16 *)pad, 1); 71 + } 72 + words++; 73 + } 74 + 75 + return words << 1; 76 + } 77 + 78 + /* 79 + * Provide our own set_mode() as we don't want to change anything that has 80 + * already been configured.. 81 + */ 82 + static int pata_gayle_set_mode(struct ata_link *link, 83 + struct ata_device **unused) 84 + { 85 + struct ata_device *dev; 86 + 87 + ata_for_each_dev(dev, link, ENABLED) { 88 + /* We don't really care */ 89 + dev->pio_mode = dev->xfer_mode = XFER_PIO_0; 90 + dev->xfer_shift = ATA_SHIFT_PIO; 91 + dev->flags |= ATA_DFLAG_PIO; 92 + ata_dev_info(dev, "configured for PIO\n"); 93 + } 94 + return 0; 95 + } 96 + 97 + static bool pata_gayle_irq_check(struct ata_port *ap) 98 + { 99 + u8 ch; 100 + 101 + ch = z_readb((unsigned long)ap->private_data); 102 + 103 + return !!(ch & GAYLE_IRQ_IDE); 104 + } 105 + 106 + static void pata_gayle_irq_clear(struct ata_port *ap) 107 + { 108 + (void)z_readb((unsigned long)ap->ioaddr.status_addr); 109 + z_writeb(0x7c, (unsigned long)ap->private_data); 110 + } 111 + 112 + static struct ata_port_operations pata_gayle_a1200_ops = { 113 + .inherits = &ata_sff_port_ops, 114 + .sff_data_xfer = pata_gayle_data_xfer, 115 + .sff_irq_check = pata_gayle_irq_check, 116 + .sff_irq_clear = pata_gayle_irq_clear, 117 + .cable_detect = ata_cable_unknown, 118 + .set_mode = pata_gayle_set_mode, 119 + }; 120 + 121 + static struct ata_port_operations pata_gayle_a4000_ops = { 122 + .inherits = &ata_sff_port_ops, 123 + .sff_data_xfer = pata_gayle_data_xfer, 124 + .cable_detect = ata_cable_unknown, 125 + .set_mode = pata_gayle_set_mode, 126 + }; 127 + 128 + static int __init pata_gayle_init_one(struct platform_device *pdev) 129 + { 130 + struct resource *res; 131 + struct gayle_ide_platform_data *pdata; 132 + struct ata_host *host; 133 + struct ata_port *ap; 134 + void __iomem *base; 135 + int ret; 136 + 137 + pdata = dev_get_platdata(&pdev->dev); 138 + 139 + dev_info(&pdev->dev, "Amiga Gayle IDE controller (A%u style)\n", 140 + pdata->explicit_ack ? 1200 : 4000); 141 + 142 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 143 + if (!res) 144 + return -ENODEV; 145 + 146 + if (!devm_request_mem_region(&pdev->dev, res->start, 147 + resource_size(res), DRV_NAME)) { 148 + pr_err(DRV_NAME ": resources busy\n"); 149 + return -EBUSY; 150 + } 151 + 152 + /* allocate host */ 153 + host = ata_host_alloc(&pdev->dev, 1); 154 + if (!host) 155 + return -ENOMEM; 156 + 157 + ap = host->ports[0]; 158 + 159 + if (pdata->explicit_ack) 160 + ap->ops = &pata_gayle_a1200_ops; 161 + else 162 + ap->ops = &pata_gayle_a4000_ops; 163 + 164 + ap->pio_mask = ATA_PIO4; 165 + ap->flags |= ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_IORDY; 166 + 167 + base = ZTWO_VADDR(pdata->base); 168 + ap->ioaddr.data_addr = base; 169 + ap->ioaddr.error_addr = base + 2 + 1 * 4; 170 + ap->ioaddr.feature_addr = base + 2 + 1 * 4; 171 + ap->ioaddr.nsect_addr = base + 2 + 2 * 4; 172 + ap->ioaddr.lbal_addr = base + 2 + 3 * 4; 173 + ap->ioaddr.lbam_addr = base + 2 + 4 * 4; 174 + ap->ioaddr.lbah_addr = base + 2 + 5 * 4; 175 + ap->ioaddr.device_addr = base + 2 + 6 * 4; 176 + ap->ioaddr.status_addr = base + 2 + 7 * 4; 177 + ap->ioaddr.command_addr = base + 2 + 7 * 4; 178 + 179 + ap->ioaddr.altstatus_addr = base + GAYLE_CONTROL; 180 + ap->ioaddr.ctl_addr = base + GAYLE_CONTROL; 181 + 182 + ap->private_data = (void *)ZTWO_VADDR(pdata->irqport); 183 + 184 + ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", pdata->base, 185 + pdata->base + GAYLE_CONTROL); 186 + 187 + ret = ata_host_activate(host, IRQ_AMIGA_PORTS, ata_sff_interrupt, 188 + IRQF_SHARED, &pata_gayle_sht); 189 + if (ret) 190 + return ret; 191 + 192 + platform_set_drvdata(pdev, host); 193 + 194 + return 0; 195 + } 196 + 197 + static int __exit pata_gayle_remove_one(struct platform_device *pdev) 198 + { 199 + struct ata_host *host = platform_get_drvdata(pdev); 200 + 201 + ata_host_detach(host); 202 + 203 + return 0; 204 + } 205 + 206 + static struct platform_driver pata_gayle_driver = { 207 + .remove = __exit_p(pata_gayle_remove_one), 208 + .driver = { 209 + .name = "amiga-gayle-ide", 210 + }, 211 + }; 212 + 213 + module_platform_driver_probe(pata_gayle_driver, pata_gayle_init_one); 214 + 215 + MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); 216 + MODULE_DESCRIPTION("low-level driver for Amiga Gayle PATA"); 217 + MODULE_LICENSE("GPL v2"); 218 + MODULE_ALIAS("platform:amiga-gayle-ide"); 219 + MODULE_VERSION(DRV_VERSION);
+3 -3
drivers/ata/pata_it821x.c
··· 658 658 u8 status; 659 659 int n = 0; 660 660 u16 *buf = kmalloc(len, GFP_KERNEL); 661 - if (buf == NULL) { 662 - printk(KERN_ERR "it821x_firmware_command: Out of memory\n"); 661 + 662 + if (!buf) 663 663 return NULL; 664 - } 664 + 665 665 /* This isn't quite a normal ATA command as we are talking to the 666 666 firmware not the drives */ 667 667 ap->ctl |= ATA_NIEN;
+4 -8
drivers/ata/pata_macio.c
··· 1131 1131 /* Allocate and init private data structure */ 1132 1132 priv = devm_kzalloc(&mdev->ofdev.dev, 1133 1133 sizeof(struct pata_macio_priv), GFP_KERNEL); 1134 - if (priv == NULL) { 1135 - dev_err(&mdev->ofdev.dev, 1136 - "Failed to allocate private memory\n"); 1134 + if (!priv) 1137 1135 return -ENOMEM; 1138 - } 1136 + 1139 1137 priv->node = of_node_get(mdev->ofdev.dev.of_node); 1140 1138 priv->mdev = mdev; 1141 1139 priv->dev = &mdev->ofdev.dev; ··· 1275 1277 /* Allocate and init private data structure */ 1276 1278 priv = devm_kzalloc(&pdev->dev, 1277 1279 sizeof(struct pata_macio_priv), GFP_KERNEL); 1278 - if (priv == NULL) { 1279 - dev_err(&pdev->dev, 1280 - "Failed to allocate private memory\n"); 1280 + if (!priv) 1281 1281 return -ENOMEM; 1282 - } 1282 + 1283 1283 priv->node = of_node_get(np); 1284 1284 priv->pdev = pdev; 1285 1285 priv->dev = &pdev->dev;
-1
drivers/ata/pata_mpc52xx.c
··· 738 738 /* Prepare our private structure */ 739 739 priv = devm_kzalloc(&op->dev, sizeof(*priv), GFP_ATOMIC); 740 740 if (!priv) { 741 - dev_err(&op->dev, "error allocating private structure\n"); 742 741 rv = -ENOMEM; 743 742 goto err1; 744 743 }
+1 -3
drivers/ata/pata_samsung_cf.c
··· 505 505 cpu_type = platform_get_device_id(pdev)->driver_data; 506 506 507 507 info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); 508 - if (!info) { 509 - dev_err(dev, "failed to allocate memory for device data\n"); 508 + if (!info) 510 509 return -ENOMEM; 511 - } 512 510 513 511 info->irq = platform_get_irq(pdev, 0); 514 512
-1
drivers/ata/sata_dwc_460ex.c
··· 901 901 /* Allocate Port Struct */ 902 902 hsdevp = kzalloc(sizeof(*hsdevp), GFP_KERNEL); 903 903 if (!hsdevp) { 904 - dev_err(ap->dev, "%s: kmalloc failed for hsdevp\n", __func__); 905 904 err = -ENOMEM; 906 905 goto CLEANUP; 907 906 }
+1
include/linux/libata.h
··· 617 617 void *private_data; 618 618 struct ata_port_operations *ops; 619 619 unsigned long flags; 620 + struct kref kref; 620 621 621 622 struct mutex eh_mutex; 622 623 struct task_struct *eh_owner;
+2
include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
··· 243 243 #define IMX6Q_GPR4_IPU_RD_CACHE_CTL BIT(0) 244 244 245 245 #define IMX6Q_GPR5_L2_CLK_STOP BIT(8) 246 + #define IMX6Q_GPR5_SATA_SW_PD BIT(10) 247 + #define IMX6Q_GPR5_SATA_SW_RST BIT(11) 246 248 247 249 #define IMX6Q_GPR6_IPU1_ID00_WR_QOS_MASK (0xf << 0) 248 250 #define IMX6Q_GPR6_IPU1_ID01_WR_QOS_MASK (0xf << 4)