From: Kishon Vijay Abraham I <kishon@ti.com>
To: <gregkh@linuxfoundation.org>
Cc: <kishon@ti.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/7] phy: exynos-usb2: add vbus regulator support
Date: Sun, 18 Oct 2015 02:03:25 +0530 [thread overview]
Message-ID: <1445114011-4191-2-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1445114011-4191-1-git-send-email-kishon@ti.com>
From: Marek Szyprowski <m.szyprowski@samsung.com>
Exynos USB2 PHY has separate power supply, which is usually provided by
VBUS regulator. This patch adds support for it. VBUS regulator is
optional, to keep compatibility with boards, which have VBUS provided
from some always-on power source.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
.../devicetree/bindings/phy/samsung-phy.txt | 3 +++
drivers/phy/phy-samsung-usb2.c | 25 ++++++++++++++++++--
drivers/phy/phy-samsung-usb2.h | 2 ++
3 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 60c6f2a..0289d3b 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -44,6 +44,9 @@ Required properties:
- the "ref" clock is used to get the rate of the clock provided to the
PHY module
+Optional properties:
+- vbus-supply: power-supply phandle for vbus power source
+
The first phandle argument in the PHY specifier identifies the PHY, its
meaning is compatible dependent. For the currently supported SoCs (Exynos 4210
and Exynos 4212) it is as follows:
diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-samsung-usb2.c
index f278a9c..1d22d93 100644
--- a/drivers/phy/phy-samsung-usb2.c
+++ b/drivers/phy/phy-samsung-usb2.c
@@ -27,6 +27,13 @@ static int samsung_usb2_phy_power_on(struct phy *phy)
dev_dbg(drv->dev, "Request to power_on \"%s\" usb phy\n",
inst->cfg->label);
+
+ if (drv->vbus) {
+ ret = regulator_enable(drv->vbus);
+ if (ret)
+ goto err_regulator;
+ }
+
ret = clk_prepare_enable(drv->clk);
if (ret)
goto err_main_clk;
@@ -48,6 +55,9 @@ err_power_on:
err_instance_clk:
clk_disable_unprepare(drv->clk);
err_main_clk:
+ if (drv->vbus)
+ regulator_disable(drv->vbus);
+err_regulator:
return ret;
}
@@ -55,7 +65,7 @@ static int samsung_usb2_phy_power_off(struct phy *phy)
{
struct samsung_usb2_phy_instance *inst = phy_get_drvdata(phy);
struct samsung_usb2_phy_driver *drv = inst->drv;
- int ret;
+ int ret = 0;
dev_dbg(drv->dev, "Request to power_off \"%s\" usb phy\n",
inst->cfg->label);
@@ -68,7 +78,10 @@ static int samsung_usb2_phy_power_off(struct phy *phy)
}
clk_disable_unprepare(drv->ref_clk);
clk_disable_unprepare(drv->clk);
- return 0;
+ if (drv->vbus)
+ ret = regulator_disable(drv->vbus);
+
+ return ret;
}
static const struct phy_ops samsung_usb2_phy_ops = {
@@ -203,6 +216,14 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
return ret;
}
+ drv->vbus = devm_regulator_get(dev, "vbus");
+ if (IS_ERR(drv->vbus)) {
+ ret = PTR_ERR(drv->vbus);
+ if (ret == -EPROBE_DEFER)
+ return ret;
+ drv->vbus = NULL;
+ }
+
for (i = 0; i < drv->cfg->num_phys; i++) {
char *label = drv->cfg->phys[i].label;
struct samsung_usb2_phy_instance *p = &drv->instances[i];
diff --git a/drivers/phy/phy-samsung-usb2.h b/drivers/phy/phy-samsung-usb2.h
index 44bead9..6563e7c 100644
--- a/drivers/phy/phy-samsung-usb2.h
+++ b/drivers/phy/phy-samsung-usb2.h
@@ -17,6 +17,7 @@
#include <linux/device.h>
#include <linux/regmap.h>
#include <linux/spinlock.h>
+#include <linux/regulator/consumer.h>
#define KHZ 1000
#define MHZ (KHZ * KHZ)
@@ -37,6 +38,7 @@ struct samsung_usb2_phy_driver {
const struct samsung_usb2_phy_config *cfg;
struct clk *clk;
struct clk *ref_clk;
+ struct regulator *vbus;
unsigned long ref_rate;
u32 ref_reg_val;
struct device *dev;
--
1.7.9.5
next prev parent reply other threads:[~2015-10-17 20:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-17 20:33 [RESEND GIT PULL] phy: for 4.4 merge window Kishon Vijay Abraham I
2015-10-17 20:33 ` Kishon Vijay Abraham I [this message]
2015-10-17 20:33 ` [PATCH 2/7] dt-bindings: Add usb3.0 phy binding for MT65xx SoCs Kishon Vijay Abraham I
2015-10-17 20:33 ` [PATCH 3/7] phy: add usb3.0 phy driver for mt65xx SoCs Kishon Vijay Abraham I
2015-10-17 20:33 ` [PATCH 4/7] phy: sun4i-usb: Use devm_gpiod_get_optional for optional GPIOs Kishon Vijay Abraham I
2015-10-17 20:33 ` [PATCH 5/7] dt-bindings: Add Cygnus PCIe PHY binding doc Kishon Vijay Abraham I
2015-10-17 20:33 ` [PATCH 6/7] phy: cygnus: pcie: Add Cygnus PCIe PHY support Kishon Vijay Abraham I
2015-10-17 20:33 ` [PATCH 7/7] MAINTAINERS: add Mediatek usb3 phy driver Kishon Vijay Abraham I
2015-10-18 3:13 ` [RESEND GIT PULL] phy: for 4.4 merge window Greg KH
-- strict thread matches above, loose matches on Subject: below --
2015-10-17 2:22 [GIT " Kishon Vijay Abraham I
2015-10-17 2:22 ` [PATCH 1/7] phy: exynos-usb2: add vbus regulator support Kishon Vijay Abraham I
2015-08-21 12:38 [PATCH 0/7] Exynos4412-based Trats2 USB gadget (DWC2) fixes Marek Szyprowski
2015-08-21 12:38 ` [PATCH 1/7] phy: exynos-usb2: add vbus regulator support Marek Szyprowski
2015-08-21 12:44 ` Kishon Vijay Abraham I
2015-08-25 5:47 ` Marek Szyprowski
2015-08-25 6:12 ` Krzysztof Kozlowski
2015-08-27 9:54 ` Kishon Vijay Abraham I
2015-09-30 6:00 ` Marek Szyprowski
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=1445114011-4191-2-git-send-email-kishon@ti.com \
--to=kishon@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.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