usb: ehci-generic: Add vbus-supply regulator support
Subsystems (2)
PATCH v4 1/1 usb: ehci-generic: Add vbus-supply regulator support
Add vbus-supply regulator support.
On some board vbus is not controlled by the phy but by an external regulator.
---
Changes in v4:
- Remove useless dev->name in dev_dgb()
Changes in v3:
- Update test on device_get_supply_regulator() call
- Replace pr_err() by dev_err()
- Replace debug() by dev_dbg()
Changes in v2:
- Add test on device_get_supply_regulator() call
drivers/usb/host/ehci-generic.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
drivers/usb/host/ehci-generic.c +38 -1
@@ -11,6 +11,7 @@#include <asm/io.h> #include <dm.h> #include "ehci.h" +#include <power/regulator.h> /* * Even though here we don't explicitly use "struct ehci_ctrl"
@@ -22,6 +23,9 @@ struct generic_ehci {struct clk *clocks;struct reset_ctl *resets;struct phy phy; +#ifdef CONFIG_DM_REGULATOR +struct udevice *vbus_supply; +#endif int clock_count;int reset_count; };
@@ -145,9 +149,26 @@ static int ehci_usb_probe(struct udevice *dev) } } +#ifdef CONFIG_DM_REGULATOR + err =device_get_supply_regulator (dev,"vbus-supply" , + &priv->vbus_supply); +if (err && err != -ENOENT ) + goto reset_err; + +if (priv->vbus_supply) { + err =regulator_set_enable (priv->vbus_supply, true); +if (err) { +dev_err (dev,"Error enabling VBUS supply\n" ); + goto reset_err; + } + }else { +dev_dbg (dev,"No vbus supply\n" ); + } +#endif + err =ehci_setup_phy (dev,0 );if (err) - goto reset_err; + goto regulator_err; hccr =map_physmem (dev_read_addr (dev),0x100 ,MAP_NOCACHE ); hcor = (struct ehci_hcor *)((uintptr_t)hccr +
@@ -164,6 +185,15 @@ phy_err:if (ret)dev_err (dev,"failed to shutdown usb phy\n" ); +regulator_err: +#ifdef CONFIG_DM_REGULATOR +if (priv->vbus_supply) { + ret =regulator_set_enable (priv->vbus_supply, false); +if (ret) +dev_err (dev,"Error disabling VBUS supply\n" ); + } +#endif + reset_err: ret =reset_release_all (priv->resets, priv->reset_count);if (ret)
@@ -189,6 +219,13 @@ static int ehci_usb_remove(struct udevice *dev)if (ret)return ret; +#ifdef CONFIG_DM_REGULATOR +if (priv->vbus_supply) { + ret =regulator_set_enable (priv->vbus_supply, false); +if (ret) +return ret; + } +#endif ret =reset_release_all (priv->resets, priv->reset_count);if (ret)return ret;
Signature · 1 line
1.9.1
PATCH v4 1/1 usb: ehci-generic: Add vbus-supply regulator support
Quoted 9 lines · Patrice Chotard
Add vbus-supply regulator support.
On some board vbus is not controlled by the phy but by an external regulator.Signed-off-by Patrice Chotard <[email protected]>---
Changes in v4:
- Remove uselessdev->nameindev_dgb()
Two remaining nits, can you pull the regulator handling into separate functions and put ifdef arounds those, with empty default implementation? That way, the ifdefs won't be spread throughout the code.
Also, rebase on u-boot-usb/master please.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v4 1/1 usb: ehci-generic: Add vbus-supply regulator support
Hi Marek
Quoted 8 lines · Marek Vasut
Quoted 7 lines · Patrice Chotard
Add vbus-supply regulator support.
On some board vbus is not controlled by the phy but by an external regulator.Signed-off-by Patrice Chotard <[email protected]>---
Quoted 6 lines
Quoted 2 lines
Changes in v4:
- Remove uselessdev->nameindev_dgb()Two remaining nits, can you pull the regulator handling into separate functions and put ifdef arounds those, with empty default implementation? That way, the ifdefs won't be spread throughout the code.
Agree it will be more readable.
Quoted 2 lines
Also, rebase on u-boot-usb/master please.
Ok
Thanks
Patrice
Quoted 1 line
PATCH v4 1/1 usb: ehci-generic: Add vbus-supply regulator support
Quoted 18 lines · Patrice CHOTARD
Hi Marek
Quoted 8 lines · Marek Vasut
Quoted 7 lines · Patrice Chotard
Add vbus-supply regulator support.
On some board vbus is not controlled by the phy but by an external regulator.Signed-off-by Patrice Chotard <[email protected]>---
Quoted 6 lines
Quoted 2 lines
Changes in v4:
- Remove uselessdev->nameindev_dgb()Two remaining nits, can you pull the regulator handling into separate functions and put ifdef arounds those, with empty default implementation? That way, the ifdefs won't be spread throughout the code.
Quoted 8 lines
Agree it will be more readable.
Quoted 2 lines
Also, rebase on u-boot-usb/master please.
Ok
Thanks
But the rest is good, thanks.
Signature · 2 lines
Best regards, Marek Vasut