Commit 9d685ed7 authored by Sjoerd Simons's avatar Sjoerd Simons Committed by Kishon Vijay Abraham I

phy: rockchip-usb: Add vbus regulator support.

On rockchip devices vbus is supplied by a separate power supply, often
through a regulator. Add support for describing the the regulator in
device-tree following the same convention as several other usb phy's.
Signed-off-by: default avatarSjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent fff3364a
...@@ -30,6 +30,7 @@ Optional Properties: ...@@ -30,6 +30,7 @@ Optional Properties:
- reset-names: Only allow the following entries: - reset-names: Only allow the following entries:
- phy-reset - phy-reset
- resets: Must contain an entry for each entry in reset-names. - resets: Must contain an entry for each entry in reset-names.
- vbus-supply: power-supply phandle for vbus power source
Example: Example:
......
...@@ -66,6 +66,7 @@ struct rockchip_usb_phy { ...@@ -66,6 +66,7 @@ struct rockchip_usb_phy {
struct phy *phy; struct phy *phy;
bool uart_enabled; bool uart_enabled;
struct reset_control *reset; struct reset_control *reset;
struct regulator *vbus;
}; };
static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy, static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
...@@ -88,6 +89,9 @@ static void rockchip_usb_phy480m_disable(struct clk_hw *hw) ...@@ -88,6 +89,9 @@ static void rockchip_usb_phy480m_disable(struct clk_hw *hw)
struct rockchip_usb_phy, struct rockchip_usb_phy,
clk480m_hw); clk480m_hw);
if (phy->vbus)
regulator_disable(phy->vbus);
/* Power down usb phy analog blocks by set siddq 1 */ /* Power down usb phy analog blocks by set siddq 1 */
rockchip_usb_phy_power(phy, 1); rockchip_usb_phy_power(phy, 1);
} }
...@@ -143,6 +147,14 @@ static int rockchip_usb_phy_power_on(struct phy *_phy) ...@@ -143,6 +147,14 @@ static int rockchip_usb_phy_power_on(struct phy *_phy)
if (phy->uart_enabled) if (phy->uart_enabled)
return -EBUSY; return -EBUSY;
if (phy->vbus) {
int ret;
ret = regulator_enable(phy->vbus);
if (ret)
return ret;
}
return clk_prepare_enable(phy->clk480m); return clk_prepare_enable(phy->clk480m);
} }
...@@ -268,6 +280,13 @@ static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base, ...@@ -268,6 +280,13 @@ static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base,
} }
phy_set_drvdata(rk_phy->phy, rk_phy); phy_set_drvdata(rk_phy->phy, rk_phy);
rk_phy->vbus = devm_regulator_get_optional(&rk_phy->phy->dev, "vbus");
if (IS_ERR(rk_phy->vbus)) {
if (PTR_ERR(rk_phy->vbus) == -EPROBE_DEFER)
return PTR_ERR(rk_phy->vbus);
rk_phy->vbus = NULL;
}
/* /*
* When acting as uart-pipe, just keep clock on otherwise * When acting as uart-pipe, just keep clock on otherwise
* only power up usb phy when it use, so disable it when init * only power up usb phy when it use, so disable it when init
......
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