From 27ea02a85fb046ef615110d4a483efa2d9f20b2e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 2 Jul 2015 17:09:54 -0600 Subject: [PATCH] Modify board_power_off() so that is is called only via boardctl() --- arch/arm/src/calypso/calypso_power.c | 15 ++++-- configs | 2 +- include/nuttx/board.h | 71 ++++++++++++++-------------- include/sys/boardctl.h | 19 +++++--- 4 files changed, 62 insertions(+), 45 deletions(-) diff --git a/arch/arm/src/calypso/calypso_power.c b/arch/arm/src/calypso/calypso_power.c index 721d8969d4..cb97d6cfff 100644 --- a/arch/arm/src/calypso/calypso_power.c +++ b/arch/arm/src/calypso/calypso_power.c @@ -2,6 +2,8 @@ * Included Files ****************************************************************************/ +#include + #include #include @@ -17,14 +19,17 @@ * board due to some other constraints. * * Input Parameters: - * None + * status - Status information provided with the power off event. * * Returned Value: - * None + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. * ****************************************************************************/ -void board_power_off(void) +#ifdef CONFIG_BOARDCTL_POWEROFF +void board_power_off(int status) { uint16_t tx; struct spi_dev_s *spi = up_spiinitialize(0); @@ -36,4 +41,8 @@ void board_power_off(void) tx = (1 << 6) | (30 << 1); SPI_SNDBLOCK(spi, &tx, 1); + + return 0; } +#endif + diff --git a/configs b/configs index ec14d18d72..4bf3b9cd47 160000 --- a/configs +++ b/configs @@ -1 +1 @@ -Subproject commit ec14d18d72612c037efb5cb906628a665dba8a9d +Subproject commit 4bf3b9cd470e9be652cdd69dd4012b8f250dd9ea diff --git a/include/nuttx/board.h b/include/nuttx/board.h index fe80da7063..ed64f8c70a 100644 --- a/include/nuttx/board.h +++ b/include/nuttx/board.h @@ -234,6 +234,42 @@ int board_adc_setup(void); int board_pwm_setup(void); +/**************************************************************************** + * Name: board_power_off + * + * Description: + * Power off the board. This function may or may not be supported by a + * particular board architecture. + * + * Input Parameters: + * status - Status information provided with the power off event. + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL_POWEROFF +int board_power_off(int status); +#endif + +/**************************************************************************** + * Name: board_ioctl + * + * Description: + * If CONFIG_LIB_BOARDCTL=y, boards may also select CONFIG_BOARDCTL_IOCTL=y + * enable board specific commands. In this case, all commands not + * recognized by boardctl() will be forwarded to the board-provided + * board_ioctl() function. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL_IOCTL +int board_ioctl(unsigned int cmd, uintptr_t arg); +#endif + /**************************************************************************** * Name: board_graphics_setup * @@ -257,41 +293,6 @@ struct fb_vtable_s; FAR struct fb_vtable_s *board_graphics_setup(unsigned int devno); #endif -/**************************************************************************** - * Name: board_ioctl - * - * Description: - * If CONFIG_LIB_BOARDCTL=y, boards may also select CONFIG_BOARDCTL_IOCTL=y - * enable board specific commands. In this case, all commands not - * recognized by boardctl() will be forwarded to the board-provided - * board_ioctl() function. - * - ****************************************************************************/ - -#ifdef CONFIG_BOARDCTL_IOCTL -int board_ioctl(unsigned int cmd, uintptr_t arg); -#endif - -/**************************************************************************** - * Name: board_power_off - * - * Description: - * Power off the board. This function may or may not be supported by a - * particular board architecture. - * - * If this function returns, then it was not possible to power-off the - * board due to some constraints. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_power_off(void); - /**************************************************************************** * Name: board_lcd_initialize, board_lcd_getdev, board_lcd_uninitialize * diff --git a/include/sys/boardctl.h b/include/sys/boardctl.h index a7c64fe7de..0e174c4d26 100644 --- a/include/sys/boardctl.h +++ b/include/sys/boardctl.h @@ -58,6 +58,12 @@ * CONFIGURATION: CONFIG_LIB_BOARDCTL * DEPENDENCIES: Board logic must provide board_app_initialization * + * CMD: BOARDIOC_POWEROFF + * DESCRIPTION: Power off the board + * ARG: Integer value providing power off status information + * CONFIGURATION: CONFIG_BOARDCTL_POWEROFF + * DEPENDENCIES: Board logic must provide board_power_off + * * CMD: BOARDIOC_TSCTEST_SETUP * DESCRIPTION: Touchscreen controller test configuration * ARG: Touch controller device minor number @@ -91,11 +97,12 @@ */ #define BOARDIOC_INIT _BOARDIOC(0x0001) -#define BOARDIOC_TSCTEST_SETUP _BOARDIOC(0x0002) -#define BOARDIOC_TSCTEST_TEARDOWN _BOARDIOC(0x0003) -#define BOARDIOC_ADCTEST_SETUP _BOARDIOC(0x0004) -#define BOARDIOC_PWMTEST_SETUP _BOARDIOC(0x0005) -#define BOARDIOC_GRAPHICS_SETUP _BOARDIOC(0x0006) +#define BOARDIOC_POWEROFF _BOARDIOC(0x0002) +#define BOARDIOC_TSCTEST_SETUP _BOARDIOC(0x0003) +#define BOARDIOC_TSCTEST_TEARDOWN _BOARDIOC(0x0004) +#define BOARDIOC_ADCTEST_SETUP _BOARDIOC(0x0005) +#define BOARDIOC_PWMTEST_SETUP _BOARDIOC(0x0006) +#define BOARDIOC_GRAPHICS_SETUP _BOARDIOC(0x0007) /* If CONFIG_BOARDCTL_IOCTL=y, then boad-specific commands will be support. * In this case, all commands not recognized by boardctl() will be forwarded @@ -104,7 +111,7 @@ * User defined board commands may begin with this value: */ -#define BOARDIOC_USER _BOARDIOC(0x0007) +#define BOARDIOC_USER _BOARDIOC(0x0008) /**************************************************************************** * Public Type Definitions