[U-Boot] [PATCH] sunxi: usb-phy: Never power off the usb ports

Hans de Goede hdegoede at redhat.com
Wed Jul 8 16:54:07 CEST 2015


USB devices are not really designed to get the power bounced off and on
at them. Esp. USB powered harddisks do not like this.

Currently we power off the USB ports both on a "usb reset" and when
booting the kernel, causing the usb-power to bounce off and then back
on again.

This patch removes the powering off calls, fixing the undesirable power
bouncing.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 arch/arm/cpu/armv7/sunxi/usb_phy.c        | 17 -----------------
 arch/arm/include/asm/arch-sunxi/usb_phy.h |  1 -
 drivers/usb/host/ehci-sunxi.c             |  1 -
 drivers/usb/host/ohci-sunxi.c             |  1 -
 drivers/usb/musb-new/sunxi.c              |  3 ---
 5 files changed, 23 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/usb_phy.c b/arch/arm/cpu/armv7/sunxi/usb_phy.c
index 4d63a74..74d251d 100644
--- a/arch/arm/cpu/armv7/sunxi/usb_phy.c
+++ b/arch/arm/cpu/armv7/sunxi/usb_phy.c
@@ -47,7 +47,6 @@ static struct sunxi_usb_phy {
 	int gpio_id_det;
 	int id;
 	int init_count;
-	int power_on_count;
 } sunxi_usb_phy[] = {
 	{
 		.usb_rst_mask = CCM_USB_CTRL_PHY0_RST | CCM_USB_CTRL_PHY0_CLK,
@@ -212,26 +211,10 @@ void sunxi_usb_phy_power_on(int index)
 {
 	struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
 
-	phy->power_on_count++;
-	if (phy->power_on_count != 1)
-		return;
-
 	if (phy->gpio_vbus >= 0)
 		gpio_set_value(phy->gpio_vbus, 1);
 }
 
-void sunxi_usb_phy_power_off(int index)
-{
-	struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
-
-	phy->power_on_count--;
-	if (phy->power_on_count != 0)
-		return;
-
-	if (phy->gpio_vbus >= 0)
-		gpio_set_value(phy->gpio_vbus, 0);
-}
-
 int sunxi_usb_phy_vbus_detect(int index)
 {
 	struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
diff --git a/arch/arm/include/asm/arch-sunxi/usb_phy.h b/arch/arm/include/asm/arch-sunxi/usb_phy.h
index 17d31b8..89a287c 100644
--- a/arch/arm/include/asm/arch-sunxi/usb_phy.h
+++ b/arch/arm/include/asm/arch-sunxi/usb_phy.h
@@ -15,7 +15,6 @@ int sunxi_usb_phy_remove(void);
 void sunxi_usb_phy_init(int index);
 void sunxi_usb_phy_exit(int index);
 void sunxi_usb_phy_power_on(int index);
-void sunxi_usb_phy_power_off(int index);
 int sunxi_usb_phy_vbus_detect(int index);
 int sunxi_usb_phy_id_detect(int index);
 void sunxi_usb_phy_enable_squelch_detect(int index, int enable);
diff --git a/drivers/usb/host/ehci-sunxi.c b/drivers/usb/host/ehci-sunxi.c
index 34130f8..38d5f92 100644
--- a/drivers/usb/host/ehci-sunxi.c
+++ b/drivers/usb/host/ehci-sunxi.c
@@ -67,7 +67,6 @@ static int ehci_usb_remove(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	sunxi_usb_phy_power_off(priv->phy_index);
 	sunxi_usb_phy_exit(priv->phy_index);
 
 #ifdef CONFIG_SUNXI_GEN_SUN6I
diff --git a/drivers/usb/host/ohci-sunxi.c b/drivers/usb/host/ohci-sunxi.c
index e33a8f7..6079272 100644
--- a/drivers/usb/host/ohci-sunxi.c
+++ b/drivers/usb/host/ohci-sunxi.c
@@ -69,7 +69,6 @@ static int ohci_usb_remove(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	sunxi_usb_phy_power_off(priv->phy_index);
 	sunxi_usb_phy_exit(priv->phy_index);
 
 #ifdef CONFIG_SUNXI_GEN_SUN6I
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 3a29b18..702c592 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -233,9 +233,6 @@ static void sunxi_musb_disable(struct musb *musb)
 	if (!enabled)
 		return;
 
-	if (is_host_enabled(musb))
-		sunxi_usb_phy_power_off(0); /* port power off */
-
 	USBC_ForceVbusValidToLow(musb->mregs);
 	mdelay(200); /* Wait for the current session to timeout */
 
-- 
2.4.3



More information about the U-Boot mailing list