diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-12-04 17:35:19 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-12-04 17:35:19 +0000 |
commit | 49d757566aca9120bc0b479b72b8aa547959ce7c (patch) | |
tree | dc8e23ad0a0d4044bbcd2d4b4488be9bc0146bb8 /nuttx | |
parent | 3d3a0af8b0d724f46656b6a9cb4a883f374558dc (diff) | |
download | px4-nuttx-49d757566aca9120bc0b479b72b8aa547959ce7c.tar.gz px4-nuttx-49d757566aca9120bc0b479b72b8aa547959ce7c.tar.bz2 px4-nuttx-49d757566aca9120bc0b479b72b8aa547959ce7c.zip |
USB class drivers need to call DEV_CONNECT
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3159 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/Documentation/NuttX.html | 6 | ||||
-rw-r--r-- | nuttx/TODO | 9 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/lpc17xx/lpc17_usbdev.c | 23 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/lpc313x/lpc313x_usbdev.c | 6 | ||||
-rwxr-xr-x | nuttx/configs/olimex-lpc1766stk/usbstorage/defconfig | 6 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/usbdev_scsi.c | 1 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/usbdev_serial.c | 10 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/usbdev_storage.c | 10 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/usbdev_storage.h | 46 | ||||
-rw-r--r-- | nuttx/include/nuttx/usbdev.h | 5 |
10 files changed, 81 insertions, 41 deletions
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 3a946b5d2..87fe3c11d 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -8,7 +8,7 @@ <tr align="center" bgcolor="#e4e4e4"> <td> <h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1> - <p>Last Updated: December 3, 2010</p> + <p>Last Updated: December 4, 2010</p> </td> </tr> </table> @@ -2011,6 +2011,10 @@ nuttx-5.15 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> or data. This is typical, for example, in "9-bit" displays where the 9th bit is the CMD/DATA bit. The cmddata method provides selection of command or data. * drivers/lcd/p14201.c -- Now used the cmddata() method of the SPI interface. + * arch/arm/src/lpc17xx/lpc17_usbdev.c -- LPC17xx USB driver is not functional. + * drivers/usbdev/usbserial.c and usbstorage.c -- All USB class drivers need + to call DEV_CONNECT() when they are ready to be enumerated. That is, + (1) initially when bound to the USB driver, and (2) after a USB reset. pascal-2.1 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/nuttx/TODO b/nuttx/TODO index 6bed0714d..256a2509f 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -716,13 +716,8 @@ o ARM/LPC17xx (arch/arm/src/lpc17xx/) Status: Open Priority: High - Description: a) USB DMA not fully implemented. Partial logic is in place but it is - fragmentary and bogus. (Leveraged from the lpc214x) - b) Possible errors in USB device driver reported "I suspect there's a few - issues in the lpc214x USB driver -- in particular it doesn't stall both - in/out endpoints for unsupported setup requests and it doesn't call - CLASS_DISCONNCET on a USB reset -- I don't have any access to that hardware - so can't pursue it really." + Description: USB DMA not fully implemented. Partial logic is in place but it is + fragmentary and bogus. (Leveraged from the lpc214x) Status: Open Priority: Low diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_usbdev.c b/nuttx/arch/arm/src/lpc17xx/lpc17_usbdev.c index a3bf002a7..8633751ad 100755 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_usbdev.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_usbdev.c @@ -1487,6 +1487,15 @@ static void lpc17_usbreset(struct lpc17_usbdev_s *priv) lpc17_putreg(USB_SLOW_INT|USB_DEVSTATUS_INT|USB_FAST_INT|USB_FRAME_INT|USB_ERROR_INT, LPC17_USBDEV_INTEN); + + /* Tell the class driver that we are disconnected. The class + * driver should then accept any new configurations. + */ + + if (priv->driver) + { + CLASS_DISCONNECT(priv->driver, &priv->usbdev); + } } /******************************************************************************* @@ -1895,8 +1904,8 @@ static inline void lpc17_ep0setup(struct lpc17_usbdev_s *priv) if (priv->stalled) { usbtrace(TRACE_DEVERROR(LPC17_TRACEERR_EP0SETUPSTALLED), priv->ep0state); - lpc17_epstall(&ep0->ep, false); - lpc17_epstall(&ep0->ep, false); + lpc17_epstall(&priv->eplist[LPC17_EP0_IN].ep, false); + lpc17_epstall(&priv->eplist[LPC17_EP0_OUT].ep, false); } } @@ -1957,9 +1966,8 @@ static inline void lpc17_ep0dataoutinterrupt(struct lpc17_usbdev_s *priv) if (priv->stalled) { usbtrace(TRACE_DEVERROR(LPC17_TRACEERR_EP0OUTSTALLED), priv->ep0state); - ep0 = &priv->eplist[LPC17_EP0_OUT]; - lpc17_epstall(&ep0->ep, false); - lpc17_epstall(&ep0->ep, false); + lpc17_epstall(&priv->eplist[LPC17_EP0_IN].ep, false); + lpc17_epstall(&priv->eplist[LPC17_EP0_OUT].ep, false); } return; } @@ -2024,9 +2032,8 @@ static inline void lpc17_ep0dataininterrupt(struct lpc17_usbdev_s *priv) if (priv->stalled) { usbtrace(TRACE_DEVERROR(LPC17_TRACEERR_EP0INSTALLED), priv->ep0state); - ep0 = &priv->eplist[LPC17_EP0_IN]; - lpc17_epstall(&ep0->ep, false); - lpc17_epstall(&ep0->ep, false); + lpc17_epstall(&priv->eplist[LPC17_EP0_IN].ep, false); + lpc17_epstall(&priv->eplist[LPC17_EP0_OUT].ep, false); } } diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_usbdev.c b/nuttx/arch/arm/src/lpc313x/lpc313x_usbdev.c index 323648fa9..c3faecee1 100755 --- a/nuttx/arch/arm/src/lpc313x/lpc313x_usbdev.c +++ b/nuttx/arch/arm/src/lpc313x/lpc313x_usbdev.c @@ -2604,7 +2604,11 @@ int usbdev_register(struct usbdevclass_driver_s *driver) /* FIXME: nothing seems to call DEV_CONNECT(), but we need to set * the RS bit to enable the controller. It kind of makes sense - * to do this after the class has bound to us... */ + * to do this after the class has bound to us... + * GEN: This bug is really in the class driver. It should make the + * soft connect when it is ready to be enumerated. I have added + * that logic to the class drivers but left this logic here. + */ lpc313x_pullup(&g_usbdev.usbdev, true); } diff --git a/nuttx/configs/olimex-lpc1766stk/usbstorage/defconfig b/nuttx/configs/olimex-lpc1766stk/usbstorage/defconfig index 0b0e93dda..6cdd31aeb 100755 --- a/nuttx/configs/olimex-lpc1766stk/usbstorage/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/usbstorage/defconfig @@ -853,6 +853,12 @@ CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n +CONFIG_EXAMPLES_USBSTRG_TRACEINIT=n +CONFIG_EXAMPLES_USBSTRG_TRACECLASS=n +CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n +CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n +CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n + # # Stack and heap information # diff --git a/nuttx/drivers/usbdev/usbdev_scsi.c b/nuttx/drivers/usbdev/usbdev_scsi.c index 7fd9f200f..0f1d9dd38 100644 --- a/nuttx/drivers/usbdev/usbdev_scsi.c +++ b/nuttx/drivers/usbdev/usbdev_scsi.c @@ -60,6 +60,7 @@ #include <sys/types.h> #include <stdint.h> #include <stdbool.h> +#include <unistd.h> #include <pthread.h> #include <string.h> #include <errno.h> diff --git a/nuttx/drivers/usbdev/usbdev_serial.c b/nuttx/drivers/usbdev/usbdev_serial.c index 4e7b38908..a5a25178d 100644 --- a/nuttx/drivers/usbdev/usbdev_serial.c +++ b/nuttx/drivers/usbdev/usbdev_serial.c @@ -1392,6 +1392,10 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver #ifdef CONFIG_USBDEV_SELFPOWERED DEV_SETSELFPOWERED(dev); #endif + + /* And pull-up the data line for the soft connect function */ + + DEV_CONNECT(dev); return OK; errout: @@ -1830,6 +1834,12 @@ static void usbclass_disconnect(FAR struct usbdev_s *dev) priv->serdev.xmit.head = 0; priv->serdev.xmit.tail = 0; irqrestore(flags); + + /* Perform the soft connect function so that we will we can be + * re-enumerated. + */ + + DEV_CONNECT(dev); } /**************************************************************************** diff --git a/nuttx/drivers/usbdev/usbdev_storage.c b/nuttx/drivers/usbdev/usbdev_storage.c index d714339eb..7aa0a388f 100644 --- a/nuttx/drivers/usbdev/usbdev_storage.c +++ b/nuttx/drivers/usbdev/usbdev_storage.c @@ -601,6 +601,10 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_ #ifdef CONFIG_USBDEV_SELFPOWERED DEV_SETSELFPOWERED(dev); #endif + + /* And pull-up the data line for the soft connect function */ + + DEV_CONNECT(dev); return OK; errout: @@ -1045,6 +1049,12 @@ static void usbstrg_disconnect(FAR struct usbdev_s *dev) priv->theventset |= USBSTRG_EVENT_DISCONNECT; pthread_cond_signal(&priv->cond); irqrestore(flags); + + /* Perform the soft connect function so that we will we can be + * re-enumerated. + */ + + DEV_CONNECT(dev); } /**************************************************************************** diff --git a/nuttx/drivers/usbdev/usbdev_storage.h b/nuttx/drivers/usbdev/usbdev_storage.h index 03c07f734..75317dcbc 100644 --- a/nuttx/drivers/usbdev/usbdev_storage.h +++ b/nuttx/drivers/usbdev/usbdev_storage.h @@ -367,21 +367,21 @@ struct usbstrg_lun_s struct usbstrg_dev_s { - FAR struct usbdev_s *usbdev; /* usbdev driver pointer (Non-null if registered) */ + FAR struct usbdev_s *usbdev; /* usbdev driver pointer (Non-null if registered) */ /* Worker thread interface */ - pthread_t thread; /* The worker thread */ - pthread_mutex_t mutex; /* Mutually exclusive access to resources*/ - pthread_cond_t cond; /* Used to signal worker thread */ + pthread_t thread; /* The worker thread */ + pthread_mutex_t mutex; /* Mutually exclusive access to resources*/ + pthread_cond_t cond; /* Used to signal worker thread */ volatile uint8_t thstate; /* State of the worker thread */ volatile uint16_t theventset; /* Set of pending events signaled to worker thread */ volatile uint8_t thvalue; /* Value passed with the event (must persist) */ /* Storage class configuration and state */ - uint8_t nluns:4; /* Number of LUNs */ - uint8_t config; /* Configuration number */ + uint8_t nluns:4; /* Number of LUNs */ + uint8_t config; /* Configuration number */ /* Endpoints */ @@ -394,29 +394,29 @@ struct usbstrg_dev_s struct usbstrg_lun_s *lun; /* Currently selected LUN */ struct usbstrg_lun_s *luntab; /* Allocated table of all LUNs */ uint8_t cdb[USBSTRG_MAXCDBLEN]; /* Command data (cdb[]) from CBW */ - uint8_t phaseerror:1; /* Need to send phase sensing status */ - uint8_t shortpacket:1; /* Host transmission stopped unexpectedly */ - uint8_t cbwdir:2; /* Direction from CBW. See USBSTRG_FLAGS_DIR* definitions */ - uint8_t cdblen; /* Length of cdb[] from CBW */ - uint8_t cbwlun; /* LUN from the CBW */ - uint16_t nsectbytes; /* Bytes buffered in iobuffer[] */ - uint16_t nreqbytes; /* Bytes buffered in head write requests */ - uint16_t iosize; /* Size of iobuffer[] */ - uint32_t cbwlen; /* Length of data from CBW */ - uint32_t cbwtag; /* Tag from the CBW */ + uint8_t phaseerror:1; /* Need to send phase sensing status */ + uint8_t shortpacket:1; /* Host transmission stopped unexpectedly */ + uint8_t cbwdir:2; /* Direction from CBW. See USBSTRG_FLAGS_DIR* definitions */ + uint8_t cdblen; /* Length of cdb[] from CBW */ + uint8_t cbwlun; /* LUN from the CBW */ + uint16_t nsectbytes; /* Bytes buffered in iobuffer[] */ + uint16_t nreqbytes; /* Bytes buffered in head write requests */ + uint16_t iosize; /* Size of iobuffer[] */ + uint32_t cbwlen; /* Length of data from CBW */ + uint32_t cbwtag; /* Tag from the CBW */ union { - uint32_t xfrlen; /* Read/Write: Sectors remaining to be transferred */ - uint32_t alloclen; /* Other device-to-host: Host allocation length */ + uint32_t xfrlen; /* Read/Write: Sectors remaining to be transferred */ + uint32_t alloclen; /* Other device-to-host: Host allocation length */ } u; - uint32_t sector; /* Current sector (relative to lun->startsector) */ - uint32_t residue; /* Untransferred amount reported in the CSW */ - uint8_t *iobuffer; /* Buffer for data transfers */ + uint32_t sector; /* Current sector (relative to lun->startsector) */ + uint32_t residue; /* Untransferred amount reported in the CSW */ + uint8_t *iobuffer; /* Buffer for data transfers */ /* Write request list */ - struct sq_queue_s wrreqlist; /* List of empty write request containers */ - struct sq_queue_s rdreqlist; /* List of filled read request containers */ + struct sq_queue_s wrreqlist; /* List of empty write request containers */ + struct sq_queue_s rdreqlist; /* List of filled read request containers */ /* Pre-allocated write request containers. The write requests will * be linked in a free list (wrreqlist), and used to send requests to diff --git a/nuttx/include/nuttx/usbdev.h b/nuttx/include/nuttx/usbdev.h index ed7f0c496..1f425aa2e 100644 --- a/nuttx/include/nuttx/usbdev.h +++ b/nuttx/include/nuttx/usbdev.h @@ -135,7 +135,10 @@ #define DEV_CLRSELFPOWERED(dev) (dev)->ops->selfpowered(dev, false) -/* Software-controlled connect to USB host */ +/* Software-controlled connect to USB host. All USB class drivers need to call + * DEV_CONNECT() when they are ready to be enumerated. That is, (1) initially when + * bound to the USB driver, and (2) after a USB reset. + */ #define DEV_CONNECT(dev) (dev)->ops->pullup ? (dev)->ops->pullup(dev,true) : -EOPNOTSUPP |