* [PATCH 3/7] AT91 UDC startup fix
@ 2013-03-12 15:54 Renaud C.
2013-03-13 10:29 ` Cerrato Renaud
0 siblings, 1 reply; 2+ messages in thread
From: Renaud C. @ 2013-03-12 15:54 UTC (permalink / raw)
To: barebox
[-- Attachment #1.1: Type: text/plain, Size: 293 bytes --]
I noticed that depending on boot timings, the USB gadget weren't detected
at all by hosts. After few hours of debugging and using the at91clk output,
I found that the UDP clock wasn't enabled from time to time.
This patch fix the startup of UDC by adding a check into the
at91_update_vbus().
[-- Attachment #1.2: Type: text/html, Size: 382 bytes --]
[-- Attachment #2: at91udc-initial-vbus-detection.patch --]
[-- Type: application/octet-stream, Size: 1434 bytes --]
From 0cd745d451109522891194b954982710c6bd736d Mon Sep 17 00:00:00 2001
From: Cerrato Renaud <r.cerrato@til-technologies.fr>
Date: Thu, 7 Mar 2013 09:02:55 +0100
Subject: [PATCH 4/4] corrected initial vbus detection
---
drivers/usb/gadget/at91_udc.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 3899db2..0654038 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1327,6 +1327,12 @@ static void at91_update_vbus(struct at91_udc *udc, u32 value)
dev_set_param(udc->dev, "vbus", "0");
udc->gpio_vbus_val = value;
+ udc->vbus = value != 0;
+
+ if(udc->driver)
+ pullup(udc, udc->vbus);
+ else
+ pullup(udc, 0);
}
int usb_gadget_poll(void)
@@ -1508,7 +1514,7 @@ static int __init at91udc_probe(struct device_d *dev)
* Get the initial state of VBUS - we cannot expect
* a pending interrupt.
*/
- udc->vbus = gpio_get_value(udc->board.vbus_pin);
+ udc->vbus = gpio_get_value(udc->board.vbus_pin) ^ udc->board.vbus_active_low;
DBG(udc, "VBUS detection: host:%s \n",
udc->vbus ? "present":"absent");
} else {
@@ -1517,7 +1523,7 @@ static int __init at91udc_probe(struct device_d *dev)
}
dev_add_param(dev, "vbus", NULL, NULL, 0);
- dev_set_param(dev, "vbus", "0");
+ dev_set_param(dev, "vbus", udc->vbus ? "1" : "0");
poller_register(&poller);
--
1.7.2.5
[-- Attachment #3: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/7] AT91 UDC startup fix
2013-03-12 15:54 [PATCH 3/7] AT91 UDC startup fix Renaud C.
@ 2013-03-13 10:29 ` Cerrato Renaud
0 siblings, 0 replies; 2+ messages in thread
From: Cerrato Renaud @ 2013-03-13 10:29 UTC (permalink / raw)
To: barebox
Inlined patch below.
Signed-off-by: Cerrato Renaud <r.cerrato@til-technologies.fr>
---
drivers/usb/gadget/at91_udc.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 3899db2..0654038 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1327,6 +1327,12 @@ static void at91_update_vbus(struct at91_udc *udc, u32 value)
dev_set_param(udc->dev, "vbus", "0");
udc->gpio_vbus_val = value;
+ udc->vbus = value != 0;
+
+ if(udc->driver)
+ pullup(udc, udc->vbus);
+ else
+ pullup(udc, 0);
}
int usb_gadget_poll(void)
@@ -1508,7 +1514,7 @@ static int __init at91udc_probe(struct device_d *dev)
* Get the initial state of VBUS - we cannot expect
* a pending interrupt.
*/
- udc->vbus = gpio_get_value(udc->board.vbus_pin);
+ udc->vbus = gpio_get_value(udc->board.vbus_pin) ^ udc->board.vbus_active_low;
DBG(udc, "VBUS detection: host:%s \n",
udc->vbus ? "present":"absent");
} else {
@@ -1517,7 +1523,7 @@ static int __init at91udc_probe(struct device_d *dev)
}
dev_add_param(dev, "vbus", NULL, NULL, 0);
- dev_set_param(dev, "vbus", "0");
+ dev_set_param(dev, "vbus", udc->vbus ? "1" : "0");
poller_register(&poller);
--
1.7.2.5
On 12/03/2013 16:54, Renaud C. wrote:
> I noticed that depending on boot timings, the USB gadget weren't detected at all by hosts. After few hours of debugging and using the at91clk output, I found that the UDP clock wasn't enabled from time to time.
>
> This patch fix the startup of UDC by adding a check into the at91_update_vbus().
>
>
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-13 10:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-12 15:54 [PATCH 3/7] AT91 UDC startup fix Renaud C.
2013-03-13 10:29 ` Cerrato Renaud
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox