diff mbox

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

Message ID 1436367247-19401-1-git-send-email-hdegoede@redhat.com
State Superseded
Delegated to: Hans de Goede
Headers show

Commit Message

Hans de Goede July 8, 2015, 2:54 p.m. UTC
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@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(-)

Comments

Marek Vasut July 8, 2015, 3:02 p.m. UTC | #1
On Wednesday, July 08, 2015 at 04:54:07 PM, Hans de Goede wrote:
> 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@redhat.com>

Shall I pick this through u-boot-usb or would you like this to go through
u-boot-sunxi ? Recently, I feel a bit left out :-) (but I'm not opposed
if you pick this through sunxi, don't get me wrong).

Best regards,
Marek Vasut
Ian Campbell July 8, 2015, 3:03 p.m. UTC | #2
On Wed, 2015-07-08 at 16:54 +0200, Hans de Goede wrote:
> 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@redhat.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Hans de Goede July 8, 2015, 5:49 p.m. UTC | #3
Hi,

On 08-07-15 17:02, Marek Vasut wrote:
> On Wednesday, July 08, 2015 at 04:54:07 PM, Hans de Goede wrote:
>> 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@redhat.com>
>
> Shall I pick this through u-boot-usb or would you like this to go through
> u-boot-sunxi ? Recently, I feel a bit left out :-)

Heh, sorry but we've a bunch of other sunxi/usb mixed patches already
queued up, so I think it is best if I take this one through the sunxi
tree to avoid conflicts.

Regards,

Hans
Marek Vasut July 8, 2015, 9:19 p.m. UTC | #4
On Wednesday, July 08, 2015 at 07:49:37 PM, Hans de Goede wrote:
> Hi,

Hi!

> On 08-07-15 17:02, Marek Vasut wrote:
> > On Wednesday, July 08, 2015 at 04:54:07 PM, Hans de Goede wrote:
> >> 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@redhat.com>
> > 
> > Shall I pick this through u-boot-usb or would you like this to go through
> > u-boot-sunxi ? Recently, I feel a bit left out :-)
> 
> Heh, sorry but we've a bunch of other sunxi/usb mixed patches already
> queued up, so I think it is best if I take this one through the sunxi
> tree to avoid conflicts.

*SULK* !!

All righty. Also:

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut
diff mbox

Patch

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 */