power: fill acivity callback to greedy_governor

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2022-06-10 16:07:37 +08:00 committed by Xiang Xiao
parent 25b16576e8
commit 479689eae9
1 changed files with 62 additions and 15 deletions

View File

@ -46,16 +46,27 @@
* Private Types
****************************************************************************/
struct pm_domain_state_s
{
struct wdog_s wdog;
};
struct pm_greedy_governor_s
{
struct pm_domain_state_s domain_states[CONFIG_PM_NDOMAINS];
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* 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);
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);
static void greedy_governor_activity(int domain, int count);
/****************************************************************************
* Private Data
@ -63,14 +74,14 @@ static enum pm_state_e greedy_governor_checkstate(int domain);
static const struct pm_governor_s g_greedy_governor_ops =
{
greedy_governor_initialize, /* initialize */
NULL, /* deinitialize */
greedy_governor_statechanged, /* statechanged */
greedy_governor_checkstate, /* checkstate */
NULL, /* activity */
NULL /* priv */
.initialize = greedy_governor_initialize, /* initialize */
.statechanged = greedy_governor_statechanged, /* statechanged */
.checkstate = greedy_governor_checkstate, /* checkstate */
.activity = greedy_governor_activity, /* activity */
};
static struct pm_greedy_governor_s g_pm_greedy_governor;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -111,10 +122,12 @@ static void greedy_governor_statechanged(int domain,
static enum pm_state_e greedy_governor_checkstate(int domain)
{
FAR struct pm_domain_state_s *pdomstate;
FAR struct pm_domain_s *pdom;
int state;
irqstate_t flags;
int state;
pdomstate = &g_pm_greedy_governor.domain_states[domain];
pdom = &g_pmglobals.domain[domain];
state = PM_NORMAL;
@ -124,11 +137,14 @@ static enum pm_state_e greedy_governor_checkstate(int domain)
flags = pm_lock(domain);
/* Find the lowest power-level which is not locked. */
while (!pdom->stay[state] && state < (PM_COUNT - 1))
if (!WDOG_ISACTIVE(&pdomstate->wdog))
{
state++;
/* Find the lowest power-level which is not locked. */
while (!pdom->stay[state] && state < (PM_COUNT - 1))
{
state++;
}
}
pm_unlock(domain, flags);
@ -138,6 +154,37 @@ static enum pm_state_e greedy_governor_checkstate(int domain)
return state;
}
/****************************************************************************
* Name: governor_timer_cb
****************************************************************************/
static void greedy_governor_timer_cb(wdparm_t arg)
{
}
/****************************************************************************
* Name: greedy_activity
****************************************************************************/
static void greedy_governor_activity(int domain, int count)
{
FAR struct pm_domain_state_s *pdomstate;
irqstate_t flags;
pdomstate = &g_pm_greedy_governor.domain_states[domain];
count = count ? count : 1;
flags = pm_lock(domain);
if (TICK2SEC(wd_gettime(&pdomstate->wdog)) < count)
{
wd_start(&pdomstate->wdog, SEC2TICK(count),
greedy_governor_timer_cb, (wdparm_t)domain);
}
pm_unlock(domain, flags);
}
/****************************************************************************
* Public Functions
****************************************************************************/