Add support for serial class driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@968 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
e55508240a
commit
d2fd11e1f1
@ -707,7 +707,7 @@ static int lpc214x_wrrequest(struct lpc214x_ep_s *privep)
|
||||
privreq = (struct lpc214x_req_s *)sq_peek(&privep->reqlist);
|
||||
if (!privreq)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NULLREQUEST), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NULLREQUEST), 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -776,7 +776,7 @@ static int lpc214x_rdrequest(struct lpc214x_ep_s *privep)
|
||||
privreq = (struct lpc214x_req_s *)sq_peek(&privep->reqlist);
|
||||
if (!privreq)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NULLREQUEST), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NULLREQUEST), 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -791,7 +791,7 @@ static int lpc214x_rdrequest(struct lpc214x_ep_s *privep)
|
||||
nbytesread = lpc214x_epread(privep->epphy, buf, privep->ep.maxpacket);
|
||||
if (nbytesread < 0)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_EPREAD), nbytesread);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_EPREAD), nbytesread);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
@ -1320,7 +1320,7 @@ static inline void lpc214x_ep0setup(struct lpc214x_usbdev_s *priv)
|
||||
|
||||
if (priv->stalled)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
||||
lpc214x_epstall(&ep0->ep, FALSE);
|
||||
lpc214x_epstall(&ep0->ep, FALSE);
|
||||
}
|
||||
@ -1383,7 +1383,7 @@ static inline void lpc214x_ep0dataoutinterrupt(struct lpc214x_usbdev_s *priv)
|
||||
|
||||
if (priv->stalled)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
||||
ep0 = &priv->eplist[LPC214X_EP0_OUT];
|
||||
lpc214x_epstall(&ep0->ep, FALSE);
|
||||
lpc214x_epstall(&ep0->ep, FALSE);
|
||||
@ -1443,7 +1443,7 @@ static inline void lpc214x_ep0dataininterrupt(struct lpc214x_usbdev_s *priv)
|
||||
|
||||
if (priv->stalled)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
||||
ep0 = &priv->eplist[LPC214X_EP0_IN];
|
||||
lpc214x_epstall(&ep0->ep, FALSE);
|
||||
lpc214x_epstall(&ep0->ep, FALSE);
|
||||
@ -1806,7 +1806,7 @@ static int lpc214x_dmasetup(struct lpc214x_usbdev_s *priv, ubyte epphy,
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!priv || epphy < 2)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
@ -1817,7 +1817,7 @@ static int lpc214x_dmasetup(struct lpc214x_usbdev_s *priv, ubyte epphy,
|
||||
|
||||
if (!dmadesc)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NODMADESC), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NODMADESC), 0);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
@ -1825,7 +1825,7 @@ static int lpc214x_dmasetup(struct lpc214x_usbdev_s *priv, ubyte epphy,
|
||||
|
||||
if ((dmadesc->status & USB_DMADESC_STATUSMASK) == USB_DMADESC_BEINGSERVICED)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_DMABUSY), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_DMABUSY), 0);
|
||||
return -EBUSY; /* Shouldn't happen */
|
||||
}
|
||||
|
||||
@ -1991,7 +1991,7 @@ static int lpc214x_epdisable(FAR struct usbdev_ep_s *ep)
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!ep)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
@ -2033,7 +2033,7 @@ static FAR struct usbdev_req_s *lpc214x_epallocreq(FAR struct usbdev_ep_s *ep)
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!ep)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@ -2042,7 +2042,7 @@ static FAR struct usbdev_req_s *lpc214x_epallocreq(FAR struct usbdev_ep_s *ep)
|
||||
privreq = (FAR struct lpc214x_req_s *)malloc(sizeof(struct lpc214x_req_s));
|
||||
if (!privreq)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_ALLOCFAIL), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_ALLOCFAIL), 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2065,7 +2065,7 @@ static void lpc214x_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!ep || !req)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -2145,7 +2145,7 @@ static int lpc214x_epsubmit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!req || !req->callback || !req->buf || !ep)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
@ -2154,7 +2154,7 @@ static int lpc214x_epsubmit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
||||
|
||||
if (!priv->driver || priv->usbdev.speed == USB_SPEED_UNKNOWN)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NOTCONFIGURED), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NOTCONFIGURED), 0);
|
||||
return -ESHUTDOWN;
|
||||
}
|
||||
|
||||
@ -2166,7 +2166,7 @@ static int lpc214x_epsubmit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
||||
flags = irqsave();
|
||||
if (req->len == 0 && (privep->in || privep->epphy == 3))
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NULLPACKET), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NULLPACKET), 0);
|
||||
sq_addlast(&privreq->sqe, &privep->reqlist);
|
||||
goto success_notransfer;
|
||||
}
|
||||
@ -2202,7 +2202,7 @@ static int lpc214x_epsubmit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
||||
}
|
||||
else
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_BADREQUEST), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_BADREQUEST), 0);
|
||||
ret = ERROR;
|
||||
goto errout;
|
||||
}
|
||||
@ -2239,7 +2239,7 @@ static int lpc214x_epcancel(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!ep || !req)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
@ -2303,7 +2303,7 @@ static FAR struct usbdev_ep_s *lcp214x_allocep(FAR struct usbdev_s *dev, ubyte e
|
||||
{
|
||||
if (epphy >= LPC214X_NLOGENDPOINTS)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_BADEPNO), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_BADEPNO), 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2339,7 +2339,7 @@ static FAR struct usbdev_ep_s *lcp214x_allocep(FAR struct usbdev_s *dev, ubyte e
|
||||
|
||||
case USB_EP_ATTR_XFER_CONTROL: /* Control endpoint -- not a valid choice */
|
||||
default:
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_BADEPTYPE), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_BADEPTYPE), 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2375,7 +2375,7 @@ static FAR struct usbdev_ep_s *lcp214x_allocep(FAR struct usbdev_s *dev, ubyte e
|
||||
irqrestore(flags);
|
||||
}
|
||||
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NOEP), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NOEP), 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2473,7 +2473,7 @@ static int lpc214x_selfpowered(struct usbdev_s *dev, boolean selfpowered)
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!dev)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
@ -2554,7 +2554,7 @@ void up_usbinitialize(void)
|
||||
|
||||
if (irq_attach(LPC214X_USB_IRQ, lpc214x_usbinterrupt) != 0)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_IRQREGISTRATION), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_IRQREGISTRATION), 0);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
@ -2597,7 +2597,7 @@ void up_usbuninitialize(void)
|
||||
usbtrace(TRACE_DEVUNINIT, 0);
|
||||
if (priv->driver)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_DRIVERREGISTERED), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_DRIVERREGISTERED), 0);
|
||||
usbdev_unregister(priv->driver);
|
||||
}
|
||||
|
||||
@ -2640,13 +2640,13 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
||||
if (!driver || !driver->ops->bind || !driver->ops->unbind ||
|
||||
!driver->ops->disconnect || !driver->ops->setup)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (g_usbdev.driver)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_DRIVER), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_DRIVER), 0);
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif
|
||||
@ -2660,7 +2660,7 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
||||
ret = CLASS_BIND(driver, &g_usbdev.usbdev);
|
||||
if (ret)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_BINDFAILED), (uint16)-ret);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_BINDFAILED), (uint16)-ret);
|
||||
g_usbdev.driver = NULL;
|
||||
}
|
||||
return ret;
|
||||
@ -2683,7 +2683,7 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (driver != g_usbdev.driver)
|
||||
{
|
||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
@ -4,6 +4,12 @@
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* NOTE: This interface was inspired by the Linux gadget interface by
|
||||
* David Brownell. That work was very helpful in determining a usable
|
||||
* partitioning of functionality between standard class drivers and various
|
||||
* implementations of USB controller drivers. This work, however, does
|
||||
* not derive directly from that work and is licensed differently.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -317,6 +323,16 @@ EXTERN int usbdev_register(FAR struct usbdevclass_driver_s *driver);
|
||||
|
||||
EXTERN int usbdev_unregister(FAR struct usbdevclass_driver_s *driver);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbdev_serialinit
|
||||
*
|
||||
* Description:
|
||||
* Register USB serial port (and USB serial console if so configured).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int usbdev_serialinitialize(int minor);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
@ -64,7 +64,8 @@
|
||||
#define TRACE_READ_ID (0x0800) /* Read (OUT) action */
|
||||
#define TRACE_WRITE_ID (0x0900) /* Write (IN) action */
|
||||
#define TRACE_COMPLETE_ID (0x0a00) /* Request completed */
|
||||
#define TRACE_ERROR_ID (0x0b00) /* Error event */
|
||||
#define TRACE_DEVERROR_ID (0x0b00) /* USB controller driver error event */
|
||||
#define TRACE_CLSERROR_ID (0x0c00) /* USB class driver error event */
|
||||
|
||||
/* Initialization events */
|
||||
|
||||
@ -93,14 +94,17 @@
|
||||
#define TRACE_DEVSELFPOWERED TRACE_EVENT(TRACE_DEV_ID, 0x0005)
|
||||
#define TRACE_DEVPULLUP TRACE_EVENT(TRACE_DEV_ID, 0x0006)
|
||||
|
||||
#define TRACE_CLASSBIN TRACE_EVENT(TRACE_CLASS_ID, 0x0001)
|
||||
#define TRACE_CLASSUNBIND TRACE_EVENT(TRACE_CLASS_ID, 0x0001)
|
||||
#define TRACE_CLASSDISCONNECT TRACE_EVENT(TRACE_CLASS_ID, 0x0001)
|
||||
#define TRACE_CLASSSETUP TRACE_EVENT(TRACE_CLASS_ID, 0x0001)
|
||||
#define TRACE_CLASSSUSPEND TRACE_EVENT(TRACE_CLASS_ID, 0x0001)
|
||||
#define TRACE_CLASSRESUME TRACE_EVENT(TRACE_CLASS_ID, 0x0001)
|
||||
#define TRACE_CLASSBIND TRACE_EVENT(TRACE_CLASS_ID, 0x0001)
|
||||
#define TRACE_CLASSUNBIND TRACE_EVENT(TRACE_CLASS_ID, 0x0002)
|
||||
#define TRACE_CLASSDISCONNECT TRACE_EVENT(TRACE_CLASS_ID, 0x0003)
|
||||
#define TRACE_CLASSSETUP TRACE_EVENT(TRACE_CLASS_ID, 0x0004)
|
||||
#define TRACE_CLASSSUSPEND TRACE_EVENT(TRACE_CLASS_ID, 0x0005)
|
||||
#define TRACE_CLASSRESUME TRACE_EVENT(TRACE_CLASS_ID, 0x0006)
|
||||
|
||||
/* Interrupt events -- id is hardware specific */
|
||||
/* USB device controller interrupt events. The 'id' is specific to the driver.
|
||||
* Particular values for 'id' are unique for a given implementation of a
|
||||
* controller driver
|
||||
*/
|
||||
|
||||
#define TRACE_INTENTRY(id) TRACE_EVENT(TRACE_INTENTRY_ID, id)
|
||||
#define TRACE_INTDECODE(id) TRACE_EVENT(TRACE_INTDECODE_ID, id)
|
||||
@ -113,9 +117,43 @@
|
||||
#define TRACE_WRITE(ep) TRACE_EVENT(TRACE_WRITE_ID, ep)
|
||||
#define TRACE_COMPLETE(ep) TRACE_EVENT(TRACE_COMPLETE_ID, ep)
|
||||
|
||||
/* Error events -- id is specific to the driver */
|
||||
/* USB device controller error events. The 'id' is specific to the driver.
|
||||
* Particular values for 'id' are unique for a given implementation of a
|
||||
* controller driver
|
||||
*/
|
||||
|
||||
#define TRACE_ERROR(id) TRACE_EVENT(TRACE_ERROR_ID, id)
|
||||
#define TRACE_DEVERROR(id) TRACE_EVENT(TRACE_CLSERROR_ID, id)
|
||||
|
||||
/* USB class driver error events. The 'id' is specific to the class driver,
|
||||
* but common to all driver controller instances.
|
||||
*/
|
||||
|
||||
#define TRACE_CLSERROR(id) TRACE_EVENT(TRACE_CLSERROR_ID, id)
|
||||
|
||||
/* Values of the class error ID used by the USB serial driver */
|
||||
|
||||
#define USBSER_TRACEERR_ALLOCCTRLREQ 0x0001
|
||||
#define USBSER_TRACEERR_ALREADYCLOSED 0x0002
|
||||
#define USBSER_TRACEERR_CONSOLEREGISTER 0x0003
|
||||
#define USBSER_TRACEERR_DEVREGISTER 0x0004
|
||||
#define USBSER_TRACEERR_EPRESPQ 0x0005
|
||||
#define USBSER_TRACEERR_GETUNKNOWNDESC 0x0006
|
||||
#define USBSER_TRACEERR_INALLOCEPFAIL 0x0007
|
||||
#define USBSER_TRACEERR_INCONFIGEPFAIL 0x0008
|
||||
#define USBSER_TRACEERR_INVALIDARG 0x0009
|
||||
#define USBSER_TRACEERR_OUTALLOCEPFAIL 0x000a
|
||||
#define USBSER_TRACEERR_OUTCONFIGEPFAIL 0x000b
|
||||
#define USBSER_TRACEERR_RDALLOCREQ 0x000c
|
||||
#define USBSER_TRACEERR_RDSHUTDOWN 0x000d
|
||||
#define USBSER_TRACEERR_RDSUBMIT 0x000e
|
||||
#define USBSER_TRACEERR_RDUNEXPECTED 0x000f
|
||||
#define USBSER_TRACEERR_REQRESULT 0x0010
|
||||
#define USBSER_TRACEERR_SETUPNOTCONNECTED 0x0011
|
||||
#define USBSER_TRACEERR_SUBMITFAIL 0x0012
|
||||
#define USBSER_TRACEERR_UARTREGISTER 0x0013
|
||||
#define USBSER_TRACEERR_WRALLOCREQ 0x0014
|
||||
#define USBSER_TRACEERR_WRSHUTDOWN 0x0015
|
||||
#define USBSER_TRACEERR_WRUNEXPECTED 0x0016
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
@ -177,7 +215,7 @@ EXTERN void usbtrace_enable(boolean enable);
|
||||
#ifdef CONFIG_USBDEV_TRACE
|
||||
EXTERN void usbtrace(uint16 event, uint16 value);
|
||||
#else
|
||||
# define usbtrace(event)
|
||||
# define usbtrace(event, value)
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user