From 40525cedcd351a73c85d7d9db919bd9b1dd0dcc8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 26 Aug 2013 11:05:23 -0600 Subject: [PATCH] SAMA5 EHCI: Taking direction from wrong bit in SETUP request; need to flush data buffer before starting SETUP request --- arch/arm/src/sama5/sam_ehci.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/sama5/sam_ehci.c b/arch/arm/src/sama5/sam_ehci.c index 02f99fee22..0076563d79 100755 --- a/arch/arm/src/sama5/sam_ehci.c +++ b/arch/arm/src/sama5/sam_ehci.c @@ -1523,6 +1523,18 @@ static int sam_qtd_addbpl(struct sam_qtd_s *qtd, const void *buffer, size_t bufl uint32_t next; int ndx; + /* Flush the contents of the data buffer to RAM so that the correct contents + * will be accessed for an OUT DMA. + */ + + cp15_coherent_dcache((uintptr_t)buffer, (uintptr_t)buffer + buflen); + + /* Loop, adding the aligned physical addresses of the buffer to the buffer page + * list. Only the first entry need not be aligned (because only the first + * entry has the offset field). The subsequent entries must begin on 4KB + * address boundaries. + */ + physaddr = (uint32_t)sam_physramaddr((uintptr_t)buffer); for (ndx = 0; ndx < 5; ndx++) @@ -1825,7 +1837,7 @@ static ssize_t sam_async_transfer(struct sam_rhport_s *rhport, datapid = QTD_TOKEN_PID_OUT; if (req) { - if ((req->req & USB_REQ_DIR_MASK) == USB_REQ_DIR_IN) + if ((req->type & USB_REQ_DIR_MASK) == USB_REQ_DIR_IN) { datapid = QTD_TOKEN_PID_IN; }