From: Corentin Labbe <clabbe.montjoie@gmail.com>
To: axboe@kernel.dk, hdegoede@redhat.com, mark.rutland@arm.com,
maxime.ripard@bootlin.com, robh+dt@kernel.org, wens@csie.org
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-sunxi@googlegroups.com,
Corentin Labbe <clabbe.montjoie@gmail.com>
Subject: [PATCH v5 4/9] ata: ahci_platform: add support for PHY controller regulator
Date: Mon, 3 Sep 2018 12:01:56 +0200 [thread overview]
Message-ID: <20180903100201.23131-5-clabbe.montjoie@gmail.com> (raw)
In-Reply-To: <20180903100201.23131-1-clabbe.montjoie@gmail.com>
The 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.
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
drivers/ata/ahci.h | 1 +
drivers/ata/libahci_platform.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 1415f1012de5..ef356e70e6de 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -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.
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index a886b61476a3..dc4d79b1c9ae 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -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)) {
--
2.16.4
next prev parent reply other threads:[~2018-09-03 10:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-03 10:01 [PATCH v5 0/9] ata: ahci_platform: support allwinner R40 AHCI Corentin Labbe
2018-09-03 10:01 ` [PATCH v5 1/9] dt-bindings: ata: ahci-platform: fix indentation of target-supply Corentin Labbe
2018-09-10 16:25 ` Rob Herring
2018-09-03 10:01 ` [PATCH v5 2/9] ata: ahci_platform: add support for AHCI controller regulator Corentin Labbe
2018-09-03 10:01 ` [PATCH v5 3/9] dt-bindings: ata: ahci-platform: document ahci-supply Corentin Labbe
2018-09-03 10:01 ` Corentin Labbe [this message]
2018-09-03 10:01 ` [PATCH v5 5/9] dt-bindings: ata: ahci-platform: document phy-supply Corentin Labbe
2018-09-10 18:18 ` Rob Herring
2018-09-03 10:01 ` [PATCH v5 6/9] ata: ahci_sunxi: add support for r40 Corentin Labbe
2018-09-03 10:01 ` [PATCH v5 7/9] dt-bindings: ata: update ahci_sunxi bindings Corentin Labbe
2018-09-10 18:18 ` Rob Herring
2018-09-03 10:02 ` [PATCH v5 8/9] ARM: dts: sun8i: r40: add sata node Corentin Labbe
2018-09-03 10:02 ` [PATCH v5 9/9] ARM: dts: sun8i: sun8i-r40-bananapi-m2-ultra: enable AHCI Corentin Labbe
2018-09-03 12:42 ` [PATCH v5 0/9] ata: ahci_platform: support allwinner R40 AHCI Maxime Ripard
2018-09-03 12:58 ` Hans de Goede
2018-09-03 14:26 ` Jens Axboe
2018-09-05 7:25 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180903100201.23131-5-clabbe.montjoie@gmail.com \
--to=clabbe.montjoie@gmail.com \
--cc=axboe@kernel.dk \
--cc=devicetree@vger.kernel.org \
--cc=hdegoede@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=mark.rutland@arm.com \
--cc=maxime.ripard@bootlin.com \
--cc=robh+dt@kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).