* [PATCH 1/6] ehci: Make has_tt configurable via platform data
2010-06-24 9:45 USB related patches Sascha Hauer
@ 2010-06-24 9:45 ` Sascha Hauer
2010-06-24 9:45 ` [PATCH 2/6] ehci: Handle hub port reset properly Sascha Hauer
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2010-06-24 9:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/usb_ehci_core.c | 18 ++++++++++++------
include/usb/ehci.h | 10 ++++++++++
2 files changed, 22 insertions(+), 6 deletions(-)
create mode 100644 include/usb/ehci.h
diff --git a/drivers/usb/usb_ehci_core.c b/drivers/usb/usb_ehci_core.c
index d7efaad..f3611cd 100644
--- a/drivers/usb/usb_ehci_core.c
+++ b/drivers/usb/usb_ehci_core.c
@@ -31,6 +31,7 @@
#include <xfuncs.h>
#include <clock.h>
#include <errno.h>
+#include <usb/ehci.h>
#include <asm/mmu.h>
#include "usb_ehci.h"
@@ -43,6 +44,7 @@ struct ehci_priv {
struct QH *qh_list;
void *qhp;
int portreset;
+ unsigned long flags;
};
#define to_ehci(ptr) container_of(ptr, struct ehci_priv, host)
@@ -112,13 +114,8 @@ static struct descriptor {
255 /* bInterval */
},
};
-#define CONFIG_EHCI_IS_TDI // FIXME
-#if defined(CONFIG_EHCI_IS_TDI)
-#define ehci_is_TDI() (1)
-#else
-#define ehci_is_TDI() (0)
-#endif
+#define ehci_is_TDI() (ehci->flags & EHCI_HAS_TT)
#ifdef CONFIG_MMU
/*
@@ -861,10 +858,19 @@ static int ehci_probe(struct device_d *dev)
struct usb_host *host;
struct ehci_priv *ehci;
uint32_t reg;
+ struct ehci_platform_data *pdata = dev->platform_data;
ehci = xmalloc(sizeof(struct ehci_priv));
host = &ehci->host;
+ if (pdata)
+ ehci->flags = pdata->flags;
+ else
+ /* default to EHCI_HAS_TT to not change behaviour of boards
+ * with platform_data
+ */
+ ehci->flags = EHCI_HAS_TT;
+
host->init = ehci_init;
host->submit_int_msg = submit_int_msg;
host->submit_control_msg = submit_control_msg;
diff --git a/include/usb/ehci.h b/include/usb/ehci.h
new file mode 100644
index 0000000..3304b60
--- /dev/null
+++ b/include/usb/ehci.h
@@ -0,0 +1,10 @@
+#ifndef __USB_EHCI_H
+#define __USB_EHCI_H
+
+#define EHCI_HAS_TT (1 << 0)
+
+struct ehci_platform_data {
+ unsigned long flags;
+};
+
+#endif /* __USB_EHCI_H */
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/6] ehci: Handle hub port reset properly
2010-06-24 9:45 USB related patches Sascha Hauer
2010-06-24 9:45 ` [PATCH 1/6] ehci: Make has_tt configurable via platform data Sascha Hauer
@ 2010-06-24 9:45 ` Sascha Hauer
2010-06-24 9:45 ` [PATCH 3/6] usb: Check return value of host controller init Sascha Hauer
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2010-06-24 9:45 UTC (permalink / raw)
To: barebox
This has been copied from the U-Boot ehci driver.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/usb_ehci_core.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/usb_ehci_core.c b/drivers/usb/usb_ehci_core.c
index f3611cd..c5d4da3 100644
--- a/drivers/usb/usb_ehci_core.c
+++ b/drivers/usb/usb_ehci_core.c
@@ -676,6 +676,8 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
ehci_writel(status_reg, reg);
break;
} else {
+ int ret;
+
reg |= EHCI_PS_PR;
reg &= ~EHCI_PS_PE;
ehci_writel(status_reg, reg);
@@ -686,6 +688,22 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
*/
wait_ms(50);
ehci->portreset |= 1 << le16_to_cpu(req->index);
+ /* terminate the reset */
+ ehci_writel(status_reg, reg & ~EHCI_PS_PR);
+ /*
+ * A host controller must terminate the reset
+ * and stabilize the state of the port within
+ * 2 milliseconds
+ */
+ ret = handshake(status_reg, EHCI_PS_PR, 0,
+ 2 * 1000);
+ if (!ret)
+ ehci->portreset |=
+ 1 << le16_to_cpu(req->index);
+ else
+ printf("port(%d) reset error\n",
+ le16_to_cpu(req->index) - 1);
+
}
break;
default:
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/6] usb: Check return value of host controller init
2010-06-24 9:45 USB related patches Sascha Hauer
2010-06-24 9:45 ` [PATCH 1/6] ehci: Make has_tt configurable via platform data Sascha Hauer
2010-06-24 9:45 ` [PATCH 2/6] ehci: Handle hub port reset properly Sascha Hauer
@ 2010-06-24 9:45 ` Sascha Hauer
2010-06-24 9:45 ` [PATCH 4/6] ehci: use is_timeout for timeout instead of udelay counter Sascha Hauer
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2010-06-24 9:45 UTC (permalink / raw)
To: barebox
And do not scan the bus if initialization failed.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/usb.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/usb.c b/drivers/usb/usb.c
index 1ad4bab..76e033e 100644
--- a/drivers/usb/usb.c
+++ b/drivers/usb/usb.c
@@ -453,6 +453,7 @@ static int __usb_init(void)
{
struct usb_device *dev, *tmp;
struct usb_host *host;
+ int ret;
list_for_each_entry_safe(dev, tmp, &usb_device_list, list) {
list_del(&dev->list);
@@ -466,7 +467,9 @@ static int __usb_init(void)
dev_index = 0;
list_for_each_entry(host, &host_list, list) {
- host->init(host);
+ ret = host->init(host);
+ if (ret)
+ continue;
dev = usb_alloc_new_device();
dev->host = host;
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/6] ehci: use is_timeout for timeout instead of udelay counter
2010-06-24 9:45 USB related patches Sascha Hauer
` (2 preceding siblings ...)
2010-06-24 9:45 ` [PATCH 3/6] usb: Check return value of host controller init Sascha Hauer
@ 2010-06-24 9:45 ` Sascha Hauer
2010-06-24 9:45 ` [PATCH 5/6] ehci: Force a ehci_halt before trying to reset Sascha Hauer
2010-06-24 9:45 ` [PATCH 6/6] ehci: remove unused code Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2010-06-24 9:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/usb_ehci_core.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/usb_ehci_core.c b/drivers/usb/usb_ehci_core.c
index c5d4da3..e70e871 100644
--- a/drivers/usb/usb_ehci_core.c
+++ b/drivers/usb/usb_ehci_core.c
@@ -213,18 +213,20 @@ static inline void ehci_invalidate_dcache(struct QH *qh)
static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec)
{
uint32_t result;
+ uint64_t start;
- do {
+ start = get_time_ns();
+
+ while (1) {
result = ehci_readl(ptr);
if (result == ~(uint32_t)0)
return -1;
result &= mask;
if (result == done)
return 0;
- udelay(1);
- usec--;
- } while (usec > 0);
- return -1;
+ if (is_timeout(start, usec * USECOND))
+ return -ETIMEDOUT;
+ }
}
static int ehci_reset(struct ehci_priv *ehci)
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/6] ehci: Force a ehci_halt before trying to reset
2010-06-24 9:45 USB related patches Sascha Hauer
` (3 preceding siblings ...)
2010-06-24 9:45 ` [PATCH 4/6] ehci: use is_timeout for timeout instead of udelay counter Sascha Hauer
@ 2010-06-24 9:45 ` Sascha Hauer
2010-06-24 9:45 ` [PATCH 6/6] ehci: remove unused code Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2010-06-24 9:45 UTC (permalink / raw)
To: barebox
As observed on OMAP some controllers do not like being
resetted when running.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/usb_ehci_core.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/usb_ehci_core.c b/drivers/usb/usb_ehci_core.c
index e70e871..fe988c3 100644
--- a/drivers/usb/usb_ehci_core.c
+++ b/drivers/usb/usb_ehci_core.c
@@ -770,12 +770,33 @@ unknown:
return -1;
}
+/* force HC to halt state from unknown (EHCI spec section 2.3) */
+static int ehci_halt(struct ehci_priv *ehci)
+{
+ u32 temp = ehci_readl(&ehci->hcor->or_usbsts);
+
+ /* disable any irqs left enabled by previous code */
+ ehci_writel(&ehci->hcor->or_usbintr, 0);
+
+ if (temp & STS_HALT)
+ return 0;
+
+ temp = ehci_readl(&ehci->hcor->or_usbcmd);
+ temp &= ~CMD_RUN;
+ ehci_writel(&ehci->hcor->or_usbcmd, temp);
+
+ return handshake(&ehci->hcor->or_usbsts,
+ STS_HALT, STS_HALT, 16 * 125);
+}
+
static int ehci_init(struct usb_host *host)
{
struct ehci_priv *ehci = to_ehci(host);
uint32_t reg;
uint32_t cmd;
+ ehci_halt(ehci);
+
/* EHCI spec section 4.1 */
if (ehci_reset(ehci) != 0)
return -1;
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 6/6] ehci: remove unused code
2010-06-24 9:45 USB related patches Sascha Hauer
` (4 preceding siblings ...)
2010-06-24 9:45 ` [PATCH 5/6] ehci: Force a ehci_halt before trying to reset Sascha Hauer
@ 2010-06-24 9:45 ` Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2010-06-24 9:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/usb_ehci.h | 4 ----
drivers/usb/usb_ehci_core.c | 5 -----
2 files changed, 0 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/usb_ehci.h b/drivers/usb/usb_ehci.h
index b3c1d5d..af49249 100644
--- a/drivers/usb/usb_ehci.h
+++ b/drivers/usb/usb_ehci.h
@@ -187,8 +187,4 @@ struct QH {
uint8_t fill[16];
};
-/* Low level init functions */
-int ehci_hcd_init(void);
-int ehci_hcd_stop(void);
-
#endif /* USB_EHCI_H */
diff --git a/drivers/usb/usb_ehci_core.c b/drivers/usb/usb_ehci_core.c
index fe988c3..af066de 100644
--- a/drivers/usb/usb_ehci_core.c
+++ b/drivers/usb/usb_ehci_core.c
@@ -801,11 +801,6 @@ static int ehci_init(struct usb_host *host)
if (ehci_reset(ehci) != 0)
return -1;
-#if defined(CONFIG_EHCI_HCD_INIT_AFTER_RESET)
- if (ehci_hcd_init() != 0)
- return -1;
-#endif
-
/* Set head of reclaim list */
ehci->qhp = xzalloc(sizeof(struct QH) + 32);
ehci->qh_list = (struct QH *)(((unsigned long)ehci->qhp + 32) & ~31);
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread