Skip to content

Commit 8fc025b

Browse files
mwaskommaka1deb-intel
committed
arch: fw: zephyr based power management
SOF power management architecture description and flows using Zephyr RTOS infrastructure Signed-off-by: Michal Wasko <[email protected]> Co-authored-by: Marcin Maka <[email protected]> Co-authored-by: Deb Taylor <[email protected]>
1 parent af9da2d commit 8fc025b

11 files changed

+462
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@startuml
2+
hide empty description
3+
4+
state "D0 / D0ix" as D0 {
5+
[*] --> PM_STATE_ACTIVE: Initialization
6+
PM_STATE_ACTIVE -> PM_STATE_RUNTIME_IDLE
7+
PM_STATE_RUNTIME_IDLE -> PM_STATE_ACTIVE
8+
PM_STATE_ACTIVE --> [*]
9+
}
10+
11+
[*] --> D0: Go to D0 / Power DSP on
12+
D0 --> [*]: Go to D3 / Power DSP Off
13+
14+
@enduml
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@startuml
2+
3+
[*] --> D3
4+
D3 --> D0
5+
D0 --> D0ix: SET_D0ix(wake = 0)
6+
D0ix --> D0: SET_D0ix(wake = 1)
7+
D0ix --> D3: ENTER_DX_STATE
8+
D0 --> D3: ENTER_DX_STATE
9+
10+
@enduml
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@startuml
2+
3+
box "Host" #LightSkyBlue
4+
participant "Driver" as DRIVER
5+
end box
6+
7+
box "SOF" #LightBlue
8+
participant "Core #0: Zephyr lib" as sof_zephyr_lib
9+
participant "Zephyr Power Manager" as zephyr_power_manager
10+
end box
11+
12+
DRIVER -> sof_zephyr_lib: SET_D0ix(prevent_power_gating = 1) IPC request
13+
activate sof_zephyr_lib
14+
sof_zephyr_lib -> zephyr_power_manager: pm_policy_state_lock_get\n(PM_STATE_RUNTIME_IDLE)
15+
activate zephyr_power_manager
16+
return
17+
return SET_D0ix IPC response
18+
19+
@enduml
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@startuml
2+
3+
box "SOF" #LightBlue
4+
participant "Core #N: Zephyr lib" as sof_zephyr_lib
5+
participant "Zephyr Power Manager" as zephyr_power_manager
6+
participant "Zephyr SoC HAL" as soc_hal
7+
end box
8+
9+
box "Hardware" #LightGreen
10+
participant "Core #N: Control" as core_hw_control
11+
end box
12+
13+
opt When Core is Idle
14+
15+
zephyr_power_manager -> sof_zephyr_lib: pm_policy_next_state (PID: Core #N, ticks)
16+
activate sof_zephyr_lib
17+
activate zephyr_power_manager
18+
sof_zephyr_lib -> zephyr_power_manager: pm_policy_state_lock_get\n(PM_STATE_RUNTIME_IDLE)
19+
activate zephyr_power_manager
20+
return
21+
alt if no lock on D0ix state
22+
return PM_STATE_RUNTIME_IDLE
23+
else if there is lock on D0ix state
24+
return PM_STATE_ACTIVE
25+
end
26+
27+
zephyr_power_manager -> soc_hal: pm_power_state_set\n(power_state, PID: Core #N)
28+
activate soc_hal
29+
alt If power_state is PM_STATE_IDLE
30+
soc_hal -> soc_hal: arch_clear_power_gating_prevent (Core #N)
31+
soc_hal -> core_hw_control: Clear power gating prevent
32+
else if PM_STATE_RUNTIME_ACTIVE
33+
soc_hal -> soc_hal: arch_set_power_gating_prevent (Core #N)
34+
soc_hal -> core_hw_control: Set power gating prevent
35+
end
36+
return
37+
38+
deactivate zephyr_power_manager
39+
end
40+
41+
@enduml
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@startuml
2+
3+
box "Host" #LightSkyBlue
4+
participant "driver" as driver
5+
end box
6+
7+
box "SOF" #LightBlue
8+
participant "Core #0: Zephyr lib" as sof_zephyr_lib
9+
participant "Zephyr Power Manager" as zephyr_power_manager
10+
end box
11+
12+
driver -> sof_zephyr_lib: SET_D0ix(prevent_power_gating = 0) IPC request
13+
activate sof_zephyr_lib
14+
sof_zephyr_lib -> zephyr_power_manager: pm_policy_state_lock_put\n(PM_STATE_RUNTIME_IDLE)
15+
activate zephyr_power_manager
16+
return
17+
sof_zephyr_lib -> zephyr_power_manager: pm_policy_state_lock_is_active\n(PM_STATE_RUNTIME_IDLE)
18+
activate zephyr_power_manager
19+
return
20+
21+
alt if D0ix is still locked
22+
sof_zephyr_lib --> driver: return ERROR
23+
note right: Zephyr PM Policy can be used concurrently\nand there can be more then one lock\non D0ix state
24+
else
25+
sof_zephyr_lib --> driver: return SUCCESS
26+
end
27+
28+
deactivate sof_zephyr_lib
29+
@enduml
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@startuml
2+
3+
scale max 1280 width
4+
5+
box "Host" #LightSkyBlue
6+
participant "driver" as driver
7+
end box
8+
9+
box "SOF" #LightBlue
10+
participant "Core #0: Zephyr lib" as sof_zephyr_lib_0
11+
participant "Zephyr Power Manager" as zephyr_power_manager
12+
participant "Zephyr SoC HAL" as soc_hal
13+
end box
14+
15+
box "Hardware" #LightGreen
16+
participant "Core #0: Control" as core_hw_control
17+
end box
18+
19+
opt If D0ix is enabled
20+
driver -> sof_zephyr_lib_0: SET_D0ix(prevent D0ix) IPC request
21+
activate sof_zephyr_lib_0
22+
sof_zephyr_lib_0 -> zephyr_power_manager: pm_policy_state_lock_get\n(PM_STATE_RUNTIME_IDLE)
23+
activate zephyr_power_manager
24+
return
25+
return
26+
end
27+
28+
== DSP FW in PM_STATE_ACTIVE ==
29+
30+
driver -> sof_zephyr_lib_0: SET_DX(PID: Core #0, D3) IPC request
31+
activate sof_zephyr_lib_0
32+
sof_zephyr_lib_0 -> zephyr_power_manager: Read status of secondary cores
33+
activate zephyr_power_manager
34+
return
35+
36+
alt If any secondary core is powered up
37+
sof_zephyr_lib_0 --> driver: SET_DX(ERROR) IPC response
38+
else else
39+
sof_zephyr_lib_0 -> zephyr_power_manager: pm_power_state_force\n(PM_STATE_SOFT_OFF, PID: Core #0)
40+
activate zephyr_power_manager
41+
zephyr_power_manager -> soc_hal: pm_power_state_set\n(PM_STATE_SOFT_OFF, PID: Core #0)
42+
activate soc_hal
43+
soc_hal -> soc_hal: Save context
44+
soc_hal -> soc_hal: Prepare restore vector
45+
return
46+
return
47+
48+
return SET_DX(SUCCESS) IPC response
49+
end
50+
51+
driver -> core_hw_control: clear power register
52+
loop Until Core #0 power is down
53+
driver -> core_hw_control: Read Core #0 power bit
54+
end
55+
56+
@enduml
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@startuml
2+
3+
box "Host" #LightSkyBlue
4+
participant "driver" as driver
5+
end box
6+
7+
box "SOF" #LightBlue
8+
participant "Core #0: Zephyr lib" as sof_zephyr_lib_0
9+
participant "Core #1: FW Init" as fw_init_1
10+
participant "Zephyr Power Manager" as zephyr_power_manager
11+
participant "Zephyr SoC HAL" as soc_hal
12+
end box
13+
14+
box "Hardware" #LightGreen
15+
participant "Core #1: Control" as core_control_1
16+
end box
17+
18+
opt If D0ix is enabled
19+
driver -> sof_zephyr_lib_0: SET_D0ix(prevent D0/D0ix) IPC request
20+
activate sof_zephyr_lib_0
21+
sof_zephyr_lib_0 -> zephyr_power_manager: pm_policy_state_lock_get\n(PM_STATE_RUNTIME_IDLE)
22+
activate zephyr_power_manager
23+
return
24+
return
25+
end
26+
27+
== DSP FW in PM_STATE_ACTIVE ==
28+
29+
driver -> sof_zephyr_lib_0: SET_DX(PID: Core #1, D0) IPC request
30+
activate sof_zephyr_lib_0
31+
sof_zephyr_lib_0 -> soc_hal: arch_start_cpu(PID: Core #1)
32+
activate soc_hal
33+
soc_hal -> core_control_1: Set alternate boot vector to FW Init
34+
note right: Cores share the \nsame FW binary\nand the firmware must be\npresent in SRAM.
35+
soc_hal -> core_control_1: Set SPA bit
36+
37+
core_control_1 -> fw_init_1: Start and jump to alternate boot vector
38+
activate fw_init_1
39+
fw_init_1 -> fw_init_1: Restore context\nif any saved
40+
41+
loop Until Core #1 is enabled
42+
soc_hal -> core_control_1: read power register
43+
end
44+
deactivate fw_init_1
45+
return
46+
return
47+
48+
@enduml
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@startuml
2+
3+
scale max 1280 width
4+
5+
box "Host" #LightSkyBlue
6+
participant "driver" as driver
7+
end box
8+
9+
box "SOF" #LightBlue
10+
participant "Core #0: Zephyr lib" as sof_zephyr_lib_0
11+
participant "Zephyr Power Manager" as zephyr_power_manager
12+
participant "Zephyr SoC HAL" as soc_hal
13+
end box
14+
15+
box "Hardware" #LightGreen
16+
participant "Core #1: Control" as core_1_control
17+
end box
18+
19+
opt If D0ix is enabled
20+
driver -> sof_zephyr_lib_0: SET_D0ix(prevent D0ix) IPC request
21+
activate sof_zephyr_lib_0
22+
sof_zephyr_lib_0 -> zephyr_power_manager: pm_policy_state_lock_get\n(PM_STATE_RUNTIME_IDLE)
23+
activate zephyr_power_manager
24+
return
25+
return
26+
end
27+
28+
== DSP FW in PM_STATE_ACTIVE ==
29+
30+
driver -> sof_zephyr_lib_0: SET_DX(PID: Core #1, D3) IPC request
31+
activate sof_zephyr_lib_0
32+
sof_zephyr_lib_0 -> zephyr_power_manager: pm_power_state_force\n(PM_STATE_SOFT_OFF, PID: Core #1)
33+
activate zephyr_power_manager
34+
zephyr_power_manager -> soc_hal: pm_power_state_set\n(PM_STATE_SOFT_OFF, PID: Core #1)
35+
activate soc_hal
36+
soc_hal -> soc_hal: Save context to IMR
37+
return
38+
deactivate zephyr_power_manager
39+
40+
loop Until Core #1 transition to PM_STATE_SOFT_OFF
41+
sof_zephyr_lib_0 -> zephyr_power_manager: pm_power_state_get(PID: Core #1)
42+
activate zephyr_power_manager
43+
return
44+
end
45+
46+
sof_zephyr_lib_0 -> soc_hal: arch_stop_cpu(PID: Core #1)
47+
activate soc_hal
48+
soc_hal -> core_1_control: clear power bit
49+
loop Until Core #1 is disabled
50+
soc_hal -> core_1_control: read power register
51+
end
52+
return
53+
54+
return SET_DX(SUCCESS) IPC response
55+
56+
@enduml
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
node sw_driver [
2+
<b>SW Driver</b>
3+
* DSP power control over IPC protocol
4+
]
5+
6+
node fw [
7+
<b>SOF Zephyr Library</b>
8+
9+
* Exposes interface of <i>SOF with XTOS</i> for Host Power IPC handling
10+
* Executes requested sequence of Zephyr power operations
11+
* Waits and verifies power request completion
12+
13+
---
14+
<b>Zephyr Power Management</b>
15+
<i>Generic RTOS Power Management service</i>
16+
17+
* Manages System Power States
18+
* Manages Power Policies
19+
* Manages Device Runtime Power
20+
21+
---
22+
<b>SoC HAL</b>
23+
<i>Hardware specific power control</i>
24+
25+
* Moves SoC and its resources to power state requested by Zephyr
26+
* Interacts directly with hardware and power registers
27+
* Suppors different power states depending on the target SoC
28+
]
29+
30+
sw_driver -down-> fw : <<IPC>> <b>Set Dx</b> - power state transition D0/D3\n<<IPC>> <b>Set D0ix</b> - power gating override (on/off)

architectures/firmware/sof-zephyr/rtos_layer/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ workloads.
1111
:maxdepth: 1
1212

1313
zephyr_kernel_overview
14+
power_management
1415
io_drivers/index

0 commit comments

Comments
 (0)