Commit Graph

225 Commits

Author SHA1 Message Date
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
Shubham Kulkarni 9f139b5d83 soc/esp32: Move full logging library to IRAM
This commit updates linker script to move full logging module into
internal RAM

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-01-23 08:43:10 -05:00
Shubham Kulkarni d621dad21b soc/esp32: Move logging library to IRAM with CONFIG_LOG_MINIMAL
This commit updates linker script to move minimal log module to internal
RAM

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-01-23 08:43:10 -05:00
Shubham Kulkarni ca39c7edd7 soc: esp32: linker: Fix backtrace for Invalid cache access exception
This change moves .rodata for panic handler and fatal.c into DRAM
Moves panic handler and its dependent functions into IRAM

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-01-23 08:43:10 -05:00
Enjia Mai dd792ee11b tests: common: fix kernel.common test case build fail in intel_adsp_cavs
Fix kernel.common and kernel.common test cases fail due to build error
in platform intel_adsp_cavs15, 18, 20, 25.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-01-21 14:47:31 -05:00
Guennadi Liakhovetski 9bfee48d5d xtensa: fix an assembly warning in start_address.S
Add missing .end and .size in start_address.S

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-14 11:41:39 -05:00
Guennadi Liakhovetski ca0e5df219 xtensa: don't build and run the reset handler twice
Currently Zephyr links reset-vector.S twice in xtensa builds:
into the bootloader and the main image. It is run at the end
of the boot loader execution and immediately after that again
in the beginning of the main code. This patch adds a
configuration option to select whether to link the file to the
bootloader or to the application. The default is to the
application, as needed e.g. for QEMU, SOF links it to the
bootloader like in native builds.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-13 18:17:40 -05:00
Sylvio Alves ca940400b2 soc: esp32: add reboot call
Add ESP32 reset function

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-01-13 17:19:43 -05:00
Shubham Kulkarni 49941733c6 boards: esp32: linker: move libraries and reserve DRAM regions
Fix issues with restoring symbols from common ld templates
Workaround esptool linker sections limit
Move kernel library into IRAM
Improve UDP throughput

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-01-13 09:10:46 -05:00
Mahavir Jain 29f87c3a0f boards: esp32: add XIP support and enable bootloader build
Disable RTC WDT enabled (by default) by 2nd stage bootloader in ESP-IDF.
This WDT timer ensures correct hand-over and startup sequence from
bootloader to application.

Enabling bootloader caused system clock initialization to fail
when clock rate is greater then 80MHz. This also fixes
esp32 clock source code.

Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2021-01-13 09:10:46 -05:00
Anas Nashif f336a8ea1b soc: intel_adsp: set trace size to non-zero
Looks like those two SoCs still had old header information depending on
Kconfig from SOF, remove those and set trace size directly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-12 20:53:40 -05:00
Guennadi Liakhovetski cf005546ad bootloader: use ceiling_fraction() instead of open-coding it
Use the existing ceiling_fraction() function instead of open-
coding it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski 44bf4a124b cavs: (cosmetic) remove redundant LPRAM_* macros
LPRAM_BASE and LPRAM_SIZE are duplicates of LP_SRAM_BASE and
LP_SRAM_SIZE respectively. Remove them and use LP_SRAM_*
consistently everywhere.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski 7242b567fc cavs: fix LSPGISTS and LSPGCTL access
On cAVS 1.8, 2.0 and 2.5 LSPGISTS and LSPGCTL are located in a
different shim register range, they cannot be accessed, using the
usual SHIM_BASE offset.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski c5a763f607 cavs: remove unused mcuboot support
CONFIG_BOOTLOADER_MCUBOOT is never used in cAVS builds, remove
code, supposedly supporting it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski 8a9d2ded2f cavs_v25: fix copy-pasted definitions
shim.h on cAVS 2.5 contains register definitions, copy-pasted
from other architectures. Fix them to correct values.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski 2a6c70ab19 cavs_v25: switch over to Tigerlake H configuration
Tigerlake H has less RAM and fewer cores. Both should be
supported, selectable at the board level. For now use the H
configuration as more readily available for testing.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski 183076289d cavs_v18, v20, v25: calculate trace base address correctly
RAM window layout differs between cAVS versions. Fix apparent
copy-paste definition blocks to match cAVS 1.8, 2.0 and 2.5.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski bf0bf8840f xtensa: IPM is only required if SMP is enabled
A configuration with CONFIG_MP_NUM_CPUS > 1 and CONFIG_IPM_CAVS_IDC not
defined is valid if COMFIG_SMP is disabled.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski 0a3fa97fbe cavs: fix shim register location on 1.8 and above
Shim register location on cAVS 1.5 is different than on 1.8 and up,
fix it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski bf361c0667 xtensa: disable unused memory power down
The current unused memory calculation is broken because it doesn't
take into account the stack area, allocated at the top of HP SRAM.
Until this is fixed disable powering down unused RAM.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski daab673426 sof: remove superfluous and duplicate code
1. SOF doesn't have to be built in .bin format
2. don't include soc.c and soc_mp.c twice in cmake
3. remove an unused mailbox.h header

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski 3450aa3bd2 cavs: fix manifest base address
On cAVS 1.5, 2.0 and 2.5 platforms the correct manifest address is
0xB0032000.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Guennadi Liakhovetski 3de40b48c3 rimage: update rimage: add configuration and extended manifest
rimage dropped its "-m" parameter and switched over to using "-c"
for a configuration file, including a target name.

Add support for extended manifest for all cAVS versions.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-01-11 16:10:23 -05:00
Anas Nashif 7aaead1e81 soc: intel_cavs: use correct config for V15
Use SOC_INTEL_CAVS_V15 instead of SOC_INTEL_CAVS_APL.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-08 07:49:19 -05:00
Anas Nashif 364129dc25 intel_adsp: disable IPM_INTEL_ADSP
We are using IPM_CAVS_IDC.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-06 07:53:46 -06:00
Guennadi Liakhovetski bc90256423 cavs: unify defconfigs for v15, v18, v20 and v25
Unify default configurations to support both SMP and UP:

1. make SMP default, although it's currently disabled in prj.conf
2. use CAVS timer by default in both UP and SMP configurations
3. make MP_NUM_CPUS, IPM and IPM_CAVS_IDC depend on SMP

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2020-12-27 18:19:00 +01:00
Andy Ross a5110b52ca soc/intel_adsp: Robustify logging code
The existing implementation of the adsplog.py script worked fine for
individual runs (e.g. when running specific code) but had no support
for detecting system reset events and thus could not be used for
monitoring applications like test automation.  It also could not
handle the case where a rapid log burst would overflow the buffer
before being noticed at the client.  Also, the protocol here was also
rife with opportunities for race conditions.  Fix all that up via what
is mostly a rewrite of the script.  The protocol itself hasn't
changed, just the handling.

Also includes some changes to the trace_out.c code on the device side.
These are required to get ordering correct to make race conditions
tractably handleable on the reader side.

Some of the specific cases that are managed:

* There is a 0.4s backoff when a reset is detected.  Continuing to
  poll the buffer has been observed to hang the device (I'm fairly
  sure this is actually a hardware bug, reads aren't visible to the
  DSP software).

* The "no magic number" case needs to be reserved for detecting system
  reset.

* Slot data must be read BETWEEN two reads of the ID value to detect
  the case where the slot gets clobbered while being read.

* The "currently being filled" slot needs to always have an ID value
  that does not appear in sequence from the prior slot.

* We need to check the full history in the buffer at each poll to
  detect resets, which opens up a race between the read of the "next
  slot" (which is absent) and the full history retrieval (when it can
  now be present!).  Detect that.

* A null termination bug in the current output slot got fixed.

Broadly: this was a huge bear to make work.  It sounds like this
should be a simple protocol, but it's not in practice.

Also: clean up the error reporting in the script so it can handle new
PCI IDs being added, and reports permissions failures on the required
sysfs file as a human-readable error.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-12-20 14:49:09 -05:00