PM: Add activity domain to all PM callbacks

This commit is contained in:
Gregory Nutt
2016-03-27 11:19:39 -06:00
parent 8b21db7fc7
commit dea4fe5d90
7 changed files with 52 additions and 15 deletions
+3
View File
@@ -11587,3 +11587,6 @@
board. From Dave (2016-03-25). board. From Dave (2016-03-25).
7.16 2016-xx-xx Gregory Nutt <gnutt@nuttx.org> 7.16 2016-xx-xx Gregory Nutt <gnutt@nuttx.org>
* PM: Add activity domain to all PM driver callbacks (2016-03-27).
+1 -1
Submodule arch updated: 9da37a0989...f4b99ebe1f
+1 -1
Submodule configs updated: ed6b75b8a0...07937231ef
+9
View File
@@ -26,6 +26,15 @@ config PM_SLICEMS
CONFIG_PM_SLICEMS provides the duration of that time slice in CONFIG_PM_SLICEMS provides the duration of that time slice in
milliseconds. Default: 100 Milliseconds milliseconds. Default: 100 Milliseconds
config PM_NDOMAINS
int "Number of PM activity domains"
default 1
---help---
Defines the number of "domains" that activity may be monitored on.
For example, you may want to separately manage the power from the
Network domain, shutting down the network when it is not be used,
from the UI domain, shutting down the UI when it is not in use.
config PM_MEMORY config PM_MEMORY
int "PM memory (msec)" int "PM memory (msec)"
default 2 default 2
+15 -9
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/power/pm_changestate.c * drivers/power/pm_changestate.c
* *
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. * Copyright (C) 2011-2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -77,6 +77,7 @@
* Prepare every driver for the state change. * Prepare every driver for the state change.
* *
* Input Parameters: * Input Parameters:
* domain - Identifies the domain of the new PM state
* newstate - Identifies the new PM state * newstate - Identifies the new PM state
* *
* Returned Value: * Returned Value:
@@ -90,7 +91,7 @@
* *
****************************************************************************/ ****************************************************************************/
static int pm_prepall(enum pm_state_e newstate) static int pm_prepall(int domain, enum pm_state_e newstate)
{ {
FAR sq_entry_t *entry; FAR sq_entry_t *entry;
int ret = OK; int ret = OK;
@@ -108,7 +109,7 @@ static int pm_prepall(enum pm_state_e newstate)
{ {
/* Yes.. prepare the driver */ /* Yes.. prepare the driver */
ret = cb->prepare(cb, newstate); ret = cb->prepare(cb, domain, newstate);
} }
} }
@@ -119,9 +120,11 @@ static int pm_prepall(enum pm_state_e newstate)
* Name: pm_changeall * Name: pm_changeall
* *
* Description: * Description:
* domain - Identifies the domain of the new PM state
* Inform all drivers of the state change. * Inform all drivers of the state change.
* *
* Input Parameters: * Input Parameters:
* domain - Identifies the domain of the new PM state
* newstate - Identifies the new PM state * newstate - Identifies the new PM state
* *
* Returned Value: * Returned Value:
@@ -132,7 +135,7 @@ static int pm_prepall(enum pm_state_e newstate)
* *
****************************************************************************/ ****************************************************************************/
static inline void pm_changeall(enum pm_state_e newstate) static inline void pm_changeall(int domain, enum pm_state_e newstate)
{ {
FAR sq_entry_t *entry; FAR sq_entry_t *entry;
@@ -147,7 +150,7 @@ static inline void pm_changeall(enum pm_state_e newstate)
{ {
/* Yes.. notify the driver */ /* Yes.. notify the driver */
cb->notify(cb, newstate); cb->notify(cb, domain, newstate);
} }
} }
} }
@@ -165,6 +168,7 @@ static inline void pm_changeall(enum pm_state_e newstate)
* drivers that have registered for power management event callbacks. * drivers that have registered for power management event callbacks.
* *
* Input Parameters: * Input Parameters:
* domain - Identifies the domain of the new PM state
* newstate - Identifies the new PM state * newstate - Identifies the new PM state
* *
* Returned Value: * Returned Value:
@@ -183,11 +187,13 @@ static inline void pm_changeall(enum pm_state_e newstate)
* *
****************************************************************************/ ****************************************************************************/
int pm_changestate(enum pm_state_e newstate) int pm_changestate(int domain, enum pm_state_e newstate)
{ {
irqstate_t flags; irqstate_t flags;
int ret; int ret;
DEBUGASSERT(domain >=0 && domain < CONFIG_PM_NDOMAINS);
/* Disable interrupts throught this operation... changing driver states /* Disable interrupts throught this operation... changing driver states
* could cause additional driver activity that might interfere with the * could cause additional driver activity that might interfere with the
* state change. When the state change is complete, interrupts will be * state change. When the state change is complete, interrupts will be
@@ -200,7 +206,7 @@ int pm_changestate(enum pm_state_e newstate)
* drivers may refuse the state state change. * drivers may refuse the state state change.
*/ */
ret = pm_prepall(newstate); ret = pm_prepall(domain, newstate);
if (ret != OK) if (ret != OK)
{ {
/* One or more drivers is not ready for this state change. Revert to /* One or more drivers is not ready for this state change. Revert to
@@ -208,14 +214,14 @@ int pm_changestate(enum pm_state_e newstate)
*/ */
newstate = g_pmglobals.state; newstate = g_pmglobals.state;
(void)pm_prepall(newstate); (void)pm_prepall(domain, newstate);
} }
/* All drivers have agreed to the state change (or, one or more have /* All drivers have agreed to the state change (or, one or more have
* disagreed and the state has been reverted). Set the new state. * disagreed and the state has been reverted). Set the new state.
*/ */
pm_changeall(newstate); pm_changeall(domain, newstate);
g_pmglobals.state = newstate; g_pmglobals.state = newstate;
/* Restore the interrupt state */ /* Restore the interrupt state */
+22 -3
View File
@@ -78,6 +78,20 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* CONFIG_PM_NDOMAINS. Defines the number of "domains" that activity may be
* monitored on. For example, you may want to separately manage the power
* from the Network domain, shutting down the network when it is not be used,
* from the UI domain, shutting down the UI when it is not in use.
*/
#ifndef CONFIG_PM_NDOMAINS
# define CONFIG_PM_NDOMAINS 1
#endif
#if CONFIG_PM_NDOMAINS < 1
# error CONFIG_PM_NDOMAINS invalid
#endif
/* CONFIG_IDLE_CUSTOM. Some architectures support this definition. This, /* CONFIG_IDLE_CUSTOM. Some architectures support this definition. This,
* if defined, will allow you replace the default IDLE loop with your * if defined, will allow you replace the default IDLE loop with your
* own, custom idle loop to support board-specific IDLE time power management * own, custom idle loop to support board-specific IDLE time power management
@@ -278,6 +292,7 @@ struct pm_callback_s
* cb - Returned to the driver. The driver version of the callback * cb - Returned to the driver. The driver version of the callback
* structure may include additional, driver-specific state * structure may include additional, driver-specific state
* data at the end of the structure. * data at the end of the structure.
* domain - Identifies the activity domain of the state change
* pmstate - Identifies the new PM state * pmstate - Identifies the new PM state
* *
* Returned Value: * Returned Value:
@@ -292,7 +307,8 @@ struct pm_callback_s
* *
**************************************************************************/ **************************************************************************/
int (*prepare)(FAR struct pm_callback_s *cb, enum pm_state_e pmstate); int (*prepare)(FAR struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
/************************************************************************** /**************************************************************************
* Name: notify * Name: notify
@@ -306,6 +322,7 @@ struct pm_callback_s
* cb - Returned to the driver. The driver version of the callback * cb - Returned to the driver. The driver version of the callback
* structure may include additional, driver-specific state * structure may include additional, driver-specific state
* data at the end of the structure. * data at the end of the structure.
* domain - Identifies the activity domain of the state change
* pmstate - Identifies the new PM state * pmstate - Identifies the new PM state
* *
* Returned Value: * Returned Value:
@@ -316,7 +333,8 @@ struct pm_callback_s
* *
**************************************************************************/ **************************************************************************/
void (*notify)(FAR struct pm_callback_s *cb, enum pm_state_e pmstate); void (*notify)(FAR struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
}; };
/**************************************************************************** /****************************************************************************
@@ -444,6 +462,7 @@ enum pm_state_e pm_checkstate(void);
* drivers that have registered for power management event callbacks. * drivers that have registered for power management event callbacks.
* *
* Input Parameters: * Input Parameters:
* domain - Identifies the domain of the new PM state
* newstate - Identifies the new PM state * newstate - Identifies the new PM state
* *
* Returned Value: * Returned Value:
@@ -462,7 +481,7 @@ enum pm_state_e pm_checkstate(void);
* *
****************************************************************************/ ****************************************************************************/
int pm_changestate(enum pm_state_e newstate); int pm_changestate(int domain, enum pm_state_e newstate);
#undef EXTERN #undef EXTERN
#ifdef __cplusplus #ifdef __cplusplus