power_mgmt: Add device power management support

Added device power management hook infrastructure. Added
DEVICE_INIT_PM and SYS_INIT_PM macros that creates device
structures with the supplied device_ops structure containing
the hooks.

Added example support in gpio_dw driver.  Updated the sample
app and tested using LPS and Device Suspend Only policies.

Change-Id: I2fe347f8d8fd1041d8318e02738990deb8c5d68e
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Ramesh Thomas 2016-03-23 23:23:10 -07:00 committed by Anas Nashif
commit 4104bbfb08
15 changed files with 276 additions and 144 deletions

View file

@ -150,8 +150,6 @@ typedef int (*gpio_enable_callback_t)(struct device *port,
typedef int (*gpio_disable_callback_t)(struct device *port,
int access_op,
uint32_t pin);
typedef int (*gpio_suspend_port_t)(struct device *port);
typedef int (*gpio_resume_port_t)(struct device *port);
struct gpio_driver_api {
gpio_config_t config;
@ -160,8 +158,6 @@ struct gpio_driver_api {
gpio_set_callback_t set_callback;
gpio_enable_callback_t enable_callback;
gpio_disable_callback_t disable_callback;
gpio_suspend_port_t suspend;
gpio_resume_port_t resume;
};
/**
* @endcond
@ -325,31 +321,6 @@ static inline int gpio_port_disable_callback(struct device *port)
return api->disable_callback(port, GPIO_ACCESS_BY_PORT, 0);
}
/**
* @brief Save the state of the device and make it go to the
* low power state.
* @param port Pointer to the device structure for the driver instance.
*/
static inline int gpio_suspend(struct device *port)
{
struct gpio_driver_api *api;
api = (struct gpio_driver_api *) port->driver_api;
return api->suspend(port);
}
/**
* @brief Restore the state stored during suspend and resume operation.
* @param port Pointer to the device structure for the driver instance.
*/
static inline int gpio_resume(struct device *port)
{
struct gpio_driver_api *api;
api = (struct gpio_driver_api *) port->driver_api;
return api->resume(port);
}
#ifdef __cplusplus
}
#endif