From 970822b351bcb1922c05ee67e7b8dab10a5c263a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 27 Mar 2016 10:18:20 -0600 Subject: [PATCH] Add missing PM configuratin options to Kconfig file --- configs | 2 +- drivers/Kconfig | 18 --- drivers/power/Kconfig | 231 +++++++++++++++++++++++++++++++++++++++ include/nuttx/power/pm.h | 32 ++++-- 4 files changed, 257 insertions(+), 26 deletions(-) diff --git a/configs b/configs index 1c7f6821663..ed6b75b8a05 160000 --- a/configs +++ b/configs @@ -1 +1 @@ -Subproject commit 1c7f6821663ed326f2109183d945413c2bb33997 +Subproject commit ed6b75b8a0531a2d59629d0a128f01b89b5f32f6 diff --git a/drivers/Kconfig b/drivers/Kconfig index d9105fcd947..6cc4ea3d869 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -471,25 +471,7 @@ if PIPES source drivers/pipes/Kconfig endif # PIPES -config PM - bool "Power management (PM) driver interfaces" - default n - ---help--- - Power management (PM) driver interfaces. These interfaces are used - to manage power usage of a platform by monitoring driver activity - and by placing drivers into reduce power usage modes when the - drivers are not active. - -menuconfig POWER - bool "Power Management Support" - default n - ---help--- - Enable building of power-related devices (battery monitors, chargers, - etc). - -if POWER source drivers/power/Kconfig -endif # POWER menuconfig SENSORS bool "Sensor Device Support" diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 4084a5284b7..891fc1be240 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -3,6 +3,235 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +menuconfig PM + bool "Power management (PM) driver interfaces" + default n + ---help--- + Power management (PM) driver interfaces. These interfaces are used + to manage power usage of a platform by monitoring driver activity + and by placing drivers into reduce power usage modes when the + drivers are not active. + +if PM + +config PM_SLICEMS + int "PM time slice (msec)" + default 100 + ---help--- + The power management module collects activity counts in time slices. + At the end of the time slice, the count accumulated during that + interval is applied to an averaging algorithm to determine the + activity level. + + CONFIG_PM_SLICEMS provides the duration of that time slice in + milliseconds. Default: 100 Milliseconds + +config PM_MEMORY + int "PM memory (msec)" + default 2 + range 1 6 + ---help--- + The averaging algorithm is simply: Y = (An*X + SUM(Ai*Yi))/SUM(Aj), + where i = 1..n-1 and j= 1..n, n is the length of the "memory", + Ai is the weight applied to each value, and X is the current + activity. These weights may be negative and a limited to the + range of int16_t. + + CONFIG_PM_MEMORY provides the memory for the algorithm. Default: 2 + CONFIG_PM_COEFn provides weight for each sample. Default: 1 + + Setting CONFIG_PM_MEMORY=1 disables all smoothing. + +config PM_COEFN + int "PM coefficient" + default 1 + ---help--- + See help associated with CONFIG_PM_MEMORY. + +config PM_COEF1 + int "PM coefficient 1" + default 1 + ---help--- + See help associated with CONFIG_PM_MEMORY. + +config PM_COEF2 + int "PM coefficient 2" + default 1 + ---help--- + See help associated with CONFIG_PM_MEMORY + + Ignored if CONFIG_PM_MEMORY <= 2 + +config PM_COEF3 + int "PM coefficient 3" + default 1 + ---help--- + See help associated with CONFIG_PM_MEMORY + + Ignored if CONFIG_PM_MEMORY <= 3 + +config PM_COEF4 + int "PM coefficient 4" + default 1 + ---help--- + See help associated with CONFIG_PM_MEMORY + + Ignored if CONFIG_PM_MEMORY <= 4 + +config PM_COEF5 + int "PM coefficient 5" + default 1 + ---help--- + See help associated with CONFIG_PM_MEMORY + + Ignored if CONFIG_PM_MEMORY <= 5 + +config PM_IDLEENTER_THRESH + int "PM IDLE enter threshold" + default 1 + ---help--- + State changes then occur when the weight activity account crosses + threshold values for certain periods of time (time slice count). + + CONFIG_PM_xxxENTER_THRESH is the threshold value for entering state xxx. + CONFIG_PM_xxxENTER_COUNT is the count for entering state xxx. + + Resuming to normal state, on the other hand, is usually immediate and + controlled by wakeup conditions established by the platform. The PM + + Default: <=1: Essentially no activity + +config PM_IDLEEXIT_THRESH + int "PM IDLE exit threshold" + default 2 + ---help--- + State changes then occur when the weight activity account crosses + threshold values for certain periods of time (time slice count). + + CONFIG_PM_xxxENTER_THRESH is the threshold value for entering state xxx. + CONFIG_PM_xxxENTER_COUNT is the count for entering state xxx. + + Resuming to normal state, on the other hand, is usually immediate and + controlled by wakeup conditions established by the platform. The PM + + Default: >=2: Active + +config PM_IDLEENTER_COUNT + int "PM IDLE enter count" + default 30 + ---help--- + State changes then occur when the weight activity account crosses + threshold values for certain periods of time (time slice count). + + CONFIG_PM_xxxENTER_THRESH is the threshold value for entering state xxx. + CONFIG_PM_xxxENTER_COUNT is the count for entering state xxx. + + Resuming to normal state, on the other hand, is usually immediate and + controlled by wakeup conditions established by the platform. The PM + + Default: Thirty IDLE slices to enter IDLE mode from normal + +config PM_STANDBYENTER_THRESH + int "PM STANDBY enter threshold" + default 1 + ---help--- + State changes then occur when the weight activity account crosses + threshold values for certain periods of time (time slice count). + + CONFIG_PM_xxxENTER_THRESH is the threshold value for entering state xxx. + CONFIG_PM_xxxENTER_COUNT is the count for entering state xxx. + + Resuming to normal state, on the other hand, is usually immediate and + controlled by wakeup conditions established by the platform. The PM + + Default: <=1: Essentially no activity + +config PM_STANDBYEXIT_THRESH + int "PM STANDBY exit threshold" + default 2 + ---help--- + State changes then occur when the weight activity account crosses + threshold values for certain periods of time (time slice count). + + CONFIG_PM_xxxENTER_THRESH is the threshold value for entering state xxx. + CONFIG_PM_xxxENTER_COUNT is the count for entering state xxx. + + Resuming to normal state, on the other hand, is usually immediate and + controlled by wakeup conditions established by the platform. The PM + + Default: >=2: Active + +config PM_STANDBYENTER_COUNT + int "PM STANDBY enter count" + default 50 + ---help--- + State changes then occur when the weight activity account crosses + threshold values for certain periods of time (time slice count). + + CONFIG_PM_xxxENTER_THRESH is the threshold value for entering state xxx. + CONFIG_PM_xxxENTER_COUNT is the count for entering state xxx. + + Resuming to normal state, on the other hand, is usually immediate and + controlled by wakeup conditions established by the platform. The PM + + Default: Fifty IDLE slices to enter STANDBY mode from IDLE + +config PM_SLEEPENTER_THRESH + int "PM SLEEP enter threshold" + default 1 + ---help--- + State changes then occur when the weight activity account crosses + threshold values for certain periods of time (time slice count). + + CONFIG_PM_xxxENTER_THRESH is the threshold value for entering state xxx. + CONFIG_PM_xxxENTER_COUNT is the count for entering state xxx. + + Resuming to normal state, on the other hand, is usually immediate and + controlled by wakeup conditions established by the platform. The PM + + Default: <=1: Essentially no activity + +config PM_SLEEPEXIT_THRESH + int "PM SLEEP exit threshold" + default 2 + ---help--- + State changes then occur when the weight activity account crosses + threshold values for certain periods of time (time slice count). + + CONFIG_PM_xxxENTER_THRESH is the threshold value for entering state xxx. + CONFIG_PM_xxxENTER_COUNT is the count for entering state xxx. + + Resuming to normal state, on the other hand, is usually immediate and + controlled by wakeup conditions established by the platform. The PM + + Default: >=2: Active + +config PM_SLEEPENTER_COUNT + int "PM SLEEP enter count" + default 50 + ---help--- + State changes then occur when the weight activity account crosses + threshold values for certain periods of time (time slice count). + + CONFIG_PM_xxxENTER_THRESH is the threshold value for entering state xxx. + CONFIG_PM_xxxENTER_COUNT is the count for entering state xxx. + + Resuming to normal state, on the other hand, is usually immediate and + controlled by wakeup conditions established by the platform. The PM + + Default: Fifty IDLE slices to enter SLEEP mode from STANDBY + +endif # PM + +menuconfig POWER + bool "Power Management Support" + default n + ---help--- + Enable building of power-related devices (battery monitors, chargers, + etc). + +if POWER + config BATTERY_CHARGER bool "Battery Charger support" default n @@ -39,3 +268,5 @@ config I2C_BQ2425X config I2C_MAX1704X bool default y if MAX1704X + +endif # POWER diff --git a/include/nuttx/power/pm.h b/include/nuttx/power/pm.h index 16f4d6f02df..bb39dbdcb0e 100644 --- a/include/nuttx/power/pm.h +++ b/include/nuttx/power/pm.h @@ -2,7 +2,7 @@ * include/nuttx/power/pm.h * NuttX Power Management Interfaces * - * Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -78,24 +78,42 @@ * 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 */ -/* Time slices. The power management module collects activity counts in - * time slices. At the end of the time slice, the count accumulated during - * that interval is applied to an averaging algorithm to determine the - * activity level. +/* CONFIG_PM_SLICEMS. The power management module collects activity counts + * in time slices. At the end of the time slice, the count accumulated + * during that interval is applied to an averaging algorithm to determine + * the activity level. * - * CONFIG_PM_SLICEMS provides the duration of that time slice. Default: 100 - * Milliseconds + * CONFIG_PM_SLICEMS provides the duration of that time slice in + * milliseconds. Default: 100 Milliseconds */ #ifndef CONFIG_PM_SLICEMS # define CONFIG_PM_SLICEMS 100 /* Default is 100 msec */ #endif +#if CONFIG_PM_SLICEMS < 1 +# error CONFIG_PM_SLICEMS invalid +#endif + /* The averaging algorithm is simply: Y = (An*X + SUM(Ai*Yi))/SUM(Aj), where * i = 1..n-1 and j= 1..n, n is the length of the "memory", Ai is the * weight applied to each value, and X is the current activity. These weights