From b19a1869ec03614550061cee24697d47c0986f51 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 13 Sep 2012 14:14:18 +0000 Subject: [PATCH] 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 --- ChangeLog | 3 + arch/arm/src/dm320/dm320_usbdev.c | 20 +++- arch/arm/src/lpc17xx/lpc17_usbdev.c | 40 ++++++-- arch/arm/src/lpc214x/lpc214x_usbdev.c | 38 +++++++- arch/arm/src/lpc31xx/lpc31_usbdev.c | 20 +++- arch/arm/src/lpc43xx/lpc43_usb0dev.c | 20 +++- arch/arm/src/stm32/stm32_otgfsdev.c | 20 +++- arch/avr/src/at90usb/at90usb_usbdev.c | 21 ++++- drivers/usbdev/Kconfig | 129 ++++++++++++++++---------- include/nuttx/fs/fat.h | 10 +- include/nuttx/usb/usbdev.h | 35 ++++++- 11 files changed, 269 insertions(+), 87 deletions(-) diff --git a/ChangeLog b/ChangeLog index eec1c96695..5728e117f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/arch/arm/src/dm320/dm320_usbdev.c b/arch/arm/src/dm320/dm320_usbdev.c index abc89e31d9..c924db1976 100644 --- a/arch/arm/src/dm320/dm320_usbdev.c +++ b/arch/arm/src/dm320/dm320_usbdev.c @@ -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 diff --git a/arch/arm/src/lpc17xx/lpc17_usbdev.c b/arch/arm/src/lpc17xx/lpc17_usbdev.c index ccaa3528a4..a5cb443e4b 100644 --- a/arch/arm/src/lpc17xx/lpc17_usbdev.c +++ b/arch/arm/src/lpc17xx/lpc17_usbdev.c @@ -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 diff --git a/arch/arm/src/lpc214x/lpc214x_usbdev.c b/arch/arm/src/lpc214x/lpc214x_usbdev.c index 1d4cd54743..78a5fe1c37 100644 --- a/arch/arm/src/lpc214x/lpc214x_usbdev.c +++ b/arch/arm/src/lpc214x/lpc214x_usbdev.c @@ -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 diff --git a/arch/arm/src/lpc31xx/lpc31_usbdev.c b/arch/arm/src/lpc31xx/lpc31_usbdev.c index 0e8fcf17c5..255f28da14 100755 --- a/arch/arm/src/lpc31xx/lpc31_usbdev.c +++ b/arch/arm/src/lpc31xx/lpc31_usbdev.c @@ -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 diff --git a/arch/arm/src/lpc43xx/lpc43_usb0dev.c b/arch/arm/src/lpc43xx/lpc43_usb0dev.c index 2ce19a3250..b4ca554204 100644 --- a/arch/arm/src/lpc43xx/lpc43_usb0dev.c +++ b/arch/arm/src/lpc43xx/lpc43_usb0dev.c @@ -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 diff --git a/arch/arm/src/stm32/stm32_otgfsdev.c b/arch/arm/src/stm32/stm32_otgfsdev.c index 81c919cdfd..461d500ad1 100644 --- a/arch/arm/src/stm32/stm32_otgfsdev.c +++ b/arch/arm/src/stm32/stm32_otgfsdev.c @@ -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 diff --git a/arch/avr/src/at90usb/at90usb_usbdev.c b/arch/avr/src/at90usb/at90usb_usbdev.c index dcda5d6d09..89949e662b 100644 --- a/arch/avr/src/at90usb/at90usb_usbdev.c +++ b/arch/avr/src/at90usb/at90usb_usbdev.c @@ -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 diff --git a/drivers/usbdev/Kconfig b/drivers/usbdev/Kconfig index 4930b9d21e..70c7a04f05 100644 --- a/drivers/usbdev/Kconfig +++ b/drivers/usbdev/Kconfig @@ -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 diff --git a/include/nuttx/fs/fat.h b/include/nuttx/fs/fat.h index 680aefbe93..ac85c502f4 100644 --- a/include/nuttx/fs/fat.h +++ b/include/nuttx/fs/fat.h @@ -40,6 +40,7 @@ * Included Files ****************************************************************************/ +#include #include /**************************************************************************** @@ -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 diff --git a/include/nuttx/usb/usbdev.h b/include/nuttx/usb/usbdev.h index 89813cac96..1270fe13ad 100644 --- a/include/nuttx/usb/usbdev.h +++ b/include/nuttx/usb/usbdev.h @@ -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) }