From 5c16454cdff7d9d950641f9169762e9af7eeac74 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 21 Apr 2015 13:44:14 -0600 Subject: [PATCH] Add USB hub initialization logic to a couple of board configurations --- configs/olimex-lpc1766stk/src/lpc17_hidkbd.c | 15 +++++++++++++++ configs/olimex-lpc1766stk/src/lpc17_hidmouse.c | 12 +++++++++++- configs/olimex-lpc1766stk/src/lpc17_nsh.c | 13 +++++++++++++ configs/olimex-lpc1766stk/src/lpc17_usbmsc.c | 3 ++- configs/sama5d4-ek/src/sam_usb.c | 14 ++++++++++++-- drivers/usbhost/usbhost_hub.c | 4 ++-- include/nuttx/usb/usbhost.h | 6 +++--- 7 files changed, 58 insertions(+), 9 deletions(-) diff --git a/configs/olimex-lpc1766stk/src/lpc17_hidkbd.c b/configs/olimex-lpc1766stk/src/lpc17_hidkbd.c index e01eb4b66c..3e8f3ab1c7 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_hidkbd.c +++ b/configs/olimex-lpc1766stk/src/lpc17_hidkbd.c @@ -39,6 +39,9 @@ #include +#include +#include + #include #include "lpc17_usbhost.h" @@ -66,6 +69,18 @@ struct usbhost_connection_s *arch_usbhost_initialize(void) { +#ifdef CONFIG_USBHOST_HUB + int ret; + + /* Initialize USB hub support */ + + ret = usbhost_hub_initialize(); + if (ret < 0) + { + udbg("ERROR: usbhost_hub_initialize failed: %d\n", ret); + } +#endif + return lpc17_usbhost_initialize(0); } #endif /* CONFIG_LPC17_USBHOST && CONFIG_USBHOST && CONFIG_EXAMPLES_HIDKBD */ diff --git a/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c b/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c index 255eae9633..8c8f6f38ad 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c +++ b/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c @@ -41,9 +41,9 @@ #include #include -#include #include #include +#include #include #include @@ -125,6 +125,16 @@ int board_tsc_setup(int minor) if (!initialized) { +#ifdef CONFIG_USBHOST_HUB + /* Initialize USB hub support */ + + ret = usbhost_hub_initialize(); + if (ret < 0) + { + idbg("ERROR: usbhost_hub_initialize failed: %d\n", ret); + } +#endif + /* Initialize and register the USB HID mouse device class */ ret = usbhost_mouse_init(); diff --git a/configs/olimex-lpc1766stk/src/lpc17_nsh.c b/configs/olimex-lpc1766stk/src/lpc17_nsh.c index 0541e4d435..d17933c611 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_nsh.c +++ b/configs/olimex-lpc1766stk/src/lpc17_nsh.c @@ -248,6 +248,19 @@ static int nsh_usbhostinitialize(void) */ syslog(LOG_INFO, "Register class drivers\n"); + +#ifdef CONFIG_USBHOST_HUB + /* Initialize USB hub support */ + + ret = usbhost_hub_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: usbhost_hub_initialize failed: %d\n", ret); + } +#endif + + /* Initialize mass storage support */ + ret = usbhost_storageinit(); if (ret != OK) { diff --git a/configs/olimex-lpc1766stk/src/lpc17_usbmsc.c b/configs/olimex-lpc1766stk/src/lpc17_usbmsc.c index 6f6886e583..412b9e04da 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_usbmsc.c +++ b/configs/olimex-lpc1766stk/src/lpc17_usbmsc.c @@ -135,4 +135,5 @@ int usbmsc_archinitialize(void) errout: lpc17_gpiowrite(LPC1766STK_MMC_PWR, true); - return ret;} + return ret; +} diff --git a/configs/sama5d4-ek/src/sam_usb.c b/configs/sama5d4-ek/src/sam_usb.c index 1d34bd84ea..df7e8afdb1 100644 --- a/configs/sama5d4-ek/src/sam_usb.c +++ b/configs/sama5d4-ek/src/sam_usb.c @@ -311,10 +311,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 support */ + + ret = usbhost_hub_initialize(); + if (ret < 0) + { + udbg("ERROR: usbhost_hub_initialize failed: %d\n", ret); + } +#endif + + /* Register the USB host Mass Storage Class */ + ret = usbhost_storageinit(); if (ret != OK) { diff --git a/drivers/usbhost/usbhost_hub.c b/drivers/usbhost/usbhost_hub.c index 211e7833e3..165576b26c 100644 --- a/drivers/usbhost/usbhost_hub.c +++ b/drivers/usbhost/usbhost_hub.c @@ -1341,7 +1341,7 @@ static int usbhost_disconnected(struct usbhost_class_s *hubclass) ****************************************************************************/ /**************************************************************************** - * Name: usbhost_hubinit + * Name: usbhost_hub_initialize * * Description: * Initialize the USB hub class. This function should be called @@ -1357,7 +1357,7 @@ static int usbhost_disconnected(struct usbhost_class_s *hubclass) * ****************************************************************************/ -int usbhost_hubinit(void) +int usbhost_hub_initialize(void) { /* Advertise our availability to support (certain) mass storage devices */ diff --git a/include/nuttx/usb/usbhost.h b/include/nuttx/usb/usbhost.h index f5031c2393..1694eb5283 100644 --- a/include/nuttx/usb/usbhost.h +++ b/include/nuttx/usb/usbhost.h @@ -865,8 +865,8 @@ int usbhost_registerclass(struct usbhost_registry_s *devclass); const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id); #ifdef CONFIG_USBHOST_HUB -/**************************************************************************** - * Name: usbhost_hubinit + /**************************************************************************** + * Name: usbhost_hub_initialize * * Description: * Initialize the USB hub class. This function should be called @@ -882,7 +882,7 @@ const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id * ****************************************************************************/ -int usbhost_hubinit(void); +int usbhost_hub_initialize(void); #endif #ifdef CONFIG_USBHOST_MSC