Skip to content

Commit 9151fbe

Browse files
committed
power: rename APIs and removing leading _
Remove leading underscore from PM APIs. _ was used for internal APIs. Signed-off-by: Anas Nashif <[email protected]>
1 parent 68086c0 commit 9151fbe

File tree

26 files changed

+117
-117
lines changed

26 files changed

+117
-117
lines changed

arch/arc/core/reset.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ done_cache_invalidate:
9090

9191
#if defined(CONFIG_SYS_POWER_DEEP_SLEEP) && \
9292
!defined(CONFIG_BOOTLOADER_CONTEXT_RESTORE)
93-
jl @_sys_soc_resume_from_deep_sleep
93+
jl @sys_soc_resume_from_deep_sleep
9494
#endif
9595

9696
#ifdef CONFIG_INIT_STACKS

arch/x86/core/crt0.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#endif
4040

4141
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP
42-
GTEXT(_sys_soc_resume_from_deep_sleep)
42+
GTEXT(sys_soc_resume_from_deep_sleep)
4343
#endif
4444

4545
#ifdef CONFIG_REALMODE
@@ -255,13 +255,13 @@ __csSet:
255255
* the ISR stack size are some multiple of STACK_ALIGN, which
256256
* is at least 4.
257257
*
258-
* This is also used to call the _sys_soc_resume_from_deep_sleep()
258+
* This is also used to call the sys_soc_resume_from_deep_sleep()
259259
* routine to avoid memory corruption if the system is resuming from
260-
* deep sleep. It is important that _sys_soc_resume_from_deep_sleep()
260+
* deep sleep. It is important that sys_soc_resume_from_deep_sleep()
261261
* restores the stack pointer to what it was at deep sleep before
262262
* enabling interrupts. This is necessary to avoid
263263
* interfering with interrupt handler use of this stack.
264-
* If it is a cold boot then _sys_soc_resume_from_deep_sleep() should
264+
* If it is a cold boot then sys_soc_resume_from_deep_sleep() should
265265
* not do anything and must return immediately.
266266
*/
267267
#ifdef CONFIG_INIT_STACKS
@@ -287,7 +287,7 @@ __csSet:
287287
#if defined(CONFIG_SYS_POWER_DEEP_SLEEP) && \
288288
!defined(CONFIG_BOOTLOADER_CONTEXT_RESTORE)
289289
/*
290-
* Invoke _sys_soc_resume_from_deep_sleep() hook to handle resume from
290+
* Invoke sys_soc_resume_from_deep_sleep() hook to handle resume from
291291
* deep sleep. It should first check whether system is recovering from
292292
* deep sleep state. If it is, then this function should restore
293293
* states and resume at the point system went to deep sleep.
@@ -298,7 +298,7 @@ __csSet:
298298
* return and execution falls through to cold boot path.
299299
*/
300300

301-
call _sys_soc_resume_from_deep_sleep
301+
call sys_soc_resume_from_deep_sleep
302302

303303
#endif
304304

doc/subsystems/power_management.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ Suspend Hook function
103103

104104
.. code-block:: c
105105
106-
int _sys_soc_suspend(s32_t ticks);
106+
int sys_soc_suspend(s32_t ticks);
107107
108108
When the kernel is about to go idle, the power management subsystem calls the
109-
:code:`_sys_soc_suspend()` function, notifying the SOC interface that the kernel
109+
:code:`sys_soc_suspend()` function, notifying the SOC interface that the kernel
110110
is ready to enter the idle state.
111111

112112
At this point, the kernel has disabled interrupts and computed the maximum
@@ -116,7 +116,7 @@ can be done in the available time. The power management operation must halt
116116
execution on a CPU or SOC low power state. Before entering the low power state,
117117
the SOC interface must setup a wake event.
118118

119-
The power management subsystem expects the :code:`_sys_soc_suspend()` to
119+
The power management subsystem expects the :code:`sys_soc_suspend()` to
120120
return one of the following values based on the power management operations
121121
the SOC interface executed:
122122

@@ -137,22 +137,22 @@ Resume Hook function
137137

138138
.. code-block:: c
139139
140-
void _sys_soc_resume(void);
140+
void sys_soc_resume(void);
141141
142142
The power management subsystem optionally calls this hook function when exiting
143143
kernel idling if power management operations were performed in
144-
:code:`_sys_soc_suspend()`. Any necessary recovery operations can be performed
144+
:code:`sys_soc_suspend()`. Any necessary recovery operations can be performed
145145
in this function before the kernel scheduler schedules another thread. Some
146146
power states may not need this notification. It can be disabled by calling
147-
:code:`_sys_soc_pm_idle_exit_notification_disable()` from
148-
:code:`_sys_soc_suspend()`.
147+
:code:`sys_soc_pm_idle_exit_notification_disable()` from
148+
:code:`sys_soc_suspend()`.
149149

150150
Resume From Deep Sleep Hook function
151151
====================================
152152

153153
.. code-block:: c
154154
155-
void _sys_soc_resume_from_deep_sleep(void);
155+
void sys_soc_resume_from_deep_sleep(void);
156156
157157
This function is optionally called when exiting from deep sleep if the SOC
158158
interface does not have bootloader support to handle resume from deep sleep.
@@ -231,7 +231,7 @@ in power saving mode. This method allows saving power even when the CPU is
231231
active. The components that use the devices need to be power aware and should
232232
be able to make decisions related to managing device power. In this method, the
233233
SOC interface can enter CPU or SOC low power states quickly when
234-
:code:`_sys_soc_suspend()` gets called. This is because it does not need to
234+
:code:`sys_soc_suspend()` gets called. This is because it does not need to
235235
spend time doing device power management if the devices are already put in
236236
the appropriate low power state by the application or component managing the
237237
devices.
@@ -240,7 +240,7 @@ Central method
240240
==============
241241

242242
In this method device power management is mostly done inside
243-
:code:`_sys_soc_suspend()` along with entering a CPU or SOC low power state.
243+
:code:`sys_soc_suspend()` along with entering a CPU or SOC low power state.
244244

245245
If a decision to enter deep sleep is made, the implementation would enter it
246246
only after checking if the devices are not in the middle of a hardware
@@ -380,21 +380,21 @@ off, then such transactions would be left in an inconsistent state. This
380380
infrastructure guards such transactions by indicating to the SOC interface that
381381
the device is in the middle of a hardware transaction.
382382

383-
When the :code:`_sys_soc_suspend()` is called, the SOC interface checks if any device
383+
When the :code:`sys_soc_suspend()` is called, the SOC interface checks if any device
384384
is busy. The SOC interface can then decide to execute a power management scheme other than deep sleep or
385385
to defer power management operations until the next call of
386-
:code:`_sys_soc_suspend()`.
386+
:code:`sys_soc_suspend()`.
387387

388388
An alternative to using the busy status mechanism is to use the
389389
`distributed method`_ of device power management. In such a method where the
390390
device power management is handled in a distributed manner rather than centrally in
391-
:code:`_sys_soc_suspend()`, the decision to enter deep sleep can be made based
391+
:code:`sys_soc_suspend()`, the decision to enter deep sleep can be made based
392392
on whether all devices are already turned off.
393393

394394
This feature can be also used to emulate a hardware feature found in some SOCs
395395
that causes the system to automatically enter deep sleep when all devices are idle.
396396
In such an usage, the busy status can be set by default and cleared as each
397-
device becomes idle. When :code:`_sys_soc_suspend()` is called, deep sleep can
397+
device becomes idle. When :code:`sys_soc_suspend()` is called, deep sleep can
398398
be entered if no device is found to be busy.
399399

400400
Here are the APIs used to set, clear, and check the busy status of devices.

drivers/i2c/i2c_dw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ static int i2c_dw_transfer(struct device *dev,
433433

434434
/*
435435
* While waiting at device_sync_sem, kernel can switch to idle
436-
* task which in turn can call _sys_soc_suspend() hook of Power
436+
* task which in turn can call sys_soc_suspend() hook of Power
437437
* Management App (PMA).
438438
* device_busy_set() call here, would indicate to PMA that it should not
439439
* execute PM policies that would turn off this ip block, causing an

include/power.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern "C" {
2020

2121
#define SYS_PM_NOT_HANDLED SYS_PM_ACTIVE_STATE
2222

23-
extern unsigned char _sys_pm_idle_exit_notify;
23+
extern unsigned char sys_pm_idle_exit_notify;
2424

2525

2626
/**
@@ -40,15 +40,15 @@ extern unsigned char _sys_pm_idle_exit_notify;
4040
/**
4141
* @brief Function to disable power management idle exit notification
4242
*
43-
* _sys_soc_resume() would be called from the ISR of the event that caused
43+
* sys_soc_resume() would be called from the ISR of the event that caused
4444
* exit from kernel idling after PM operations. For some power operations,
4545
* this notification may not be necessary. This function can be called in
46-
* _sys_soc_suspend to disable the corresponding _sys_soc_resume notification.
46+
* sys_soc_suspend to disable the corresponding sys_soc_resume notification.
4747
*
4848
*/
49-
static inline void _sys_soc_pm_idle_exit_notification_disable(void)
49+
static inline void sys_soc_pm_idle_exit_notification_disable(void)
5050
{
51-
_sys_pm_idle_exit_notify = 0;
51+
sys_pm_idle_exit_notify = 0;
5252
}
5353

5454
/**
@@ -66,13 +66,13 @@ static inline void _sys_soc_pm_idle_exit_notification_disable(void)
6666
* function should return immediately.
6767
*
6868
*/
69-
void _sys_soc_resume_from_deep_sleep(void);
69+
void sys_soc_resume_from_deep_sleep(void);
7070

7171
/**
7272
* @brief Hook function to notify exit from kernel idling after PM operations
7373
*
7474
* This function would notify exit from kernel idling if a corresponding
75-
* _sys_soc_suspend() notification was handled and did not return
75+
* sys_soc_suspend() notification was handled and did not return
7676
* SYS_PM_NOT_HANDLED.
7777
*
7878
* This function would be called from the ISR context of the event
@@ -84,11 +84,11 @@ void _sys_soc_resume_from_deep_sleep(void);
8484
* those cases, the ISR would be invoked immediately after the event wakes up
8585
* the CPU, before code following the CPU wait, gets a chance to execute. This
8686
* can be ignored if no operation needs to be done at the wake event
87-
* notification. Alternatively _sys_soc_pm_idle_exit_notification_disable() can
88-
* be called in _sys_soc_suspend to disable this notification.
87+
* notification. Alternatively sys_soc_pm_idle_exit_notification_disable() can
88+
* be called in sys_soc_suspend to disable this notification.
8989
*
9090
*/
91-
void _sys_soc_resume(void);
91+
void sys_soc_resume(void);
9292

9393
/**
9494
* @brief Hook function to allow entry to low power state
@@ -116,7 +116,7 @@ void _sys_soc_resume(void);
116116
* @retval SYS_PM_LOW_POWER_STATE If CPU low power state was entered.
117117
* @retval SYS_PM_DEEP_SLEEP If SOC low power state was entered.
118118
*/
119-
extern int _sys_soc_suspend(s32_t ticks);
119+
extern int sys_soc_suspend(s32_t ticks);
120120

121121
#ifdef CONFIG_PM_CONTROL_OS_DEBUG
122122
/**

kernel/idle.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
2121

2222
#ifdef CONFIG_SYS_POWER_MANAGEMENT
2323
/*
24-
* Used to allow _sys_soc_suspend() implementation to control notification
24+
* Used to allow sys_soc_suspend() implementation to control notification
2525
* of the event that caused exit from kernel idling after pm operations.
2626
*/
27-
unsigned char _sys_pm_idle_exit_notify;
27+
unsigned char sys_pm_idle_exit_notify;
2828

2929
#if defined(CONFIG_SYS_POWER_LOW_POWER_STATE)
30-
void __attribute__((weak)) _sys_soc_resume(void)
30+
void __attribute__((weak)) sys_soc_resume(void)
3131
{
3232
}
3333
#endif
3434

3535
#if defined(CONFIG_SYS_POWER_DEEP_SLEEP)
36-
void __attribute__((weak)) _sys_soc_resume_from_deep_sleep(void)
36+
void __attribute__((weak)) sys_soc_resume_from_deep_sleep(void)
3737
{
3838
}
3939
#endif
@@ -77,7 +77,7 @@ static void sys_power_save_idle(void)
7777
#if (defined(CONFIG_SYS_POWER_LOW_POWER_STATE) || \
7878
defined(CONFIG_SYS_POWER_DEEP_SLEEP))
7979

80-
_sys_pm_idle_exit_notify = 1U;
80+
sys_pm_idle_exit_notify = 1U;
8181

8282
/*
8383
* Call the suspend hook function of the soc interface to allow
@@ -92,8 +92,8 @@ static void sys_power_save_idle(void)
9292
* idle processing re-enables interrupts which is essential for
9393
* the kernel's scheduling logic.
9494
*/
95-
if (_sys_soc_suspend(ticks) == SYS_PM_NOT_HANDLED) {
96-
_sys_pm_idle_exit_notify = 0U;
95+
if (sys_soc_suspend(ticks) == SYS_PM_NOT_HANDLED) {
96+
sys_pm_idle_exit_notify = 0U;
9797
k_cpu_idle();
9898
}
9999
#else
@@ -108,11 +108,11 @@ void _sys_power_save_idle_exit(s32_t ticks)
108108
/* Some CPU low power states require notification at the ISR
109109
* to allow any operations that needs to be done before kernel
110110
* switches task or processes nested interrupts. This can be
111-
* disabled by calling _sys_soc_pm_idle_exit_notification_disable().
111+
* disabled by calling sys_soc_pm_idle_exit_notification_disable().
112112
* Alternatively it can be simply ignored if not required.
113113
*/
114-
if (_sys_pm_idle_exit_notify) {
115-
_sys_soc_resume();
114+
if (sys_pm_idle_exit_notify) {
115+
sys_soc_resume();
116116
}
117117
#endif
118118

samples/boards/nrf52/power_mgr/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This sample demonstrates a power manager app that uses the Zephyr
1010
power management infrastructure to enter into Low Power state.
1111

1212
This app will cycle through the following power schemes each time idle thread
13-
calls _sys_soc_suspend() hook function :
13+
calls sys_soc_suspend() hook function :
1414

1515
1. Low Power State: Low Power State is SOC specific and being in this state is
1616
transparent to devices. SOC and devices do not lose context in this Mode.

samples/boards/nrf52/power_mgr/src/power.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static int low_power_state_entry(void)
6868
} else {
6969
printk("--> Entering into Low Power State -");
7070
}
71-
_sys_soc_set_power_state(pm_state);
71+
sys_soc_set_power_state(pm_state);
7272
return SYS_PM_LOW_POWER_STATE;
7373
}
7474

@@ -83,24 +83,24 @@ static int low_power_suspend_entry(void)
8383
{
8484
printk("--> Entering into Deep Sleep State -");
8585
/* Don't need pm idle exit event notification */
86-
_sys_soc_pm_idle_exit_notification_disable();
86+
sys_soc_pm_idle_exit_notification_disable();
8787
/* Save device states and turn off peripherals as necessary */
8888
suspend_devices();
89-
_sys_soc_set_power_state(SYS_POWER_STATE_DEEP_SLEEP);
89+
sys_soc_set_power_state(SYS_POWER_STATE_DEEP_SLEEP);
9090
/* Exiting from Deep Sleep State */
9191
low_power_suspend_exit();
9292

9393
return SYS_PM_DEEP_SLEEP;
9494
}
9595

96-
/* Function name : _sys_soc_suspend
96+
/* Function name : sys_soc_suspend
9797
* Return Value : Power Mode Entered Success/Failure
9898
* Input : Idleness in number of Ticks
9999
*
100100
* Description: All request from Idle thread to Enter into
101101
* Low Power Mode or Deep Sleep State land in this function
102102
*/
103-
int _sys_soc_suspend(s32_t ticks)
103+
int sys_soc_suspend(s32_t ticks)
104104
{
105105
int ret = SYS_PM_NOT_HANDLED;
106106

@@ -142,14 +142,14 @@ int _sys_soc_suspend(s32_t ticks)
142142
low_power_state_exit();
143143
}
144144
post_ops_done = 1;
145-
_sys_soc_power_state_post_ops(pm_state);
145+
sys_soc_power_state_post_ops(pm_state);
146146
}
147147
}
148148

149149
return ret;
150150
}
151151

152-
void _sys_soc_resume(void)
152+
void sys_soc_resume(void)
153153
{
154154
/*
155155
* This notification is called from the ISR of the event
@@ -163,14 +163,14 @@ void _sys_soc_resume(void)
163163
* The kernel scheduler will get control after the ISR finishes
164164
* and it may schedule another thread.
165165
*
166-
* Call _sys_soc_pm_idle_exit_notification_disable() if this
166+
* Call sys_soc_pm_idle_exit_notification_disable() if this
167167
* notification is not required.
168168
*/
169169
if (!post_ops_done) {
170170
if (pm_state == SYS_POWER_STATE_CPU_LPS) {
171171
low_power_state_exit();
172172
}
173173
post_ops_done = 1;
174-
_sys_soc_power_state_post_ops(pm_state);
174+
sys_soc_power_state_post_ops(pm_state);
175175
}
176176
}

samples/boards/quark_se_c1000/power_mgr/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A sample implementation of a power manager app that uses the Zephyr
1010
power management infrastructure.
1111

1212
This app will cycle through the various power schemes at every call
13-
to _sys_soc_suspend() hook function.
13+
to sys_soc_suspend() hook function.
1414
It will cycle through the following states:
1515

1616
1. CPU Low Power State

0 commit comments

Comments
 (0)