USB device drivers: Add hooks to to use common, external DMA buffer allocation implementation..

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5142 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-09-13 14:14:18 +00:00
parent b94212a272
commit b19a1869ec
11 changed files with 269 additions and 87 deletions

View File

@ -3334,4 +3334,7 @@
* configs/stm3240g-eval/discover: A configuration for testing
the UDP discovery utility. Contributed by Max Holtzberg.
* mm/README.txt: Add a new README file.
* include/nuttx/usb/usb.h, arch/*/src/*usb.c, and arch/*/src/*otg*.c:
Add hooks to to use common, external DMA buffer allocation
implementation.

View File

@ -324,7 +324,7 @@ static int dm320_epconfigure(FAR struct usbdev_ep_s *ep,
static int dm320_epdisable(FAR struct usbdev_ep_s *ep);
static FAR struct usbdev_req_s *dm320_epallocreq(FAR struct usbdev_ep_s *ep);
static void dm320_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req);
#ifdef CONFIG_DM320_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static FAR void *dm320_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbytes);
static void dm320_epfreebuffer(FAR struct usbdev_ep_s *ep, void *buf);
#endif
@ -353,7 +353,7 @@ static const struct usbdev_epops_s g_epops =
.disable = dm320_epdisable,
.allocreq = dm320_epallocreq,
.freereq = dm320_epfreereq,
#ifdef CONFIG_DM320_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
.allocbuffer = dm320_epallocbuffer,
.freebuffer = dm320_epfreebuffer,
#endif
@ -1979,11 +1979,16 @@ static void dm320_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
*
*******************************************************************************/
#ifdef CONFIG_DM320_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void *dm320_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
{
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
return malloc(bytes)
#ifdef CONFIG_USBDEV_DMAMEMORY
return usbdev_dma_alloc(bytes);
#else
return malloc(bytes);
#endif
}
#endif
@ -1995,11 +2000,16 @@ static void *dm320_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
*
*******************************************************************************/
#ifdef CONFIG_DM320_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void dm320_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf)
{
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
#ifdef CONFIG_USBDEV_DMAMEMORY
usbdev_dma_free(buf);
#else
free(buf);
#endif
}
#endif

View File

@ -434,7 +434,7 @@ static int lpc17_epdisable(FAR struct usbdev_ep_s *ep);
static FAR struct usbdev_req_s *lpc17_epallocreq(FAR struct usbdev_ep_s *ep);
static void lpc17_epfreereq(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *);
#ifdef CONFIG_LPC17_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static FAR void *lpc17_epallocbuffer(FAR struct usbdev_ep_s *ep,
uint16_t nbytes);
static void lpc17_epfreebuffer(FAR struct usbdev_ep_s *ep, void *buf);
@ -471,7 +471,7 @@ static const struct usbdev_epops_s g_epops =
.disable = lpc17_epdisable,
.allocreq = lpc17_epallocreq,
.freereq = lpc17_epfreereq,
#ifdef CONFIG_LPC17_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
.allocbuffer = lpc17_epallocbuffer,
.freebuffer = lpc17_epfreebuffer,
#endif
@ -2684,9 +2684,11 @@ static void lpc17_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
*
*******************************************************************************/
#ifdef CONFIG_LPC17_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static FAR void *lpc17_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbytes)
{
#if defined(CONFIG_LPC17_USBDEV_DMA)
FAR struct lpc17_ep_s *privep = (FAR struct lpc17_ep_s *)ep;
int descndx;
@ -2700,6 +2702,18 @@ static FAR void *lpc17_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbytes
g_udca[privep->epphy] = &g_usbddesc[descndx];
return &g_usbddesc[descndx]
#elif defined(CONFIG_USBDEV_DMAMEMORY)
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
return usbdev_dma_alloc(bytes);
#else
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
return malloc(bytes);
#endif
}
#endif
@ -2711,9 +2725,11 @@ static FAR void *lpc17_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbytes
*
*******************************************************************************/
#ifdef CONFIG_LPC17_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void lpc17_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf)
{
#if defined(CONFIG_LPC17_USBDEV_DMA)
FAR struct lpc17_ep_s *privep = (FAR struct lpc17_ep_s *)ep;
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
@ -2724,7 +2740,19 @@ static void lpc17_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf)
/* Mark the DMA descriptor as free for re-allocation */
#error "LOGIC INCOMPLETE"
# error "LOGIC INCOMPLETE"
#elif defined(CONFIG_USBDEV_DMAMEMORY)
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
usbdev_dma_free(buf);
#else
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
free(buf);
#endif
}
#endif

View File

@ -445,7 +445,7 @@ static int lpc214x_epdisable(FAR struct usbdev_ep_s *ep);
static FAR struct usbdev_req_s *lpc214x_epallocreq(FAR struct usbdev_ep_s *ep);
static void lpc214x_epfreereq(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *);
#ifdef CONFIG_LPC214X_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static FAR void *lpc214x_epallocbuffer(FAR struct usbdev_ep_s *ep,
uint16_t nbytes);
static void lpc214x_epfreebuffer(FAR struct usbdev_ep_s *ep, void *buf);
@ -482,7 +482,7 @@ static const struct usbdev_epops_s g_epops =
.disable = lpc214x_epdisable,
.allocreq = lpc214x_epallocreq,
.freereq = lpc214x_epfreereq,
#ifdef CONFIG_LPC214X_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
.allocbuffer = lpc214x_epallocbuffer,
.freebuffer = lpc214x_epfreebuffer,
#endif
@ -2652,6 +2652,8 @@ static void lpc214x_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_
#ifdef CONFIG_LPC214X_USBDEV_DMA
static FAR void *lpc214x_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbytes)
{
#ifdef CONFIG_USBDEV_DMA
FAR struct lpc214x_ep_s *privep = (FAR struct lpc214x_ep_s *)ep;
int descndx;
@ -2665,6 +2667,18 @@ static FAR void *lpc214x_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbyt
USB_UDCA[privep->epphy] = &USB_DDESC[descndx];
return &USB_DDESC[descndx]
#elif defined(CONFIG_USBDEV_DMAMEMORY)
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
return usbdev_dma_alloc(bytes);
#else
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
return malloc(bytes);
#endif
}
#endif
@ -2676,9 +2690,11 @@ static FAR void *lpc214x_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbyt
*
*******************************************************************************/
#ifdef CONFIG_LPC214X_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void lpc214x_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf)
{
#ifdef CONFIG_LPC214X_USBDEV_DMA
FAR struct lpc214x_ep_s *privep = (FAR struct lpc214x_ep_s *)ep;
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
@ -2689,7 +2705,19 @@ static void lpc214x_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf)
/* Mark the DMA descriptor as free for re-allocation */
#error "LOGIC INCOMPLETE"
# error "LOGIC INCOMPLETE"
#elif defined(CONFIG_USBDEV_DMAMEMORY)
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
usbdev_dma_free(buf);
#else
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
free(buf);
#endif
}
#endif

View File

@ -401,7 +401,7 @@ static int lpc31_epdisable(FAR struct usbdev_ep_s *ep);
static FAR struct usbdev_req_s *lpc31_epallocreq(FAR struct usbdev_ep_s *ep);
static void lpc31_epfreereq(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *);
#ifdef CONFIG_LPC31_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void *lpc31_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes);
static void lpc31_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf);
#endif
@ -438,7 +438,7 @@ static const struct usbdev_epops_s g_epops =
.disable = lpc31_epdisable,
.allocreq = lpc31_epallocreq,
.freereq = lpc31_epfreereq,
#ifdef CONFIG_LPC31_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
.allocbuffer = lpc31_epallocbuffer,
.freebuffer = lpc31_epfreebuffer,
#endif
@ -1955,11 +1955,16 @@ static void lpc31_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
*
*******************************************************************************/
#ifdef CONFIG_LPC31_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void *lpc31_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
{
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
return malloc(bytes)
#ifdef CONFIG_USBDEV_DMAMEMORY
return usbdev_dma_alloc(bytes);
#else
return malloc(bytes);
#endif
}
#endif
@ -1971,11 +1976,16 @@ static void *lpc31_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
*
*******************************************************************************/
#ifdef CONFIG_LPC31_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void lpc31_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf)
{
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
#ifdef CONFIG_USBDEV_DMAMEMORY
usbdev_dma_free(buf);
#else
free(buf);
#endif
}
#endif

View File

@ -404,7 +404,7 @@ static int lpc43_epdisable(FAR struct usbdev_ep_s *ep);
static FAR struct usbdev_req_s *lpc43_epallocreq(FAR struct usbdev_ep_s *ep);
static void lpc43_epfreereq(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *);
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void *lpc43_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes);
static void lpc43_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf);
#endif
@ -441,7 +441,7 @@ static const struct usbdev_epops_s g_epops =
.disable = lpc43_epdisable,
.allocreq = lpc43_epallocreq,
.freereq = lpc43_epfreereq,
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
.allocbuffer = lpc43_epallocbuffer,
.freebuffer = lpc43_epfreebuffer,
#endif
@ -1958,11 +1958,16 @@ static void lpc43_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
*
*******************************************************************************/
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void *lpc43_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
{
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
return malloc(bytes)
#ifdef CONFIG_USBDEV_DMAMEMORY
return usbdev_dma_alloc(bytes);
#else
return malloc(bytes);
#endif
}
#endif
@ -1974,11 +1979,16 @@ static void *lpc43_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
*
*******************************************************************************/
#ifdef CONFIG_LPC433x_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void lpc43_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf)
{
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
#ifdef CONFIG_USBDEV_DMAMEMORY
usbdev_dma_free(buf);
#else
free(buf);
#endif
}
#endif

View File

@ -607,7 +607,7 @@ static void stm32_ep_freereq(FAR struct usbdev_ep_s *ep,
/* Endpoint buffer management */
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void *stm32_ep_allocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes);
static void stm32_ep_freebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf);
#endif
@ -669,7 +669,7 @@ static const struct usbdev_epops_s g_epops =
.disable = stm32_ep_disable,
.allocreq = stm32_ep_allocreq,
.freereq = stm32_ep_freereq,
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
.allocbuffer = stm32_ep_allocbuffer,
.freebuffer = stm32_ep_freebuffer,
#endif
@ -4070,11 +4070,16 @@ static void stm32_ep_freereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
*
*******************************************************************************/
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void *stm32_ep_allocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
{
usbtrace(TRACE_EPALLOCBUFFER, privep->epphy);
return malloc(bytes)
#ifdef CONFIG_USBDEV_DMAMEMORY
return usbdev_dma_alloc(bytes);
#else
return malloc(bytes);
#endif
}
#endif
@ -4086,11 +4091,16 @@ static void *stm32_ep_allocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
*
*******************************************************************************/
#ifdef CONFIG_STM32_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void stm32_ep_freebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf)
{
usbtrace(TRACE_EPFREEBUFFER, privep->epphy);
#ifdef CONFIG_USBDEV_DMAMEMORY
usbdev_dma_free(buf);
#else
free(buf);
#endif
}
#endif

View File

@ -313,7 +313,7 @@ static int avr_epdisable(FAR struct usbdev_ep_s *ep);
static FAR struct usbdev_req_s *avr_epallocreq(FAR struct usbdev_ep_s *ep);
static void avr_epfreereq(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *);
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void *avr_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes);
static void avr_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf);
#endif
@ -346,7 +346,7 @@ static const struct usbdev_epops_s g_epops =
.disable = avr_epdisable,
.allocreq = avr_epallocreq,
.freereq = avr_epfreereq,
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
.allocbuffer = avr_epallocbuffer,
.freebuffer = avr_epfreebuffer,
#endif
@ -2314,11 +2314,17 @@ static void avr_epfreereq(FAR struct usbdev_ep_s *ep,
*
*******************************************************************************/
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void *avr_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
{
usbtrace(TRACE_EPALLOCBUFFER, privep->ep.eplog);
return malloc(bytes)}
#ifdef CONFIG_USBDEV_DMAMEMORY
return usbdev_dma_alloc(bytes);
#else
return malloc(bytes);
#endif
}
#endif
/*******************************************************************************
@ -2329,11 +2335,16 @@ static void *avr_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes)
*
*******************************************************************************/
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
static void avr_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf)
{
usbtrace(TRACE_EPFREEBUFFER, privep->ep.eplog);
#ifdef CONFIG_USBDEV_DMAMEMORY
usbdev_dma_free(buf);
#else
free(buf);
#endif
}
#endif

View File

@ -3,6 +3,88 @@
# see misc/tools/kconfig-language.txt.
#
menu "Device Controller Driver Options"
config USBDEV_ISOCHRONOUS
bool "Enable isochronous"
default n
---help---
Build in extra support for isochronous endpoints
config USBDEV_DUALSPEED
bool "Enable high and full speed"
default n
---help---
Hardware handles high and full speed operation (USB 2.0)
choice USBDEV_POWERED
prompt "Select USB device powered"
default USBDEV_SELFPOWERED
config USBDEV_SELFPOWERED
bool "Self powered"
---help---
Will cause USB features to indicate that the device is self-powered
config USBDEV_BUSPOWERED
bool "Bus powered"
---help---
Will cause USB features to indicate that the device is self-powered
endchoice
config USBDEV_MAXPOWER
int "Maximum power consumption in mA"
default 100
depends on USBDEV_BUSPOWERED
---help---
Maximum power consumption in mA
config USBDEV_DMA
bool "Enable DMA methods"
default n
---help---
Select this enable DMA-related methods in USB device controller driver
interface. These methods include the DMA buffer allocation methods:
allobuffer() and freebuffer().
The USB class driver allocates packet I/O buffers for data transfer by
calling the driver allocbuffer() and freebuffer() methods. Those methods
are only available if USBDEV_DMA is defined in the system configuration.
config USBDEV_DMAMEMORY
bool "Board DMA Allocation Hooks"
default n
depends on USBDEV_DMA
---help---
The USB class driver allocates packet I/O buffers for data transfer by
calling the driver allocbuffer() and freebuffer() methods. Those methods
are only available if USBDEV_DMA is defined in the system configuration.
If USBDEV_DMAMEMORY is also defined in the NuttX configuration, then
the driver implementations of the allocbuffer() and freebuffer()
methods may use board-specific usbdev_dma_alloc() and usbdev_dma_free().
If USBDEV_DMA and USBDEV_DMAMEMORY are both defined, then the board-
specific logic must provide the functions usbdev_dma_alloc() and
usbdev_dma_free(): usbdev_dma_alloc() will allocate DMA-capable
memory of the specified size; usbdev_dma_free() is the corresponding
function that will be called to free the DMA-capable memory.
config USBDEV_TRACE
bool "Enable USB tracing for debug"
default n
---help---
Enables USB tracing for debug
config USBDEV_TRACE_NRECORDS
int "Number of trace entries to remember"
default 32
depends on USBDEV_TRACE
---help---
Number of trace entries to remember
endmenu
menuconfig USBDEV_COMPOSITE
bool "USB composite device support"
default n
@ -65,53 +147,6 @@ config COMPOSITE_VERSIONNO
Interface version number.
endif
config USBDEV_ISOCHRONOUS
bool "Enable isochronous"
default n
---help---
Build in extra support for isochronous endpoints
config USBDEV_DUALSPEED
bool "Enable high and full speed"
default n
---help---
Hardware handles high and full speed operation (USB 2.0)
choice USBDEV_POWERED
prompt "Select USB device powered"
default USBDEV_SELFPOWERED
config USBDEV_SELFPOWERED
bool "Self powerd"
---help---
Will cause USB features to indicate that the device is self-powered
config USBDEV_BUSPOWERED
bool "Bus powerd"
---help---
Will cause USB features to indicate that the device is self-powered
endchoice
config USBDEV_MAXPOWER
int "Maximum power consumption in mA"
default 100
depends on USBDEV_BUSPOWERED
---help---
Maximum power consumption in mA
config USBDEV_TRACE
bool "Enable USB tracing for debug"
default n
---help---
Enables USB tracing for debug
config USBDEV_TRACE_NRECORDS
int "Number of trace entries to remember"
default 32
depends on USBDEV_TRACE
---help---
Number of trace entries to remember
menuconfig PL2303
bool "Emulates the Prolific PL2303 serial/USB converter"
default n

View File

@ -40,6 +40,7 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
@ -98,15 +99,20 @@ EXTERN int fat_setattrib(const char *path, fat_attrib_t setbits, fat_attrib_t cl
* Some hardware, however, may require special DMA-capable memory in
* order to perform the the transfers. If CONFIG_FAT_DMAMEMORY is defined
* then the architecture-specific hardware must provide the funtions
* fat_dma_alloc() and fat_dma_free() as prototyped below: fat_dmalloc()
* will allocate DMA-capable memory of the specified size; fat_dmafree()
* fat_dma_alloc() and fat_dma_free() as prototyped below: fat_dma_alloc()
* will allocate DMA-capable memory of the specified size; fat_dma_free()
* is the corresponding function that will be called to free the DMA-
* capable memory.
*
* This functions may be simple wrappers around gran_alloc() and gran_free()
* (See nuttx/gran.h).
*
****************************************************************************/
#ifdef CONFIG_FAT_DMAMEMORY
EXTERN FAR void *fat_dma_alloc(size_t size);
EXTERN void fat_dma_free(FAR void *memory, size_t size);
#endif
#undef EXTERN
#ifdef __cplusplus

View File

@ -85,7 +85,7 @@
/* Allocate/free an I/O buffer. Should not be called from interrupt processing! */
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
# define EP_ALLOCBUFFER(ep,nb) (ep)->ops->alloc(ep,nb)
# define EP_FREEBUFFER(ep,buff) (ep)->ops->free(ep,buf)
#else
@ -234,7 +234,7 @@ struct usbdev_epops_s
/* Allocate and free I/O buffers */
#ifdef CONFIG_ARCH_USBDEV_DMA
#ifdef CONFIG_USBDEV_DMA
FAR void *(*allocbuffer)(FAR struct usbdev_ep_s *ep, uint16_t nbytes);
void (*freebuffer)(FAR struct usbdev_ep_s *ep, FAR void *buf);
#endif
@ -354,6 +354,37 @@ EXTERN int usbdev_register(FAR struct usbdevclass_driver_s *driver);
EXTERN int usbdev_unregister(FAR struct usbdevclass_driver_s *driver);
/****************************************************************************
* Name: usbdev_dma_alloc and usbdev_dma_free
*
* Description:
* The USB class driver allocates packet I/O buffers for data transfer by
* calling the driver allocbuffer() and freebuffer() methods. Those
* methods are only available if CONFIG_USBDEV_DMA is defined in the
* system configuration.
*
* If CONFIG_USBDEV_DMAMEMORY is also defined in the NuttX configuration,
* then the driver implementations of the allocbuffer() and freebuffer()
* methods may use board-specific usbdev_dma_alloc() and usbdev_dma_free().
* If CONFIG_USBDEV_DMA and CONFIG_USBDEV_DMAMEMORY are both defined,
* then the board-specific logic must provide the functions
* usbdev_dma_alloc() and usbdev_dma_free() as prototyped below:
* usbdev_dma_alloc() will allocate DMA-capable memory of the specified
* size; usbdev_dma_free() is the corresponding function that will be
* called to free the DMA-capable memory.
*
* This functions may be simple wrappers around gran_alloc() and
* gran_free() (See nuttx/gran.h). Note that the gran_free() function
* does require the size of the allocation to be freed; that would need
* to be managed in the board-specific logic.
*
****************************************************************************/
#if defined(CONFIG_USBDEV_DMA) && defined(CONFIG_USBDEV_DMAMEMORY)
EXTERN FAR void *usbdev_dma_alloc(size_t size);
EXTERN void usbdev_dma_free(FAR void *memory);
#endif
#undef EXTERN
#if defined(__cplusplus)
}