ata: ahci_platform: support allwinner R40 AHCI
Subsystems (4)
v5 cover ata: ahci_platform: support allwinner R40 AHCI
This patchset add support for allwinner R40 AHCI controller.
The whole patchset is tested on sun8i-r40-bananapi-m2-ultra and on sun7i-a20-cubieboard2 which doesnt have any of the ressources added by this serie, so no regression should come with it.
Patchs 1-7 should go via the ata tree
Patchs 8,9 should go via the sunxi tree
Changes since v4:
- dropped PHY dedicated driver
- added the optionnal phy-supply
Changes since v3:
- Moved PHY code to a new sun4i-a10-phy-sata driver
- Removed reset code since ahci_platform support now reset controller.
Changes since V2
- Moved all ressources management to ahci_platform
Corentin Labbe (9):
dt-bindings: ata: ahci-platform: fix indentation of target-supply
ata: ahci_platform: add support for AHCI controller regulator
dt-bindings: ata: ahci-platform: document ahci-supply
ata: ahci_platform: add support for PHY controller regulator
dt-bindings: ata: ahci-platform: document phy-supply
ata: ahci_sunxi: add support for r40
dt-bindings: ata: update ahci_sunxi bindings
ARM: dts: sun8i: r40: add sata node
ARM: dts: sun8i: sun8i-r40-bananapi-m2-ultra: enable AHCI
.../devicetree/bindings/ata/ahci-platform.txt | 6 ++- arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts | 18 +++++++++ arch/arm/boot/dts/sun8i-r40.dtsi | 13 ++++++ drivers/ata/ahci.h | 2 + drivers/ata/ahci_sunxi.c | 3 +- drivers/ata/libahci_platform.c | 46 +++++++++++++++++++++- 6 files changed, 84 insertions(+), 4 deletions(-)
Signature · 1 line
2.16.4
PATCH v5 1/9 dt-bindings: ata: ahci-platform: fix indentation of target-supply
This patch fix the indentation of target-supply's ':'.
--- Documentation/devicetree/bindings/ata/ahci-platform.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/ata/ahci-platform.txt +1 -1
@@ -47,7 +47,7 @@ Sub-nodes required properties: - reg : the port number And at least one of the following properties: - phys : reference to the SATA PHY node -- target-supply : regulator for SATA target power +- target-supply : regulator for SATA target power Examples: sata at ffe08000 {
Signature · 1 line
2.16.4
Rob Herring
maintainerRe: [PATCH v5 1/9] dt-bindings: ata: ahci-platform: fix indentation of target-supply
Quoted 6 lines · Corentin Labbe
This patch fix the indentation of target-supply's ':'.
Signed-off-by Corentin Labbe <[email protected]>--- Documentation/devicetree/bindings/ata/ahci-platform.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Please add acks/reviewed-bys when posting new versions.
Rob
PATCH v5 2/9 ata: ahci_platform: add support for AHCI controller regulator
In reply to Corentin LabbeThe SoC R40 AHCI controller need a regulator to work.
So this patch add a way to add an optional regulator on AHCI controller.
--- drivers/ata/ahci.h | 1 + drivers/ata/libahci_platform.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-)
drivers/ata/ahci.h +1 -0
@@ -352,6 +352,7 @@ struct ahci_host_priv {struct clk *clks[AHCI_MAX_CLKS ];/* Optional */ struct reset_control *rsts;/* Optional */ struct regulator **target_pwrs;/* Optional */ +struct regulator *ahci_regulator;/* Optional */ /* * If platform uses PHYs. There is a 1:1 relation between the port number and * the PHY position in this array.
drivers/ata/libahci_platform.c +24 -2
@@ -139,7 +139,7 @@ EXPORT_SYMBOL_GPL(ahci_platform_disable_clks);* ahci_platform_enable_regulators - Enable regulators * @hpriv: host private area to store config values * -* This function enables all the regulators found in +* This function enables all the regulators found in controller and * hpriv->target_pwrs, if any. If a regulator fails to be enabled, it * disables all the regulators already enabled in reverse order and * returns an error.
@@ -151,6 +151,12 @@ int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv) {int rc, i; +if (hpriv->ahci_regulator) { + rc =regulator_enable (hpriv->ahci_regulator); +if (rc) +return rc; + } +for (i =0 ; i < hpriv->nports; i++) {if (!hpriv->target_pwrs[i])continue ;
@@ -167,6 +173,8 @@ int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv)if (hpriv->target_pwrs[i])regulator_disable (hpriv->target_pwrs[i]); +if (hpriv->ahci_regulator) +regulator_disable (hpriv->ahci_regulator);return rc; }EXPORT_SYMBOL_GPL (ahci_platform_enable_regulators);
@@ -175,7 +183,8 @@ EXPORT_SYMBOL_GPL(ahci_platform_enable_regulators);* ahci_platform_disable_regulators - Disable regulators * @hpriv: host private area to store config values * -* This function disables all regulators found in hpriv->target_pwrs. +* This function disables all regulators found in hpriv->target_pwrs and +* AHCI controller. */ void ahci_platform_disable_regulators (struct ahci_host_priv *hpriv) {
@@ -186,6 +195,9 @@ void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv)continue ;regulator_disable (hpriv->target_pwrs[i]); } + +if (hpriv->ahci_regulator) +regulator_disable (hpriv->ahci_regulator); }EXPORT_SYMBOL_GPL (ahci_platform_disable_regulators);/**
@@ -351,6 +363,7 @@ static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port,* * 1) mmio registers (IORESOURCE_MEM 0, mandatory) * 2) regulator for controlling the targets power (optional) +* regulator for controlling the AHCI controller (optional) * 3) 0 - AHCI_MAX_CLKS clocks, as specified in the devs devicetree node, * or for non devicetree enabled platforms a single clock * 4) resets, if flags has AHCI_PLATFORM_GET_RESETS (optional)
@@ -408,6 +421,15 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, hpriv->clks[i] = clk; } + hpriv->ahci_regulator =devm_regulator_get_optional (dev,"ahci" ); +if (IS_ERR (hpriv->ahci_regulator)) { + rc =PTR_ERR (hpriv->ahci_regulator); +if (rc == -EPROBE_DEFER ) + goto err_out; + rc =0 ; + hpriv->ahci_regulator =NULL ; + } +if (flags &AHCI_PLATFORM_GET_RESETS ) { hpriv->rsts =devm_reset_control_array_get_optional_shared (dev);if (IS_ERR (hpriv->rsts)) {
Signature · 1 line
2.16.4
PATCH v5 3/9 dt-bindings: ata: ahci-platform: document ahci-supply
In reply to Corentin LabbeThis patch document the new optional ahci-supply.
--- Documentation/devicetree/bindings/ata/ahci-platform.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/ata/ahci-platform.txt +1 -0
@@ -33,6 +33,7 @@ Optional properties: - target-supply : regulator for SATA target power - phys : reference to the SATA PHY node - phy-names : must be "sata-phy" +- ahci-supply : regulator for AHCI controller - ports-implemented : Mask that indicates which ports that the HBA supports are available for software to use. Useful if PORTS_IMPL is not programmed by the BIOS, which is true with
Signature · 1 line
2.16.4
PATCH v5 4/9 ata: ahci_platform: add support for PHY controller regulator
In reply to Corentin LabbeThe SoC R40 AHCI controller need a PHY regulator to work.
But since the PHY is embedded in the controller, we cannot do a DT node for it, since phy-supply works only in node with a PHY compatible.
So this patch adds a way to add an optional phy-supply regulator on AHCI controller node.
--- drivers/ata/ahci.h | 1 + drivers/ata/libahci_platform.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+)
drivers/ata/ahci.h +1 -0
@@ -353,6 +353,7 @@ struct ahci_host_priv {struct reset_control *rsts;/* Optional */ struct regulator **target_pwrs;/* Optional */ struct regulator *ahci_regulator;/* Optional */ +struct regulator *phy_regulator;/* Optional */ /* * If platform uses PHYs. There is a 1:1 relation between the port number and * the PHY position in this array.
drivers/ata/libahci_platform.c +20 -0
@@ -157,6 +157,12 @@ int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv)return rc; } +if (hpriv->phy_regulator) { + rc =regulator_enable (hpriv->phy_regulator); +if (rc) + goto disable_ahci_pwrs; + } +for (i =0 ; i < hpriv->nports; i++) {if (!hpriv->target_pwrs[i])continue ;
@@ -173,6 +179,9 @@ int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv)if (hpriv->target_pwrs[i])regulator_disable (hpriv->target_pwrs[i]); +if (hpriv->phy_regulator) +regulator_disable (hpriv->phy_regulator); +disable_ahci_pwrs:if (hpriv->ahci_regulator)regulator_disable (hpriv->ahci_regulator);return rc;
@@ -198,6 +207,8 @@ void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv)if (hpriv->ahci_regulator)regulator_disable (hpriv->ahci_regulator); +if (hpriv->phy_regulator) +regulator_disable (hpriv->phy_regulator); }EXPORT_SYMBOL_GPL (ahci_platform_disable_regulators);/**
@@ -430,6 +441,15 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, hpriv->ahci_regulator =NULL ; } + hpriv->phy_regulator =devm_regulator_get_optional (dev,"phy" ); +if (IS_ERR (hpriv->phy_regulator)) { + rc =PTR_ERR (hpriv->phy_regulator); +if (rc == -EPROBE_DEFER ) + goto err_out; + rc =0 ; + hpriv->phy_regulator =NULL ; + } +if (flags &AHCI_PLATFORM_GET_RESETS ) { hpriv->rsts =devm_reset_control_array_get_optional_shared (dev);if (IS_ERR (hpriv->rsts)) {
Signature · 1 line
2.16.4
PATCH v5 5/9 dt-bindings: ata: ahci-platform: document phy-supply
In reply to Corentin LabbeThis patch document the new optional phy-supply.
--- Documentation/devicetree/bindings/ata/ahci-platform.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/ata/ahci-platform.txt +1 -0
@@ -31,6 +31,7 @@ Optional properties: - clocks : a list of phandle + clock specifier pairs - resets : a list of phandle + reset specifier pairs - target-supply : regulator for SATA target power +- phy-supply : regulator for PHY power - phys : reference to the SATA PHY node - phy-names : must be "sata-phy" - ahci-supply : regulator for AHCI controller
Signature · 1 line
2.16.4
Rob Herring
maintainerRe: [PATCH v5 5/9] dt-bindings: ata: ahci-platform: document phy-supply
Quoted 12 lines · Corentin Labbe
This patch document the new optional phy-supply.
Signed-off-by Corentin Labbe <[email protected]>--- Documentation/devicetree/bindings/ata/ahci-platform.txt | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/ata/ahci-platform.txt +0
-0
Documentation/devicetree/bindings/ata/ahci-platform.txt Optional properties: · line 34
Quoted 4 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt +1
-0@@ -31,6 +31,7 @@ Optional properties: - clocks : a list of phandle + clock specifier pairs - resets : a list of phandle + reset specifier pairs - target-supply : regulator for SATA target power +- phy-supply : regulator for PHY power
This should be mutually exclusive with the phys property. If you have a phy node, then its supply belongs there.
Quoted 6 lines
Documentation/devicetree/bindings/ata/ahci-platform.txt +0
-0- phys : reference to the SATA PHY node - phy-names : must be "sata-phy" - ahci-supply : regulator for AHCI controllerSignature · 1 line
2.16.4
PATCH v5 6/9 ata: ahci_sunxi: add support for r40
In reply to Corentin LabbeThis patch add the r40 compatible to the ahci_sunxi's supported list of compatible.
Since R40 need ahci_platform to handle the reset controller, we also add the new AHCI_PLATFORM_GET_RESETS flag for ahci_platform_get_resources(). This has no consequence for older platform (a10, a20) since the reset is optional.
--- drivers/ata/ahci_sunxi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ata/ahci_sunxi.c +2 -1
@@ -181,7 +181,7 @@ static int ahci_sunxi_probe(struct platform_device *pdev)struct ahci_host_priv *hpriv;int rc; - hpriv =ahci_platform_get_resources (pdev,0 ); + hpriv =ahci_platform_get_resources (pdev,AHCI_PLATFORM_GET_RESETS );if (IS_ERR (hpriv))return PTR_ERR (hpriv);
@@ -250,6 +250,7 @@ static SIMPLE_DEV_PM_OPS(ahci_sunxi_pm_ops, ahci_platform_suspend,static const struct of_device_id ahci_sunxi_of_match[] = { { .compatible ="allwinner,sun4i-a10-ahci" , }, + { .compatible ="allwinner,sun8i-r40-ahci" , }, { }, };MODULE_DEVICE_TABLE (of, ahci_sunxi_of_match);
Signature · 1 line
2.16.4
PATCH v5 7/9 dt-bindings: ata: update ahci_sunxi bindings
In reply to Corentin LabbeThis patch update binding with the new R40 compatible.
--- Documentation/devicetree/bindings/ata/ahci-platform.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/ata/ahci-platform.txt +2 -0
@@ -10,6 +10,7 @@ PHYs. Required properties: - compatible : compatible string, one of: - "allwinner,sun4i-a10-ahci" + - "allwinner,sun8i-r40-ahci" - "brcm,iproc-ahci" - "hisilicon,hisi-ahci" - "cavium,octeon-7130-ahci"
@@ -44,6 +45,7 @@ Required properties when using sub-nodes: - #address-cells : number of cells to encode an address - #size-cells : number of cells representing the size of an address +For allwinner,sun8i-r40-ahci, the reset propertie must be present. Sub-nodes required properties: - reg : the port number
Signature · 1 line
2.16.4
Re: [PATCH v5 7/9] dt-bindings: ata: update ahci_sunxi bindings
Quoted 7 lines · Corentin Labbe
This patch update binding with the new R40 compatible.
Signed-off-by Corentin Labbe <[email protected]>--- Documentation/devicetree/bindings/ata/ahci-platform.txt | 2 ++ 1 file changed, 2 insertions(+)
PATCH v5 8/9 ARM: dts: sun8i: r40: add sata node
In reply to Corentin LabbeR40 have a sata controller which is the same as A20. This patch adds a DT node for it.
--- arch/arm/boot/dts/sun8i-r40.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm/boot/dts/sun8i-r40.dtsi +13 -0
@@ -550,6 +550,19 @@ #size-cells = <0>; }; + ahci: sata at 1c18000 { + compatible = "allwinner,sun8i-r40-ahci"; + reg = <0x01c18000 0x1000>; + interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_SATA>, <&ccu CLK_SATA>; + resets = <&ccu RST_BUS_SATA>; + resets-name = "ahci"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + }; + gmac: ethernet at 1c50000 { compatible = "allwinner,sun8i-r40-gmac"; syscon = <&ccu>;
Signature · 1 line
2.16.4
PATCH v5 9/9 ARM: dts: sun8i: sun8i-r40-bananapi-m2-ultra: enable AHCI
In reply to Corentin LabbeThis patch enable the AHCI controller.
Since this controller need two regulator, this patch add them.
--- arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts +18 -0
@@ -105,6 +105,12 @@ }; }; +&ahci { + ahci-supply = <®_dldo4>; + phy-supply = <®_eldo3>; + status = "okay"; +}; + &de { status = "okay"; };
@@ -250,6 +256,18 @@ regulator-name = "vcc-wifi"; }; +®_dldo4 { + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <2500000>; + regulator-name = "vdd2v5-sata"; +}; + +®_eldo3 { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-name = "vdd1v2-sata"; +}; + &tcon_tv0 { status = "okay"; };
Signature · 1 line
2.16.4
Quoted 9 lines · Corentin Labbe
This patchset add support for allwinner R40 AHCI controller.
The whole patchset is tested on sun8i-r40-bananapi-m2-ultra and on sun7i-a20-cubieboard2 which doesnt have any of the ressources added by this serie, so no regression should come with it.
Patchs 1-7 should go via the ata tree
Patchs 8,9 should go via the sunxi tree
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180903/e9c58cd6/attachment.sig>
Hans de Goede
Reviewed-byHi,
Quoted 7 lines · Maxime Ripard
Quoted 6 lines · Corentin Labbe
This patchset add support for allwinner R40 AHCI controller.
The whole patchset is tested on sun8i-r40-bananapi-m2-ultra and on sun7i-a20-cubieboard2 which doesnt have any of the ressources added by this serie, so no regression should come with it.
Quoted 5 lines
Quoted 3 lines
Patchs 1-7 should go via the ata tree
Patchs 8,9 should go via the sunxi treeAcked-by Maxime Ripard <[email protected]>
The entire series looks good to me too:
Regards,
Hans
Quoted 8 lines · Corentin Labbe
This patchset add support for allwinner R40 AHCI controller.
The whole patchset is tested on sun8i-r40-bananapi-m2-ultra and on sun7i-a20-cubieboard2 which doesnt have any of the ressources added by this serie, so no regression should come with it.
Patchs 1-7 should go via the ata tree
Patchs 8,9 should go via the sunxi tree
Applied 1-7 for 4.20, thanks everyone.
Signature · 1 line
Jens Axboe
Quoted 11 lines · Jens Axboe
Quoted 8 lines · Corentin Labbe
This patchset add support for allwinner R40 AHCI controller.
The whole patchset is tested on sun8i-r40-bananapi-m2-ultra and on sun7i-a20-cubieboard2 which doesnt have any of the ressources added by this serie, so no regression should come with it.
Patchs 1-7 should go via the ata tree
Patchs 8,9 should go via the sunxi treeApplied 1-7 for 4.20, thanks everyone.
Applied 8 and 9, thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180905/38e83f0c/attachment.sig>