Fix some bugs introduced with the last set of big commits
This commit is contained in:
parent
9296eca193
commit
3474a5536b
@ -194,8 +194,8 @@ struct lpc17_xfrinfo_s
|
|||||||
|
|
||||||
#ifdef CONFIG_USBHOST_ASYNCH
|
#ifdef CONFIG_USBHOST_ASYNCH
|
||||||
#if LPC17_IOBUFFERS > 0
|
#if LPC17_IOBUFFERS > 0
|
||||||
/* Remember buffer related information for when the asynchronous transfer
|
/* Remember the allocated DMA buffer address so that it can be freed when
|
||||||
* completes.
|
* the transfer completes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint16_t buflen; /* Buffer length */
|
uint16_t buflen; /* Buffer length */
|
||||||
@ -1499,13 +1499,12 @@ static int lpc17_ctrltd(struct lpc17_usbhost_s *priv, struct lpc17_ed_s *ed,
|
|||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
xfrinfo = ed->xfrinfo;
|
/* Allocate a structure to retain the information needed when the transfer
|
||||||
DEBUGASSERT(xfrinfo);
|
* completes.
|
||||||
|
|
||||||
/* Allocate a structure to retain the information needed when the asynchronous
|
|
||||||
* transfer completes.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
DEBUGASSERT(ed->xfrinfo == NULL);
|
||||||
|
|
||||||
xfrinfo = lpc17_alloc_xfrinfo();
|
xfrinfo = lpc17_alloc_xfrinfo();
|
||||||
if (xfrinfo == NULL)
|
if (xfrinfo == NULL)
|
||||||
{
|
{
|
||||||
@ -1686,6 +1685,12 @@ static int lpc17_usbinterrupt(int irq, void *context)
|
|||||||
ullvdbg("Disconnected\n");
|
ullvdbg("Disconnected\n");
|
||||||
priv->connected = false;
|
priv->connected = false;
|
||||||
priv->change = true;
|
priv->change = true;
|
||||||
|
|
||||||
|
/* Set the port speed to the default (FULL). We cannot
|
||||||
|
* yet free the function address. That has to be done
|
||||||
|
* by the class when responds to the disconnection.
|
||||||
|
*/
|
||||||
|
|
||||||
priv->rhport.hport.speed = USB_SPEED_FULL;
|
priv->rhport.hport.speed = USB_SPEED_FULL;
|
||||||
|
|
||||||
/* Are we bound to a class instance? */
|
/* Are we bound to a class instance? */
|
||||||
@ -1774,13 +1779,24 @@ static int lpc17_usbinterrupt(int irq, void *context)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Determine the number of bytes actually transfer by
|
||||||
|
* subtracting the buffer start address from the CBP. But be
|
||||||
|
* careful, the CBP may be zero.
|
||||||
|
*/
|
||||||
|
|
||||||
|
tmp = (uintptr_t)td->hw.cbp;
|
||||||
|
if (tmp != 0)
|
||||||
|
{
|
||||||
|
DEBUGASSERT(tmp >= (uintptr_t)xfrinfo->buffer);
|
||||||
|
|
||||||
/* Determine the size of the transfer by subtracting the
|
/* Determine the size of the transfer by subtracting the
|
||||||
* current buffer pointer (CBP) from the initial buffer
|
* current buffer pointer (CBP) from the initial buffer
|
||||||
* pointer (on packet receipt only).
|
* pointer (on packet receipt only).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tmp = (uintptr_t)td->hw.cbp - (uintptr_t)xfrinfo->buffer;
|
tmp -= (uintptr_t)xfrinfo->buffer;
|
||||||
DEBUGASSERT(tmp < UINT16_MAX);
|
DEBUGASSERT(tmp < UINT16_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
xfrinfo->xfrd = (uint16_t)tmp;
|
xfrinfo->xfrd = (uint16_t)tmp;
|
||||||
|
|
||||||
@ -1796,6 +1812,7 @@ static int lpc17_usbinterrupt(int irq, void *context)
|
|||||||
lpc17_givesem(&ed->wdhsem);
|
lpc17_givesem(&ed->wdhsem);
|
||||||
xfrinfo->wdhwait = false;
|
xfrinfo->wdhwait = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_USBHOST_ASYNCH
|
#ifdef CONFIG_USBHOST_ASYNCH
|
||||||
/* Perform any pending callbacks for the case of asynchronous
|
/* Perform any pending callbacks for the case of asynchronous
|
||||||
* transfers.
|
* transfers.
|
||||||
@ -1871,20 +1888,27 @@ static int lpc17_wait(struct usbhost_connection_s *conn,
|
|||||||
if (priv->change)
|
if (priv->change)
|
||||||
{
|
{
|
||||||
connport = &priv->rhport.hport;
|
connport = &priv->rhport.hport;
|
||||||
|
priv->change = false;
|
||||||
|
|
||||||
/* Yes. Remember the new state */
|
/* Yes.. check for false alarms */
|
||||||
|
|
||||||
|
if (priv->connected != connport->connected)
|
||||||
|
{
|
||||||
|
/* Not a false alarm.. Remember the new state */
|
||||||
|
|
||||||
connport->connected = priv->connected;
|
connport->connected = priv->connected;
|
||||||
priv->change = false;
|
|
||||||
|
|
||||||
/* And return the root hub port */
|
/* And return the root hub port */
|
||||||
|
|
||||||
*hport = connport;
|
*hport = connport;
|
||||||
irqrestore(flags);
|
irqrestore(flags);
|
||||||
|
|
||||||
udbg("RHport Connected: %s\n", connport->connected ? "YES" : "NO");
|
udbg("RHport Connected: %s\n",
|
||||||
|
connport->connected ? "YES" : "NO");
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_USBHOST_HUB
|
#ifdef CONFIG_USBHOST_HUB
|
||||||
/* Is a device connected to an external hub? */
|
/* Is a device connected to an external hub? */
|
||||||
@ -2842,7 +2866,6 @@ static ssize_t lpc17_transfer(struct usbhost_driver_s *drvr, usbhost_ep_t ep,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DEBUGASSERT(priv && ed && buffer && buflen > 0);
|
DEBUGASSERT(priv && ed && buffer && buflen > 0);
|
||||||
DEBUGASSERT(ed->xfrinfo == NULL);
|
|
||||||
|
|
||||||
/* We must have exclusive access to the endpoint, the TD pool, the I/O buffer
|
/* We must have exclusive access to the endpoint, the TD pool, the I/O buffer
|
||||||
* pool, the bulk and interrupt lists, and the HCCA interrupt table.
|
* pool, the bulk and interrupt lists, and the HCCA interrupt table.
|
||||||
@ -2850,10 +2873,12 @@ static ssize_t lpc17_transfer(struct usbhost_driver_s *drvr, usbhost_ep_t ep,
|
|||||||
|
|
||||||
lpc17_takesem(&priv->exclsem);
|
lpc17_takesem(&priv->exclsem);
|
||||||
|
|
||||||
/* Allocate a structure to retain the information needed when the asynchronous
|
/* Allocate a structure to retain the information needed when the transfer
|
||||||
* transfer completes.
|
* completes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
DEBUGASSERT(ed->xfrinfo == NULL);
|
||||||
|
|
||||||
xfrinfo = lpc17_alloc_xfrinfo();
|
xfrinfo = lpc17_alloc_xfrinfo();
|
||||||
if (xfrinfo == NULL)
|
if (xfrinfo == NULL)
|
||||||
{
|
{
|
||||||
@ -3092,6 +3117,8 @@ static int lpc17_asynch(struct usbhost_driver_s *drvr, usbhost_ep_t ep,
|
|||||||
* transfer completes.
|
* transfer completes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
DEBUGASSERT(ed->xfrinfo == NULL);
|
||||||
|
|
||||||
xfrinfo = lpc17_alloc_xfrinfo();
|
xfrinfo = lpc17_alloc_xfrinfo();
|
||||||
if (xfrinfo == NULL)
|
if (xfrinfo == NULL)
|
||||||
{
|
{
|
||||||
@ -3443,6 +3470,7 @@ struct usbhost_connection_s *lpc17_usbhost_initialize(int controller)
|
|||||||
#endif
|
#endif
|
||||||
hport->ep0 = EDCTRL;
|
hport->ep0 = EDCTRL;
|
||||||
hport->speed = USB_SPEED_FULL;
|
hport->speed = USB_SPEED_FULL;
|
||||||
|
hport->funcaddr = 0;
|
||||||
|
|
||||||
/* Initialize function address generation logic */
|
/* Initialize function address generation logic */
|
||||||
|
|
||||||
|
@ -2020,6 +2020,12 @@ static void sam_rhsc_bottomhalf(void)
|
|||||||
rhpndx + 1, g_ohci.pscwait);
|
rhpndx + 1, g_ohci.pscwait);
|
||||||
|
|
||||||
rhport->connected = false;
|
rhport->connected = false;
|
||||||
|
|
||||||
|
/* Set the port speed to the default (FULL). We cannot
|
||||||
|
* yet free the function address. That has to be done
|
||||||
|
* by the class when responds to the disconnection.
|
||||||
|
*/
|
||||||
|
|
||||||
rhport->hport.hport.speed = USB_SPEED_FULL;
|
rhport->hport.hport.speed = USB_SPEED_FULL;
|
||||||
|
|
||||||
/* Are we bound to a class instance? */
|
/* Are we bound to a class instance? */
|
||||||
@ -2150,13 +2156,25 @@ static void sam_wdh_bottomhalf(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Determine the size of the transfer by subtracting the current buffer
|
/* Determine the number of bytes actually transfer by* subtracting the
|
||||||
* pointer (CBP) from the initial buffer pointer (on packet receipt only).
|
* buffer start address from the CBP. But be careful, the CBP may be
|
||||||
|
* zero.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
tmp = (uintptr_t)td->hw.cbp;
|
||||||
|
if (tmp != 0)
|
||||||
|
{
|
||||||
paddr = sam_physramaddr((uintptr_t)eplist->buffer);
|
paddr = sam_physramaddr((uintptr_t)eplist->buffer);
|
||||||
tmp = (uintptr_t)td->hw.cbp - paddr;
|
DEBUGASSERT(tmp >= paddr);
|
||||||
|
|
||||||
|
/* Determine the size of the transfer by subtracting the current
|
||||||
|
* buffer pointer (CBP) from the initial buffer pointer (on packet
|
||||||
|
* receipt only).
|
||||||
|
*/
|
||||||
|
|
||||||
|
tmp -= paddr;
|
||||||
DEBUGASSERT(tmp < UINT16_MAX);
|
DEBUGASSERT(tmp < UINT16_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
eplist->xfrd = (uint16_t)tmp;
|
eplist->xfrd = (uint16_t)tmp;
|
||||||
|
|
||||||
@ -3278,6 +3296,7 @@ static ssize_t sam_transfer(struct usbhost_driver_s *drvr, usbhost_ep_t ep,
|
|||||||
|
|
||||||
DEBUGASSERT(rhport && eplist && eplist->ed && eplist->tail &&
|
DEBUGASSERT(rhport && eplist && eplist->ed && eplist->tail &&
|
||||||
buffer && buflen > 0);
|
buffer && buflen > 0);
|
||||||
|
|
||||||
ed = eplist->ed;
|
ed = eplist->ed;
|
||||||
in = (ed->hw.ctrl & ED_CONTROL_D_MASK) == ED_CONTROL_D_IN;
|
in = (ed->hw.ctrl & ED_CONTROL_D_MASK) == ED_CONTROL_D_IN;
|
||||||
|
|
||||||
@ -3912,6 +3931,7 @@ struct usbhost_connection_s *sam_ohci_initialize(int controller)
|
|||||||
hport->ep0 = &rhport->ep0;
|
hport->ep0 = &rhport->ep0;
|
||||||
hport->port = i;
|
hport->port = i;
|
||||||
hport->speed = USB_SPEED_FULL;
|
hport->speed = USB_SPEED_FULL;
|
||||||
|
hport->funcaddr = 0;
|
||||||
|
|
||||||
/* Initialize function address generation logic */
|
/* Initialize function address generation logic */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user