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 f5365ff661
commit 21a0a16908
7 changed files with 143 additions and 36 deletions

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;
@ -2699,7 +2701,19 @@ static FAR void *lpc17_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbytes
/* Set UDCA to the allocated DMA descriptor for this endpoint */
g_udca[privep->epphy] = &g_usbddesc[descndx];
return &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;
@ -2664,7 +2666,19 @@ static FAR void *lpc214x_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbyt
/* Set UDCA to the allocated DMA descriptor for this endpoint */
USB_UDCA[privep->epphy] = &USB_DDESC[descndx];
return &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