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-11-01 17:54:03 -05:00
|
|
|
#ifdef CONFIG_NXP_IMX_RT_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
|
|
|
|
2023-09-14 19:40:17 -05:00
|
|
|
#include "memc_nxp_flexram.h"
|
|
|
|
|
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
|
|
|
|
2019-05-05 13:20:04 +08:00
|
|
|
#if CONFIG_USB_DC_NXP_EHCI
|
|
|
|
/* USB PHY condfiguration */
|
|
|
|
#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
|
2023-08-24 11:10:41 -05:00
|
|
|
#if defined(CONFIG_ETH_NXP_ENET) || defined(CONFIG_ETH_MCUX)
|
2023-05-17 05:37:54 +05:30
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay)
|
2019-01-04 09:15:37 -06:00
|
|
|
.enableClkOutput = true,
|
2019-01-08 08:27:52 +08:00
|
|
|
#endif
|
2023-05-17 05:37:54 +05:30
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet2), okay)
|
|
|
|
.enableClkOutput1 = true,
|
|
|
|
#endif
|
|
|
|
#endif
|
2021-05-17 14:36:21 +08:00
|
|
|
#if defined(CONFIG_PTP_CLOCK_MCUX)
|
|
|
|
.enableClkOutput25M = true,
|
|
|
|
#else
|
2019-01-04 09:15:37 -06:00
|
|
|
.enableClkOutput25M = false,
|
2021-05-17 14:36:21 +08:00
|
|
|
#endif
|
2023-06-04 23:56:09 +05:30
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay)
|
2019-01-04 09:15:37 -06:00
|
|
|
.loopDivider = 1,
|
2023-06-04 23:56:09 +05:30
|
|
|
#endif
|
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet2), okay)
|
|
|
|
.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
|
|
|
|
|
2018-12-27 08:09:53 -06:00
|
|
|
#ifdef CONFIG_NXP_IMX_RT_BOOT_HEADER
|
|
|
|
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
|
|
|
|
*/
|
2019-09-30 12:31:07 -07:00
|
|
|
static ALWAYS_INLINE 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);
|
|
|
|
|
2022-01-17 22:16:10 -06:00
|
|
|
/* Setting the VDD_SOC value.
|
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-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)) {
|
|
|
|
;
|
|
|
|
}
|
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
|
|
|
|
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
|
|
|
|
|
|
|
/* Set PRE_PERIPH_CLK to PLL1, 1200M */
|
|
|
|
CLOCK_SetMux(kCLOCK_PrePeriphMux, 0x3);
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
CLOCK_SetMux(kCLOCK_LpspiMux, 1); /* Set SPI source to USB1 PFD0 720M */
|
|
|
|
CLOCK_SetDiv(kCLOCK_LpspiDiv, 7); /* Set SPI divider to 8 */
|
|
|
|
#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
|
|
|
|
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET
|
2023-06-29 11:11:24 +02:00
|
|
|
#if CONFIG_ETH_MCUX_RMII_EXT_CLK
|
|
|
|
/* 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
|
|
|
|
2023-06-04 23:56:09 +05:30
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet2), okay) && CONFIG_NET_L2_ETHERNET
|
|
|
|
/* 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
|
|
|
|
|
2022-02-24 12:40:02 -06:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usb1), okay) && CONFIG_USB_DC_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));
|
2019-05-05 13:20:04 +08:00
|
|
|
USB_EhciPhyInit(kUSB_ControllerEhci0, CPU_XTAL_CLK_HZ, &usbPhyConfig);
|
|
|
|
#endif
|
2019-07-03 21:28:35 -07:00
|
|
|
|
2022-02-24 12:40:02 -06:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usb2), okay) && CONFIG_USB_DC_NXP_EHCI
|
|
|
|
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));
|
|
|
|
USB_EhciPhyInit(kUSB_ControllerEhci1, CPU_XTAL_CLK_HZ, &usbPhyConfig);
|
|
|
|
#endif
|
|
|
|
|
2022-02-16 14:53:43 -06:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc1), okay) && 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
|
2022-02-16 14:53:43 -06:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc2), okay) && 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
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* @return 0
|
|
|
|
*/
|
|
|
|
|
init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:
- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices
They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:
```c
struct init_entry {
int (*init)(const struct device *dev);
/* only set by DEVICE_*, otherwise NULL */
const struct device *dev;
}
```
As a result, we end up with such weird/ugly pattern:
```c
static int my_init(const struct device *dev)
{
/* always NULL! add ARG_UNUSED to avoid compiler warning */
ARG_UNUSED(dev);
...
}
```
This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:
```c
static int my_init(void)
{
...
}
```
This is achieved using a union:
```c
union init_function {
/* for SYS_INIT, used when init_entry.dev == NULL */
int (*sys)(void);
/* for DEVICE*, used when init_entry.dev != NULL */
int (*dev)(const struct device *dev);
};
struct init_entry {
/* stores init function (either for SYS_INIT or DEVICE*)
union init_function init_fn;
/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
* to know which union entry to call.
*/
const struct device *dev;
}
```
This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.
**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
init: convert SYS_INIT functions to the new signature
Conversion scripted using scripts/utils/migrate_sys_init.py.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
manifest: update projects for SYS_INIT changes
Update modules with updated SYS_INIT calls:
- hal_ti
- lvgl
- sof
- TraceRecorderSource
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
tests: devicetree: devices: adjust test
Adjust test according to the recently introduced SYS_INIT
infrastructure.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
tests: kernel: threads: adjust SYS_INIT call
Adjust to the new signature: int (*init_fn)(void);
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-19 09:33:44 +02:00
|
|
|
static int imxrt_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
|
|
|
{
|
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();
|
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
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-03-16 12:14:00 -05:00
|
|
|
#ifdef CONFIG_PLATFORM_SPECIFIC_INIT
|
|
|
|
void z_arm_platform_init(void)
|
|
|
|
{
|
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
|
|
|
|
|
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
|
|
|
SYS_INIT(imxrt_init, PRE_KERNEL_1, 0);
|