diff --git a/configs/mcu123-lpc214x/src/lpc2148_composite.c b/configs/mcu123-lpc214x/src/lpc2148_composite.c index ae776dbc576..7dab84d2d4f 100644 --- a/configs/mcu123-lpc214x/src/lpc2148_composite.c +++ b/configs/mcu123-lpc214x/src/lpc2148_composite.c @@ -167,7 +167,7 @@ static int board_mscclassobject(int minor, ****************************************************************************/ #ifdef CONFIG_USBMSC_COMPOSITE -void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) +static void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) { DEBUGASSERT(g_mschandle != NULL); usbmsc_uninitialize(g_mschandle); @@ -175,69 +175,6 @@ void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) } #endif -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_composite_initialize - * - * Description: - * Perform architecture specific initialization of a composite USB device. - * - ****************************************************************************/ - -int board_composite_initialize(int port) -{ - /* If system/composite is built as an NSH command, then SD slot should - * already have been initialized in board_app_initialize() (see lpc2148_appinit.c). - * In this case, there is nothing further to be done here. - * - * NOTE: CONFIG_NSH_BUILTIN_APPS is not a fool-proof indication that NSH - * was built. - */ - -#ifndef CONFIG_NSH_BUILTIN_APPS - FAR struct spi_dev_s *spi; - int ret; - - /* Get the SPI port */ - - syslog(LOG_INFO, "Initializing SPI port %d\n", LPC214X_MMCSDSPIPORTNO); - - spi = lpc214x_spibus_initialize(LPC214X_MMCSDSPIPORTNO); - if (!spi) - { - syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n", - LPC214X_MMCSDSPIPORTNO); - return -ENODEV; - } - - syslog(LOG_INFO, "Successfully initialized SPI port %d\n", - LPC214X_MMCSDSPIPORTNO); - - /* Bind the SPI port to the slot */ - - syslog(LOG_INFO, "Binding SPI port %d to MMC/SD slot %d\n", - LPC214X_MMCSDSPIPORTNO, LPC214X_MMCSDSLOTNO); - - ret = mmcsd_spislotinitialize(0, LPC214X_MMCSDSLOTNO, spi); - if (ret < 0) - { - syslog(LOG_ERR, - "ERROR: Failed to bind SPI port %d to MMC/SD slot %d: %d\n", - LPC214X_MMCSDSPIPORTNO, LPC214X_MMCSDSLOTNO, ret); - return ret; - } - - syslog(LOG_INFO, "Successfully bound SPI port %d to MMC/SD slot %d\n", - LPC214X_MMCSDSPIPORTNO, LPC214X_MMCSDSLOTNO); - -#endif /* CONFIG_NSH_BUILTIN_APPS */ - - return OK; -} - /**************************************************************************** * Name: board_composite0_connect * @@ -255,7 +192,7 @@ int board_composite_initialize(int port) ****************************************************************************/ #ifdef CONFIG_USBMSC_COMPOSITE -FAR void *board_composite0_connect(int port) +static FAR void *board_composite0_connect(int port) { /* Here we are composing the configuration of the usb composite device. * @@ -352,7 +289,7 @@ FAR void *board_composite0_connect(int port) * ****************************************************************************/ -FAR void *board_composite1_connect(int port) +static FAR void *board_composite1_connect(int port) { struct composite_devdesc_s dev[2]; int strbase = COMPOSITE_NSTRIDS; @@ -395,6 +332,69 @@ FAR void *board_composite1_connect(int port) return composite_initialize(2, dev); } +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_composite_initialize + * + * Description: + * Perform architecture specific initialization of a composite USB device. + * + ****************************************************************************/ + +int board_composite_initialize(int port) +{ + /* If system/composite is built as an NSH command, then SD slot should + * already have been initialized in board_app_initialize() (see lpc2148_appinit.c). + * In this case, there is nothing further to be done here. + * + * NOTE: CONFIG_NSH_BUILTIN_APPS is not a fool-proof indication that NSH + * was built. + */ + +#ifndef CONFIG_NSH_BUILTIN_APPS + FAR struct spi_dev_s *spi; + int ret; + + /* Get the SPI port */ + + syslog(LOG_INFO, "Initializing SPI port %d\n", LPC214X_MMCSDSPIPORTNO); + + spi = lpc214x_spibus_initialize(LPC214X_MMCSDSPIPORTNO); + if (!spi) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n", + LPC214X_MMCSDSPIPORTNO); + return -ENODEV; + } + + syslog(LOG_INFO, "Successfully initialized SPI port %d\n", + LPC214X_MMCSDSPIPORTNO); + + /* Bind the SPI port to the slot */ + + syslog(LOG_INFO, "Binding SPI port %d to MMC/SD slot %d\n", + LPC214X_MMCSDSPIPORTNO, LPC214X_MMCSDSLOTNO); + + ret = mmcsd_spislotinitialize(0, LPC214X_MMCSDSLOTNO, spi); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to bind SPI port %d to MMC/SD slot %d: %d\n", + LPC214X_MMCSDSPIPORTNO, LPC214X_MMCSDSLOTNO, ret); + return ret; + } + + syslog(LOG_INFO, "Successfully bound SPI port %d to MMC/SD slot %d\n", + LPC214X_MMCSDSPIPORTNO, LPC214X_MMCSDSLOTNO); + +#endif /* CONFIG_NSH_BUILTIN_APPS */ + + return OK; +} + /**************************************************************************** * Name: board_composite_connect * diff --git a/configs/olimexino-stm32/src/stm32_composite.c b/configs/olimexino-stm32/src/stm32_composite.c index bb55ce54652..894a093a254 100644 --- a/configs/olimexino-stm32/src/stm32_composite.c +++ b/configs/olimexino-stm32/src/stm32_composite.c @@ -182,7 +182,7 @@ static int board_mscclassobject(int minor, ****************************************************************************/ #ifdef CONFIG_USBMSC_COMPOSITE -void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) +static void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) { DEBUGASSERT(g_mschandle != NULL); usbmsc_uninitialize(g_mschandle); @@ -190,64 +190,6 @@ void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) } #endif -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_composite_initialize - * - * Description: - * Perform architecture specific initialization of a composite USB device. - * - ****************************************************************************/ - -int board_composite_initialize(int port) -{ - /* If system/composite is built as an NSH command, then SD slot should - * already have been initialized in board_app_initialize() (see stm32_appinit.c). - * In this case, there is nothing further to be done here. - */ - - FAR struct spi_dev_s *spi; - int ret; - - /* First, get an instance of the SPI interface */ - - syslog(LOG_INFO, "Initializing SPI port %d\n", - OLIMEXINO_STM32_MMCSDSPIPORTNO); - - spi = stm32_spibus_initialize(OLIMEXINO_STM32_MMCSDSPIPORTNO); - if (!spi) - { - syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n", - OLIMEXINO_STM32_MMCSDSPIPORTNO); - return -ENODEV; - } - - syslog(LOG_INFO, "Successfully initialized SPI port %d\n", - OLIMEXINO_STM32_MMCSDSPIPORTNO); - - /* Now bind the SPI interface to the MMC/SD driver */ - - syslog(LOG_INFO, "Bind SPI to the MMC/SD driver, minor=0 slot=%d\n", - OLIMEXINO_STM32_MMCSDSLOTNO); - - ret = mmcsd_spislotinitialize(0, OLIMEXINO_STM32_MMCSDSLOTNO, spi); - if (ret != OK) - { - syslog(LOG_ERR, - "ERROR: Failed to bind SPI port %d to MMC/SD minor=0 slot=%d %d\n", - OLIMEXINO_STM32_MMCSDSPIPORTNO, OLIMEXINO_STM32_MMCSDSLOTNO, - ret); - return ret; - } - - syslog(LOG_INFO, "Successfully bound SPI to the MMC/SD driver\n"); - - return OK; -} - /**************************************************************************** * Name: board_composite0_connect * @@ -265,7 +207,7 @@ int board_composite_initialize(int port) ****************************************************************************/ #ifdef CONFIG_USBMSC_COMPOSITE -FAR void *board_composite0_connect(int port) +static FAR void *board_composite0_connect(int port) { /* Here we are composing the configuration of the usb composite device. * @@ -362,20 +304,21 @@ FAR void *board_composite0_connect(int port) * ****************************************************************************/ -FAR void *board_composite1_connect(int port) +static FAR void *board_composite1_connect(int port) { - struct composite_devdesc_s dev[2]; - int strbase = COMPOSITE_NSTRIDS; - int ifnobase = 0; - int epno; - int i; - /* REVISIT: This configuration currently fails. stm32_epallocpma() fails * allocate a buffer for the 6th endpoint. Currenlty it supports 7x64 byte * buffers, two required for EP0, leaving only buffers for 5 additional * endpoints. */ +#if 0 + struct composite_devdesc_s dev[2]; + int strbase = COMPOSITE_NSTRIDS; + int ifnobase = 0; + int epno; + int i; + for (i = 0, epno = 1; i < 2; i++) { /* Ask the cdcacm driver to fill in the constants we didn't know here */ @@ -409,6 +352,67 @@ FAR void *board_composite1_connect(int port) } return composite_initialize(2, dev); +#else + return NULL; +#endif +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_composite_initialize + * + * Description: + * Perform architecture specific initialization of a composite USB device. + * + ****************************************************************************/ + +int board_composite_initialize(int port) +{ + /* If system/composite is built as an NSH command, then SD slot should + * already have been initialized in board_app_initialize() (see stm32_appinit.c). + * In this case, there is nothing further to be done here. + */ + + FAR struct spi_dev_s *spi; + int ret; + + /* First, get an instance of the SPI interface */ + + syslog(LOG_INFO, "Initializing SPI port %d\n", + OLIMEXINO_STM32_MMCSDSPIPORTNO); + + spi = stm32_spibus_initialize(OLIMEXINO_STM32_MMCSDSPIPORTNO); + if (!spi) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n", + OLIMEXINO_STM32_MMCSDSPIPORTNO); + return -ENODEV; + } + + syslog(LOG_INFO, "Successfully initialized SPI port %d\n", + OLIMEXINO_STM32_MMCSDSPIPORTNO); + + /* Now bind the SPI interface to the MMC/SD driver */ + + syslog(LOG_INFO, "Bind SPI to the MMC/SD driver, minor=0 slot=%d\n", + OLIMEXINO_STM32_MMCSDSLOTNO); + + ret = mmcsd_spislotinitialize(0, OLIMEXINO_STM32_MMCSDSLOTNO, spi); + if (ret != OK) + { + syslog(LOG_ERR, + "ERROR: Failed to bind SPI port %d to MMC/SD minor=0 slot=%d %d\n", + OLIMEXINO_STM32_MMCSDSPIPORTNO, OLIMEXINO_STM32_MMCSDSLOTNO, + ret); + return ret; + } + + syslog(LOG_INFO, "Successfully bound SPI to the MMC/SD driver\n"); + + return OK; } /**************************************************************************** diff --git a/configs/samv71-xult/src/sam_composite.c b/configs/samv71-xult/src/sam_composite.c index 9cab73e1965..05b813f4e4b 100644 --- a/configs/samv71-xult/src/sam_composite.c +++ b/configs/samv71-xult/src/sam_composite.c @@ -150,7 +150,7 @@ static int board_mscclassobject(int minor, ****************************************************************************/ #ifdef CONFIG_USBMSC_COMPOSITE -void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) +static void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) { DEBUGASSERT(g_mschandle != NULL); usbmsc_uninitialize(g_mschandle); diff --git a/configs/spark/src/stm32_composite.c b/configs/spark/src/stm32_composite.c index 11449cffc5d..7ee281f80df 100644 --- a/configs/spark/src/stm32_composite.c +++ b/configs/spark/src/stm32_composite.c @@ -384,7 +384,7 @@ static int board_mscclassobject(int minor, ****************************************************************************/ #ifdef CONFIG_USBMSC_COMPOSITE -void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) +static void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) { DEBUGASSERT(g_mschandle != NULL); usbmsc_uninitialize(g_mschandle); @@ -392,27 +392,6 @@ void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) } #endif -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_composite_initialize - * - * Description: - * Perform architecture specific initialization of a composite USB device. - * - ****************************************************************************/ - -int board_composite_initialize(int port) -{ -#ifdef CONFIG_NSH_BUILTIN_APPS - return OK; -#else - return stm32_composite_initialize(); -#endif -} - /**************************************************************************** * Name: board_composite0_connect * @@ -430,7 +409,7 @@ int board_composite_initialize(int port) ****************************************************************************/ #ifdef CONFIG_USBMSC_COMPOSITE -FAR void *board_composite0_connect(int port) +static FAR void *board_composite0_connect(int port) { /* Here we are composing the configuration of the usb composite device. * @@ -527,20 +506,21 @@ FAR void *board_composite0_connect(int port) * ****************************************************************************/ -FAR void *board_composite1_connect(int port) +static FAR void *board_composite1_connect(int port) { - struct composite_devdesc_s dev[2]; - int strbase = COMPOSITE_NSTRIDS; - int ifnobase = 0; - int epno; - int i; - /* REVISIT: This configuration currently fails. stm32_epallocpma() fails * allocate a buffer for the 6th endpoint. Currenlty it supports 7x64 byte * buffers, two required for EP0, leaving only buffers for 5 additional * endpoints. */ +#if 0 + struct composite_devdesc_s dev[2]; + int strbase = COMPOSITE_NSTRIDS; + int ifnobase = 0; + int epno; + int i; + for (i = 0, epno = 1; i < 2; i++) { /* Ask the cdcacm driver to fill in the constants we didn't know here */ @@ -575,6 +555,30 @@ FAR void *board_composite1_connect(int port) return composite_initialize(2, dev); } +#else + return NULL; +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_composite_initialize + * + * Description: + * Perform architecture specific initialization of a composite USB device. + * + ****************************************************************************/ + +int board_composite_initialize(int port) +{ +#ifdef CONFIG_NSH_BUILTIN_APPS + return OK; +#else + return stm32_composite_initialize(); +#endif +} /**************************************************************************** * Name: board_composite_connect @@ -594,7 +598,7 @@ FAR void *board_composite1_connect(int port) * ****************************************************************************/ -FAR void *board_composite_connect(int port, int configid) +static FAR void *board_composite_connect(int port, int configid) { if (configid == 0) { diff --git a/configs/stm3210e-eval/src/stm32_composite.c b/configs/stm3210e-eval/src/stm32_composite.c index 13ea8f95ae1..325d0b86de3 100644 --- a/configs/stm3210e-eval/src/stm32_composite.c +++ b/configs/stm3210e-eval/src/stm32_composite.c @@ -178,7 +178,7 @@ static int board_mscclassobject(int minor, ****************************************************************************/ #ifdef CONFIG_USBMSC_COMPOSITE -void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) +static void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) { DEBUGASSERT(g_mschandle != NULL); usbmsc_uninitialize(g_mschandle); @@ -186,71 +186,6 @@ void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev) } #endif -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: board_composite_initialize - * - * Description: - * Perform architecture specific initialization of a composite USB device. - * - ****************************************************************************/ - -int board_composite_initialize(int port) -{ - /* If system/composite is built as an NSH command, then SD slot should - * already have been initialized in board_app_initialize() (see - * stm32_appinit.c). In this case, there is nothing further to be done here. - * - * NOTE: CONFIG_NSH_BUILTIN_APPS is not a fool-proof indication that NSH - * was built. - */ - -#ifndef CONFIG_NSH_BUILTIN_APPS - FAR struct sdio_dev_s *sdio; - int ret; - - /* First, get an instance of the SDIO interface */ - - syslog(LOG_INFO, "Initializing SDIO slot %d\n", STM32_MMCSDSLOTNO); - - sdio = sdio_initialize(STM32_MMCSDSLOTNO); - if (!sdio) - { - syslog(LOG_ERR, "ERROR: Failed to initialize SDIO slot %d\n", - STM32_MMCSDSLOTNO); - return -ENODEV; - } - - /* Now bind the SDIO interface to the MMC/SD driver */ - - syslog(LOG_INFO, "Bind SDIO to the MMC/SD driver, minor=0\n"); - - ret = mmcsd_slotinitialize(0, sdio); - if (ret != OK) - { - syslog(LOG_ERR, - "ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", - ret); - return ret; - } - - syslog(LOG_INFO, "Successfully bound SDIO to the MMC/SD driver\n"); - - /* Then let's guess and say that there is a card in the slot. I need to check to - * see if the STM3210E-EVAL board supports a GPIO to detect if there is a card in - * the slot. - */ - - sdio_mediachange(sdio, true); - -#endif /* CONFIG_NSH_BUILTIN_APPS */ - - return OK; -} - /**************************************************************************** * Name: board_composite0_connect * @@ -268,7 +203,7 @@ int board_composite_initialize(int port) ****************************************************************************/ #ifdef CONFIG_USBMSC_COMPOSITE -FAR void *board_composite0_connect(int port) +static FAR void *board_composite0_connect(int port) { /* Here we are composing the configuration of the usb composite device. * @@ -365,20 +300,21 @@ FAR void *board_composite0_connect(int port) * ****************************************************************************/ -FAR void *board_composite1_connect(int port) +static FAR void *board_composite1_connect(int port) { - struct composite_devdesc_s dev[2]; - int strbase = COMPOSITE_NSTRIDS; - int ifnobase = 0; - int epno; - int i; - /* REVISIT: This configuration currently fails. stm32_epallocpma() fails * allocate a buffer for the 6th endpoint. Currenlty it supports 7x64 byte * buffers, two required for EP0, leaving only buffers for 5 additional * endpoints. */ +#if 0 + struct composite_devdesc_s dev[2]; + int strbase = COMPOSITE_NSTRIDS; + int ifnobase = 0; + int epno; + int i; + for (i = 0, epno = 1; i < 2; i++) { /* Ask the cdcacm driver to fill in the constants we didn't know here */ @@ -412,6 +348,74 @@ FAR void *board_composite1_connect(int port) } return composite_initialize(2, dev); +#else + return NULL; +#endif +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_composite_initialize + * + * Description: + * Perform architecture specific initialization of a composite USB device. + * + ****************************************************************************/ + +int board_composite_initialize(int port) +{ + /* If system/composite is built as an NSH command, then SD slot should + * already have been initialized in board_app_initialize() (see + * stm32_appinit.c). In this case, there is nothing further to be done here. + * + * NOTE: CONFIG_NSH_BUILTIN_APPS is not a fool-proof indication that NSH + * was built. + */ + +#ifndef CONFIG_NSH_BUILTIN_APPS + FAR struct sdio_dev_s *sdio; + int ret; + + /* First, get an instance of the SDIO interface */ + + syslog(LOG_INFO, "Initializing SDIO slot %d\n", STM32_MMCSDSLOTNO); + + sdio = sdio_initialize(STM32_MMCSDSLOTNO); + if (!sdio) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SDIO slot %d\n", + STM32_MMCSDSLOTNO); + return -ENODEV; + } + + /* Now bind the SDIO interface to the MMC/SD driver */ + + syslog(LOG_INFO, "Bind SDIO to the MMC/SD driver, minor=0\n"); + + ret = mmcsd_slotinitialize(0, sdio); + if (ret != OK) + { + syslog(LOG_ERR, + "ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", + ret); + return ret; + } + + syslog(LOG_INFO, "Successfully bound SDIO to the MMC/SD driver\n"); + + /* Then let's guess and say that there is a card in the slot. I need to check to + * see if the STM3210E-EVAL board supports a GPIO to detect if there is a card in + * the slot. + */ + + sdio_mediachange(sdio, true); + +#endif /* CONFIG_NSH_BUILTIN_APPS */ + + return OK; } /****************************************************************************