diff mbox series

[04/13] usb: ehci-mx6: Turn on the power domain of USB PHY

Message ID 20200916125705.4341-5-peng.fan@nxp.com
State New
Headers show
Series ehci-mx6: update and fix | expand

Commit Message

Peng Fan Sept. 16, 2020, 12:56 p.m. UTC
From: Ye Li <ye.li@nxp.com>


Since there is no uclass for USB PHY. The device won't be setup for the USB PHY
node in DTB. And its associated power domain device won't be turned on neither
by DM framework.

This patch modifies the ehci-mx6 driver to enable the power domain device before
access the USB PHY. This is only for DM driver. For non-DM part, users still
need to power on the USB PHY in boards/SoC codes.

Reviewed-by: Peng Fan <peng.fan@nxp.com>

Signed-off-by: Ye Li <ye.li@nxp.com>

Signed-off-by: Peng Fan <peng.fan@nxp.com>

---
 drivers/usb/host/ehci-mx6.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

-- 
2.28.0

Comments

Marek Vasut Sept. 16, 2020, 1:38 p.m. UTC | #1
On 9/16/20 2:56 PM, peng.fan@nxp.com wrote:
[...]
> @@ -569,6 +571,20 @@ static int ehci_usb_phy_mode(struct udevice *dev)

>  		if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)

>  			return -EINVAL;

>  

> +		/* Need to power on the PHY before access it */

> +#if CONFIG_IS_ENABLED(POWER_DOMAIN)

> +		struct udevice phy_dev;

> +		struct power_domain pd;

> +		int ret;

> +

> +		phy_dev.node = offset_to_ofnode(phy_off);

> +		if (!power_domain_get(&phy_dev, &pd)) {

> +			ret = power_domain_on(&pd);

> +			if (ret)

> +				return ret;

> +		}

> +#endif


Should we also turn it OFF somewhere ?
diff mbox series

Patch

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index b1721cd915..0727aafc92 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -2,6 +2,7 @@ 
 /*
  * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
  * Copyright (C) 2010 Freescale Semiconductor, Inc.
+ *
  */
 
 #include <common.h>
@@ -19,6 +20,7 @@ 
 #include <asm/mach-imx/sys_proto.h>
 #include <dm.h>
 #include <asm/mach-types.h>
+#include <power-domain.h>
 #include <power/regulator.h>
 #include <linux/iopoll.h>
 #include <linux/usb/otg.h>
@@ -569,6 +571,20 @@  static int ehci_usb_phy_mode(struct udevice *dev)
 		if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)
 			return -EINVAL;
 
+		/* Need to power on the PHY before access it */
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+		struct udevice phy_dev;
+		struct power_domain pd;
+		int ret;
+
+		phy_dev.node = offset_to_ofnode(phy_off);
+		if (!power_domain_get(&phy_dev, &pd)) {
+			ret = power_domain_on(&pd);
+			if (ret)
+				return ret;
+		}
+#endif
+
 		phy_ctrl = (void __iomem *)(addr + USBPHY_CTRL);
 		val = readl(phy_ctrl);