Commit Graph

252 Commits

Author SHA1 Message Date
Glauber Maroto Ferreira 9ae5fd1b34 esp32: drivers: interrupt_controller: add interrupt allocation support
Add interrupt allocation support for ESP32.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-07-16 07:19:28 -04:00
Sylvio Alves 4303cfdb3c hal: esp32: driver changes to allow HAL update
hal_espressif repository was updated from esp-idf v4.2
to esp-idf v4.3 to allow latest Espressif chips integration.
As a consequence, it added a few changes in drivers
and peripherals. To maintain bisectability, changes in this
PR cannot be split. Here are some details:

wifi: update linker script by adding libphy and new attributes.

spi: update some APIs and fixed missing wait_idle check

west.yml: esp32: update hal to new version

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-07-07 15:01:16 -04:00
Sylvio Alves 59d07b0247 linker: esp32: Add missing iterable sections
This fixes missing PPP iterable and adds all
common-rom.ld iterables.

ESP32 and esptool does not support more then 16 segments, which
blocks including common iterables section as is.

This partially reverts commit ad0bf94f77

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-07-07 12:37:39 -04:00
Kai Vehmanen e0bcf9f959 xtensa: cavs: add uncached ram sections to cavs25 linker script
Align cavs25 with cavs15/18 and add memory segment for uncached mapping
of the SRAM to linker script. Assign sections to uncached and cached
segments as done in cavs15/18.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2021-06-14 21:48:44 -04:00
Kumar Gala 79e0ab743e soc: xtensa: linker: Update linker scripts for C++ build
When we link in crtbegin.o for C++ exception support we end up pulling
in the .tm_clone_table section.  We need to update the linker scripts
to handle this.  soc/xtensa/sample_controller/linker.ld was already
updated, this fixes the others.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-05-28 09:32:44 -05:00
Torsten Rasmussen 7d37fe21d1 cmake: c++ exceptions linking support
Fixes part of: #32448

This commit updates the CMake CMAKE_CXX_LINK_EXECUTABLE to include
crtbegin.o and crtend.o at the right locations when linking with gcc.

It also updates linker scripts to ensure proper location of the
exception header frame sections.

This ensure proper handling of exceptions for those architectures
- x86
- xtensa
- riscv32

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-05-27 07:43:28 -05:00
Sylvio Alves ad0bf94f77 linker: esp32: fix empty iterable symbols
Z_ITERABLE_SECTION_ROM symbols were empty, meaning
that those symbols were not taking place in the linker script.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-05-13 22:03:39 -04:00
Guennadi Liakhovetski 03f097b178 xtensa: cavs: fix linker warnings on cAVS 2.0 and 2.5
Add the missing .cached section on cAVS 2.0 and 2.5 to fix
compiler warnings.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-07 12:44:34 -04:00
Guennadi Liakhovetski f5b261db7d cavs: add missing macros to cAVS 1.8
PLATFORM_RESET_MHE_AT_BOOT and
PLATFORM_DISABLE_L2CACHE_AT_BOOT have to be defined on cAVS 1.8
too, without them secondary cores cannot be used.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-07 12:44:34 -04:00
Guennadi Liakhovetski e027a54440 cavs: remove unused and dangerous definitions
uncache_to_cache(), cache_to_uncache() and is_uncached() macros
are currently unused in Zephyr, besides the former two are
dangerous because they add and subtract an offset instead of
masking and unmasking a bit, which can lead to wrong addresses
if applied repeatedly. Remove these macros for now, we can
re-add them later if needed in their fixed versions.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-07 12:44:34 -04:00
Guennadi Liakhovetski b592dc571e xtensa: cavs: all cAVS versions have to select ARCH_HAS_COHERENCE
Currently only cAVS 1.5 Kconfig selects ARCH_HAS_COHERENCE,
which is wrong. cAVS 1.8, 2.0 and 2.5 have to select it too.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-07 12:44:34 -04:00
Shubham Kulkarni a24707a4bd esp32: Add config options in Kconfig.board, remove _heap_start symbol
This commit adds config options for supporting multiple memory
allocation using k_malloc()

Update west.yml with hal_espressif change

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-05-05 08:46:35 -04:00
Shubham Kulkarni 67d2368398 esp32: SPIRAM Support
Adds SPIRAM support for ESP32

Configures k_heap for SPIRAM memory range

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-05-05 08:46:35 -04:00
Guennadi Liakhovetski 4208bf1927 xtensa: cavs_v18: use uncached addresses to support SMP
SMP support on cAVS is implemented by using uncached addresses
for all writable data sections except for stack, i.e. for .data,
.bss and some other specialised ones. So far that has been
implemented for cAVS 1.5. This patch does the same for cAVS 1.8.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-04 22:40:59 -04:00
Guennadi Liakhovetski 0a801aa1dd ADSP / SOF: don't force uniprocessor mode
Allow SMP processing for SOF on ADSP. Note, that after this
SOF will build with SMP support enabled on all cAVS versions,
but secondary cores will remain disabled unless an SMP
topology is loaded by the host.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-03 17:13:01 -04:00
Guennadi Liakhovetski 3509cffac6 xtensa: fix delayed booting secondary cores
With SOF secondary cores are booted later at run-time instead
of the traditional simultaneous booting of all the cores.
Adjust arch_start_cpu() to make that possible.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-03 17:13:01 -04:00
Guennadi Liakhovetski deb57e3b85 xtensa: ADSP: fix disabling the IDC interrupt
To disable the IDC interrupt on the interrupt controller a bit
must be set in the MSD register instead of clearing the bit in
the MCD register, which has no effect.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-03 17:13:01 -04:00
Guennadi Liakhovetski 77e59f2444 xtensa: (cosmetic) remove duplicate parentheses
No need to enclose macro parameters in double parentheses.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-03 17:13:01 -04:00
Guennadi Liakhovetski 88c0063a3f xtensa: Intel ADSP: fix a typo
Fix a copy-paste typo.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-03 17:13:01 -04:00
Guennadi Liakhovetski a871f0be49 xtensa: cavs: fix irq_enable() argument
irq_enable() should be called with the composite IRQ code as its
argument, not just the Xtensa proper part of it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-05-03 17:13:01 -04:00
Sylvio Alves a3c35c93ff driver: esp32: add bluetooth support
Add support to BLE and BR/EDR feature.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-04-30 16:51:30 -04:00
Sylvio Alves 6ae038ca27 esp32: linker clean up to support BT
BT support requires lots of PROVIDE calls that  cannot
be added into this linker file. All necessary includes
were moved into hal module to proper handled as needed.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-04-30 16:51:30 -04:00
Sylvio Alves fe621f7071 wifi: esp32: allow wifi symbols into flash
When BT and WiFi coexists, IRAM usage increases a lot.
Add configuration that allow wifi symbols
to be placed in flash, freeing space in IRAM.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-04-26 13:39:21 +02:00
Sylvio Alves df5b22b264 linker: esp32: moved windowspill to IRAM
xthal_window_spill call has to be placed into IRAM
in order to allow flash cache disabled operation, otherwise
it will crash.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-04-19 13:04:51 -04:00
Sylvio Alves 56d4e835b9 linker: esp32: remove libhal dependency
libhal.a is not used and can be removed from linker

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-04-19 13:04:51 -04:00
Daniel Leung 7c4b13c583 soc: intel_s1000: remove log and ztest XCC fixes
These fixes are no longer needed for apps to compile.
So removing them.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-03-26 11:19:52 -05:00
Flavio Ceolin 9fd4ea91b7 coccinelle: Remove extra semicolon
coccicheck --mode=patch --cocci=semicolon.cocci

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-25 11:35:30 -05:00
Andy Ross c65cf1cd15 soc/intel_adsp: Newlib heap should be uncached
The sentry symbols that mark the ends of the newlib heap area were
being placed in cached memory, which violates the coherence rules.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-15 08:57:46 -04:00
Andy Ross f5267d9ff2 soc/intel_adsp: Honor CONFIG_KERNEL_BINARY_NAME
Turns out that the user can configure the "zephyr.elf" name via
kconfig to be "something_else.elf" instead.  And there's a test the
does this.  Use the right variable; don't hardcode.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 19:25:25 -05:00
Andy Ross ebd0e9f605 soc/intel_adsp: Remove LOG_PRINTK
This was added early when we had (somewhat oddly) a log subsystem
backend but not a printk char_out hook. Now we have one backend that
works with both.  No need, and this fixes build errors with a handful
of tests that specify LOG_MINIMAL (LOG_PRINTK requires the full log
subsystem and doesn't work with MINIMAL).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 19:25:25 -05:00
Andy Ross 376e1310f6 soc/intel_adsp_cavs15: Unbreak newlib linkage
In commit efa05d1e42 ("soc/intel_adsp: Put initial stack into the
CPU0 interrupt stack") the "_end" symbol was accidentally removed from
the linker script.  Newlib needs this to size its heap.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 19:25:25 -05:00
Anas Nashif 65ac2f6d1b cmake: remove TOOLCHAIN_INCLUDES
This seems to be orphaned and not being used anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-08 16:04:28 -05:00
Anas Nashif 90eaa9ee5c intel_adsp: simplify bootloader cmake file
Checking for existence if cmake files here is not needed and was used
with out of tree boards.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-08 16:04:28 -05:00
Anas Nashif 37cd0abd1d soc: intel_adsp: include cleanup
Do not include SOF headers in SoC code and cleanup unused and relative
paths.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-08 16:04:28 -05:00
Anas Nashif 8f9fd94352 xcc: do not enable builtin atomics with xcc
XCC does not have builtin atomic operations, so do not select if xcc is
being used.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-08 16:04:28 -05:00
Andy Ross 64cf33952d arch/xtensa: Add non-HAL caching primitives
The Xtensa L1 cache layer has straightforward semantics accessible via
single-instructions that operate on cache lines via physical
addresses.  These are very amenable to inlining.

Unfortunately the Xtensa HAL layer requires function calls to do this,
leading to significant code waste at the calling site, an extra frame
on the stack and needless runtime instructions for situations where
the call is over a constant region that could elide the loop.  This is
made even worse because the HAL library is not built with
-ffunction-sections, so pulling in even one of these tiny cache
functions has the effect of importing a 1500-byte object file into the
link!

Add our own tiny cache layer to include/arch/xtensa/cache.h and use
that instead.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 11:14:27 -05:00
Andy Ross a230fafde5 arch/xtensa: soc/intel_adsp: Rework MP code entry
Instead of passing the crt1 _start function as the entry code for
auxiliary CPUs, use a tiny assembly stub instead which can avoid the
runtime testing needed to skip the work in _start.  All the crt1 code
was doing was clearing BSS (which must not happen on a second CPU) and
setting the stack pointer (which is wrong on the second CPU).

This allows us to clean out the SMP code in crt1.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 11:14:27 -05:00
Andy Ross d60c8496e3 soc/intel_adsp: Put initial stack into the CPU0 interrupt stack
Zephyr's normal architecture is to do all initialization in the
interrupt stacks.  The CAVS code was traditionally written to start
the stack at the end of HP-SRAM, where it has no protection against
overlap with other uses (e.g. MP startup used the same region for
stacks and saw cache collisions, and the SOF heap lives in this area
too).  Put it where Zephyr expects and we'll have fewer surprises.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 11:14:27 -05:00
Andy Ross 613594e68c soc/intel_adsp: Use the correct MP stack pointer
The kernel passes the CPU's interrupt stack expected that it will
start on that, so do it.  Pass the initial stack pointer from the SOC
layer in the variable "z_mp_stack_top" and set it in the assembly
startup before calling z_mp_entry().

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 11:14:27 -05:00
Andy Ross 14d008775a soc/intel_adsp: Clean up cache handling in MP startup
There's no need to muck with the cache directly as long as we're
careful about addressing the shared start record through an uncached
volatile pointer.

Correct a theoretical bug with the initial cache invalidate on the
second CPU which was actually doing a flush (and thus potentially
pushing things the boot ROM wrote into RAM now owned by the OS).

Optimize memory layout a bit when using KERNEL_COHERENCE; we don't
need a full cache line for the start record there as it's already in
uncached memory.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 11:14:27 -05:00
Andy Ross 2f7a48d387 soc/intel_adsp: Clean up MP startup
The multiprocessor entry code here had some bits that look to have
been copied from esp32, including a clumsy stack switch that's needed
there.  But it wasn't actually switching the stack at all, which on
this device is pointed at the top of HP-SRAM and can stay there until
the second CPU swaps away into a real thread (this will need to change
once we support >2 CPUS though).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 11:14:27 -05:00
Andy Ross f596768427 soc/intel_adsp: Elevate cached/uncached mapping to a SoC API
The trace output layer was using this transformation already, make it
an official API.  There are other places doing similar logic that can
benefit.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 11:14:27 -05:00
Andy Ross eb1ef50b6b arch/xtensa: General cleanup, remove dead code
There was a bunch of dead historical cruft floating around in the
arch/xtensa tree, left over from older code versions.  It's time to do
a cleanup pass.  This is entirely refactoring and size optimization,
no behavior changes on any in-tree devices should be present.

Among the more notable changes:

+ xtensa_context.h offered an elaborate API to deal with a stack frame
  and context layout that we no longer use.

+ xtensa_rtos.h was entirely dead code

+ xtensa_timer.h was a parallel abstraction layer implementing in the
  architecture layer what we're already doing in our timer driver.

+ The architecture thread structs (_callee_saved and _thread_arch)
  aren't used by current code, and had dead fields that were removed.
  Unfortunately for standards compliance and C++ compatibility it's
  not possible to leave an empty struct here, so they have a single
  byte field.

+ xtensa_api.h was really just some interrupt management inlines used
  by irq.h, so fold that code into the outer header.

+ Remove the stale assembly offsets.  This architecture doesn't use
  that facility.

All told, more than a thousand lines have been removed.  Not bad.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 11:14:27 -05:00
Glauber Maroto Ferreira d8f6e66588 esp32: drivers: spi_flash: add host flash support
Add support for ESP32 host flash chip

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-03-06 09:34:35 -05:00
Glauber Maroto Ferreira c344d0d74d esp32: drivers: counter: add support for general-purpose counters
Adds support for ESP32 general-purpose Counters

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-03-03 13:02:02 +01:00
Kumar Gala 5d02978640 audio: intel_dmic: get dma properties from devicetree
Move to using devicetree to get dma controller and dma channel
information.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 14:59:17 -05:00
Shubham Kulkarni e16e606923 esp32: add esp32 wifi driver
add support for esp32 wifi

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-02-25 17:00:20 -05:00
Glauber Maroto Ferreira 74922049ba drivers: spi: esp32: add basic SPI master support
Include SPI master support for blocking and asynchronous calls.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-02-22 08:17:04 -05:00
Sylvio Alves 3b86b4d120 soc: esp32: remove unused config file
deleted sdkconfig file

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-02-15 09:42:42 -05:00
Andy Ross 746c65acb7 soc/intel_adsp: Move KERNEL_COHERENCE to cavs15
Only the CAVS 1.5 linker script has full support for the coherence
features, don't advertise it on the other SoC's yet.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-02-11 14:47:40 -05:00