From dea4fe5d90abf80855ea6fc6aff85b4a08842671 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 27 Mar 2016 11:19:39 -0600 Subject: [PATCH] PM: Add activity domain to all PM callbacks --- ChangeLog | 3 +++ Documentation | 2 +- arch | 2 +- configs | 2 +- drivers/power/Kconfig | 9 +++++++++ drivers/power/pm_changestate.c | 24 +++++++++++++++--------- include/nuttx/power/pm.h | 25 ++++++++++++++++++++++--- 7 files changed, 52 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c5d73ce69a..26ab44a22c0 100755 --- a/ChangeLog +++ b/ChangeLog @@ -11587,3 +11587,6 @@ board. From Dave (2016-03-25). 7.16 2016-xx-xx Gregory Nutt + + * PM: Add activity domain to all PM driver callbacks (2016-03-27). + diff --git a/Documentation b/Documentation index ce8bd7e82a4..a15cb168507 160000 --- a/Documentation +++ b/Documentation @@ -1 +1 @@ -Subproject commit ce8bd7e82a4418b24c6c04026f6019d8e0ffe849 +Subproject commit a15cb168507bf218b37a3325902df18085ede4a6 diff --git a/arch b/arch index 9da37a0989a..f4b99ebe1fd 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit 9da37a0989a52853fe27bb4acadf52dc155e7440 +Subproject commit f4b99ebe1fd5ab77e9a6adda04611787b4a26205 diff --git a/configs b/configs index ed6b75b8a05..07937231ef9 160000 --- a/configs +++ b/configs @@ -1 +1 @@ -Subproject commit ed6b75b8a0531a2d59629d0a128f01b89b5f32f6 +Subproject commit 07937231ef92ab88e2043dc9a17d2d677e26903c diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 891fc1be240..bcebe1cabf6 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -26,6 +26,15 @@ config PM_SLICEMS CONFIG_PM_SLICEMS provides the duration of that time slice in 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 int "PM memory (msec)" default 2 diff --git a/drivers/power/pm_changestate.c b/drivers/power/pm_changestate.c index 271858710dd..37caa12b88a 100644 --- a/drivers/power/pm_changestate.c +++ b/drivers/power/pm_changestate.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -77,6 +77,7 @@ * Prepare every driver for the state change. * * Input Parameters: + * domain - Identifies the domain of the new PM state * newstate - Identifies the new PM state * * 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; int ret = OK; @@ -108,7 +109,7 @@ static int pm_prepall(enum pm_state_e newstate) { /* 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 * * Description: + * domain - Identifies the domain of the new PM state * Inform all drivers of the state change. * * Input Parameters: + * domain - Identifies the domain of the new PM state * newstate - Identifies the new PM state * * 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; @@ -147,7 +150,7 @@ static inline void pm_changeall(enum pm_state_e newstate) { /* 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. * * Input Parameters: + * domain - Identifies the domain of the new PM state * newstate - Identifies the new PM state * * 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; int ret; + DEBUGASSERT(domain >=0 && domain < CONFIG_PM_NDOMAINS); + /* Disable interrupts throught this operation... changing driver states * could cause additional driver activity that might interfere with the * 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. */ - ret = pm_prepall(newstate); + ret = pm_prepall(domain, newstate); if (ret != OK) { /* 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; - (void)pm_prepall(newstate); + (void)pm_prepall(domain, newstate); } /* All drivers have agreed to the state change (or, one or more have * disagreed and the state has been reverted). Set the new state. */ - pm_changeall(newstate); + pm_changeall(domain, newstate); g_pmglobals.state = newstate; /* Restore the interrupt state */ diff --git a/include/nuttx/power/pm.h b/include/nuttx/power/pm.h index 2141ece1ee0..3dc9e4c38e3 100644 --- a/include/nuttx/power/pm.h +++ b/include/nuttx/power/pm.h @@ -78,6 +78,20 @@ * Pre-processor Definitions ****************************************************************************/ /* 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, * if defined, will allow you replace the default IDLE loop with your * 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 * structure may include additional, driver-specific state * data at the end of the structure. + * domain - Identifies the activity domain of the state change * pmstate - Identifies the new PM state * * 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 @@ -306,6 +322,7 @@ struct pm_callback_s * cb - Returned to the driver. The driver version of the callback * structure may include additional, driver-specific state * data at the end of the structure. + * domain - Identifies the activity domain of the state change * pmstate - Identifies the new PM state * * 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. * * Input Parameters: + * domain - Identifies the domain of the new PM state * newstate - Identifies the new PM state * * 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 #ifdef __cplusplus