1menu "Power Management"
2    config PM_ENABLE
3        bool "Support for power management"
4        # SMP FreeRTOS currently does not support power management IDF-4997
5        depends on !FREERTOS_SMP
6        default n
7        help
8            If enabled, application is compiled with support for power management.
9            This option has run-time overhead (increased interrupt latency,
10            longer time to enter idle state), and it also reduces accuracy of
11            RTOS ticks and timers used for timekeeping.
12            Enable this option if application uses power management APIs.
13
14    config PM_DFS_INIT_AUTO
15        bool "Enable dynamic frequency scaling (DFS) at startup"
16        depends on PM_ENABLE
17        default n
18        help
19            If enabled, startup code configures dynamic frequency scaling.
20            Max CPU frequency is set to DEFAULT_CPU_FREQ_MHZ setting,
21            min frequency is set to XTAL frequency.
22            If disabled, DFS will not be active until the application
23            configures it using esp_pm_configure function.
24
25    config PM_PROFILING
26        bool "Enable profiling counters for PM locks"
27        depends on PM_ENABLE
28        default n
29        help
30            If enabled, esp_pm_* functions will keep track of the amount of time
31            each of the power management locks has been held, and esp_pm_dump_locks
32            function will print this information.
33            This feature can be used to analyze which locks are preventing the chip
34            from going into a lower power state, and see what time the chip spends
35            in each power saving mode. This feature does incur some run-time
36            overhead, so should typically be disabled in production builds.
37
38    config PM_TRACE
39        bool "Enable debug tracing of PM using GPIOs"
40        depends on PM_ENABLE
41        default n
42        help
43            If enabled, some GPIOs will be used to signal events such as RTOS ticks,
44            frequency switching, entry/exit from idle state. Refer to pm_trace.c
45            file for the list of GPIOs.
46            This feature is intended to be used when analyzing/debugging behavior
47            of power management implementation, and should be kept disabled in
48            applications.
49
50    config PM_SLP_IRAM_OPT
51        bool "Put lightsleep related codes in internal RAM"
52        depends on FREERTOS_USE_TICKLESS_IDLE
53        help
54            If enabled, about 1.8KB of lightsleep related source code would be in IRAM and chip would sleep
55            longer for 760us at most each time.
56            This feature is intended to be used when lower power consumption is needed
57            while there is enough place in IRAM to place source code.
58
59    config PM_RTOS_IDLE_OPT
60        bool "Put RTOS IDLE related codes in internal RAM"
61        depends on FREERTOS_USE_TICKLESS_IDLE
62        help
63            If enabled, about 260B of RTOS_IDLE related source code would be in IRAM and chip would sleep
64            longer for 40us at most each time.
65            This feature is intended to be used when lower power consumption is needed
66            while there is enough place in IRAM to place source code.
67
68    config PM_SLP_DISABLE_GPIO
69        bool "Disable all GPIO when chip at sleep"
70        depends on FREERTOS_USE_TICKLESS_IDLE
71        help
72            This feature is intended to disable all GPIO pins at automantic sleep to get a lower power mode.
73            If enabled, chips will disable all GPIO pins at automantic sleep to reduce about 200~300 uA current.
74            If you want to specifically use some pins normally as chip wakes when chip sleeps,
75            you can call 'gpio_sleep_sel_dis' to disable this feature on those pins.
76            You can also keep this feature on and call 'gpio_sleep_set_direction' and 'gpio_sleep_set_pull_mode'
77            to have a different GPIO configuration at sleep.
78            Waring: If you want to enable this option on ESP32, you should enable `GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL`
79            at first, otherwise you will not be able to switch pullup/pulldown mode.
80
81    config PM_SLP_DEFAULT_PARAMS_OPT
82        bool
83        default n
84
85    config PM_CHECK_SLEEP_RETENTION_FRAME
86        bool
87        depends on PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
88        default n if !IDF_CI_BUILD
89        help
90            This option is invisible to users, and it is only used for ci testing,
91            enabling it in the application will increase the sleep and wake-up time overhead
92
93    config PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
94        bool "Power down CPU in light sleep"
95        depends on SOC_PM_SUPPORT_CPU_PD
96        select PM_POWER_DOWN_TAGMEM_IN_LIGHT_SLEEP if ESP32S3_DATA_CACHE_16KB
97        default y
98        help
99            If enabled, the CPU will be powered down in light sleep. On esp32c3 soc, enabling this
100            option will consume 1.68 KB of internal RAM and will reduce sleep current consumption
101            by about 100 uA. On esp32s3 soc, enabling this option will consume 8.58 KB of internal
102            RAM and will reduce sleep current consumption by about 650 uA.
103
104    config PM_POWER_DOWN_TAGMEM_IN_LIGHT_SLEEP
105        bool "Power down I/D-cache tag memory in light sleep"
106        depends on IDF_TARGET_ESP32S3 && PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
107        default y
108        help
109            If enabled, the I/D-cache tag memory will be retained in light sleep. Depending on the the
110            cache configuration, if this option is enabled, it will consume up to 9 KB of internal RAM.
111
112    config PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
113        bool "Power down Digital Peripheral in light sleep (EXPERIMENTAL)"
114        depends on SOC_PAU_SUPPORTED
115        default n #TODO: enable by default if periph init/deinit management supported (WIFI-5252)
116        help
117            If enabled, digital peripherals will be powered down in light sleep, it will reduce sleep
118            current consumption by about 100 uA. Chip will save/restore register context at sleep/wake
119            time to keep the system running. Enabling this option will increase static RAM and heap usage,
120            the actual cost depends on the peripherals you have initialized. In order to save/restore the
121            context of the necessary hardware for FreeRTOS to run, it will need at least 4.55 KB free heap
122            at sleep time. Otherwise sleep will not power down the peripherals.
123
124            Note1: Please use this option with caution, the current IDF does not support the retention of
125            all peripherals. When the digital peripherals are powered off and a sleep and wake-up is completed,
126            the peripherals that have not saved the running context are equivalent to performing a reset.
127            !!! Please confirm the peripherals used in your application and their sleep retention support status
128            before enabling this option, peripherals sleep retention driver support status is tracked in
129            power_management.rst
130
131            Note2: When this option is enabled simultaneously with FREERTOS_USE_TICKLESS_IDLE, since the UART will
132            be powered down, the uart FIFO will be flushed before sleep to avoid data loss, however, this has the
133            potential to block the sleep process and cause the wakeup time to be skipped, which will cause the tick
134            of freertos to not be compensated correctly when returning from sleep and cause the system to crash.
135            To avoid this, you can increase FREERTOS_IDLE_TIME_BEFORE_SLEEP threshold in menuconfig.
136
137    config PM_UPDATE_CCOMPARE_HLI_WORKAROUND
138        bool
139        default y if PM_ENABLE && BTDM_CTRL_HLI
140
141endmenu # "Power Management"
142