Skip to contentSkip to conversation

USB: ehci-s5p: Fix phy reset

PATCH Superseded Alexander Graf 3 participants 6 messages Mar 13, 2013 – Mar 14, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: ehci-s5p: Fix phy reset

On my Exynos 5 based Arndale system, I need to pull the reset line down and then let it go up again to actually perform a reset. Without that reset, I can't find any USB hubs on my bus, rendering the USB controller useless.

So this patch implements the above logic, making EHCI and OHCI work on Arndale systems for me.

CC Vivek Gautam <[email protected]>
CC Jingoo Han <[email protected]>
CC Alan Stern <[email protected]>
CC Kukjin Kim <[email protected]>
CC Felipe Balbi <[email protected]>
CC Greg Kroah-Hartman <[email protected]>

---

As this affects 3.9, this patch should definitely be considered for inclusion there.

---
 drivers/usb/host/ehci-s5p.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/usb/host/ehci-s5p.c +8 -2
index 20ebf6a..c6d67e4 100644
@@ -103,9 +103,15 @@ static void s5p_setup_vbus_gpio(struct platform_device *pdev)
 	if (!gpio_is_valid(gpio))
 		return;
 
-	err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
-	if (err)
+	/* reset pulls the line down, then up again */
+	err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, "ehci_vbus_gpio");
+	if (err) {
 		dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
+		return;
+	}
+	mdelay(1);
+	__gpio_set_value(gpio, 1);
+	gpio_free(gpio);
 }
 
 static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
Signature · 1 line
1.7.12.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 36 lines · Alexander Graf

On my Exynos 5 based Arndale system, I need to pull the reset line down and then let it go up again to actually perform a reset. Without that reset, I can't find any USB hubs on my bus, rendering the USB controller useless.

So this patch implements the above logic, making EHCI and OHCI work on Arndale systems for me.

CC Vivek Gautam <[email protected]>
CC Jingoo Han <[email protected]>
CC Alan Stern <[email protected]>
CC Kukjin Kim <[email protected]>
CC Felipe Balbi <[email protected]>
CC Greg Kroah-Hartman <[email protected]>

---

As this affects 3.9, this patch should definitely be considered for inclusion there.

---
 drivers/usb/host/ehci-s5p.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/usb/host/ehci-s5p.c +2 -2
index 20ebf6a..c6d67e4 100644
@@ -103,9 +103,15 @@ static void s5p_setup_vbus_gpio(struct platform_device *pdev)
 	if (!gpio_is_valid(gpio))
 		return;
 
-	err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
-	if (err)
+	/* reset pulls the line down, then up again */
+	err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, "ehci_vbus_gpio");

drivers/usb/host/ehci-s5p.c static void s5p_setup_vbus_gpio(struct platform_device *pdev) · line 117

Quoted 10 lines
drivers/usb/host/ehci-s5p.c +6 -0
+	if (err) {
 		dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
+		return;
+	}
+	mdelay(1);
+	__gpio_set_value(gpio, 1);
+	gpio_free(gpio);
 }
 
 static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
#2 lore raw
In reply to Alexander Graf

Alexander,

drivers/usb/host/ehci-s5p.c static void s5p_setup_vbus_gpio(struct platform_device *pdev) · line 114

Quoted 11 lines · Alexander Graf
drivers/usb/host/ehci-s5p.c +8 -2
-       err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
-       if (err)
+       /* reset pulls the line down, then up again */
+       err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, "ehci_vbus_gpio");
+       if (err) {
                dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
+               return;
+       }
+       mdelay(1);
+       __gpio_set_value(gpio, 1);
+       gpio_free(gpio);

Freeing the gpio is a little on the iffy side since you actually care about keeping the value. Perhaps you can change this to devm_gpio_request_one() and avoid the free? I was about to submit a patch to do just that (since otherwise you run into trouble if you ever defer the probe) but then ran across your patch.

Thanks!

-Doug

#3 lore raw
Quoted 15 lines · Doug Anderson

Alexander,

drivers/usb/host/ehci-s5p.c static void s5p_setup_vbus_gpio(struct platform_device *pdev) · line 114

Quoted 11 lines · Alexander Graf
drivers/usb/host/ehci-s5p.c +8 -2
-       err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
-       if (err)
+       /* reset pulls the line down, then up again */
+       err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, "ehci_vbus_gpio");
+       if (err) {
               dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
+               return;
+       }
+       mdelay(1);
+       __gpio_set_value(gpio, 1);
+       gpio_free(gpio);
Quoted 5 lines

Freeing the gpio is a little on the iffy side since you actually care about keeping the value. Perhaps you can change this to devm_gpio_request_one() and avoid the free? I was about to submit a patch to do just that (since otherwise you run into trouble if you ever defer the probe) but then ran across your patch.

I could also just return it when the function exits and only free it when we exit the probe function with a negative value. The reason I put it in here was that on probe deferral, the pin simply gets blocked.

However, I could probably also just completely take the gpio_free() out of this patch and resubmit, as it should be pretty much unrelated. Then you can patch it properly.

Alex

Quoted 4 lines

Thanks!

-Doug

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Alexander,

Quoted 9 lines · Alexander Graf
Quoted 8 lines
Quoted 2 lines

+ gpio_free(gpio);

Freeing the gpio is a little on the iffy side since you actually care about keeping the value. Perhaps you can change this to devm_gpio_request_one() and avoid the free? I was about to submit a patch to do just that (since otherwise you run into trouble if you ever defer the probe) but then ran across your patch.

Quoted 3 lines

I could also just return it when the function exits and only free it when we exit the probe function with a negative value. The reason I put it in here was that on probe deferral, the pin simply gets blocked.

However, I could probably also just completely take the gpio_free() out of this patch and resubmit, as it should be pretty much unrelated. Then you can patch it properly.

Sure, if you want to resubmit without the gpio_free() I'll submit a new patch atop yours with the change to devm and people can see if they like it...

#5 lore raw
Quoted 12 lines · Doug Anderson

Alexander,

Quoted 9 lines · Alexander Graf
Quoted 8 lines
Quoted 2 lines

+ gpio_free(gpio);

Freeing the gpio is a little on the iffy side since you actually care about keeping the value. Perhaps you can change this to devm_gpio_request_one() and avoid the free? I was about to submit a patch to do just that (since otherwise you run into trouble if you ever defer the probe) but then ran across your patch.

Quoted 7 lines
Quoted 3 lines

I could also just return it when the function exits and only free it when we exit the probe function with a negative value. The reason I put it in here was that on probe deferral, the pin simply gets blocked.

However, I could probably also just completely take the gpio_free() out of this patch and resubmit, as it should be pretty much unrelated. Then you can patch it properly.

Sure, if you want to resubmit without the gpio_free() I'll submit a new patch atop yours with the change to devm and people can see if they like it...

Hrm. So when I remove the gpio_free() again, I can't find the USB hub anymore. If I however postpone the whole reset procedure until after the potential deferral, it works (see patch below).

Any idea what is going on here?

Alex

drivers/usb/host/ehci-s5p.c +2 -2
index f692f70..b29b2b8 100644
@@ -136,8 +136,6 @@ static int s5p_ehci_probe(struct platform_device *pdev)
        if (!pdev->dev.coherent_dma_mask)
                pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
 
-       s5p_setup_vbus_gpio(pdev);
-
        s5p_ehci = devm_kzalloc(&pdev->dev, sizeof(struct s5p_ehci_hcd),
                                GFP_KERNEL);
        if (!s5p_ehci)
@@ -157,6 +155,8 @@ static int s5p_ehci_probe(struct platform_device *pdev)
                s5p_ehci->otg = phy->otg;
        }
 
+       s5p_setup_vbus_gpio(pdev);
+
        s5p_ehci->dev = &pdev->dev;
 
        hcd = usb_create_hcd(&s5p_ehci_hc_driver, &pdev->dev,