Commit Graph

276 Commits

Author SHA1 Message Date
Jouni Ukkonen 8382916d26 Map iMX93 OCRAM memory to mmu
Signed-off-by: Jouni Ukkonen <jouni.ukkonen@unikie.com>
2024-05-31 10:22:27 +08:00
Jouni Ukkonen e8de8cf60a Add S3MUA base address for Security Enclave
Signed-off-by: Jouni Ukkonen <jouni.ukkonen@unikie.com>
2024-05-31 10:22:27 +08:00
xuxin19 275ec7102c cmake:bugfix CMake compilation options settings should not use strings
when repeatedly enabling and disabling string-controlled configurations,
the generated toolchain configuration may be incorrect.

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-05-30 10:02:10 -03:00
Eero Nurkkala 2f753a48c7 arm64: s/ARCH_BOOT_EL3/ARCH_ARM64_EXCEPTION_LEVEL/g
Search and replace ARCH_BOOT_EL3 with more generic
ARCH_ARM64_EXCEPTION_LEVEL that holds the EL level
in an integer variable.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2024-05-21 09:02:35 +08:00
Eero Nurkkala 1d3ce6b527 arm64/imx9: provide EL3 bootloader support for iMX9
This provides a capable bootloader that may be run from OCRAM.
The OCRAM contains regions that are always zero, so the linker
file avoids those with best effort.

iMX9 infrastructure expects:
  - 0x20480000 (Start of OCRAM, AHAB)
  - 0x2049a000 (NuttX or SPL)
  - 0x204e0000 (ARM Trustzone, not used)

When started from SD-card, the offsets are:
  - 0x1f000 with AHAB
  - 0xa000  without AHAB

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2024-05-21 09:02:35 +08:00
Eero Nurkkala 1c308296a1 arm64: provide EL3 interrupt support via FIQs
Value 1021, when read from ICC_IAR0_EL1 means:

"The GIC returns this value in response to a read of ICC_IAR0_EL1 or ICC_HPPIR0_EL1 at EL3,
to indicate that the interrupt being acknowledged is one which is expected to be handled at
Non-secure EL1 or EL2. This INTID is only returned when the PE is executing at EL3 using
AArch64 state, or when the PE is executing in AArch32 state in Monitor mode."

When this happens:
  - FIQ is fired on group0
  - IRQ is pending at group1

So simply check and handle the interrupt. In short, this provides interrupt support for
EL3.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2024-05-21 09:02:35 +08:00
Eero Nurkkala 505f57dd00 arm64: introduce MMU support for EL3
Currently MMU supports only EL1.  Introduce EL3 support as well.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2024-05-21 09:02:35 +08:00
Eero Nurkkala 0f9a262311 arm64: provide EL3 support
This provides means to run NuttX completely in EL3.  This may
be useful with NuttX based bootloaders that are executed from
OCRAM.  Instead of SPL/U-boot combo, NuttX may replace SPL
completely.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2024-05-21 09:02:35 +08:00
Eero Nurkkala ae00569ef9 imx9_clockconfig: fix a thinko
putreg32() arguments were swapped.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2024-05-21 09:02:35 +08:00
yinshengkai 20ebe0e64c Replace all asserts in kernel code with ASSERT
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-05-17 10:18:16 -03:00
hujun5 6c1b900e82 arm64: optimise for arm64_switchcontext
We can save execution time by
       inline arm64_fullcontextrestore and arm64_switchcontext

test:
We can use qemu for testing.

compiling
make distclean -j20; ./tools/configure.sh -l qemu-armv8a:nsh_smp ;make -j20
running
qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-05-14 16:03:08 -03:00
simbit18 d1789d84e8 fix nxstyle
fix Relative file path does not match actual file.
2024-05-13 22:24:36 +02:00
hujun5 5cee996588 up_putc: int up_putc, enter_critical_section may be called
before kernel has been iniitialized,we use spin_lock_irqsave to replace.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-05-09 13:45:02 +08:00
Jani Paalijarvi 5b3ef20629 arm64/imx9: Allocate 64B granules instead of 256B
Optimal size of granule is 64B (the dcache line size).
We can use it now as we don't have max. 32 granules limitation anymore.

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2024-05-08 08:48:12 +08:00
Jani Paalijarvi 0d3a1bc617 arm64/imx9: Fix fat_dma_ macro issue.
Defining fat_dma_alloc(s) as imx9_dma_alloc(s) causes compiler errors.

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2024-05-08 08:48:12 +08:00
Jani Paalijarvi c11ffaa78f arm64/imx9: Add DMA preflight support for uSDHC
Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2024-05-08 08:48:12 +08:00
Jani Paalijarvi 602bd685ec arm64/imx9: Add uSDHC driver
Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2024-05-08 08:48:12 +08:00
Jukka Laitinen cc9c3ed80b arch/arm64/src/imx9: Add Ethernet driver
This adds a driver for i.MX93 ENET1 MAC block

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-05-02 16:30:41 -03:00
Ville Juven 3b5b755d1e arch/imx9_lpspi: Use DMA safe buffers to do the DMA transfers
Using user allocated buffers for DMA transfers is not safe for two reasons:
- User space memory is virtual memory, DMA needs physical memory
- User memory buffer alignment cannot be guaranteed -> cache line ops
  are not safe
2024-04-30 19:46:58 +08:00
Ville Juven 3079caf2ce arm64/imx9: Add DMA memory allocator
Add a simple allocator for DMA safe memory. It will provide contiguous
blocks of memory with D-Cache line size alignment.

NOTE: The optimal granule size is the D-Cache line size (64), but due
to restrictions in the granule allocator this would result in a maximum
block size of 2K only, thus use 256B granules instead givin 8K max block
size.

Once the granule allocator is fixed this limitation can be removed.
2024-04-30 19:46:58 +08:00
Philippe Leduc 3dc6b4c9bd Add basic support for locales in order to C++ streams to build and work for simple cases (POSIX / C locale).
Fix build with C++ GCC toolchain
2024-04-29 17:34:10 +08:00
Ville Juven 0d9a3d94eb imx9_clockconfig: Add way to set PLL frequencies
This patch adds a way to configure PLL frequencies. The configuration is
given by board logic.

These values should only be modified by the bootloader, but we don't have
that yet so the flag is never activated.
2024-04-25 19:24:16 -03:00
Ville Juven e3f4749a3c imx9_clockconfig: Add way to query / calculate PLL frequencies
The frequency LUT idea is not necessary as the PLL output can be calculated
by the CPU. It is better to do this as the clocks are set by the SPL (2nd
stage program loader) which means the NuttX payload would not have access
to such a LUT anyhow.

The mask PLL_DIV_RDIV_MASK is also fixed, as that was simply wrong.

Also add call to imx9_clockconfig (although it does not do anything yet).
2024-04-25 19:24:16 -03:00
Ville Juven 89752e9993 arm64/imx9: Add eDMA driver
This driver supports both eDMA3 and eDMA4 (also referred to as DMA0 / DMA1
in some contexts..)

The IP blocks are almost identical, with sufficiently minor differences
to use them via a unified driver. The price is a great amount of code
obfuscation in the hardware description layer.
2024-04-24 11:52:53 +08:00
Yanfeng Liu 5c3fc2796b tools/export: fix names for app linker script and program entry.
This fixes names of program entry and linker script files so that to
support building kernel mode apps using CMake and export package.

flat and protected mode should be the same as before.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-04-24 11:40:16 +08:00
Ville Juven 1b7a95c756 arch/imx9: Add PSCI (system reset) support
ARMv8.2-A has PSCI -> it also has support for system reset
2024-04-23 21:30:56 +08:00
Jukka Laitinen 33d0276f3e arch/arm64/src/imx9/imx9_lpuart.c: Change ARMV8M_DCACHE_LINESIZE -> ARMV8A_DCACHE_LINESIZE
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-20 18:43:41 +08:00
Jukka Laitinen 155c776ba8 arch/arm64/src/imx9/imx9_usbdev.c: Fix the descriptor alignments and cache management
Align all the dtd and dqh on cache line boundaries and clean up the cache management

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-20 18:43:41 +08:00
Ville Juven d73aab9f71 arm64/imx9: Add LPSPI driver
Add driver for LPSPI

Co-authored-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-18 10:58:02 -03:00
Ville Juven 169dd50a08 imx9_gpioirq: Fix testing of ICR field from pinset
icr is tested below with macros like GPIO_INT_LOWLEVEL et al. Those macros
are shifted left by GPIO_INTCFG_SHIFT, so the temporary icr variable
should not be shifted right.
2024-04-18 00:40:07 +08:00
Ville Juven 09a6c400f6 imx9_boot.c: Add initialization of pin interrupts
Initialize the pin interrupt support during boot
2024-04-18 00:40:07 +08:00
Jukka Laitinen 58f0ee6364 arch/arm64/src/imx9: Add a more capable uart driver
Add an uart driver supporting LPUART1-8, dma, flow control, tc etc.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-17 00:10:10 +08:00
Ville Juven 4a82838be7 imx9_iomux.h: Fix issues with the header file
- Add missing include guard
- Add missing C++ guard
- Fix the initialization ordering in IOMUX_PADCFG macro. Why ? Becaused of:

imx9_iomuxc.h:54:3: error: designator order for field 'iomux_padcfg_s::dsyreg' does not match declaration order in 'iomux_padcfg_s'
   54 |   }
      |
2024-04-16 10:56:33 -03:00
Ville Juven f8c5b91522 arm64/imx9: Add LPI2C driver 2024-04-16 19:14:43 +08:00
Ville Juven 8e32a3ce24 imx93_gpioirq: Fix the GPIO interrupt source names
The original assumption was that the interrupt numbers are divided
so that 16 pins from 1 port are handled by a single interrupt source.

So source 0 would handle pins 0-15 and source 1 would handle pins 16-31.
This assumption is wrong, each pin has two sources, thus there are two
interrupt lines for each pin.

The driver uses source 0, and leaves source 1 disabled.
2024-04-16 19:11:31 +08:00
simbit18 b0504f1e5e fix nxstyle
fix Relative file path does not match actual file.
2024-04-15 15:33:17 -03:00
Ville Juven 2e638f6f19 arch/arm64: Add atomic modifyregXX
These are needed by drivers
2024-04-15 11:53:13 -03:00
Jukka Laitinen 729e9fc8e3 arch/arm64/src/Toolchain.defs: Add -mcpu=cortex-a55 if CONFIG_ARCH_CORTEX_A55 is defined
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-09 19:39:33 -03:00
Xiang Xiao 4ea2aeff6b arch: Remove xxx_intstack_top and xxx_intstack_alloc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-04-09 16:59:00 -03:00
ligd 4e725ecd44 arch: color the intstack for all the CPUs
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-04-09 16:59:00 -03:00
ligd 3844efb5b8 stack: update up_get_intstackbase API to support cpu id
For crash dump all the CPU intstack

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-04-09 16:59:00 -03:00
Jukka Laitinen 5e5640992d arch/arm64/src/imx9/imx9_flexio_pwm.c: Fix wrong input scale and pulse width
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-08 03:02:42 +08:00
W-M-R 0ede3fc377 kasan: Implementing global variable out of bounds detection
Extracting global variable information using scripts:
kasan_global.py:
1. Extract the global variable information provided by the -- param asan globals=1 option
2. Generate shadow regions for global variable out of bounds detection
Makefile:
1. Implement multiple links, embed the shadow area into the program, and call it by the Kasan module

Signed-off-by: W-M-R <mike_0528@163.com>
2024-04-07 23:31:13 +08:00
Jukka Laitinen 0f596ec496 arch/arm64/src/imx9: Add TPM based PWM driver for IMX9
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-05 10:13:32 -03:00
Jukka Laitinen 62a64b06bc arch/arm64/src/imx9: Add imx9 usb device driver
This is a modified version from imxrt driver, which has the same controller.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-04 15:47:32 -03:00
Jukka Laitinen d1d5a4abfe arch/arm64/src/imx9/hardware/imx93/imx93_memorymap.h: Clean up some base address macros
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-04 15:47:32 -03:00
Jukka Laitinen 4d3b753a1a arch/arm64/include/imx9/imx93_irq.h: Define IRQ_USBx interrupt numbers
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-04 15:47:32 -03:00
Jukka Laitinen 47f37e84ba arch/arm64/src/imx9: Flex-IO based PWM driver for imx9
This is a high resolution PWM driver, utilizing one 16-bit Flex-IO timer for
generating PWM period and the rest of the timers to generate PWM duty cycles.

This means that the period has to be the same for every PWM generated from one
FLEXIO block, but this way we can get 16-bit resolution for the PWM signals.

For a typical IMX9 HW there are 8 timers for each Flex-IO block, which means
that by using this driver one can get 7 PWM outputs from one block.

This driver can be later extended to have configuration options to use all
8 channels per flex-io by either using 8+8 -bit timer (less resolution) or by
using an external trigger from an LPIT.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-04-04 23:17:59 +08:00
Ville Juven 3294598541 arm64/imx9: Add GPIO, IOMUX and external interrupt support
This adds memory mapped registers and drivers for digital I/O.
2024-04-04 12:12:01 +08:00
Ville Juven f50c439f21 imx9_clockconfig.c: Add way to query clock frequency
The frequency of a clock source is stored in a LUT. Currently the
LUT contains the PLL frequencies set by the boot ROM code.
2024-04-04 12:12:01 +08:00