arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
/*
|
2023-05-17 05:37:54 +05:30
|
|
|
* Copyright 2017-2023 NXP
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2022-05-06 11:11:04 +02:00
|
|
|
#include <zephyr/kernel.h>
|
|
|
|
#include <zephyr/device.h>
|
|
|
|
#include <zephyr/init.h>
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
#include <soc.h>
|
2022-05-06 11:11:04 +02:00
|
|
|
#include <zephyr/linker/sections.h>
|
|
|
|
#include <zephyr/linker/linker-defs.h>
|
2023-12-18 10:41:25 +01:00
|
|
|
#include <zephyr/cache.h>
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
#include <fsl_clock.h>
|
2022-09-14 22:23:15 +02:00
|
|
|
#ifdef CONFIG_NXP_IMXRT_BOOT_HEADER
|
2018-12-27 08:09:53 -06:00
|
|
|
#include <fsl_flexspi_nor_boot.h>
|
2022-11-01 17:54:03 -05:00
|
|
|
#endif
|
2022-05-06 11:11:04 +02:00
|
|
|
#include <zephyr/dt-bindings/clock/imx_ccm.h>
|
2022-03-23 09:41:42 -05:00
|
|
|
#include <fsl_iomuxc.h>
|
2019-05-05 13:20:04 +08:00
|
|
|
#if CONFIG_USB_DC_NXP_EHCI
|
|
|
|
#include "usb_phy.h"
|
2022-08-18 19:14:27 -05:00
|
|
|
#include "usb.h"
|
2019-05-05 13:20:04 +08:00
|
|
|
#endif
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
|
2025-02-18 10:05:37 -06:00
|
|
|
#include <zephyr/drivers/misc/flexram/nxp_flexram.h>
|
2023-09-14 19:40:17 -05:00
|
|
|
|
2023-06-29 18:22:37 +02:00
|
|
|
#include <cmsis_core.h>
|
|
|
|
|
2022-08-31 22:43:34 +02:00
|
|
|
#define CCM_NODE DT_INST(0, nxp_imx_ccm)
|
|
|
|
|
2022-09-07 10:02:16 +02:00
|
|
|
#define BUILD_ASSERT_PODF_IN_RANGE(podf, a, b) \
|
|
|
|
BUILD_ASSERT(DT_PROP(DT_CHILD(CCM_NODE, podf), clock_div) >= (a) && \
|
|
|
|
DT_PROP(DT_CHILD(CCM_NODE, podf), clock_div) <= (b), \
|
|
|
|
#podf " is out of supported range (" #a ", " #b ")")
|
|
|
|
|
2018-05-14 07:45:32 +08:00
|
|
|
#ifdef CONFIG_INIT_ARM_PLL
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
/* ARM PLL configuration for RUN mode */
|
|
|
|
const clock_arm_pll_config_t armPllConfig = {
|
|
|
|
.loopDivider = 100U
|
|
|
|
};
|
2018-05-14 07:45:32 +08:00
|
|
|
#endif
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
|
2024-04-29 18:52:53 -05:00
|
|
|
#if CONFIG_INIT_SYS_PLL
|
|
|
|
/* Configure System PLL */
|
|
|
|
const clock_sys_pll_config_t sysPllConfig = {
|
|
|
|
.loopDivider = (DT_PROP(DT_CHILD(CCM_NODE, sys_pll), loop_div) - 20) / 2,
|
|
|
|
.numerator = DT_PROP(DT_CHILD(CCM_NODE, sys_pll), numerator),
|
|
|
|
.denominator = DT_PROP(DT_CHILD(CCM_NODE, sys_pll), denominator),
|
|
|
|
.src = DT_PROP(DT_CHILD(CCM_NODE, sys_pll), src),
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2019-05-05 13:20:04 +08:00
|
|
|
#if CONFIG_USB_DC_NXP_EHCI
|
2025-02-17 18:34:28 +01:00
|
|
|
/* USB PHY configuration */
|
2019-05-05 13:20:04 +08:00
|
|
|
#define BOARD_USB_PHY_D_CAL (0x0CU)
|
|
|
|
#define BOARD_USB_PHY_TXCAL45DP (0x06U)
|
|
|
|
#define BOARD_USB_PHY_TXCAL45DM (0x06U)
|
|
|
|
#endif
|
|
|
|
|
2019-01-09 14:01:41 +08:00
|
|
|
#ifdef CONFIG_INIT_ENET_PLL
|
|
|
|
/* ENET PLL configuration for RUN mode */
|
2018-11-15 18:28:47 +02:00
|
|
|
const clock_enet_pll_config_t ethPllConfig = {
|
2020-10-23 10:37:17 +08:00
|
|
|
#if defined(CONFIG_SOC_MIMXRT1011) || \
|
|
|
|
defined(CONFIG_SOC_MIMXRT1015) || \
|
|
|
|
defined(CONFIG_SOC_MIMXRT1021) || \
|
|
|
|
defined(CONFIG_SOC_MIMXRT1024)
|
2019-01-08 08:27:52 +08:00
|
|
|
.enableClkOutput500M = true,
|
2019-01-20 21:14:08 +01:00
|
|
|
#endif
|
2025-01-28 09:57:27 -06:00
|
|
|
#if defined(CONFIG_ETH_NXP_ENET)
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet))
|
2019-01-04 09:15:37 -06:00
|
|
|
.enableClkOutput = true,
|
2019-01-08 08:27:52 +08:00
|
|
|
#endif
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet2))
|
2023-05-17 05:37:54 +05:30
|
|
|
.enableClkOutput1 = true,
|
|
|
|
#endif
|
|
|
|
#endif
|
2025-01-28 09:57:27 -06:00
|
|
|
#if defined(CONFIG_PTP_CLOCK_NXP_ENET)
|
2021-05-17 14:36:21 +08:00
|
|
|
.enableClkOutput25M = true,
|
|
|
|
#else
|
2019-01-04 09:15:37 -06:00
|
|
|
.enableClkOutput25M = false,
|
2021-05-17 14:36:21 +08:00
|
|
|
#endif
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet))
|
2019-01-04 09:15:37 -06:00
|
|
|
.loopDivider = 1,
|
2023-06-04 23:56:09 +05:30
|
|
|
#endif
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet2))
|
2023-06-04 23:56:09 +05:30
|
|
|
.loopDivider1 = 1,
|
|
|
|
#endif
|
2018-11-15 18:28:47 +02:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2019-05-05 13:20:04 +08:00
|
|
|
#if CONFIG_USB_DC_NXP_EHCI
|
|
|
|
usb_phy_config_struct_t usbPhyConfig = {
|
|
|
|
BOARD_USB_PHY_D_CAL, BOARD_USB_PHY_TXCAL45DP, BOARD_USB_PHY_TXCAL45DM,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2019-01-02 13:11:28 -06:00
|
|
|
#ifdef CONFIG_INIT_VIDEO_PLL
|
|
|
|
const clock_video_pll_config_t videoPllConfig = {
|
|
|
|
.loopDivider = 31,
|
|
|
|
.postDivider = 8,
|
|
|
|
.numerator = 0,
|
|
|
|
.denominator = 0,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2022-09-14 22:23:15 +02:00
|
|
|
#ifdef CONFIG_NXP_IMXRT_BOOT_HEADER
|
2018-12-27 08:09:53 -06:00
|
|
|
const __imx_boot_data_section BOOT_DATA_T boot_data = {
|
2023-08-21 15:39:01 -05:00
|
|
|
#ifdef CONFIG_XIP
|
2018-12-27 08:09:53 -06:00
|
|
|
.start = CONFIG_FLASH_BASE_ADDRESS,
|
2023-08-21 15:39:01 -05:00
|
|
|
.size = (uint32_t)&_flash_used,
|
|
|
|
#else
|
|
|
|
.start = CONFIG_SRAM_BASE_ADDRESS,
|
|
|
|
.size = (uint32_t)&_image_ram_size,
|
|
|
|
#endif
|
2018-12-27 08:09:53 -06:00
|
|
|
.plugin = PLUGIN_FLAG,
|
|
|
|
.placeholder = 0xFFFFFFFF,
|
|
|
|
};
|
|
|
|
|
|
|
|
const __imx_boot_ivt_section ivt image_vector_table = {
|
|
|
|
.hdr = IVT_HEADER,
|
2020-08-17 16:29:05 -05:00
|
|
|
.entry = (uint32_t) _vector_start,
|
2018-12-27 08:09:53 -06:00
|
|
|
.reserved1 = IVT_RSVD,
|
2018-12-28 08:43:48 -06:00
|
|
|
#ifdef CONFIG_DEVICE_CONFIGURATION_DATA
|
|
|
|
.dcd = (uint32_t) dcd_data,
|
|
|
|
#else
|
2018-12-27 08:09:53 -06:00
|
|
|
.dcd = (uint32_t) NULL,
|
2018-12-28 08:43:48 -06:00
|
|
|
#endif
|
2018-12-27 08:09:53 -06:00
|
|
|
.boot_data = (uint32_t) &boot_data,
|
|
|
|
.self = (uint32_t) &image_vector_table,
|
|
|
|
.csf = (uint32_t)CSF_ADDRESS,
|
|
|
|
.reserved2 = IVT_RSVD,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
/**
|
|
|
|
* @brief Initialize the system clock
|
|
|
|
*/
|
2025-01-27 16:13:43 -06:00
|
|
|
__weak void clock_init(void)
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
{
|
|
|
|
/* Boot ROM did initialize the XTAL, here we only sets external XTAL
|
|
|
|
* OSC freq
|
|
|
|
*/
|
2022-08-31 22:43:34 +02:00
|
|
|
CLOCK_SetXtalFreq(DT_PROP(DT_CLOCKS_CTLR_BY_NAME(CCM_NODE, xtal),
|
|
|
|
clock_frequency));
|
|
|
|
CLOCK_SetRtcXtalFreq(DT_PROP(DT_CLOCKS_CTLR_BY_NAME(CCM_NODE, rtc_xtal),
|
|
|
|
clock_frequency));
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
|
|
|
|
/* Set PERIPH_CLK2 MUX to OSC */
|
|
|
|
CLOCK_SetMux(kCLOCK_PeriphClk2Mux, 0x1);
|
|
|
|
|
|
|
|
/* Set PERIPH_CLK MUX to PERIPH_CLK2 */
|
|
|
|
CLOCK_SetMux(kCLOCK_PeriphMux, 0x1);
|
|
|
|
|
2025-03-14 14:41:39 +01:00
|
|
|
#if CONFIG_ADJUST_DCDC
|
|
|
|
/* Setting the VDD_SOC value */
|
2022-01-17 22:16:10 -06:00
|
|
|
DCDC->REG3 = (DCDC->REG3 & (~DCDC_REG3_TRG_MASK)) | DCDC_REG3_TRG(CONFIG_DCDC_VALUE);
|
2018-05-14 07:45:59 +08:00
|
|
|
/* Waiting for DCDC_STS_DC_OK bit is asserted */
|
|
|
|
while (DCDC_REG0_STS_DC_OK_MASK !=
|
|
|
|
(DCDC_REG0_STS_DC_OK_MASK & DCDC->REG0)) {
|
|
|
|
;
|
|
|
|
}
|
2025-03-14 14:41:39 +01:00
|
|
|
#endif
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
|
2018-05-14 07:45:32 +08:00
|
|
|
#ifdef CONFIG_INIT_ARM_PLL
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
CLOCK_InitArmPll(&armPllConfig); /* Configure ARM PLL to 1200M */
|
2018-05-14 07:45:32 +08:00
|
|
|
#endif
|
2019-01-09 14:01:41 +08:00
|
|
|
#ifdef CONFIG_INIT_ENET_PLL
|
2018-11-15 18:28:47 +02:00
|
|
|
CLOCK_InitEnetPll(ðPllConfig);
|
|
|
|
#endif
|
2019-01-02 13:11:28 -06:00
|
|
|
#ifdef CONFIG_INIT_VIDEO_PLL
|
|
|
|
CLOCK_InitVideoPll(&videoPllConfig);
|
|
|
|
#endif
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
|
2024-04-29 18:52:53 -05:00
|
|
|
#if CONFIG_INIT_SYS_PLL
|
|
|
|
CLOCK_InitSysPll(&sysPllConfig);
|
|
|
|
#endif
|
|
|
|
|
2022-09-07 10:02:16 +02:00
|
|
|
#if DT_NODE_EXISTS(DT_CHILD(CCM_NODE, arm_podf))
|
|
|
|
/* Set ARM PODF */
|
|
|
|
BUILD_ASSERT_PODF_IN_RANGE(arm_podf, 1, 8);
|
|
|
|
CLOCK_SetDiv(kCLOCK_ArmDiv, DT_PROP(DT_CHILD(CCM_NODE, arm_podf), clock_div) - 1);
|
2019-09-24 08:52:39 +08:00
|
|
|
#endif
|
2022-09-07 10:02:16 +02:00
|
|
|
/* Set AHB PODF */
|
|
|
|
BUILD_ASSERT_PODF_IN_RANGE(ahb_podf, 1, 8);
|
|
|
|
CLOCK_SetDiv(kCLOCK_AhbDiv, DT_PROP(DT_CHILD(CCM_NODE, ahb_podf), clock_div) - 1);
|
|
|
|
/* Set IPG PODF */
|
|
|
|
BUILD_ASSERT_PODF_IN_RANGE(ipg_podf, 1, 4);
|
|
|
|
CLOCK_SetDiv(kCLOCK_IpgDiv, DT_PROP(DT_CHILD(CCM_NODE, ipg_podf), clock_div) - 1);
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
|
2024-04-29 18:53:45 -05:00
|
|
|
#ifdef CONFIG_SOC_MIMXRT1042
|
|
|
|
/* Set PRE_PERIPH_CLK to SYS_PLL */
|
|
|
|
CLOCK_SetMux(kCLOCK_PrePeriphMux, 0x0);
|
|
|
|
#else
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
/* Set PRE_PERIPH_CLK to PLL1, 1200M */
|
|
|
|
CLOCK_SetMux(kCLOCK_PrePeriphMux, 0x3);
|
2024-04-29 18:53:45 -05:00
|
|
|
#endif
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
|
|
|
|
/* Set PERIPH_CLK MUX to PRE_PERIPH_CLK */
|
|
|
|
CLOCK_SetMux(kCLOCK_PeriphMux, 0x0);
|
|
|
|
|
|
|
|
#ifdef CONFIG_UART_MCUX_LPUART
|
|
|
|
/* Configure UART divider to default */
|
|
|
|
CLOCK_SetMux(kCLOCK_UartMux, 0); /* Set UART source to PLL3 80M */
|
|
|
|
CLOCK_SetDiv(kCLOCK_UartDiv, 0); /* Set UART divider to 1 */
|
|
|
|
#endif
|
2018-05-15 03:06:14 -08:00
|
|
|
|
2019-01-16 15:22:22 -06:00
|
|
|
#ifdef CONFIG_I2C_MCUX_LPI2C
|
|
|
|
CLOCK_SetMux(kCLOCK_Lpi2cMux, 0); /* Set I2C source as USB1 PLL 480M */
|
|
|
|
CLOCK_SetDiv(kCLOCK_Lpi2cDiv, 5); /* Set I2C divider to 6 */
|
|
|
|
#endif
|
|
|
|
|
2018-09-14 16:18:41 -05:00
|
|
|
#ifdef CONFIG_SPI_MCUX_LPSPI
|
2025-03-03 14:00:35 -06:00
|
|
|
/* Configure input clock to be able to reach the datasheet specified band rate. */
|
|
|
|
CLOCK_SetMux(kCLOCK_LpspiMux, 1); /* Set SPI source to USB1 PFD0 */
|
|
|
|
CLOCK_SetDiv(kCLOCK_LpspiDiv, 0); /* Set SPI divider to 1 */
|
2018-09-14 16:18:41 -05:00
|
|
|
#endif
|
|
|
|
|
2019-01-02 13:11:28 -06:00
|
|
|
#ifdef CONFIG_DISPLAY_MCUX_ELCDIF
|
2023-01-18 10:40:15 -06:00
|
|
|
/* MUX selects video PLL, which is initialized to 93MHz */
|
2019-01-02 13:11:28 -06:00
|
|
|
CLOCK_SetMux(kCLOCK_LcdifPreMux, 2);
|
2023-01-18 10:40:15 -06:00
|
|
|
/* Divide output by 2 */
|
2019-01-02 13:11:28 -06:00
|
|
|
CLOCK_SetDiv(kCLOCK_LcdifDiv, 1);
|
2023-01-18 10:40:15 -06:00
|
|
|
/* Set final div based on LCDIF clock-frequency */
|
|
|
|
CLOCK_SetDiv(kCLOCK_LcdifPreDiv,
|
|
|
|
((CLOCK_GetPllFreq(kCLOCK_PllVideo) / 2) /
|
|
|
|
DT_PROP(DT_CHILD(DT_NODELABEL(lcdif), display_timings),
|
|
|
|
clock_frequency)) - 1);
|
2019-01-02 13:11:28 -06:00
|
|
|
#endif
|
|
|
|
|
2022-03-23 09:41:42 -05:00
|
|
|
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet)) && CONFIG_NET_L2_ETHERNET
|
2025-01-28 09:15:56 -06:00
|
|
|
#if CONFIG_ETH_NXP_ENET_RMII_EXT_CLK
|
2023-06-29 11:11:24 +02:00
|
|
|
/* Enable clock input for ENET1 */
|
|
|
|
IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1TxClkOutputDir, false);
|
|
|
|
#else
|
2022-03-23 09:41:42 -05:00
|
|
|
/* Enable clock output for ENET1 */
|
|
|
|
IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1TxClkOutputDir, true);
|
|
|
|
#endif
|
2023-06-29 11:11:24 +02:00
|
|
|
#endif
|
2022-03-23 09:41:42 -05:00
|
|
|
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet2)) && CONFIG_NET_L2_ETHERNET
|
2023-06-04 23:56:09 +05:30
|
|
|
/* Set ENET2 ref clock to be generated by External OSC,*/
|
|
|
|
/* direction as output and frequency to 50MHz */
|
|
|
|
IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET2TxClkOutputDir |
|
|
|
|
kIOMUXC_GPR_ENET2RefClkMode, true);
|
|
|
|
#endif
|
|
|
|
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(usb1)) && \
|
2024-05-27 15:43:27 +08:00
|
|
|
(CONFIG_USB_DC_NXP_EHCI || CONFIG_UDC_NXP_EHCI)
|
2019-05-05 13:20:04 +08:00
|
|
|
CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usb480M,
|
2022-02-24 12:40:02 -06:00
|
|
|
DT_PROP_BY_PHANDLE(DT_NODELABEL(usb1), clocks, clock_frequency));
|
2019-05-05 13:20:04 +08:00
|
|
|
CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M,
|
2022-02-24 12:40:02 -06:00
|
|
|
DT_PROP_BY_PHANDLE(DT_NODELABEL(usb1), clocks, clock_frequency));
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(usb1)) && CONFIG_USB_DC_NXP_EHCI
|
2019-05-05 13:20:04 +08:00
|
|
|
USB_EhciPhyInit(kUSB_ControllerEhci0, CPU_XTAL_CLK_HZ, &usbPhyConfig);
|
|
|
|
#endif
|
2024-05-27 15:43:27 +08:00
|
|
|
#endif
|
2019-07-03 21:28:35 -07:00
|
|
|
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(usb2)) && \
|
2024-05-27 15:43:27 +08:00
|
|
|
(CONFIG_USB_DC_NXP_EHCI || CONFIG_UDC_NXP_EHCI)
|
2022-02-24 12:40:02 -06:00
|
|
|
CLOCK_EnableUsbhs1PhyPllClock(kCLOCK_Usb480M,
|
|
|
|
DT_PROP_BY_PHANDLE(DT_NODELABEL(usb2), clocks, clock_frequency));
|
|
|
|
CLOCK_EnableUsbhs1Clock(kCLOCK_Usb480M,
|
|
|
|
DT_PROP_BY_PHANDLE(DT_NODELABEL(usb2), clocks, clock_frequency));
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(usb1)) && CONFIG_USB_DC_NXP_EHCI
|
2022-02-24 12:40:02 -06:00
|
|
|
USB_EhciPhyInit(kUSB_ControllerEhci1, CPU_XTAL_CLK_HZ, &usbPhyConfig);
|
|
|
|
#endif
|
2024-05-27 15:43:27 +08:00
|
|
|
#endif
|
2022-02-24 12:40:02 -06:00
|
|
|
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(usdhc1)) && CONFIG_IMX_USDHC
|
2019-07-03 21:28:35 -07:00
|
|
|
/* Configure USDHC clock source and divider */
|
2022-02-01 19:33:18 -06:00
|
|
|
CLOCK_InitSysPfd(kCLOCK_Pfd0, 24U);
|
2022-01-17 22:16:10 -06:00
|
|
|
CLOCK_SetDiv(kCLOCK_Usdhc1Div, 1U);
|
2019-07-03 21:28:35 -07:00
|
|
|
CLOCK_SetMux(kCLOCK_Usdhc1Mux, 1U);
|
|
|
|
CLOCK_EnableClock(kCLOCK_Usdhc1);
|
|
|
|
#endif
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(usdhc2)) && CONFIG_IMX_USDHC
|
2021-02-24 11:07:56 +01:00
|
|
|
/* Configure USDHC clock source and divider */
|
2022-02-01 19:33:18 -06:00
|
|
|
CLOCK_InitSysPfd(kCLOCK_Pfd0, 24U);
|
2022-01-17 22:16:10 -06:00
|
|
|
CLOCK_SetDiv(kCLOCK_Usdhc2Div, 1U);
|
2019-07-03 21:28:35 -07:00
|
|
|
CLOCK_SetMux(kCLOCK_Usdhc2Mux, 1U);
|
|
|
|
CLOCK_EnableClock(kCLOCK_Usdhc2);
|
|
|
|
#endif
|
2021-02-24 11:07:56 +01:00
|
|
|
|
2019-07-01 14:47:14 +02:00
|
|
|
#ifdef CONFIG_VIDEO_MCUX_CSI
|
|
|
|
CLOCK_EnableClock(kCLOCK_Csi); /* Disable CSI clock gate */
|
|
|
|
CLOCK_SetDiv(kCLOCK_CsiDiv, 0); /* Set CSI divider to 1 */
|
|
|
|
CLOCK_SetMux(kCLOCK_CsiMux, 0); /* Set CSI source to OSC 24M */
|
|
|
|
#endif
|
2020-09-03 11:13:09 -04:00
|
|
|
#ifdef CONFIG_CAN_MCUX_FLEXCAN
|
|
|
|
CLOCK_SetDiv(kCLOCK_CanDiv, 1); /* Set CAN_CLK_PODF. */
|
|
|
|
CLOCK_SetMux(kCLOCK_CanMux, 2); /* Set Can clock source. */
|
|
|
|
#endif
|
2019-05-05 13:20:04 +08:00
|
|
|
|
2022-05-25 11:30:36 -05:00
|
|
|
#ifdef CONFIG_LOG_BACKEND_SWO
|
|
|
|
/* Enable ARM trace clock to enable SWO output */
|
|
|
|
CLOCK_EnableClock(kCLOCK_Trace);
|
|
|
|
/* Divide root clock output by 3 */
|
|
|
|
CLOCK_SetDiv(kCLOCK_TraceDiv, 3);
|
|
|
|
/* Source clock from 528MHz system PLL */
|
|
|
|
CLOCK_SetMux(kCLOCK_TraceMux, 0);
|
|
|
|
#endif
|
|
|
|
|
2018-06-22 08:14:32 -05:00
|
|
|
/* Keep the system clock running so SYSTICK can wake up the system from
|
|
|
|
* wfi.
|
|
|
|
*/
|
|
|
|
CLOCK_SetMode(kCLOCK_ModeRun);
|
|
|
|
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
}
|
|
|
|
|
2022-01-21 11:53:06 +08:00
|
|
|
#if CONFIG_I2S_MCUX_SAI
|
|
|
|
void imxrt_audio_codec_pll_init(uint32_t clock_name, uint32_t clk_src,
|
|
|
|
uint32_t clk_pre_div, uint32_t clk_src_div)
|
|
|
|
{
|
|
|
|
switch (clock_name) {
|
|
|
|
case IMX_CCM_SAI1_CLK:
|
|
|
|
CLOCK_SetMux(kCLOCK_Sai1Mux, clk_src);
|
|
|
|
CLOCK_SetDiv(kCLOCK_Sai1PreDiv, clk_pre_div);
|
|
|
|
CLOCK_SetDiv(kCLOCK_Sai1Div, clk_src_div);
|
|
|
|
break;
|
|
|
|
case IMX_CCM_SAI2_CLK:
|
|
|
|
CLOCK_SetMux(kCLOCK_Sai2Mux, clk_src);
|
|
|
|
CLOCK_SetDiv(kCLOCK_Sai2PreDiv, clk_pre_div);
|
|
|
|
CLOCK_SetDiv(kCLOCK_Sai2Div, clk_src_div);
|
|
|
|
break;
|
|
|
|
case IMX_CCM_SAI3_CLK:
|
|
|
|
CLOCK_SetMux(kCLOCK_Sai2Mux, clk_src);
|
|
|
|
CLOCK_SetDiv(kCLOCK_Sai2PreDiv, clk_pre_div);
|
|
|
|
CLOCK_SetDiv(kCLOCK_Sai2Div, clk_src_div);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-09-10 09:42:40 -04:00
|
|
|
extern void rt10xx_power_init(void);
|
|
|
|
extern void imxrt_lpm_init(void);
|
|
|
|
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief Perform basic hardware initialization
|
|
|
|
*
|
|
|
|
* Initialize the interrupt controller device drivers.
|
|
|
|
* Also initialize the timer device driver, if required.
|
|
|
|
*/
|
2024-09-10 09:42:40 -04:00
|
|
|
void soc_early_init_hook(void)
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
{
|
2023-12-18 10:41:25 +01:00
|
|
|
sys_cache_instr_enable();
|
|
|
|
sys_cache_data_enable();
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
|
2018-05-15 03:06:14 -08:00
|
|
|
/* Initialize system clock */
|
2019-09-30 12:31:07 -07:00
|
|
|
clock_init();
|
2024-09-10 09:42:40 -04:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
#ifdef CONFIG_SOC_MIMXRT1064
|
|
|
|
imxrt_lpm_init();
|
|
|
|
#endif
|
|
|
|
rt10xx_power_init();
|
|
|
|
#endif
|
arm: Introduce NXP i.MX family, RT series, and mimxrt1052 SoC
Adds the mimxrt1052 SoC, which belongs to a new family (nxp_imx) and
series (rt) of SoCs. The mimxrt1052 integrates an Arm Cortex-M7 core,
512 KB TCM, and many peripherals including 2D graphics, an LCD display
controller, camera interface, SPDIF and I2S. Unlike other SoCs in
Zephyr, the mimxrt1052 has no internal flash.
This initial port to mimxrt1052 configures the system clock to operate
at 528 MHz, and enables the serial/uart and gpio interfaces to support
the hello_world and blinky samples. Support for additional Zephyr driver
interfaces will come later.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-11 14:42:40 -05:00
|
|
|
}
|
|
|
|
|
2024-08-06 09:17:48 -04:00
|
|
|
#ifdef CONFIG_SOC_RESET_HOOK
|
|
|
|
void soc_reset_hook(void)
|
2022-03-16 12:14:00 -05:00
|
|
|
{
|
2022-11-07 17:26:44 -06:00
|
|
|
/* Call CMSIS SystemInit */
|
|
|
|
SystemInit();
|
2023-09-14 19:40:17 -05:00
|
|
|
|
|
|
|
#if defined(FLEXRAM_RUNTIME_BANKS_USED)
|
|
|
|
/* Configure flexram if not running from RAM */
|
|
|
|
memc_flexram_dt_partition();
|
|
|
|
#endif
|
2022-03-16 12:14:00 -05:00
|
|
|
}
|
|
|
|
#endif
|