summaryrefslogtreecommitdiff
path: root/drivers/phy/phy-stm32-usbphyc.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-11-25 11:00:52 -0500
committerTom Rini <trini@konsulko.com>2020-11-25 11:00:52 -0500
commit7889951d0f56eab746a7c8fde350a022ba0361ca (patch)
treeb9adb403422089be4ec363e4ee983fdb7aaa6b6d /drivers/phy/phy-stm32-usbphyc.c
parentd361eafe82bfbf90ab0a592ae59daef99faee5ec (diff)
parent60a2dd6aa20f6c0938856b764e7ebdee722d998e (diff)
downloadu-boot-WIP/25Nov2020.tar.gz
Merge tag 'u-boot-stm32-20201125' of https://gitlab.denx.de/u-boot/custodians/u-boot-stmWIP/25Nov2020
- STM32 MCU's DT update - Add DHCOM based STM32MP15x PicoITX board - Correct ALIGN macro usage for on syram for SPL dcache support - Fixes on DHCOM: uSD card-detect GPIO and Drop QSPI CS2 - Fix compilation issue for spl_mmc_boot_partition - Fix MTD partitions for serial boot - Add support of MCU HOLD BOOT with reset for stm32 remoteproc (prepare alligneent with kernel DT) - Correct bias information and support in STM32 soc and STMFX - Support optional vbus in usbphyc - Update FIT examples to avoid kernel zImage relocation before decompression
Diffstat (limited to 'drivers/phy/phy-stm32-usbphyc.c')
-rw-r--r--drivers/phy/phy-stm32-usbphyc.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
index 9d4296d649..ab4a913c93 100644
--- a/drivers/phy/phy-stm32-usbphyc.c
+++ b/drivers/phy/phy-stm32-usbphyc.c
@@ -59,6 +59,7 @@ struct stm32_usbphyc {
struct udevice *vdda1v8;
struct stm32_usbphyc_phy {
struct udevice *vdd;
+ struct udevice *vbus;
bool init;
bool powered;
} phys[MAX_PHYS];
@@ -244,6 +245,11 @@ static int stm32_usbphyc_phy_power_on(struct phy *phy)
if (ret)
return ret;
}
+ if (usbphyc_phy->vbus) {
+ ret = regulator_set_enable(usbphyc_phy->vbus, true);
+ if (ret)
+ return ret;
+ }
usbphyc_phy->powered = true;
@@ -262,6 +268,11 @@ static int stm32_usbphyc_phy_power_off(struct phy *phy)
if (stm32_usbphyc_is_powered(usbphyc))
return 0;
+ if (usbphyc_phy->vbus) {
+ ret = regulator_set_enable(usbphyc_phy->vbus, false);
+ if (ret)
+ return ret;
+ }
if (usbphyc_phy->vdd) {
ret = regulator_set_enable_if_allowed(usbphyc_phy->vdd, false);
if (ret)
@@ -271,7 +282,7 @@ static int stm32_usbphyc_phy_power_off(struct phy *phy)
return 0;
}
-static int stm32_usbphyc_get_regulator(struct udevice *dev, ofnode node,
+static int stm32_usbphyc_get_regulator(ofnode node,
char *supply_name,
struct udevice **regulator)
{
@@ -281,19 +292,14 @@ static int stm32_usbphyc_get_regulator(struct udevice *dev, ofnode node,
ret = ofnode_parse_phandle_with_args(node, supply_name,
NULL, 0, 0,
&regulator_phandle);
- if (ret) {
- dev_err(dev, "Can't find %s property (%d)\n", supply_name, ret);
+ if (ret)
return ret;
- }
ret = uclass_get_device_by_ofnode(UCLASS_REGULATOR,
regulator_phandle.node,
regulator);
-
- if (ret) {
- dev_err(dev, "Can't get %s regulator (%d)\n", supply_name, ret);
+ if (ret)
return ret;
- }
return 0;
}
@@ -380,10 +386,17 @@ static int stm32_usbphyc_probe(struct udevice *dev)
usbphyc_phy->init = false;
usbphyc_phy->powered = false;
- ret = stm32_usbphyc_get_regulator(dev, node, "phy-supply",
+ ret = stm32_usbphyc_get_regulator(node, "phy-supply",
&usbphyc_phy->vdd);
- if (ret)
+ if (ret) {
+ dev_err(dev, "Can't get phy-supply regulator\n");
return ret;
+ }
+
+ ret = stm32_usbphyc_get_regulator(node, "vbus-supply",
+ &usbphyc_phy->vbus);
+ if (ret)
+ usbphyc_phy->vbus = NULL;
node = dev_read_next_subnode(node);
}