power: move EXPLICIT_RELAX opreation to common place
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
f0a1a2dc0b
commit
b34925e6eb
@ -33,7 +33,7 @@ CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PM=y
|
||||
CONFIG_PM_GOVERNOR_EXPLICIT_RELAX=y
|
||||
CONFIG_PM_GOVERNOR_EXPLICIT_RELAX=-1
|
||||
CONFIG_PM_GOVERNOR_GREEDY=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RR_INTERVAL=200
|
||||
|
@ -34,7 +34,7 @@ CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PM=y
|
||||
CONFIG_PM_GOVERNOR_EXPLICIT_RELAX=y
|
||||
CONFIG_PM_GOVERNOR_EXPLICIT_RELAX=-1
|
||||
CONFIG_PM_GOVERNOR_GREEDY=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
|
@ -41,22 +41,25 @@ config PM_GOVERNOR_ACTIVITY
|
||||
|
||||
menu "Governor options"
|
||||
|
||||
if PM_GOVERNOR_GREEDY
|
||||
|
||||
config PM_GOVERNOR_EXPLICIT_RELAX
|
||||
bool "Stay initially at PM_NORMAL"
|
||||
int "Stay initially at PM_NORMAL"
|
||||
default 0
|
||||
---help---
|
||||
If you boot into NSH, when using the greedy PM governor, since NuttX will
|
||||
almost immediately go idle (when waiting for a prompt), he lowest possible
|
||||
run-level will be selected, which may not be desirable.
|
||||
If you boot into NSH, especially using the greedy PM governor, since
|
||||
NuttX will almost immediately go idle (when waiting for a prompt), the
|
||||
lowest possible run-level will be selected, which may not be desirable.
|
||||
This is not a problem if you directly run you application at boot, which
|
||||
can hold off power levels using pm_stay() (via boardctl).
|
||||
|
||||
This option will initialize all run levels as if pm_stay() were to be
|
||||
called once for each, so that your application needs to call pm_relax()
|
||||
(via boardctl()) for every run-level you wish to allow to enter.
|
||||
This option will initialize all run levels as if
|
||||
pm_stay/pm_stay_timeout() were to be called once for each.
|
||||
|
||||
endif
|
||||
if set to -1, that means pm_stay(), so that your application
|
||||
needs to call pm_relax() (via boardctl()) for every run-level you
|
||||
wish to allow to enter.
|
||||
|
||||
if set to timeout (unit: ms), that means pm_stay_timeout(ms).
|
||||
pm_relax() will be auto called after timeout.
|
||||
|
||||
if PM_GOVERNOR_ACTIVITY
|
||||
|
||||
|
@ -62,7 +62,6 @@ struct pm_greedy_governor_s
|
||||
|
||||
/* PM governor methods */
|
||||
|
||||
static void greedy_governor_initialize(void);
|
||||
static void greedy_governor_statechanged(int domain,
|
||||
enum pm_state_e newstate);
|
||||
static enum pm_state_e greedy_governor_checkstate(int domain);
|
||||
@ -74,7 +73,6 @@ static void greedy_governor_activity(int domain, int count);
|
||||
|
||||
static const struct pm_governor_s g_greedy_governor_ops =
|
||||
{
|
||||
.initialize = greedy_governor_initialize, /* initialize */
|
||||
.statechanged = greedy_governor_statechanged, /* statechanged */
|
||||
.checkstate = greedy_governor_checkstate, /* checkstate */
|
||||
.activity = greedy_governor_activity, /* activity */
|
||||
@ -86,23 +84,6 @@ static struct pm_greedy_governor_s g_pm_greedy_governor;
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: greedy_governor_initialize
|
||||
****************************************************************************/
|
||||
|
||||
static void greedy_governor_initialize(void)
|
||||
{
|
||||
#ifdef CONFIG_PM_GOVERNOR_EXPLICIT_RELAX
|
||||
for (int dom = 0; dom < CONFIG_PM_NDOMAINS; dom++)
|
||||
{
|
||||
for (int state = 0; state < PM_COUNT; state++)
|
||||
{
|
||||
pm_stay(dom, state);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: greedy_governor_statechanged
|
||||
****************************************************************************/
|
||||
|
@ -70,6 +70,11 @@
|
||||
|
||||
int pm_set_governor(int domain, FAR const struct pm_governor_s *gov)
|
||||
{
|
||||
#if CONFIG_PM_GOVERNOR_EXPLICIT_RELAX
|
||||
int state;
|
||||
int dom;
|
||||
#endif
|
||||
|
||||
if (gov == NULL)
|
||||
{
|
||||
return -EINVAL;
|
||||
@ -88,5 +93,19 @@ int pm_set_governor(int domain, FAR const struct pm_governor_s *gov)
|
||||
g_pmglobals.domain[domain].governor->initialize();
|
||||
}
|
||||
|
||||
#if CONFIG_PM_GOVERNOR_EXPLICIT_RELAX
|
||||
for (dom = 0; dom < CONFIG_PM_NDOMAINS; dom++)
|
||||
{
|
||||
for (state = 0; state < PM_COUNT; state++)
|
||||
{
|
||||
#if CONFIG_PM_GOVERNOR_EXPLICIT_RELAX < 0
|
||||
pm_stay(dom, state);
|
||||
#else
|
||||
pm_stay_timeout(dom, state, CONFIG_PM_GOVERNOR_EXPLICIT_RELAX);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user