Move SMPS driver to drivers/power (and header to include/nuttx/power). Rename debug to IOCTLs to more general power naming; create a separate file to coordinate power-related IOCTL commands.

This commit is contained in:
Gregory Nutt
2017-07-23 07:35:09 -06:00
parent a9a236fea5
commit 4be064d19a
8 changed files with 156 additions and 74 deletions
+6
View File
@@ -89,6 +89,7 @@
#define _CLIOCBASE (0x2400) /* Contactless modules ioctl commands */
#define _USBCBASE (0x2500) /* USB-C controller ioctl commands */
#define _MAC802154BASE (0x2600) /* 802.15.4 MAC ioctl commands */
#define _PWRBASE (0x2700) /* Power-related ioctl commands */
/* boardctl() commands share the same number space */
@@ -428,6 +429,11 @@
#define _MAC802154IOCVALID(c) (_IOC_TYPE(c)==_MAC802154BASE)
#define _MAC802154IOC(nr) _IOC(_MAC802154BASE,nr)
/* Power-Related IOCTLs *****************************************************/
#define _PWRIOCVALID(c) (_IOC_TYPE(c)==_SMPS_BASE)
#define _PWRIOC(nr) _IOC(_PWRBASE,nr)
/* boardctl() command definitions *******************************************/
#define _BOARDIOCVALID(c) (_IOC_TYPE(c)==_BOARDBASE)
+5
View File
@@ -48,6 +48,11 @@
* Pre-processor Definitions
****************************************************************************/
/* All battery-related IOCTL commands must be defined in this header file
* in order to assure that every IOCTL command is unique and will not be
* aliased.
*/
#define BATIOC_STATE _BATIOC(0x0001)
#define BATIOC_HEALTH _BATIOC(0x0002)
#define BATIOC_ONLINE _BATIOC(0x0003)
+66
View File
@@ -0,0 +1,66 @@
/****************************************************************************
* include/nuttx/power/power_ioctl.h
* NuttX Power-Related IOCTLs definitions
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_POWER_POWER_IOCTL_H
#define __INCLUDE_NUTTX_POWER_POWER_IOCTL_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/fs/ioctl.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* All power-related IOCTL commands must be defined in this header file
* in order to assure that every IOCTL command is unique and will not be
* aliased.
*/
#define PWRIOC_START _PWRIOC(1)
#define PWRIOC_STOP _PWRIOC(2)
#define PWRIOC_SET_MODE _PWRIOC(3)
#define PWRIOC_SET_LIMITS _PWRIOC(4)
#define PWRIOC_GET_STATE _PWRIOC(5)
#define PWRIOC_GET_FAULT _PWRIOC(6)
#define PWRIOC_SET_FAULT _PWRIOC(7)
#define PWRIOC_CLEAN_FAULT _PWRIOC(8)
#define PWRIOC_SET_PARAMS _PWRIOC(9)
#endif /* __INCLUDE_NUTTX_POWER_POWER_IOCTL_H */
@@ -1,5 +1,5 @@
/****************************************************************************
* include/nuttx/drivers/smps.h
* include/nuttx/power/smps.h
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <raiden00@railab.me>
@@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_DRIVERS_SMPS_H
#define __INCLUDE_NUTTX_DRIVERS_SMPS_H
#ifndef __INCLUDE_NUTTX_DRIVERS_POWER_H
#define __INCLUDE_NUTTX_DRIVERS_POWER_H
/*
* The SMPS (switched-mode power supply) driver is split into two parts:
@@ -56,55 +56,14 @@
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/power/power_ioctl.h>
#ifdef CONFIG_SMPS
#ifdef CONFIG_DRIVERS_SMPS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* REVISIT: move to fs/ioctl.h ? */
/* General ioctl definitions ************************************************/
#define _SMPSBASE (0x2700) /* SMPS ioctl commands */
/* SMPS IOCTLs **************************************************************/
#define _SMPSIOCVALID(c) (_IOC_TYPE(c)==_SMPS_BASE)
#define _SMPSIOC(nr) _IOC(_SMPSBASE,nr)
/* Ioctl Commands ************************************************************/
#define SMPSIOC_START _SMPSIOC(1)
#define SMPSIOC_STOP _SMPSIOC(2)
#define SMPSIOC_SET_MODE _SMPSIOC(3)
#define SMPSIOC_SET_LIMITS _SMPSIOC(4)
#define SMPSIOC_GET_STATE _SMPSIOC(5)
#define SMPSIOC_GET_FAULT _SMPSIOC(6)
#define SMPSIOC_SET_FAULT _SMPSIOC(7)
#define SMPSIOC_CLEAN_FAULT _SMPSIOC(8)
#define SMPSIOC_SET_PARAMS _SMPSIOC(9)
#ifdef CONFIG_DEBUG_SMPS_ERROR
# define smpserr(format, ...) _err(format, ##__VA_ARGS__)
#else
# define smpserr(x...)
#endif
#ifdef CONFIG_DEBUG_SMPS_WARN
# define smpswarn(format, ...) _warn(format, ##__VA_ARGS__)
#else
# define smpswarn(x...)
#endif
#ifdef CONFIG_DEBUG_SMPS_INFO
# define smpsinfo(format, ...) _info(format, ##__VA_ARGS__)
#else
# define smpsinfo(x...)
#endif
/****************************************************************************
* Public Types
****************************************************************************/
@@ -331,5 +290,5 @@ int smps_register(FAR const char *path, FAR struct smps_dev_s *dev,
}
#endif
#endif /* CONFIG_SMPS */
#endif /* __INCLUDE_NUTTX_DRIVERS_SMPS_H */
#endif /* CONFIG_DRIVERS_SMPS */
#endif /* __INCLUDE_NUTTX_DRIVERS_POWER_H */