Skip to content

Commit e9cfb64

Browse files
Jaska Uimonenkv2019i
authored andcommitted
zephyr: cavs: use zephyr pm, clk and dma glue
Start using zephyr pm_runtime, clk and dma glue code in cavs25 native drivers build. Move the files from ace/lib into zephyr/lib. Also update west.yaml to related zephyr commit as power related files have been moved to zephyr side. Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
1 parent 51156a7 commit e9cfb64

File tree

9 files changed

+91
-80
lines changed

9 files changed

+91
-80
lines changed

app/overlays/tgl-h/ipc4_overlay.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ CONFIG_FORMAT_CONVERT_HIFI3=n
2727
CONFIG_PM=y
2828
CONFIG_PM_DEVICE=y
2929
CONFIG_PM_DEVICE_RUNTIME=y
30+
CONFIG_PM_POLICY_CUSTOM=y
31+
32+
CONFIG_CLOCK_CONTROL_ADSP=y
33+
CONFIG_CLOCK_CONTROL=y
3034

3135
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
3236
CONFIG_DAI=y

app/overlays/tgl/ipc4_overlay.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ CONFIG_FORMAT_CONVERT_HIFI3=n
2727
CONFIG_PM=y
2828
CONFIG_PM_DEVICE=y
2929
CONFIG_PM_DEVICE_RUNTIME=y
30+
CONFIG_PM_POLICY_CUSTOM=y
31+
32+
CONFIG_CLOCK_CONTROL_ADSP=y
33+
CONFIG_CLOCK_CONTROL=y
3034

3135
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
3236
CONFIG_DAI=y

src/ipc/ipc4/handler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ static int ipc4_module_process_dx(struct ipc4_message_request *ipc4)
955955
/* do platform specific suspending */
956956
platform_context_save(sof_get());
957957

958-
#if !defined(CONFIG_LIBRARY) && defined(CONFIG_CAVS)
958+
#if !defined(CONFIG_LIBRARY) && !defined(CONFIG_ZEPHYR_NATIVE_DRIVERS)
959959
arch_irq_lock();
960960
platform_timer_stop(timer_get());
961961
#endif

west.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ manifest:
4343

4444
- name: zephyr
4545
repo-path: zephyr
46-
revision: e40859f787128b9a8e000b51009502278fc59586
46+
revision: 95168e6776d6c8803a5e1f3ed10e1a8b6bc98311
4747
remote: zephyrproject
48+
4849
# Import some projects listed in zephyr/west.yml@revision
4950
#
5051
# Warning: changes to zephyr/west.yml or to any other _imported_

zephyr/CMakeLists.txt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ if (CONFIG_SOC_SERIES_INTEL_CAVS_V25)
170170
endif()
171171

172172
# Platform sources
173+
if (NOT CONFIG_ZEPHYR_NATIVE_DRIVERS)
173174
zephyr_library_sources(
174175
${SOF_PLATFORM_PATH}/intel/cavs/platform.c
175176
${SOF_PLATFORM_PATH}/intel/cavs/lib/mem_window.c
@@ -179,8 +180,18 @@ if (CONFIG_SOC_SERIES_INTEL_CAVS_V25)
179180
${SOF_PLATFORM_PATH}/intel/cavs/lib/pm_memory.c
180181
${SOF_PLATFORM_PATH}/intel/cavs/lib/clk.c
181182
${SOF_PLATFORM_PATH}/intel/cavs/lib/dma.c
182-
#${SOF_PLATFORM_PATH}/intel/cavs/lps_pic_restore_vector.S
183183
)
184+
set_source_files_properties(${SOF_PLATFORM_PATH}/intel/cavs/lib/power_down.S PROPERTIES COMPILE_FLAGS -DASSEMBLY)
185+
else()
186+
zephyr_library_sources(
187+
${SOF_PLATFORM_PATH}/intel/cavs/platform.c
188+
${SOF_PLATFORM_PATH}/intel/cavs/lib/mem_window.c
189+
${SOF_PLATFORM_PATH}/tigerlake/lib/clk.c
190+
lib/pm_runtime.c
191+
lib/clk.c
192+
lib/dma.c
193+
)
194+
endif()
184195

185196
# SOF core infrastructure - runs on top of Zephyr
186197
zephyr_library_sources(
@@ -191,9 +202,6 @@ if (CONFIG_SOC_SERIES_INTEL_CAVS_V25)
191202
${SOF_PLATFORM_PATH}/intel/cavs/lps_wait.c
192203
)
193204

194-
set_source_files_properties(${SOF_PLATFORM_PATH}/intel/cavs/lib/power_down.S PROPERTIES COMPILE_FLAGS -DASSEMBLY)
195-
set_source_files_properties(${SOF_PLATFORM_PATH}/intel/cavs/lps_pic_restore_vector.S PROPERTIES COMPILE_FLAGS -DASSEMBLY)
196-
197205
set(PLATFORM "tigerlake")
198206
zephyr_include_directories(${SOF_PLATFORM_PATH}/intel/cavs/include)
199207
endif()
@@ -210,9 +218,9 @@ if (CONFIG_ACE_VERSION_1_5)
210218
zephyr_library_sources(
211219
${SOF_PLATFORM_PATH}/intel/ace/platform.c
212220
${SOF_PLATFORM_PATH}/meteorlake/lib/clk.c
213-
${SOF_PLATFORM_PATH}/intel/ace/lib/pm_runtime.c
214-
${SOF_PLATFORM_PATH}/intel/ace/lib/clk.c
215-
${SOF_PLATFORM_PATH}/intel/ace/lib/dma.c
221+
lib/pm_runtime.c
222+
lib/clk.c
223+
lib/dma.c
216224
)
217225

218226
# SOF core infrastructure - runs on top of Zephyr

zephyr/lib/cpu.c

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -57,71 +57,7 @@ static FUNC_NORETURN void secondary_init(void *arg)
5757
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
5858
}
5959

60-
#ifndef CONFIG_ACE
61-
static int w_core_enable_mask = 0x1; /*Core 0 is always active*/
62-
63-
int cpu_enable_core(int id)
64-
{
65-
pm_runtime_get(PM_RUNTIME_DSP, PWRD_BY_TPLG | id);
66-
67-
/* only called from single core, no RMW lock */
68-
__ASSERT_NO_MSG(cpu_get_id() == PLATFORM_PRIMARY_CORE_ID);
69-
70-
w_core_enable_mask |= BIT(id);
71-
72-
return 0;
73-
}
74-
75-
int cpu_enable_secondary_core(int id)
76-
{
77-
/*
78-
* This is an open-coded version of zephyr/kernel/smp.c
79-
* z_smp_start_cpu(). We do this, so we can use a customized
80-
* secondary_init() for SOF.
81-
*/
82-
83-
if (arch_cpu_active(id))
84-
return 0;
85-
86-
#if ZEPHYR_VERSION(3, 0, 99) <= ZEPHYR_VERSION_CODE
87-
z_init_cpu(id);
88-
#endif
89-
90-
atomic_clear(&start_flag);
91-
atomic_clear(&ready_flag);
92-
93-
arch_start_cpu(id, z_interrupt_stacks[id], CONFIG_ISR_STACK_SIZE,
94-
secondary_init, &start_flag);
95-
96-
while (!atomic_get(&ready_flag))
97-
k_busy_wait(100);
98-
99-
atomic_set(&start_flag, 1);
100-
101-
return 0;
102-
}
103-
104-
void cpu_disable_core(int id)
105-
{
106-
/* TODO: call Zephyr API */
107-
108-
/* only called from single core, no RMW lock */
109-
__ASSERT_NO_MSG(cpu_get_id() == PLATFORM_PRIMARY_CORE_ID);
110-
111-
w_core_enable_mask &= ~BIT(id);
112-
}
113-
114-
int cpu_is_core_enabled(int id)
115-
{
116-
return w_core_enable_mask & BIT(id);
117-
}
118-
119-
int cpu_enabled_cores(void)
120-
{
121-
return w_core_enable_mask;
122-
}
123-
124-
#else /* CONFIG_ACE */
60+
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
12561
#include <sof/trace/trace.h>
12662
#include <rtos/wait.h>
12763
#include <zephyr/pm/pm.h>
@@ -217,7 +153,70 @@ int cpu_enabled_cores(void)
217153

218154
return mask;
219155
}
220-
#endif /* CONFIG_ACE */
156+
#else
157+
static int w_core_enable_mask = 0x1; /*Core 0 is always active*/
158+
159+
int cpu_enable_core(int id)
160+
{
161+
pm_runtime_get(PM_RUNTIME_DSP, PWRD_BY_TPLG | id);
162+
163+
/* only called from single core, no RMW lock */
164+
__ASSERT_NO_MSG(cpu_get_id() == PLATFORM_PRIMARY_CORE_ID);
165+
166+
w_core_enable_mask |= BIT(id);
167+
168+
return 0;
169+
}
170+
171+
int cpu_enable_secondary_core(int id)
172+
{
173+
/*
174+
* This is an open-coded version of zephyr/kernel/smp.c
175+
* z_smp_start_cpu(). We do this, so we can use a customized
176+
* secondary_init() for SOF.
177+
*/
178+
179+
if (arch_cpu_active(id))
180+
return 0;
181+
182+
#if ZEPHYR_VERSION(3, 0, 99) <= ZEPHYR_VERSION_CODE
183+
z_init_cpu(id);
184+
#endif
185+
186+
atomic_clear(&start_flag);
187+
atomic_clear(&ready_flag);
188+
189+
arch_start_cpu(id, z_interrupt_stacks[id], CONFIG_ISR_STACK_SIZE,
190+
secondary_init, &start_flag);
191+
192+
while (!atomic_get(&ready_flag))
193+
k_busy_wait(100);
194+
195+
atomic_set(&start_flag, 1);
196+
197+
return 0;
198+
}
199+
200+
void cpu_disable_core(int id)
201+
{
202+
/* TODO: call Zephyr API */
203+
204+
/* only called from single core, no RMW lock */
205+
__ASSERT_NO_MSG(cpu_get_id() == PLATFORM_PRIMARY_CORE_ID);
206+
207+
w_core_enable_mask &= ~BIT(id);
208+
}
209+
210+
int cpu_is_core_enabled(int id)
211+
{
212+
return w_core_enable_mask & BIT(id);
213+
}
214+
215+
int cpu_enabled_cores(void)
216+
{
217+
return w_core_enable_mask;
218+
}
219+
#endif /* CONFIG_ZEPHYR_NATIVE_DRIVERS */
221220

222221
void cpu_power_down_core(uint32_t flags)
223222
{
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <user/trace.h>
1010
#include <sof_versions.h>
1111
#include <stdint.h>
12-
13-
#include <adsp_boot.h>
1412
#include <zephyr/pm/policy.h>
1513

1614
LOG_MODULE_REGISTER(power, CONFIG_SOF_LOG_LEVEL);
@@ -89,9 +87,6 @@ void platform_pm_runtime_disable(uint32_t context, uint32_t index)
8987
case PM_RUNTIME_DSP:
9088
tr_dbg(&power_tr, "putting prevent on d0i3");
9189
pm_policy_state_lock_get(PM_STATE_RUNTIME_IDLE, PM_ALL_SUBSTATES);
92-
/* Disable power gating when preventing */
93-
DSPCS.bootctl[PLATFORM_PRIMARY_CORE_ID].bctl |=
94-
DSPBR_BCTL_WAITIPCG | DSPBR_BCTL_WAITIPPG;
9590
break;
9691
default:
9792
break;

0 commit comments

Comments
 (0)