Commit graph

747 commits

Author SHA1 Message Date
Tomasz Leman d6048afeea Revert "soc: intel_adsp/ace: fix CPU halting"
This reverts commit 81908cd367.

This commit introduced a regression on SOF. Value of soc_cpus_active is
set by the core X it self in functions pm_state_set and
pm_state_exit_post_ops. soc_adsp_halt_cpu can by called only by the
primary core.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2023-01-11 07:06:10 -05:00
Adrian Warecki 21f278c04b adsp: boot: power: Fixed used register name
The code used the name DFDSPBRCP referring to the DSP Boot / Recovery
Capability Pointer register from DSP Subsystem Capability / Status
Registers range. The address used, however, pointed to DSP Core Shim
(DSPCS) registers block. Changed define names to not be misleading.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2023-01-09 17:05:58 -05:00
Kai Vehmanen e753af063f intel_adsp: ace: power: fix build error with asserts enabled
If defined(CONFIG_ASSERT) and !defined(CONFIG_ADSP_IMR_CONTEXT_SAVE),
build will fail as symbol "global_imr_ram_storage" is not defined.

Link: https://github.com/thesofproject/sof/issues/6896
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2023-01-03 18:49:29 -05:00
Sylvio Alves 42b33382f7 driver: clock: esp32: retrieve HW clock from DTS
ESP32 and ESP32-S2 HW clock are tied to DTS clock configuration.
This changes updates the default configuration to retrieve
this information from DTS.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2023-01-03 17:12:06 -05:00
Sylvio Alves 7f55b2162c soc: esp32: add CCOUNT xtensa rate default value
Xtensa's ESP32 misses this base CCOUNT value, which causes wrong
arch_timing_freq_get() value reference.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2023-01-03 17:12:06 -05:00
Lucas Tamborrino 9e289c1b20 arch: xtensa: save FPU register in context switching
Save FP user register and FP register file during context switch.

This change enables shared FP registers mode using CONFIG_FPU_SHARING.

Since there is no lazy stacking, the FPU registers will be saved regardless
of whether floating point calculations are performed in the threads when
CONFIG_FPU_SHARING is enabled. This require 72 additional bytes in the
stack memory.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2022-12-27 13:23:17 +01:00
Jakub Dabek 72f626046d memory manager: add region calculation for virtual memory
Add region calculations and implementation of
sys_mm_drv_query_memory_regions to pass calculated regions down
the line.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
2022-12-20 07:03:55 -05:00
Jakub Dabek d76419973a devicetree: add virtual memory entry for intel platform
Add virtual memory entry in dt to use as virtual space
regions for aplication.
Add virtual memory definition in adsp_memory.h

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
2022-12-20 07:03:55 -05:00
Tomasz Leman 720787f75a intel_adsp: boot: allow boot from imr without restore
This patch makes IMR context save an option that can be enabled. By
default FW, after D3 state transition, will be boot using normal flow.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2022-12-16 11:03:46 -08:00
Jaroslaw Stelter caf309c6f6 intel_adsp: remove ace_v1x-regs.h file
ACE code is no longer using this header, so it could be dropped.

Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
2022-12-16 05:53:23 +01:00
Anders Rillbert 2c162449eb xtensa: linker: Fix #52539 by updating the linker scripts
include all drom sections in the calculation of drom size.

Signed-off-by: Anders Rillbert <anders.rillbert@kutso.se>
2022-12-08 18:46:59 +01:00
Glauber Maroto Ferreira 063d94c0ec pm: esp32s2: system power management
Adds initial system power management support.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2022-12-05 15:09:53 +01:00
Glauber Maroto Ferreira 204bf27824 soc: esp32s2: set RTC registers to known state
Low-power management is part of the RTC peripherals' domain
on ESP32S2. This dependency implies the need to bring some RTC
registers to a known state, during system initialization, to
achieve proper low-power handling.

The RTC slow memory region is also delimited and used during
power domain options selection.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2022-12-05 15:09:53 +01:00
Glauber Maroto Ferreira bf65685a83 pm: esp32: system power management
- Adds initial system power management support.
- Adds option to add extra delay when waking from
deep sleep.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2022-12-05 15:09:53 +01:00
Glauber Maroto Ferreira a92bbb2d19 soc: esp32: set RTC registers to known state
Low-power management is part of the RTC peripherals' domain
on ESP32. This dependency implies the need to bring some RTC
registers to a known state, during system initialization, to
achieve proper low-power handling.

The RTC slow memory region is also delimited and used during
power domain options selection.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2022-12-05 15:09:53 +01:00
Glauber Maroto Ferreira f0b4eb5557 soc: esp32x: replace STATUS by int
Replace 'STATUS' by 'int' in extern function
signatures.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2022-12-05 15:09:53 +01:00
Tomasz Leman 8e9a01d96a intel_adsp: ace: power header update
This patch is replacing hardcoded register address with one taken from
device tree.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2022-11-30 17:46:17 -05:00
Sylvio Alves 2bfc4451cf linker: esp32: fix IRAM length for mcuboot
When MCUBoot is enabled, IRAM region needs to be set
to a smaller value to avoid overlapping. This shall be re-worked
when MCUboot build for ESP32 is performed in Zephyr environment.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2022-11-30 13:40:10 +01:00
Arsen Eloglian 3659c2db4b intel_common: clean up & rename cavs_* to adsp_*
ADSP common definitions has been fixed
and changed from CAVS_* to  ADSP_*

Signed-off-by: Arsen Eloglian <ArsenX.Eloglian@intel.com>
2022-11-28 17:45:20 -05:00
Marc Herbert 57ea358afc intel_adsp: strip rimage main.mod when CONFIG_BUILD_OUTPUT_STRIPPED
Be consistency with zephyr.strip

This will help with reproducibility issues like the one in
https://github.com/thesofproject/sof-bin/pull/106

Use the `strip_command` introduced by commit c060b075a6 ("cmake:
toolchain: bintools abstraction")

boot.mod is already deterministic because it has no debug symbols; no
need to strip it.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-11-28 10:00:50 -05:00
Marcin Szkudlinski eb280f80e6 mtl: drv: avoid compilation warnings in ace/power.c
SOF compilation is sensitive to compilation warnings
Some simple and neutral changes to avoid them

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-11-26 05:46:08 -05:00
Marcin Szkudlinski 0f067896a6 mtl: drv: move ACE specific procedures to ace directory
IMR save and restore context is a flow implemented for ACE
move boot specific procedures to ace subdir

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-11-26 05:46:08 -05:00
Przemyslaw Blaszkowski 67791ddd70 soc: xtensa: ipc: unmask intc for core 0 only
In ACE architecture, only core 0 should receive IPC interrupts from host.
Unmasking secodnary core IPC interrupts was causing race condition in
ipc irq handler after enabling secondary core.

Signed-off-by: Przemyslaw Blaszkowski <przemyslaw.blaszkowski@intel.com>
2022-11-25 06:37:03 -05:00
Fabio Baltieri b1d1f442cc xtensa: linker: add missing snippets-sections to ace-link.ld
The linker script for intel_adsp ace was missing the
snippets-sections.ld include, causing it to ignore any custom section
defined in with cmake zephyr_linker_sources().

Adding it in the same location as it's done in xtensa-cavs-linker.ld.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-11-24 16:37:49 +01:00
Arsen Eloglian 54c76ea7c1 soc: intel_adsp: adsp_shim: DfPMCCH definition
Add DfPMCCH block definition for mtl ACE platform

Signed-off-by: Arsen Eloglian <ArsenX.Eloglian@intel.com>
2022-11-22 20:03:06 -05:00
Carles Cufi 4796ffee7a drivers: mm: Move mm_drv_intel_adsp_mtl_tlb to zephyr/
This file was mistakenly placed in include/ instead of include/zephyr.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-11-21 20:43:50 +09:00
Marcin Szkudlinski c01a8c8807 mtl: soc: store power gating state in D3 state
Power gating register must be stored when CPU is in
power off state

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-11-18 13:00:04 -05:00
Marcin Szkudlinski 1631d2dc2d mtl: soc: add context save and restore flow
Context save is saving whole memory to persistent
memory area, than turning off memory and CPU
Context restore is a modified boot flow, where
the previously saved context is restored

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-11-18 13:00:04 -05:00
Marcin Szkudlinski c929bbcc58 mtl: dts: add L3 memory definitions macros
Add helper macros for l3 memory definitions from
the Device Tree

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-11-18 13:00:04 -05:00
Tomasz Leman f246d9540c intel_adsp: ace: power: ipc procedure update
This patch updates ipc response procedure in power down function. New
flow is only limited to the writs into two registers. We need to clear
the IPCxIDD register in case if its contains any leftovers from a
previous responce. And then write a response to the IPCxIDR.

To prepare response we need to copy incoming request and then mark it as
replay. New message with IPC Busy bit set is then send to host.

The reason for this is a change in the behavior of the IPC driver
compared to how it worked when this function was originaly implemented.
The biggest difference are enabled interrupts in register IPCxCTL.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2022-11-17 11:19:50 +01:00
Flavio Ceolin e3aac24821 xtensa: linker: Use zephyr's convention for rodata
Zephyr maps start/end of rodata section with variables
using __rodata_region namespace. The exception was Xtensa.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-11-17 15:44:48 +09:00
Kumar Gala fb351a63e8 soc: xtensa: intel_adsp: ace: Rework setting soc_num_cpus
Move setting soc_num_cpus into its own SYS_INIT function such
that we can ensure it happens as one of the first things.  We
need soc_num_cpus set before soc_mp_init is called but also before
interrupt controller init functions might be called.

Also, by having it in its own function, it ensures that
soc_num_cpus gets set regardless of how CONFIG_MP_MAX_NUM_CPUS
is set.  Since if CONFIG_MP_MAX_NUM_CPUS=1, we do not call
soc_mp_init().

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-11-15 07:02:37 -05:00
Marcin Szkudlinski 6f3e0babb3 intel_adsp: include toolchain.h in adsp_memory.h
\MTL SOF is not compiling when
8d0eb6ce10
(devicetree: remove deprecated DT_CHOSEN_*_LABEL macros)
is applied
Fix - zephyr/toolchain used to be included by
devicetree/zephyr.h. The file has been removed by 8d0eb6ce10
Include is needed for ALWAYS_INLINE macro

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-11-14 14:27:01 -05:00
Adrian Bonislawski 728506df6f soc: intel_adsp/ace: wait for lpsram power up
Wait for lpsram power up before bbzero

Fixes commit 195db14

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-11-08 10:48:30 +01:00
Adrian Bonislawski 7e0c1a81cb soc: intel_adsp/ace: remove z_delay from hpsram init
No delay needed here, at init time fw can boot as soon as possible

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-11-08 10:48:30 +01:00
Kumar Gala e3e24b266d soc: xtensa: intel_adsp: ace: Fix build when CONFIG_MP_NUM_CPUS=1
When CONFIG_MP_MAX_NUM_CPUS=1, which it does for some tests, we will
get compiler warnings with soc_adsp_halt_cpu(), so only build it
when CONFIG_MP_MAX_NUM_CPUS > 1.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-11-07 21:12:54 -05:00
Kumar Gala a574957c74 soc: xtensa: intel_adsp: ace: set number of cpus at boot
We look at the Intra DSP communications capability register (DFIDCCP)
to determine the number of cores.  There might be a better way to
determine the number of cores, but this works for now.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-11-03 16:43:53 -04:00
Ederson de Souza e98a748ad2 soc/xtensa/intel_adsp/cavs: Support for code relocation
Basically:
  - Name RAMABLE_REGION as "RAM";
  - Insert the relocation hooks for gen_relocate_app.py.

Also, to help with "rimage" peculiarities, `fix_elf_addrs.py` changed to
not copy empty sections to output, as this would prevent someone trying
to move all of some section (such as BSS) to a different location and
reuse the platform linker script - which would generate an empty section
anyway.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-11-03 10:25:07 +01:00
Ederson de Souza 06990e69d6 soc/xtensa/intel_adsp/cavs: Expose linker script on include
This way, applications can reuse it by simply including it in their
custom linker scripts.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-11-03 10:25:07 +01:00
Ederson de Souza 8ac6f74a7d arch/xtensa: Enable code relocation
Besides adding ARCH_HAS_CODE_DATA_RELOCATION, this patch also adds
support for the "sample_controller" SoC (used by qemu_xtensa) as
demonstration.

As Xtensa lacks a common linker script at the arch level, enabling it
for each platform will be a piecemeal effort. This patch adds it to the
`soc/xtensa/sample_controller` SoC. Basically, default RAMABLE_REGION is
set to be called "RAM", and hooks are inserted so that
gen_relocate_app.py can add the relevant linker bits.

Also, `tests/application_developent/code_relocation` was tweaked to
support the qemu_xtensa platform. Basically, add the relevant linker
script and ensure that relevant memory regions have their program header
(PHDR) associated.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-11-03 10:25:07 +01:00
Ederson de Souza fb26f18ae1 soc/xtensa/sample_controller: Expose linker script on include
This way, applications can reuse it by simply including it in their
custom linker scripts.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-11-03 10:25:07 +01:00
Ederson de Souza d7f46136e0 soc/xtensa: Use standard __data_start/__data_end markers
Xtensa is the odd one out by using _data_start/_data_end instead. Using
the Zephyr standard helps avoid ifdefs for common code, like tests.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-11-03 10:25:07 +01:00
Jaska Uimonen 1f6d6deaef sparse: fix sparse warnings found in sof compilation
Add proper sparse_force cast to assigments into sparse_cache pointers.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
2022-11-02 14:34:20 -04:00
Kai Vehmanen af5fb91a6c soc: intel_adsp: ipc: Do not send message until previous one is acked
Fix a bug where an IPC message is sent while the peer/host ack for
the previous message has not yet been processed. There is existing
logic to check 'idr' INTEL_ADSP_IPC_BUSY bit, but this leaves
the following race:

 - DSP: msg A sent by DSP to host
 - HOST: IRQ, msg A acked, host sets DONE bit -> ADSP_IPC_BUSY cleared
 - DSP: msg B sent by DSP to host, IPC_BUSY is clear so proceeding to send
	-> e.g. 'devdata->sem' is reset --> BUG!
 - DSP: IRQ, msg A done
	-> e.g. call to 'sem_give(&devdata->sem)' which is wrong as
	   the semaphore was just reset in previous step for msg B

Add additional state to track handling of the acks. This allows
to postpone sending message B (in above example), until message A
is fully processed.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-11-02 14:33:20 -04:00
Kumar Gala 0a7c25e649 drivers: timer: intel_adsp: Update driver to use dts Kconfig symbol
Update Intel ADSP timer driver to use DT_HAS_<compat>_ENABLED Kconfig
symbol to expose the driver and enable it by default based on
devicetree.

We remove setting 'default y' for the timer driver in
Kconfig.defconfig.series as that is now handled in the driver Kconfig.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-11-01 09:03:17 +00:00
Kumar Gala f8fba49a41 soc: xtensa: intel_adsp: Convert CONFIG_MP_NUM_CPUS handling
Move runtime checks to use arch_num_cpus() and build checks
to use CONFIG_MP_MAX_NUM_CPUS.  This is to allow runtime
determination of the number of CPUs in the future.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-26 12:00:53 +02:00
Kumar Gala 0ce0f43b36 soc: xtensa: esp32: Convert CONFIG_MP_NUM_CPUS handling
Move runtime checks to use arch_num_cpus().  This is to allow
runtime determination of the number of CPUs in the future.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-26 12:00:45 +02:00
Kumar Gala 9387d8689b soc: xtensa: esp32: Add CONFIG_SMP protection
Add #ifdef CONFIG_SMP around code that only needs to exist when
SMP is enabled.

Also include ksched.h to get decleration of z_sched_ipi.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-26 12:00:45 +02:00
Kumar Gala a1195ae39b smp: Move for loops to use arch_num_cpus instead of CONFIG_MP_NUM_CPUS
Change for loops of the form:

for (i = 0; i < CONFIG_MP_NUM_CPUS; i++)
   ...

to

unsigned int num_cpus = arch_num_cpus();
for (i = 0; i < num_cpus; i++)
   ...

We do the call outside of the for loop so that it only happens once,
rather than on every iteration.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-21 13:14:58 +02:00
Lauren Murphy 938b9533c7 intel: adsp: cavs: fix NO_OPTIMIZATION boot failure
Fixes boot failure on CAVS platforms with
CONFIG_NO_OPTIMIZATIONS=y by moving z_soc_mp_asm_entry
into .text linker section to ensure it is copied to
SRAM.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2022-10-20 18:53:04 -04:00