diff --git a/configs/sama5d3-xplained/Kconfig b/configs/sama5d3-xplained/Kconfig index 25d97d6fb6..c2aa29c9d0 100644 --- a/configs/sama5d3-xplained/Kconfig +++ b/configs/sama5d3-xplained/Kconfig @@ -111,6 +111,17 @@ config SAMA5D3XPLAINED_AT25_NXFFS endchoice # AT25 serial FLASH configuration +config SAMA5D3XPLAINED_USBHOST_STACKSIZE + int "USB host waiter stack size" + default 1536 if USBHOST_HUB + default 1024 if !USBHOST_HUB + depends on USBHOST + +config SAMA5D3XPLAINED_USBHOST_PRIO + int "USB host waiter task priority" + default 100 + depends on USBHOST + config SAMA5D3XPLAINED_CHANNEL int "PWM channel number" default 0 if SAMA5_PWM_CHAN0 diff --git a/configs/sama5d3-xplained/README.txt b/configs/sama5d3-xplained/README.txt index fb3abb29af..a721aa86bb 100644 --- a/configs/sama5d3-xplained/README.txt +++ b/configs/sama5d3-xplained/README.txt @@ -738,7 +738,7 @@ Serial Console 5 PE14 (available) 6 GND - By default the DBUG is used as the NuttX serial console in all + By default the DBUG port is used as the NuttX serial console in all configurations (unless otherwise noted). The DBGU is available at logic levels at pins RXD and TXD of the DEBUG connector (J23). GND is available at J23 and +3.3V is available from J14 @@ -1397,11 +1397,13 @@ USB High-Speed Host CONFIG_USBHOST_MSC=y : Enable the mass storage class driver CONFIG_USBHOST_HIDKBD=y : Enable the HID keyboard class driver - Library Routines - CONFIG_SCHED_WORKQUEUE=y : Worker thread support is required + RTOS Features -> Work Queue Support + CONFIG_SCHED_WORKQUEUE=y : High priority worker thread support is required + CONFIG_SCHED_HPWORK=y : Application Configuration -> NSH Library - CONFIG_NSH_ARCHINIT=y : NSH board-initialization + CONFIG_NSH_ARCHINIT=y : NSH board-initialization +file1: CONFIG_USBHOST_ISOC_DISABLE=y NOTE: When OHCI is selected, the SAMA5 will operate at 384MHz instead of 396MHz. This is so that the PLL generates a frequency which is a multiple @@ -1422,7 +1424,7 @@ USB High-Speed Host System Type -> USB High Speed Host driver options CONFIG_SAMA5_EHCI=y : High-speed EHCI support CONFIG_SAMA5_OHCI=y : Low/full-speed OHCI support - : Defaults for values probably OK for both + : Defaults for values probably OK for both Device Drivers CONFIG_USBHOST=y : Enable USB host support CONFIG_USBHOST_INT_DISABLE=y : Interrupt endpoints not needed @@ -1433,11 +1435,45 @@ USB High-Speed Host CONFIG_USBHOST_MSC=y : Enable the mass storage class driver CONFIG_USBHOST_HIDKBD=y : Enable the HID keyboard class driver - Library Routines - CONFIG_SCHED_WORKQUEUE=y : Worker thread support is required + RTOS Features -> Work Queue Support + CONFIG_SCHED_WORKQUEUE=y : High priority worker thread support is required + CONFIG_SCHED_HPWORK=y : Application Configuration -> NSH Library - CONFIG_NSH_ARCHINIT=y : NSH board-initialization + CONFIG_NSH_ARCHINIT=y : NSH board-initialization + + USB Hub Support + ---------------- + + USB hub support can be included by adding the following changes to the configuration (in addition to those listed above): + + Drivers -> USB Host Driver Support + CONFIG_USBHOST_HUB=y : Enable the hub class + CONFIG_USBHOST_ASYNCH=y : Asynchonous I/O supported needed for hubs + + System Type -> USB High Speed Host driver options + CONFIG_SAMA5_OHCI_NEDS=12 : You will probably want more pipes + CONFIG_SAMA5_OHCI_NTDS=18 + CONFIG_SAMA5_OHCI_TDBUFFERS=12 + CONFIG_SAMA5_OHCI_TDBUFSIZE=128 + + Board Selection -> + CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE=2048 (bigger than it needs to be) + + RTOS Features -> Work Queue Support + CONFIG_SCHED_LPWORK=y : Low priority queue support is needed + CONFIG_SCHED_LPNTHREADS=1 + CONFIG_SCHED_LPWORKSTACKSIZE=1024 + + NOTES: + + 1. It is necessary to perform work on the low-priority work queue + (vs. the high priority work queue) because deferred hub-related + work requires some delays and waiting that is not appropriate on + the high priority work queue. + + 2. Stack usage make increase when USB hub support is enabled because + the nesting depth of certain USB host class logic can increase. Mass Storage Device Usage ------------------------- diff --git a/configs/sama5d3-xplained/src/sam_usb.c b/configs/sama5d3-xplained/src/sam_usb.c index 1f67a0b5e7..ee019a0219 100644 --- a/configs/sama5d3-xplained/src/sam_usb.c +++ b/configs/sama5d3-xplained/src/sam_usb.c @@ -63,12 +63,12 @@ * Pre-processor Definitions ************************************************************************************/ -#ifndef CONFIG_USBHOST_DEFPRIO -# define CONFIG_USBHOST_DEFPRIO 50 +#ifndef CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO +# define CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO 50 #endif -#ifndef CONFIG_USBHOST_STACKSIZE -# define CONFIG_USBHOST_STACKSIZE 1024 +#ifndef CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE +# define CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE 1024 #endif #ifdef HAVE_USBDEV @@ -257,8 +257,10 @@ void weak_function sam_usbinitialize(void) #ifdef CONFIG_SAMA5_UHPHS_RHPORT1 /* Configure Port A to support the USB OHCI/EHCI function */ +#ifdef PIO_USBA_VBUS_ENABLE /* SAMA5D3-Xplained has no port A VBUS enable */ sam_configpio(PIO_USBA_VBUS_ENABLE); /* VBUS enable, initially OFF */ #endif +#endif #ifdef CONFIG_SAMA5_UHPHS_RHPORT2 /* Configure Port B to support the USB OHCI/EHCI function */ @@ -298,10 +300,20 @@ int sam_usbhost_initialize(void) /* First, register all of the class drivers needed to support the drivers * that we care about - * - * Register theUSB host Mass Storage Class: */ +#ifdef CONFIG_USBHOST_HUB + /* Initialize USB hub class support */ + + ret = usbhost_hub_initialize(); + if (ret < 0) + { + udbg("ERROR: usbhost_hub_initialize failed: %d\n", ret); + } +#endif + + /* Register theUSB host Mass Storage Class */ + ret = usbhost_storageinit(); if (ret != OK) { @@ -330,7 +342,8 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("OHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, + pid = task_create("OHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, + CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); if (pid < 0) { @@ -351,7 +364,8 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, + pid = task_create("EHCI Monitor", CONFIG_SAMA5D3XPLAINED_USBHOST_PRIO, + CONFIG_SAMA5D3XPLAINED_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) { @@ -393,9 +407,15 @@ void sam_usbhost_vbusdrive(int rhport, bool enable) switch (rhport) { case SAM_RHPORT1: -#ifndef CONFIG_SAMA5_UHPHS_RHPORT1 +#if !defined(CONFIG_SAMA5_UHPHS_RHPORT1) udbg("ERROR: RHPort1 is not available in this configuration\n"); return; + +#elif !defined(PIO_USBA_VBUS_ENABLE) + /* SAMA5D3-Xplained has no port A VBUS enable */ + + udbg("ERROR: RHPort1 has no VBUS enable\n"); + return; #else pinset = PIO_USBA_VBUS_ENABLE; break; diff --git a/configs/sama5d3x-ek/Kconfig b/configs/sama5d3x-ek/Kconfig index 5444cd2d5c..261b632d5c 100644 --- a/configs/sama5d3x-ek/Kconfig +++ b/configs/sama5d3x-ek/Kconfig @@ -178,6 +178,17 @@ config SAMA5D3xEK_AT24_NXFFS endchoice # AT24 serial EPPROM configuration +config SAMA5D3xEK_USBHOST_STACKSIZE + int "USB host waiter stack size" + default 1536 if USBHOST_HUB + default 1024 if !USBHOST_HUB + depends on USBHOST + +config SAMA5D3xEK_USBHOST_PRIO + int "USB host waiter task priority" + default 100 + depends on USBHOST + config SAMA5D3xEK_TSD_DEVMINOR int "Touchscreen device minor" default 0 diff --git a/configs/sama5d3x-ek/README.txt b/configs/sama5d3x-ek/README.txt index b13dc2245a..2dfd48ed37 100644 --- a/configs/sama5d3x-ek/README.txt +++ b/configs/sama5d3x-ek/README.txt @@ -1572,8 +1572,9 @@ USB High-Speed Host CONFIG_USBHOST_MSC=y : Enable the mass storage class driver CONFIG_USBHOST_HIDKBD=y : Enable the HID keyboard class driver - Library Routines - CONFIG_SCHED_WORKQUEUE=y : Worker thread support is required + RTOS Features -> Work Queue Support + CONFIG_SCHED_WORKQUEUE=y : High priority worker thread support is required + CONFIG_SCHED_HPWORK=y : Application Configuration -> NSH Library CONFIG_NSH_ARCHINIT=y : NSH board-initialization @@ -1603,12 +1604,46 @@ USB High-Speed Host CONFIG_USBHOST_MSC=y : Enable the mass storage class driver CONFIG_USBHOST_HIDKBD=y : Enable the HID keyboard class driver - Library Routines - CONFIG_SCHED_WORKQUEUE=y : Worker thread support is required + RTOS Features -> Work Queue Support + CONFIG_SCHED_WORKQUEUE=y : High priority worker thread support is required + CONFIG_SCHED_HPWORK=y : Application Configuration -> NSH Library CONFIG_NSH_ARCHINIT=y : NSH board-initialization + USB Hub Support + ---------------- + + USB hub support can be included by adding the following changes to the configuration (in addition to those listed above): + + Drivers -> USB Host Driver Support + CONFIG_USBHOST_HUB=y : Enable the hub class + CONFIG_USBHOST_ASYNCH=y : Asynchonous I/O supported needed for hubs + + System Type -> USB High Speed Host driver options + CONFIG_SAMA5_OHCI_NEDS=12 : You will probably want more pipes + CONFIG_SAMA5_OHCI_NTDS=18 + CONFIG_SAMA5_OHCI_TDBUFFERS=12 + CONFIG_SAMA5_OHCI_TDBUFSIZE=128 + + Board Selection -> + CONFIG_SAMA5D3XEK_USBHOST_STACKSIZE=2048 (bigger than it needs to be) + + RTOS Features -> Work Queue Support + CONFIG_SCHED_LPWORK=y : Low priority queue support is needed + CONFIG_SCHED_LPNTHREADS=1 + CONFIG_SCHED_LPWORKSTACKSIZE=1024 + + NOTES: + + 1. It is necessary to perform work on the low-priority work queue + (vs. the high priority work queue) because deferred hub-related + work requires some delays and waiting that is not appropriate on + the high priority work queue. + + 2. Stack usage make increase when USB hub support is enabled because + the nesting depth of certain USB host class logic can increase. + Mass Storage Device Usage ------------------------- diff --git a/configs/sama5d3x-ek/src/sam_usb.c b/configs/sama5d3x-ek/src/sam_usb.c index 827060a6a6..524f4dcd33 100644 --- a/configs/sama5d3x-ek/src/sam_usb.c +++ b/configs/sama5d3x-ek/src/sam_usb.c @@ -63,12 +63,12 @@ * Pre-processor Definitions ************************************************************************************/ -#ifndef CONFIG_USBHOST_DEFPRIO -# define CONFIG_USBHOST_DEFPRIO 50 +#ifndef CONFIG_SAMA5D3xEK_USBHOST_PRIO +# define CONFIG_SAMA5D3xEK_USBHOST_PRIO 50 #endif -#ifndef CONFIG_USBHOST_STACKSIZE -# define CONFIG_USBHOST_STACKSIZE 1024 +#ifndef CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE +# define CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE 1024 #endif #ifdef HAVE_USBDEV @@ -340,7 +340,8 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("OHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, + pid = task_create("OHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO, + CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); if (pid < 0) { @@ -361,7 +362,8 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, + pid = task_create("EHCI Monitor", CONFIG_SAMA5D3xEK_USBHOST_PRIO, + CONFIG_SAMA5D3xEK_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) { diff --git a/configs/sama5d4-ek/Kconfig b/configs/sama5d4-ek/Kconfig index 200f44edf4..86aa56f2f9 100644 --- a/configs/sama5d4-ek/Kconfig +++ b/configs/sama5d4-ek/Kconfig @@ -321,6 +321,17 @@ config SAMA5D4EK_ROMFS_MOUNT_MOUNTPOINT endif # SAMA5D4EK_ROMFS_MOUNT +config SAMA5D4EK_USBHOST_STACKSIZE + int "USB host waiter stack size" + default 1536 if USBHOST_HUB + default 1024 if !USBHOST_HUB + depends on USBHOST + +config SAMA5D4EK_USBHOST_PRIO + int "USB host waiter task priority" + default 100 + depends on USBHOST + if INPUT_MXT config SAMA5D4EK_MXT_I2CFREQUENCY diff --git a/configs/sama5d4-ek/README.txt b/configs/sama5d4-ek/README.txt index fe703f28cc..4a011a4b56 100644 --- a/configs/sama5d4-ek/README.txt +++ b/configs/sama5d4-ek/README.txt @@ -1951,8 +1951,9 @@ USB High-Speed Host CONFIG_USBHOST_MSC=y : Enable the mass storage class driver CONFIG_USBHOST_HIDKBD=y : Enable the HID keyboard class driver - Library Routines - CONFIG_SCHED_WORKQUEUE=y : Worker thread support is required + RTOS Features -> Work Queue Support + CONFIG_SCHED_WORKQUEUE=y : High priority worker thread support is required + CONFIG_SCHED_HPWORK=y : Application Configuration -> NSH Library CONFIG_NSH_ARCHINIT=y : NSH board-initialization @@ -1985,12 +1986,46 @@ USB High-Speed Host CONFIG_USBHOST_MSC=y : Enable the mass storage class driver CONFIG_USBHOST_HIDKBD=y : Enable the HID keyboard class driver - Library Routines - CONFIG_SCHED_WORKQUEUE=y : Worker thread support is required + RTOS Features -> Work Queue Support + CONFIG_SCHED_WORKQUEUE=y : High priority worker thread support is required + CONFIG_SCHED_HPWORK=y : Application Configuration -> NSH Library CONFIG_NSH_ARCHINIT=y : NSH board-initialization + USB Hub Support + ---------------- + + USB hub support can be included by adding the following changes to the configuration (in addition to those listed above): + + Drivers -> USB Host Driver Support + CONFIG_USBHOST_HUB=y : Enable the hub class + CONFIG_USBHOST_ASYNCH=y : Asynchonous I/O supported needed for hubs + + System Type -> USB High Speed Host driver options + CONFIG_SAMA5_OHCI_NEDS=12 : You will probably want more pipes + CONFIG_SAMA5_OHCI_NTDS=18 + CONFIG_SAMA5_OHCI_TDBUFFERS=12 + CONFIG_SAMA5_OHCI_TDBUFSIZE=128 + + Board Selection -> + CONFIG_SAMA5D4EK_USBHOST_STACKSIZE=2048 (bigger than it needs to be) + + RTOS Features -> Work Queue Support + CONFIG_SCHED_LPWORK=y : Low priority queue support is needed + CONFIG_SCHED_LPNTHREADS=1 + CONFIG_SCHED_LPWORKSTACKSIZE=1024 + + NOTES: + + 1. It is necessary to perform work on the low-priority work queue + (vs. the high priority work queue) because deferred hub-related + work requires some delays and waiting that is not appropriate on + the high priority work queue. + + 2. Stack usage make increase when USB hub support is enabled because + the nesting depth of certain USB host class logic can increase. + Mass Storage Device Usage ------------------------- diff --git a/configs/sama5d4-ek/src/sam_usb.c b/configs/sama5d4-ek/src/sam_usb.c index 772955bf3c..5bf29ea34f 100644 --- a/configs/sama5d4-ek/src/sam_usb.c +++ b/configs/sama5d4-ek/src/sam_usb.c @@ -63,12 +63,12 @@ * Pre-processor Definitions ************************************************************************************/ -#ifndef CONFIG_USBHOST_DEFPRIO -# define CONFIG_USBHOST_DEFPRIO 50 +#ifndef CONFIG_SAMA5D4EK_USBHOST_PRIO +# define CONFIG_SAMA5D4EK_USBHOST_PRIO 50 #endif -#ifndef CONFIG_USBHOST_STACKSIZE -# define CONFIG_USBHOST_STACKSIZE 1024 +#ifndef CONFIG_SAMA5D4EK_USBHOST_STACKSIZE +# define CONFIG_SAMA5D4EK_USBHOST_STACKSIZE 1024 #endif #ifdef HAVE_USBDEV @@ -341,7 +341,8 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("OHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, + pid = task_create("OHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, + CONFIG_SAMA5D4EK_USBHOST_STACKSIZE, (main_t)ohci_waiter, (FAR char * const *)NULL); if (pid < 0) { @@ -362,7 +363,8 @@ int sam_usbhost_initialize(void) /* Start a thread to handle device connection. */ - pid = task_create("EHCI Monitor", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, + pid = task_create("EHCI Monitor", CONFIG_SAMA5D4EK_USBHOST_PRIO, + CONFIG_SAMA5D4EK_USBHOST_STACKSIZE, (main_t)ehci_waiter, (FAR char * const *)NULL); if (pid < 0) {