Commit 58f735fe authored by Roger Quadros's avatar Roger Quadros Committed by Felipe Balbi

usb: phy: nop: Handle power supply regulator for the PHY

We use "vcc" as the supply name for the PHY's power supply.
The power supply will be enabled during .init() and disabled
during .shutdown()
Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 2319fb88
...@@ -33,11 +33,13 @@ ...@@ -33,11 +33,13 @@
#include <linux/usb/nop-usb-xceiv.h> #include <linux/usb/nop-usb-xceiv.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/regulator/consumer.h>
struct nop_usb_xceiv { struct nop_usb_xceiv {
struct usb_phy phy; struct usb_phy phy;
struct device *dev; struct device *dev;
struct clk *clk; struct clk *clk;
struct regulator *vcc;
}; };
static struct platform_device *pd; static struct platform_device *pd;
...@@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy) ...@@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy)
{ {
struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev); struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
if (!IS_ERR(nop->vcc)) {
if (regulator_enable(nop->vcc))
dev_err(phy->dev, "Failed to enable power\n");
}
if (!IS_ERR(nop->clk)) if (!IS_ERR(nop->clk))
clk_enable(nop->clk); clk_enable(nop->clk);
...@@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy) ...@@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy)
if (!IS_ERR(nop->clk)) if (!IS_ERR(nop->clk))
clk_disable(nop->clk); clk_disable(nop->clk);
if (!IS_ERR(nop->vcc)) {
if (regulator_disable(nop->vcc))
dev_err(phy->dev, "Failed to disable power\n");
}
} }
static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
...@@ -154,6 +166,12 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev) ...@@ -154,6 +166,12 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
} }
} }
nop->vcc = devm_regulator_get(&pdev->dev, "vcc");
if (IS_ERR(nop->vcc)) {
dev_dbg(&pdev->dev, "Error getting vcc regulator: %ld\n",
PTR_ERR(nop->vcc));
}
nop->dev = &pdev->dev; nop->dev = &pdev->dev;
nop->phy.dev = nop->dev; nop->phy.dev = nop->dev;
nop->phy.label = "nop-xceiv"; nop->phy.label = "nop-xceiv";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment