From 60bf6827f2875a4dfad76a2d1cecff90d289c141 Mon Sep 17 00:00:00 2001 From: Andre Heinemans Date: Mon, 16 Dec 2024 14:49:24 +0100 Subject: [PATCH] boards/arm: add support for imx95-evk m7 core - Add support for the IMX95LPD5EVK-19 evaluation kit (M7 core only) - Firmware can be executed from ITCM, DDR or NOR flash - configurations: 'nsh' A minimal configuration that only enables nsh shell on a UART 'rpmsg' This configuration is similar to nsh but in addition it offers the Remote Processing Messaging (RPMsg) service to enable heterogeneous inter-core communication. --- .../arm/imx9/boards/imx95-evk/index.rst | 85 ++++++++ Documentation/platforms/arm/imx9/index.rst | 12 ++ boards/Kconfig | 14 ++ boards/arm/imx9/imx95-evk/CMakeLists.txt | 30 +++ boards/arm/imx9/imx95-evk/Kconfig | 18 ++ .../arm/imx9/imx95-evk/configs/nsh/defconfig | 58 ++++++ .../imx9/imx95-evk/configs/rpmsg/defconfig | 84 ++++++++ boards/arm/imx9/imx95-evk/include/board.h | 183 ++++++++++++++++++ boards/arm/imx9/imx95-evk/scripts/Make.defs | 56 ++++++ boards/arm/imx9/imx95-evk/scripts/ddr.ld | 137 +++++++++++++ boards/arm/imx9/imx95-evk/scripts/flash.ld | 137 +++++++++++++ boards/arm/imx9/imx95-evk/scripts/itcm.ld | 137 +++++++++++++ boards/arm/imx9/imx95-evk/src/CMakeLists.txt | 49 +++++ boards/arm/imx9/imx95-evk/src/Makefile | 44 +++++ boards/arm/imx9/imx95-evk/src/imx95-evk.h | 98 ++++++++++ boards/arm/imx9/imx95-evk/src/imx95_appinit.c | 76 ++++++++ .../arm/imx9/imx95-evk/src/imx95_boardinit.c | 116 +++++++++++ boards/arm/imx9/imx95-evk/src/imx95_bringup.c | 101 ++++++++++ boards/arm/imx9/imx95-evk/src/imx95_i2c.c | 88 +++++++++ boards/arm/imx9/imx95-evk/src/imx95_spi.c | 164 ++++++++++++++++ 20 files changed, 1687 insertions(+) create mode 100644 Documentation/platforms/arm/imx9/boards/imx95-evk/index.rst create mode 100644 Documentation/platforms/arm/imx9/index.rst create mode 100644 boards/arm/imx9/imx95-evk/CMakeLists.txt create mode 100644 boards/arm/imx9/imx95-evk/Kconfig create mode 100644 boards/arm/imx9/imx95-evk/configs/nsh/defconfig create mode 100644 boards/arm/imx9/imx95-evk/configs/rpmsg/defconfig create mode 100644 boards/arm/imx9/imx95-evk/include/board.h create mode 100644 boards/arm/imx9/imx95-evk/scripts/Make.defs create mode 100644 boards/arm/imx9/imx95-evk/scripts/ddr.ld create mode 100644 boards/arm/imx9/imx95-evk/scripts/flash.ld create mode 100644 boards/arm/imx9/imx95-evk/scripts/itcm.ld create mode 100644 boards/arm/imx9/imx95-evk/src/CMakeLists.txt create mode 100644 boards/arm/imx9/imx95-evk/src/Makefile create mode 100644 boards/arm/imx9/imx95-evk/src/imx95-evk.h create mode 100644 boards/arm/imx9/imx95-evk/src/imx95_appinit.c create mode 100644 boards/arm/imx9/imx95-evk/src/imx95_boardinit.c create mode 100644 boards/arm/imx9/imx95-evk/src/imx95_bringup.c create mode 100644 boards/arm/imx9/imx95-evk/src/imx95_i2c.c create mode 100644 boards/arm/imx9/imx95-evk/src/imx95_spi.c diff --git a/Documentation/platforms/arm/imx9/boards/imx95-evk/index.rst b/Documentation/platforms/arm/imx9/boards/imx95-evk/index.rst new file mode 100644 index 0000000000..571eef84c8 --- /dev/null +++ b/Documentation/platforms/arm/imx9/boards/imx95-evk/index.rst @@ -0,0 +1,85 @@ +=============== +IMX95LPD5EVK-19 +=============== + +The IMX95LPD5EVK-19 board is a platform designed to show the most commonly +used features of the i.MX 95 automotive applications processor. + +Features +======== + +- Multicore Processing [1]_ + - 1x Arm Cortex-M7 + - 6x Arm Cortex-A55 multicore complex + - 1x Arm Cortex-M33 +- Memory + - On-Chip Memory + - 1376kB SRAM (ECC) + - External Memory + - Up to 6.4GT/s x32 LPDDR5/LPDDR4X (with Inline ECC & Inline Encrpytion) + - 1x Octal SPI, including support for SPI NOR and SPI NAND memories +- Connectivity + - CAN FD + - UART/USART/Profibus, I²C, SPI + - Messaging Units (MU) to support IPC between heterogeneous cores + +.. [1] NuttX is currently supported exclusively on the Cortex-M7 core of the + i.MX95 + +Serial Console +============== + +The IMX95LPD5EVK-19 board features a high-speed USB-to-UART/MPSSE device, +FT4232H (U70) that provides a debug interface for the i.MX95 processor through +the USB type-C connector (J31). The device acts as a bridge to enable +communication between the target processor and the host computer, which +connects to the USB connector (J31) through a USB cable. + +Channel A is used as UART port to provide USB-to-UART option for debugging the +Arm Cortex-M7 core of the i.MX 95 processor (default option). + +J-Link External Debug Probe +=========================== + +The IMX95LPD5EVK-19 board provides a 2x5-pin Samtec FTSH-105-01-L-DV-K header +(J30) for connecting a JTAG debugger (external JTAG) for debugging the i.MX95 +processor. The FT4234H JTAG provides the remote debug option for the i.MX95 +processor. + +Configurations +============== + +nsh +--- + +Configures the NuttShell (nsh) located at examples/nsh. This NSH +configuration is focused on low level, command-line driver testing. Built-in +applications are supported, but none are enabled. This configuration does not +support a network. + +This configuration can be used in combination with the default sd-card image +that is shipped with the EVK. + +rpmsg +----- + +This configuration is similar to nsh but in addition it offers the Remote +Processing Messaging (RPMsg) service to enable heterogeneous inter-core +communication. A virtual UART (CONFIG_RPMSG_UART) is made available on which +an OS running on the A55 cores can connect. There is also an option to use +the filesystem client feature in which a remote directory can be mounted to +a local directory (CONFIG_FS_RPMSGFS). + +The rpmsg configuration executes the code from DDR since its code memory +footprint is bigger than the ITCM size. In the case of using the default +sd-card image from the EVK, adaptations are needed on the software running on +the M33 and A55 cores. + + - `System Manager `_ (M33) should give + the M7 access to the DDR region + - `linux-imx `_ (A55) should reserve + the DDR region by specifying it in the device tree so linux won't make + use of it + - `linux-imx `_ (A55) needs the + NuttX compatible rpmsg_tty and rpmsg_fs drivers. See `dev mailing list + `_ \ No newline at end of file diff --git a/Documentation/platforms/arm/imx9/index.rst b/Documentation/platforms/arm/imx9/index.rst new file mode 100644 index 0000000000..3d802e0fe4 --- /dev/null +++ b/Documentation/platforms/arm/imx9/index.rst @@ -0,0 +1,12 @@ +=================== +NXP i.MX9 +=================== + +Supported Boards +================ + +.. toctree:: + :glob: + :maxdepth: 1 + + boards/*/* \ No newline at end of file diff --git a/boards/Kconfig b/boards/Kconfig index ccaae55b2f..15ed928466 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -780,6 +780,16 @@ config ARCH_BOARD_IMXRT1170_EVK This is the board configuration for the port of NuttX to the NXP i.MXRT evaluation kit, MIMXRT1170-EVK. This board features the MIMXRT1176DVMAA MCU. +config ARCH_BOARD_IMX95_EVK + bool "NXP i.MX 95 EVK" + depends on ARCH_CHIP_IMX9_CORTEX_M + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS + ---help--- + This is the board configuration for the port of NuttX to the NXP i.MXRT + evaluation kit, IMX95-EVK. This board features the IMX95 MCU. + config ARCH_BOARD_LC823450_XGEVK bool "ON Semiconductor LC823450-XGEVK development board" depends on ARCH_CHIP_LC823450 @@ -3345,6 +3355,7 @@ config ARCH_BOARD default "imxrt1060-evk" if ARCH_BOARD_IMXRT1060_EVK default "imxrt1064-evk" if ARCH_BOARD_IMXRT1064_EVK default "imxrt1170-evk" if ARCH_BOARD_IMXRT1170_EVK + default "imx95-evk" if ARCH_BOARD_IMX95_EVK default "kwikstik-k40" if ARCH_BOARD_KWIKSTIK_K40 default "launchxl-cc1310" if ARCH_BOARD_LAUNCHXL_CC1310 default "launchxl-cc1312r1" if ARCH_BOARD_LAUNCHXL_CC1312R1 @@ -3757,6 +3768,9 @@ endif if ARCH_BOARD_IMXRT1170_EVK source "boards/arm/imxrt/imxrt1170-evk/Kconfig" endif +if ARCH_BOARD_IMX95_EVK +source "boards/arm/imx9/imx95-evk/Kconfig" +endif if ARCH_BOARD_TEENSY_4X source "boards/arm/imxrt/teensy-4.x/Kconfig" endif diff --git a/boards/arm/imx9/imx95-evk/CMakeLists.txt b/boards/arm/imx9/imx95-evk/CMakeLists.txt new file mode 100644 index 0000000000..144cb42dff --- /dev/null +++ b/boards/arm/imx9/imx95-evk/CMakeLists.txt @@ -0,0 +1,30 @@ +# ############################################################################## +# boards/arm/imx9/imx95-evk/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +add_subdirectory(src) + +if(NOT CONFIG_BUILD_FLAT) + add_subdirectory(kernel) + set_property( + GLOBAL PROPERTY LD_SCRIPT_USER ${CMAKE_CURRENT_LIST_DIR}/scripts/memory.ld + ${CMAKE_CURRENT_LIST_DIR}/scripts/user-space.ld) +endif() diff --git a/boards/arm/imx9/imx95-evk/Kconfig b/boards/arm/imx9/imx95-evk/Kconfig new file mode 100644 index 0000000000..4d0645a080 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/Kconfig @@ -0,0 +1,18 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +choice IMX95_CODE_LOCATION + prompt "Code location" + +config IMX95_RUN_FROM_ITCM + bool "Run from Instruction Tightly Coupled Memory (ITCM)" + +config IMX95_RUN_FROM_DDR + bool "Run from SDRAM (DDR)" + +config IMX95_RUN_FROM_FLASH + bool "Run from NOR flash" + +endchoice diff --git a/boards/arm/imx9/imx95-evk/configs/nsh/defconfig b/boards/arm/imx9/imx95-evk/configs/nsh/defconfig new file mode 100644 index 0000000000..2c4a85e11a --- /dev/null +++ b/boards/arm/imx9/imx95-evk/configs/nsh/defconfig @@ -0,0 +1,58 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +# CONFIG_ARCH_RAMFUNCS is not set +# CONFIG_NDEBUG is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="imx95-evk" +CONFIG_ARCH_BOARD_IMX95_EVK=y +CONFIG_ARCH_CHIP="imx9" +CONFIG_ARCH_CHIP_IMX95_M7=y +CONFIG_ARCH_CHIP_IMX9_CORTEX_M=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y +CONFIG_ARMV7M_DTCM=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_ARMV7M_ITCM=y +CONFIG_BINFMT_DISABLE=y +CONFIG_BOARD_LOOPSPERMSEC=2664 +CONFIG_BUILTIN=y +CONFIG_DEBUG_BUSFAULT=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_HARDFAULT_ALERT=y +CONFIG_DEBUG_HARDFAULT_INFO=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_USAGEFAULT=y +CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_EXAMPLES_CALIB_UDELAY=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_IMX9_LPUART3=y +CONFIG_IMX9_OCRAM_HEAP=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_LOCALTIME=y +CONFIG_LPUART3_SERIAL_CONSOLE=y +CONFIG_MM_REGIONS=2 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_RAM_SIZE=134217728 +CONFIG_RAM_START=0x80000000 +CONFIG_RAW_BINARY=y +CONFIG_SCHED_BACKTRACE=y +CONFIG_SERIAL_TERMIOS=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=14 +CONFIG_START_MONTH=3 +CONFIG_SYSTEM_NSH=y +CONFIG_TTY_SIGINT=y +CONFIG_TTY_SIGTSTP=y diff --git a/boards/arm/imx9/imx95-evk/configs/rpmsg/defconfig b/boards/arm/imx9/imx95-evk/configs/rpmsg/defconfig new file mode 100644 index 0000000000..c8bc0374f2 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/configs/rpmsg/defconfig @@ -0,0 +1,84 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +# CONFIG_ARCH_RAMFUNCS is not set +# CONFIG_NDEBUG is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="imx95-evk" +CONFIG_ARCH_BOARD_IMX95_EVK=y +CONFIG_ARCH_CHIP="imx9" +CONFIG_ARCH_CHIP_IMX95_M7=y +CONFIG_ARCH_CHIP_IMX9_CORTEX_M=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y +CONFIG_ARMV7M_DTCM=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_ARMV7M_ITCM=y +CONFIG_BINFMT_DISABLE=y +CONFIG_BOARD_LOOPSPERMSEC=2664 +CONFIG_BUILTIN=y +CONFIG_DEBUG_BUSFAULT=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_HARDFAULT_ALERT=y +CONFIG_DEBUG_HARDFAULT_INFO=y +CONFIG_DEBUG_IPC=y +CONFIG_DEBUG_IPC_ERROR=y +CONFIG_DEBUG_IPC_WARN=y +CONFIG_DEBUG_RPMSG=y +CONFIG_DEBUG_RPMSG_ERROR=y +CONFIG_DEBUG_RPMSG_WARN=y +CONFIG_DEBUG_SENSORS=y +CONFIG_DEBUG_SENSORS_ERROR=y +CONFIG_DEBUG_SENSORS_INFO=y +CONFIG_DEBUG_SENSORS_WARN=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_USAGEFAULT=y +CONFIG_DEBUG_VIRTIO=y +CONFIG_DEBUG_VIRTIO_ERROR=y +CONFIG_DEBUG_VIRTIO_INFO=y +CONFIG_DEBUG_VIRTIO_WARN=y +CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_DEV_RPMSG=y +CONFIG_DEV_SIMPLE_ADDRENV=y +CONFIG_DRIVERS_VIRTIO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_RPMSGFS=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_IMX95_RUN_FROM_DDR=y +CONFIG_IMX9_LPUART3=y +CONFIG_IMX9_MU7=y +CONFIG_IMX9_OCRAM_HEAP=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_LOCALTIME=y +CONFIG_LPUART3_SERIAL_CONSOLE=y +CONFIG_MM_HEAP_MEMPOOL_THRESHOLD=0 +CONFIG_MM_REGIONS=2 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_RAM_SIZE=134217728 +CONFIG_RAM_START=0x80000000 +CONFIG_RAW_BINARY=y +CONFIG_RPMSG_LOCAL_CPUNAME="cpuapp" +CONFIG_RPMSG_UART=y +CONFIG_RPTUN=y +CONFIG_SCHED_BACKTRACE=y +CONFIG_SENSORS=y +CONFIG_SERIAL_TERMIOS=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=14 +CONFIG_START_MONTH=3 +CONFIG_SYSTEM_CUTERM=y +CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE="/dev/ttyproxy" +CONFIG_SYSTEM_NSH=y +CONFIG_TTY_SIGINT=y +CONFIG_TTY_SIGTSTP=y diff --git a/boards/arm/imx9/imx95-evk/include/board.h b/boards/arm/imx9/imx95-evk/include/board.h new file mode 100644 index 0000000000..4b29047bda --- /dev/null +++ b/boards/arm/imx9/imx95-evk/include/board.h @@ -0,0 +1,183 @@ +/**************************************************************************** + * boards/arm/imx9/imx95-evk/include/board.h + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_IMX9_IMX95_EVK_INCLUDE_BOARD_H +#define __BOARDS_ARM_IMX9_IMX95_EVK_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define BOARD_XTAL_FREQUENCY 24000000 + +#define BOARD_CPU_FREQUENCY BOARD_XTAL_FREQUENCY //FIXME + +#define LPUART3_CLK (LPUART3_CLK_ROOT_OSC_24M_CLK | CLOCK_DIV(1)) +#define LPI2C6_CLK (LPI2C6_CLK_ROOT_OSC_24M_CLK | CLOCK_DIV(1)) +#define LPSPI1_CLK (LPSPI1_CLK_ROOT_OSC_24M_CLK | CLOCK_DIV(1)) + +#define FLEXCAN1_CLK (CAN1_CLK_ROOT_SYS_PLL1_DFS1_DIV2_CLK | CLOCK_DIV(5)) + +/* This LED is not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/imxrt_autoleds.c. The LED is used to encode + * OS-related events as follows: + * + * -------------------- ----------------------------- ------- ------- + * SYMBOL Meaning LED1 LED2 + * GREEN RED + * -------------------- ----------------------------- ------- ------- + */ + +#define LED_STARTED 0 /* NuttX has been started OFF OFF */ +#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF OFF */ +#define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF */ +#define LED_STACKCREATED 1 /* Idle stack created ON OFF */ +#define LED_INIRQ 2 /* In an interrupt (No change) */ +#define LED_SIGNAL 2 /* In a signal handler (No change) */ +#define LED_ASSERTION 2 /* An assertion failed (No change) */ +#define LED_PANIC 3 /* The system has crashed OFF FLASH */ +#undef LED_IDLE /* Not used (Not used) */ + +/* Default PAD configurations */ + +#define IOMUX_LPI2C_DEFAULT (IOMUXC_PAD_OD_ENABLE | IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X6) +#define IOMUX_LPSPI_DEFAULT (IOMUXC_PAD_PU_ON | IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6) +#define IOMUX_GPIO_DEFAULT (IOMUXC_PAD_FSEL_SLOW | IOMUXC_PAD_DSE_X6) + +/* UART pin muxings */ + +#define MUX_LPUART3_RX IOMUX_CFG(IOMUXC_PAD_GPIO_IO15_LPUART3_RX, 0, IOMUXC_MUX_SION_ON) +#define MUX_LPUART3_TX IOMUX_CFG(IOMUXC_PAD_GPIO_IO14_LPUART3_TX, IOMUXC_PAD_FSEL_SLOW | IOMUXC_PAD_DSE_X4, 0) + +/* FLEXIO to PWM pin muxings */ + +/* EVK signals + * GPIO_IO04 -> FLEXIO1_04 + * GPIO_IO05 -> FLEXIO1_05 + * GPIO_IO06 -> FLEXIO1_06 + * GPIO_IO07 -> FLEXIO1_07 + */ + +#define FLEXIO1_PWM0_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO04_FLEXIO1_FLEXIO04, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X6, 0) +#define FLEXIO1_PWM1_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO05_FLEXIO1_FLEXIO05, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X6, 0) +#define FLEXIO1_PWM2_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO06_FLEXIO1_FLEXIO06, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X6, 0) +#define FLEXIO1_PWM3_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO07_FLEXIO1_FLEXIO07, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X6, 0) + +/* LPI2Cs */ + +/* TPM3 ch3 to PWM pin GPIO_IO24 muxing */ + +#define TPM3_PWM3_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO24_TPM3_CH3, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X6, 0) + +/* LPI2Cs */ + +#define MUX_LPI2C6_SCL IOMUX_CFG(IOMUXC_PAD_GPIO_IO03_LPI2C6_SCL, IOMUX_LPI2C_DEFAULT, IOMUXC_MUX_SION_ON) +#define MUX_LPI2C6_SDA IOMUX_CFG(IOMUXC_PAD_GPIO_IO02_LPI2C6_SDA, IOMUX_LPI2C_DEFAULT, IOMUXC_MUX_SION_ON) + +/* I2C reset functionality */ + +#define GPIO_LPI2C1_SCL_RESET (GPIO_PORT1 | GPIO_PIN0 | GPIO_OUTPUT | GPIO_OUTPUT_ONE) +#define GPIO_LPI2C1_SDA_RESET (GPIO_PORT1 | GPIO_PIN1 | GPIO_OUTPUT | GPIO_OUTPUT_ONE) + +/* LPSPIs */ + +#define MUX_LPSPI1_SCK IOMUX_CFG(IOMUXC_PAD_SAI1_TXD0_LPSPI1_SCK, IOMUX_LPSPI_DEFAULT, IOMUXC_MUX_SION_ON) +#define MUX_LPSPI1_MOSI IOMUX_CFG(IOMUXC_PAD_SAI1_RXD0_LPSPI1_SOUT, IOMUX_LPSPI_DEFAULT, IOMUXC_MUX_SION_ON) +#define MUX_LPSPI1_MISO IOMUX_CFG(IOMUXC_PAD_SAI1_TXC_LPSPI1_SIN, IOMUX_LPSPI_DEFAULT, IOMUXC_MUX_SION_ON) + +/* SPI CS */ + +#define MUX_LPSPI1_CS IOMUX_CFG(IOMUXC_PAD_SAI1_TXFS_GPIO1_IO11, IOMUX_GPIO_DEFAULT, IOMUXC_MUX_SION_ON) +#define GPIO_LPSPI1_CS (GPIO_PORT1 | GPIO_PIN11 | GPIO_OUTPUT | GPIO_OUTPUT_ONE) + +/* FlexCAN */ + +#define GPIO_FLEXCAN1_TX IOMUX_CFG(IOMUXC_PAD_PDM_CLK_CAN1_TX, IOMUX_GPIO_DEFAULT, IOMUXC_MUX_SION_ON) +#define GPIO_FLEXCAN1_RX IOMUX_CFG(IOMUXC_PAD_PDM_BIT_STREAM0_CAN1_RX, IOMUX_GPIO_DEFAULT, IOMUXC_MUX_SION_ON) + +/* Set the PLL clocks as follows: + * + * - OSC24M : 24 MHz + * - ARMPLL_OUT : 1692 MHz + * - DRAMPLL : 933 MHz + * - SYSPLL1 : 4000 MHz + * - SYSPLL_PFD0 : 1000 MHz + * - SYSPLL_PFD1 : 800 MHz + * - SYSPLL_PFD2 : 625 MHz + * - AUDIOPLL_OUT : OFF + * - VIDEOPLL_OUT : OFF + * + * After reset all clock sources (OSCPLL) and root clocks (CLOCK_ROOT) are + * running, but gated (LPCG). + * + * By default, all peripheral root clocks are set to the 24 MHz oscillator. + */ + +#define ARMPLL_CFG PLL_CFG(IMX95_ARMPLL_BASE, false, PLL_PARMS(1, 2, 141, 0, 0)) +#define DRAMPLL_CFG PLL_CFG(IMX95_DRAMPLL_BASE, true, PLL_PARMS(1, 2, 155, 1, 2)) + +#define PLL_CFGS \ + { \ + PLL_CFG(IMX95_SYSPLL_BASE, true, PLL_PARMS(1, 4, 166, 2, 3)), \ + } + +#define PFD_CFGS \ + { \ + PFD_CFG(IMX95_SYSPLL_BASE, 0, PFD_PARMS(4, 0, true)), \ + PFD_CFG(IMX95_SYSPLL_BASE, 1, PFD_PARMS(5, 0, true)), \ + PFD_CFG(IMX95_SYSPLL_BASE, 2, PFD_PARMS(6, 2, true)), \ + } + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_IMX9_IMX95_EVK_INCLUDE_BOARD_H */ diff --git a/boards/arm/imx9/imx95-evk/scripts/Make.defs b/boards/arm/imx9/imx95-evk/scripts/Make.defs new file mode 100644 index 0000000000..d4591a9eb9 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/scripts/Make.defs @@ -0,0 +1,56 @@ +############################################################################ +# boards/arm/imx95/imx95-evk/scripts/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2024 NXP +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs + +ifeq ($(CONFIG_IMX95_RUN_FROM_ITCM),y) +LDSCRIPT = itcm.ld +else ifeq ($(CONFIG_IMX95_RUN_FROM_DDR),y) +LDSCRIPT = ddr.ld +else ifeq ($(CONFIG_IMX95_RUN_FROM_FLASH),y) +LDSCRIPT = flash.ld +endif + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs + +LDMODULEFLAGS = -r -e module_initialize +LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) diff --git a/boards/arm/imx9/imx95-evk/scripts/ddr.ld b/boards/arm/imx9/imx95-evk/scripts/ddr.ld new file mode 100644 index 0000000000..0f77521213 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/scripts/ddr.ld @@ -0,0 +1,137 @@ +/**************************************************************************** + * boards/arm/imx95/imx95-evk/scripts/itcm.ld + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * + ****************************************************************************/ + +/* + * Flash controller + * 1) 32 MB of FlexSPI_1 at 0x0200:0000 + * The on-chip SRAM is split in these parts: + * 1) 256Kb of program memory located at 0x0000:0000 + * 2) 256Kb of data memory beginning at the address 0x2000:0000 + * 3) 352Kb of OCRAM beginning at the address 0x2048:0000 + * 4) 4Mb of SDRAM located at 0x9000:0000 + */ + +MEMORY +{ + m_interrupts (rx) : ORIGIN = 0x90000000, LENGTH = 0x00000800 + flash (rx) : ORIGIN = 0x90000800, LENGTH = 0x003FF800 + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K + ocram (rwx) : ORIGIN = 0x20480000, LENGTH = 352K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .interrupts : + { + __VECTOR_TABLE = .; + __Vectors = .; + . = ALIGN(4); + KEEP(*(.vectors)) /* Startup code */ + . = ALIGN(4); + } > m_interrupts + + .text : { + _stext = ABSOLUTE(.); + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .resource_table : + { + . = ALIGN(8); + KEEP(*(.resource_table)) + . = ALIGN(4); + } > flash + + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } + + _ram_start = ORIGIN(sram); + _ram_size = LENGTH(sram); + _ram_end = ORIGIN(sram) + LENGTH(sram); + _ocram_start = ORIGIN(ocram); + _ocram_size = LENGTH(ocram); + _ocram_end = ORIGIN(ocram) + LENGTH(ocram); +} diff --git a/boards/arm/imx9/imx95-evk/scripts/flash.ld b/boards/arm/imx9/imx95-evk/scripts/flash.ld new file mode 100644 index 0000000000..b9e2ca360d --- /dev/null +++ b/boards/arm/imx9/imx95-evk/scripts/flash.ld @@ -0,0 +1,137 @@ +/**************************************************************************** + * boards/arm/imx95/imx95-evk/scripts/itcm.ld + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * + ****************************************************************************/ + +/* + * Flash controller + * 1) 32 MB of FlexSPI_1 at 0x0200:0000 + * The on-chip SRAM is split in these parts: + * 1) 256Kb of program memory located at 0x0000:0000 + * 2) 256Kb of data memory beginning at the address 0x2000:0000 + * 3) 352Kb of OCRAM beginning at the address 0x2048:0000 + * 4) 4Mb of SDRAM located at 0x9000:0000 + */ + +MEMORY +{ + m_interrupts (rx) : ORIGIN = 0x02000000, LENGTH = 0x00000800 + flash (rx) : ORIGIN = 0x02000800, LENGTH = 0x01FFF800 + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K + ocram (rwx) : ORIGIN = 0x20480000, LENGTH = 352K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .interrupts : + { + __VECTOR_TABLE = .; + __Vectors = .; + . = ALIGN(4); + KEEP(*(.vectors)) /* Startup code */ + . = ALIGN(4); + } > m_interrupts + + .text : { + _stext = ABSOLUTE(.); + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .resource_table : + { + . = ALIGN(8); + KEEP(*(.resource_table)) + . = ALIGN(4); + } > flash + + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } + + _ram_start = ORIGIN(sram); + _ram_size = LENGTH(sram); + _ram_end = ORIGIN(sram) + LENGTH(sram); + _ocram_start = ORIGIN(ocram); + _ocram_size = LENGTH(ocram); + _ocram_end = ORIGIN(ocram) + LENGTH(ocram); +} diff --git a/boards/arm/imx9/imx95-evk/scripts/itcm.ld b/boards/arm/imx9/imx95-evk/scripts/itcm.ld new file mode 100644 index 0000000000..d23e5d11a6 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/scripts/itcm.ld @@ -0,0 +1,137 @@ +/**************************************************************************** + * boards/arm/imx95/imx95-evk/scripts/itcm.ld + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * + ****************************************************************************/ + +/* + * Flash controller + * 1) 32 MB of FlexSPI_1 at 0x0200:0000 + * The on-chip SRAM is split in these parts: + * 1) 256Kb of program memory located at 0x0000:0000 + * 2) 256Kb of data memory beginning at the address 0x2000:0000 + * 3) 352Kb of OCRAM beginning at the address 0x2048:0000 + * 4) 4Mb of SDRAM located at 0x9000:0000 + */ + +MEMORY +{ + m_interrupts (rx) : ORIGIN = 0x00000000, LENGTH = 0x00000800 + flash (rx) : ORIGIN = 0x00000800, LENGTH = 0x0003F800 + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K + ocram (rwx) : ORIGIN = 0x20480000, LENGTH = 352K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .interrupts : + { + __VECTOR_TABLE = .; + __Vectors = .; + . = ALIGN(4); + KEEP(*(.vectors)) /* Startup code */ + . = ALIGN(4); + } > m_interrupts + + .text : { + _stext = ABSOLUTE(.); + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .resource_table : + { + . = ALIGN(8); + KEEP(*(.resource_table)) + . = ALIGN(4); + } > flash + + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } + + _ram_start = ORIGIN(sram); + _ram_size = LENGTH(sram); + _ram_end = ORIGIN(sram) + LENGTH(sram); + _ocram_start = ORIGIN(ocram); + _ocram_size = LENGTH(ocram); + _ocram_end = ORIGIN(ocram) + LENGTH(ocram); +} diff --git a/boards/arm/imx9/imx95-evk/src/CMakeLists.txt b/boards/arm/imx9/imx95-evk/src/CMakeLists.txt new file mode 100644 index 0000000000..470144134c --- /dev/null +++ b/boards/arm/imx9/imx95-evk/src/CMakeLists.txt @@ -0,0 +1,49 @@ +# ############################################################################## +# boards/arm/imx9/imx95-evk/src/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +set(SRCS imx95_boardinit.c imx95_bringup.c) + +if(CONFIG_BOARDCTL) + list(APPEND SRCS imx95_appinit.c) +endif() + +if(CONFIG_PWM) + list(APPEND SRCS imx95_pwm.c) +endif() + +if(CONFIG_IMX9_LPI2C) + list(APPEND SRCS imx95_i2c.c) +endif() + +if(CONFIG_IMX9_LPSPI) + list(APPEND SRCS imx95_spi.c) +endif() + +target_sources(board PRIVATE ${SRCS}) + +if(CONFIG_IMX95_RUN_FROM_ITCM) + set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/itcm.ld") +elseif(CONFIG_IMX95_RUN_FROM_DDR) + set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ddr.ld") +elseif(CONFIG_IMX95_RUN_FROM_FLASH) + set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld") +endif() diff --git a/boards/arm/imx9/imx95-evk/src/Makefile b/boards/arm/imx9/imx95-evk/src/Makefile new file mode 100644 index 0000000000..6150390418 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/src/Makefile @@ -0,0 +1,44 @@ +############################################################################ +# boards/arm/imx95/imx95-evk/src/Makefile +# +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2024 NXP +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +CSRCS = imx95_boardinit.c imx95_bringup.c + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += imx95_appinit.c +endif + +ifeq ($(CONFIG_PWM),y) +CSRCS += imx95_pwm.c +endif + +ifeq ($(CONFIG_IMX9_LPI2C),y) +CSRCS += imx95_i2c.c +endif + +ifeq ($(CONFIG_IMX9_LPSPI),y) +CSRCS += imx95_spi.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/imx9/imx95-evk/src/imx95-evk.h b/boards/arm/imx9/imx95-evk/src/imx95-evk.h new file mode 100644 index 0000000000..b7bcb3e973 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/src/imx95-evk.h @@ -0,0 +1,98 @@ +/**************************************************************************** + * boards/arm/imx9/imx95-evk/src/imx95-evk.h + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_IMX9_IMX95_EVK_SRC_IMX95_EVK_H +#define __BOARDS_ARM_IMX9_IMX95_EVK_SRC_IMX95_EVK_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions Definitions + ****************************************************************************/ + +/**************************************************************************** + * Name: imx95_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +#if defined(CONFIG_BOARDCTL) || defined(CONFIG_BOARD_LATE_INITIALIZE) +int imx95_bringup(void); +#endif + +/**************************************************************************** + * Name: imx95_pwm_setup + * + * Description: + * Initialize PWM outputs + * + ****************************************************************************/ + +#if defined(CONFIG_PWM) +int imx95_pwm_setup(void); +#endif + +/**************************************************************************** + * Name: imx95_i2c_setup + * + * Description: + * Initialize I2C devices and driver + * + ****************************************************************************/ + +#if defined(CONFIG_I2C_DRIVER) +int imx95_i2c_initialize(void); +#endif + +/**************************************************************************** + * Name: imx95_spi_setup + * + * Description: + * Initialize SPI devices and driver + * + ****************************************************************************/ + +#if defined(CONFIG_SPI_DRIVER) +int imx95_spi_initialize(void); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_IMX9_IMX95_EVK_SRC_IMX95_EVK_H */ diff --git a/boards/arm/imx9/imx95-evk/src/imx95_appinit.c b/boards/arm/imx9/imx95-evk/src/imx95_appinit.c new file mode 100644 index 0000000000..207befa814 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/src/imx95_appinit.c @@ -0,0 +1,76 @@ +/**************************************************************************** + * boards/arm/imx9/imx95-evk/src/imx95_appinit.c + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include "imx95-evk.h" + +#ifdef CONFIG_BOARDCTL + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ + UNUSED(arg); +#ifndef CONFIG_BOARD_LATE_INITIALIZE + /* Perform board initialization */ + + return imx95_bringup(); +#else + return OK; +#endif +} + +#endif /* CONFIG_BOARDCTL */ diff --git a/boards/arm/imx9/imx95-evk/src/imx95_boardinit.c b/boards/arm/imx9/imx95-evk/src/imx95_boardinit.c new file mode 100644 index 0000000000..a08a16edb6 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/src/imx95_boardinit.c @@ -0,0 +1,116 @@ +/**************************************************************************** + * boards/arm/imx9/imx95-evk/src/imx95_boardinit.c + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include "imx95-evk.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: imx95_memory_initialize + * + * Description: + * All i.MX8 architectures must provide the following entry point. This + * entry point is called early in the initialization before memory has + * been configured. This board-specific function is responsible for + * configuring any on-board memories. + * + * Logic in imx95_memory_initialize must be careful to avoid using any + * global variables because those will be uninitialized at the time this + * function is called. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void imx95_memory_initialize(void) +{ + /* SDRAM was initialized by a bootloader in the supported configurations. */ +} + +/**************************************************************************** + * Name: imx95_board_initialize + * + * Description: + * All i.MX8 architectures must provide the following entry point. This + * entry point is called in the initialization phase -- after + * imx_memory_initialize and after all memory has been configured and + * mapped but before any devices have been initialized. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void imx9_boardinitialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + /* Configure on-board LEDs if LED support has been selected. */ + +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will be + * called immediately after up_intitialize() is called and just before the + * initial application is started. This additional initialization phase + * may be used, for example, to initialize board-specific device drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board initialization */ + + imx95_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm/imx9/imx95-evk/src/imx95_bringup.c b/boards/arm/imx9/imx95-evk/src/imx95_bringup.c new file mode 100644 index 0000000000..0888116c2c --- /dev/null +++ b/boards/arm/imx9/imx95-evk/src/imx95_bringup.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * boards/arm/imx9/imx95-evk/src/imx95_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include "imx95-evk.h" + +#ifdef CONFIG_RPTUN +# include +#endif + +#ifdef CONFIG_RPMSG_UART +# include +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_RPMSG_UART +void rpmsg_serialinit(void) +{ + uart_rpmsg_init("netcore", "proxy", 4096, true); +} +#endif + +/**************************************************************************** + * Name: imx_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int imx95_bringup(void) +{ + int ret; + +#ifdef CONFIG_RPTUN + imx9_rptun_init("imx9-shmem", "netcore"); +#endif + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#if defined(CONFIG_IMX9_LPI2C) + /* Configure I2C peripheral interfaces */ + + ret = imx95_i2c_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize I2C driver: %d\n", ret); + } +#endif + +#if defined(CONFIG_IMX9_LPSPI1) + /* Configure SPI peripheral interfaces */ + + ret = imx95_spi_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize SPI driver: %d\n", ret); + } +#endif + + UNUSED(ret); + return OK; +} diff --git a/boards/arm/imx9/imx95-evk/src/imx95_i2c.c b/boards/arm/imx9/imx95-evk/src/imx95_i2c.c new file mode 100644 index 0000000000..b389923aaa --- /dev/null +++ b/boards/arm/imx9/imx95-evk/src/imx95_i2c.c @@ -0,0 +1,88 @@ +/**************************************************************************** + * boards/arm/imx9/imx95-evk/src/imx95_i2c.c + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "imx9_lpi2c.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_i2c_init + * + * Description: + * Configure the I2C driver. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int imx95_i2c_initialize(void) +{ + int ret = OK; + +#ifdef CONFIG_IMX9_LPI2C6 + struct i2c_master_s *i2c; + + i2c = imx9_i2cbus_initialize(6); + if (i2c == NULL) + { + i2cerr("ERROR: Failed to init I2C6 interface\n"); + return -ENODEV; + } + +#ifdef CONFIG_SENSORS_BMM150 + struct bmm150_config_s bmm150_config = { + .i2c = i2c, + .addr = 0x12, + }; + + bmm150_register_uorb(0, &bmm150_config); +#endif + +#ifdef CONFIG_I2C_DRIVER + ret = i2c_register(i2c, 0); + if (ret < 0) + { + i2cerr("ERROR: Failed to register I2C6 driver: %d\n", ret); + imx9_i2cbus_uninitialize(i2c); + return ret; + } +#endif + +#endif + return OK; +} diff --git a/boards/arm/imx9/imx95-evk/src/imx95_spi.c b/boards/arm/imx9/imx95-evk/src/imx95_spi.c new file mode 100644 index 0000000000..cf96656948 --- /dev/null +++ b/boards/arm/imx9/imx95-evk/src/imx95_spi.c @@ -0,0 +1,164 @@ +/**************************************************************************** + * boards/arm/imx9/imx95-evk/src/imx95_spi.c + * + * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: 2024 NXP + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "imx9_gpio.h" +#include "imx9_lpspi.h" + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_IMX9_LPSPI1 +static struct spi_dev_s *g_spi1; +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_IMX9_LPSPI + +/**************************************************************************** + * Name: imx95_lpspix_select + * + * Description: + * Enable/disable the SPI chip select. The implementation of this method + * must include handshaking: If a device is selected, it must hold off + * all other attempts to select the device until the device is deselected. + * Required. + * + * Input Parameters: + * dev - Device-specific state data + * devid - Identifies the device to select + * selected - true: slave selected, false: slave de-selected + * + * Returned Value: + * None + * + ****************************************************************************/ + +void imx9_lpspi_select(struct spi_dev_s *dev, uint32_t devid, bool selected) +{ +#ifdef CONFIG_IMX9_LPSPI1 + if (dev == g_spi1) + { + imx9_gpio_write(GPIO_LPSPI1_CS, !selected); + } +#endif +} + +/**************************************************************************** + * Name: imx95_lpspix_status + * + * Description: + * Get SPI/MMC status. Optional. + * + * Input Parameters: + * dev - Device-specific state data + * devid - Identifies the device to report status on + * + * Returned Value: + * Returns a bitset of status values (see SPI_STATUS_* defines) + * + ****************************************************************************/ + +uint8_t imx9_lpspi_status(struct spi_dev_s *dev, uint32_t devid) +{ + return 0; +} + +/**************************************************************************** + * Name: imx95_lpspixcmddata + * + * Description: + * Some devices require an additional out-of-band bit to specify if the + * next word sent to the device is a command or data. This is typical, for + * example, in "9-bit" displays where the 9th bit is the CMD/DATA bit. + * This function provides selection of command or data. + * + * This "latches" the CMD/DATA state. It does not have to be called before + * every word is transferred; only when the CMD/DATA state changes. This + * method is required if CONFIG_SPI_CMDDATA is selected in the NuttX + * configuration + * + * Input Parameters: + * dev - Device-specific state data + * cmd - TRUE: The following word is a command; FALSE: the following words + * are data. + * + * Returned Value: + * OK unless an error occurs. Then a negated errno value is returned + * + ****************************************************************************/ + +int imx95_lpspi_cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ + return -ENODEV; +} +#endif + +/**************************************************************************** + * Name: board_spi_initialize + * + * Description: + * Initialize and register SPI driver for the defined SPI ports. + * + ****************************************************************************/ + +int imx95_spi_initialize(void) +{ + int ret = OK; + +#if defined(CONFIG_IMX9_LPSPI1) + /* Initialize SPI device */ + + g_spi1 = imx9_lpspibus_initialize(1); + if (g_spi1 == NULL) + { + spierr("Failed to initialize SPI1\n"); + return -ENODEV; + } + +#ifdef CONFIG_SPI_DRIVER + ret = spi_register(g_spi1, 0); + if (ret < 0) + { + spierr("Failed to register /dev/spi0: %d\n", ret); + } +#endif /* CONFIG_SPI_DRIVER */ + +#endif /* CONFIG_MPFS_SPI0 */ + + return OK; +}