From 76c4b11a6b560696293e8d198131dd2e09d77ba5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 27 Mar 2016 13:02:21 -0600 Subject: [PATCH] PM: Add domain to all PM interfaces. Internal PM data structures now handle multiple PM domains. --- configs/mikroe-stm32f4/src/stm32_idle.c | 2 +- configs/stm3210e-eval/pm/defconfig | 18 ++++++++++++++++++ configs/stm3210e-eval/src/stm32_buttons.c | 4 ---- configs/stm3210e-eval/src/stm32_idle.c | 2 +- configs/stm3210e-eval/src/stm32_pmbuttons.c | 6 ++++-- configs/stm32f429i-disco/src/stm32_idle.c | 2 +- configs/stm32f4discovery/src/stm32_idle.c | 4 ++-- configs/stm32f4discovery/src/stm32_pmbuttons.c | 6 ++++-- configs/stm32l476vg-disco/src/stm32_buttons.c | 14 ++++++++------ 9 files changed, 39 insertions(+), 19 deletions(-) diff --git a/configs/mikroe-stm32f4/src/stm32_idle.c b/configs/mikroe-stm32f4/src/stm32_idle.c index 1866b7700b..12c855b497 100644 --- a/configs/mikroe-stm32f4/src/stm32_idle.c +++ b/configs/mikroe-stm32f4/src/stm32_idle.c @@ -119,7 +119,7 @@ static void up_idlepm(void) /* Decide, which power saving level can be obtained */ - newstate = pm_checkstate(); + newstate = pm_checkstate(PM_IDLE_DOMAIN); /* Check for state changes */ diff --git a/configs/stm3210e-eval/pm/defconfig b/configs/stm3210e-eval/pm/defconfig index 568ed35536..aa23e70615 100644 --- a/configs/stm3210e-eval/pm/defconfig +++ b/configs/stm3210e-eval/pm/defconfig @@ -760,6 +760,24 @@ CONFIG_LCD_RPORTRAIT=y # CONFIG_EEPROM is not set # CONFIG_PIPES is not set CONFIG_PM=y +CONFIG_PM_SLICEMS=100 +CONFIG_PM_NDOMAINS=1 +CONFIG_PM_MEMORY=2 +CONFIG_PM_COEFN=1 +CONFIG_PM_COEF1=1 +CONFIG_PM_COEF2=1 +CONFIG_PM_COEF3=1 +CONFIG_PM_COEF4=1 +CONFIG_PM_COEF5=1 +CONFIG_PM_IDLEENTER_THRESH=1 +CONFIG_PM_IDLEEXIT_THRESH=2 +CONFIG_PM_IDLEENTER_COUNT=30 +CONFIG_PM_STANDBYENTER_THRESH=1 +CONFIG_PM_STANDBYEXIT_THRESH=2 +CONFIG_PM_STANDBYENTER_COUNT=50 +CONFIG_PM_SLEEPENTER_THRESH=1 +CONFIG_PM_SLEEPEXIT_THRESH=2 +CONFIG_PM_SLEEPENTER_COUNT=70 # CONFIG_POWER is not set # CONFIG_SENSORS is not set # CONFIG_SERCOMM_CONSOLE is not set diff --git a/configs/stm3210e-eval/src/stm32_buttons.c b/configs/stm3210e-eval/src/stm32_buttons.c index df32685565..526309f017 100644 --- a/configs/stm3210e-eval/src/stm32_buttons.c +++ b/configs/stm3210e-eval/src/stm32_buttons.c @@ -49,10 +49,6 @@ #ifdef CONFIG_ARCH_BUTTONS -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - /**************************************************************************** * Private Data ****************************************************************************/ diff --git a/configs/stm3210e-eval/src/stm32_idle.c b/configs/stm3210e-eval/src/stm32_idle.c index 4930e1433b..aba327a64c 100644 --- a/configs/stm3210e-eval/src/stm32_idle.c +++ b/configs/stm3210e-eval/src/stm32_idle.c @@ -283,7 +283,7 @@ static void stm32_idlepm(void) { /* Let the PM system decide, which power saving level can be obtained */ - newstate = pm_checkstate(); + newstate = pm_checkstate(PM_IDLE_DOMAIN); } /* Check for state changes */ diff --git a/configs/stm3210e-eval/src/stm32_pmbuttons.c b/configs/stm3210e-eval/src/stm32_pmbuttons.c index 9f722ea5ee..49be1db7e2 100644 --- a/configs/stm3210e-eval/src/stm32_pmbuttons.c +++ b/configs/stm3210e-eval/src/stm32_pmbuttons.c @@ -1,7 +1,7 @@ /**************************************************************************** * configs/stm3210e-eval/src/stm32_pmbuttons.c * - * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015-2016 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * Diego Sanchez * @@ -111,6 +111,8 @@ # define CONFIG_PM_BUTTON_ACTIVITY 10 #endif +#define PM_IDLE_DOMAIN 0 /* Revisit */ + /* Miscellaneous Definitions ************************************************/ #ifndef MIN @@ -221,7 +223,7 @@ static void button_handler(int id, int irq) * special happened. */ - pm_activity(CONFIG_PM_BUTTON_ACTIVITY); + pm_activity(PM_IDLE_DOMAIN, CONFIG_PM_BUTTON_ACTIVITY); } #if MIN_BUTTON < 1 diff --git a/configs/stm32f429i-disco/src/stm32_idle.c b/configs/stm32f429i-disco/src/stm32_idle.c index b67073b8c2..1654e0fed2 100644 --- a/configs/stm32f429i-disco/src/stm32_idle.c +++ b/configs/stm32f429i-disco/src/stm32_idle.c @@ -119,7 +119,7 @@ static void stm32_idlepm(void) /* Decide, which power saving level can be obtained */ - newstate = pm_checkstate(); + newstate = pm_checkstate(PM_IDLE_DOMAIN); /* Check for state changes */ diff --git a/configs/stm32f4discovery/src/stm32_idle.c b/configs/stm32f4discovery/src/stm32_idle.c index 58fe9423cb..0e0ead8360 100644 --- a/configs/stm32f4discovery/src/stm32_idle.c +++ b/configs/stm32f4discovery/src/stm32_idle.c @@ -116,7 +116,7 @@ static void stm32_idlepm(void) /* Decide, which power saving level can be obtained */ - newstate = pm_checkstate(); + newstate = pm_checkstate(PM_IDLE_DOMAIN); /* Check for state changes */ @@ -133,7 +133,7 @@ static void stm32_idlepm(void) { /* The new state change failed, revert to the preceding state */ - (void)pm_changestatePM_IDLE_DOMAIN, oldstate); + (void)pm_changestate(PM_IDLE_DOMAIN, oldstate); /* No state change... */ diff --git a/configs/stm32f4discovery/src/stm32_pmbuttons.c b/configs/stm32f4discovery/src/stm32_pmbuttons.c index d6b7dfbda7..0ca71c9dcd 100644 --- a/configs/stm32f4discovery/src/stm32_pmbuttons.c +++ b/configs/stm32f4discovery/src/stm32_pmbuttons.c @@ -1,7 +1,7 @@ /**************************************************************************** * configs/stm32f4discovery/src/stm32_pm_buttons.c * - * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015-2016 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * Diego Sanchez * @@ -73,6 +73,8 @@ # define CONFIG_PM_BUTTON_ACTIVITY 10 #endif +#define PM_IDLE_DOMAIN 0 /* Revisit */ + /**************************************************************************** * Private Types ****************************************************************************/ @@ -111,7 +113,7 @@ static int button_handler(int irq, FAR void *context) * special happened. */ - pm_activity(CONFIG_PM_BUTTON_ACTIVITY); + pm_activity(PM_IDLE_DOMAIN, CONFIG_PM_BUTTON_ACTIVITY); return OK; } #endif /* CONFIG_ARCH_IRQBUTTONS */ diff --git a/configs/stm32l476vg-disco/src/stm32_buttons.c b/configs/stm32l476vg-disco/src/stm32_buttons.c index f4adf5d7a0..6a49927e80 100644 --- a/configs/stm32l476vg-disco/src/stm32_buttons.c +++ b/configs/stm32l476vg-disco/src/stm32_buttons.c @@ -54,10 +54,12 @@ * Pre-processor Definitions ****************************************************************************/ - #ifndef CONFIG_PM_BUTTON_ACTIVITY +#ifndef CONFIG_PM_BUTTON_ACTIVITY # define CONFIG_PM_BUTTON_ACTIVITY 10 #endif +#define PM_IDLE_DOMAIN 0 /* Revisit */ + /**************************************************************************** * Private Function Prototypes ****************************************************************************/ @@ -176,6 +178,7 @@ static void button_pm_notify(struct pm_callback_s *cb, int domain, #ifdef CONFIG_ARCH_IRQBUTTONS static int button_handler(int irq, FAR void *context) { +#ifdef CONFIG_PM /* At this point the MCU should have already awakened. The state * change will be handled in the IDLE loop when the system is re-awakened * The button interrupt handler should be totally ignorant of the PM @@ -183,8 +186,7 @@ static int button_handler(int irq, FAR void *context) * special happened. */ -#ifdef CONFIG_PM - pm_activity(CONFIG_PM_BUTTON_ACTIVITY); + pm_activity(PM_IDLE_DOMAIN, CONFIG_PM_BUTTON_ACTIVITY); #endif return OK; } @@ -285,14 +287,14 @@ uint8_t board_buttons(void) } } +#ifdef CONFIG_PM /* if the user pressed any buttons, notify power management system we are * active */ -#ifdef CONFIG_PM - if ( 0 != ret ) + if (0 != ret) { - pm_activity(CONFIG_PM_BUTTON_ACTIVITY); + pm_activity(PM_IDLE_DOMAIN, CONFIG_PM_BUTTON_ACTIVITY); } #endif