diff mbox series

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

Message ID 20200629021350.21262-3-peng.fan@nxp.com
State New
Headers show
Series [1/7] usb: ehci-mx6: Add powerup_fixup implementation | expand

Commit Message

Peng Fan June 29, 2020, 2:13 a.m. UTC
From: Ye Li <ye.li at 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 at nxp.com>
Signed-off-by: Ye Li <ye.li at nxp.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 drivers/usb/host/ehci-mx6.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Marek Vasut June 29, 2020, 2:27 a.m. UTC | #1
On 6/29/20 4:13 AM, Peng Fan wrote:
[...]
> @@ -23,6 +25,9 @@
>  #include <linux/usb/otg.h>
>  
>  #include "ehci.h"
> +#if CONFIG_IS_ENABLED(POWER_DOMAIN)
> +#include <power-domain.h>
> +#endif

The ifdef here should not be needed.

>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -590,6 +595,18 @@ 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;
> +
> +		phy_dev.node = offset_to_ofnode(phy_off);
> +		if (!power_domain_get(&phy_dev, &pd)) {
> +			if (power_domain_on(&pd))
> +				return -EINVAL;

Please return the return value of power_domain_on() in case of failure.

[...]
diff mbox series

Patch

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 191d619220..92e8bb91d2 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -2,6 +2,8 @@ 
 /*
  * Copyright (c) 2009 Daniel Mack <daniel at caiaq.de>
  * Copyright (C) 2010 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ *
  */
 
 #include <common.h>
@@ -23,6 +25,9 @@ 
 #include <linux/usb/otg.h>
 
 #include "ehci.h"
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+#include <power-domain.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -590,6 +595,18 @@  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;
+
+		phy_dev.node = offset_to_ofnode(phy_off);
+		if (!power_domain_get(&phy_dev, &pd)) {
+			if (power_domain_on(&pd))
+				return -EINVAL;
+		}
+#endif
+
 		phy_ctrl = (void __iomem *)(addr + USBPHY_CTRL);
 		val = readl(phy_ctrl);