2024-01-21 21:58:31 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2024 NXP
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <zephyr/init.h>
|
|
|
|
#include <zephyr/kernel.h>
|
|
|
|
#include <zephyr/device.h>
|
|
|
|
#include <zephyr/dt-bindings/rdc/imx_rdc.h>
|
|
|
|
#include <fsl_common.h>
|
|
|
|
#include <fsl_rdc.h>
|
|
|
|
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(rdc))
|
2024-08-26 19:12:31 +08:00
|
|
|
|
|
|
|
#define rdc_inst ((RDC_Type *)DT_REG_ADDR(DT_NODELABEL(rdc)))
|
|
|
|
|
2024-01-21 21:58:31 +08:00
|
|
|
/* set RDC permission for peripherals */
|
|
|
|
static void soc_rdc_init(void)
|
|
|
|
{
|
|
|
|
rdc_domain_assignment_t assignment = {0};
|
|
|
|
rdc_periph_access_config_t periphConfig;
|
|
|
|
|
2024-08-26 19:12:31 +08:00
|
|
|
RDC_Init(rdc_inst);
|
2024-01-21 21:58:31 +08:00
|
|
|
assignment.domainId = A53_DOMAIN_ID;
|
2024-08-26 19:12:31 +08:00
|
|
|
RDC_SetMasterDomainAssignment(rdc_inst, kRDC_Master_A53, &assignment);
|
2024-01-21 21:58:31 +08:00
|
|
|
|
|
|
|
RDC_GetDefaultPeriphAccessConfig(&periphConfig);
|
|
|
|
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart2)) && DT_NODE_HAS_PROP(DT_NODELABEL(uart2), rdc)
|
2024-01-21 21:58:31 +08:00
|
|
|
periphConfig.periph = kRDC_Periph_UART2;
|
|
|
|
periphConfig.policy = RDC_DT_VAL(uart2);
|
2024-08-26 19:12:31 +08:00
|
|
|
RDC_SetPeriphAccessConfig(rdc_inst, &periphConfig);
|
2024-01-21 21:58:31 +08:00
|
|
|
#endif
|
|
|
|
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart4)) && DT_NODE_HAS_PROP(DT_NODELABEL(uart4), rdc)
|
2024-01-21 21:58:31 +08:00
|
|
|
periphConfig.periph = kRDC_Periph_UART4;
|
|
|
|
periphConfig.policy = RDC_DT_VAL(uart4);
|
2024-08-26 19:12:31 +08:00
|
|
|
RDC_SetPeriphAccessConfig(rdc_inst, &periphConfig);
|
2024-01-21 21:58:31 +08:00
|
|
|
#endif
|
2024-04-24 11:00:34 +08:00
|
|
|
|
2024-09-20 12:47:40 +08:00
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet)) && DT_NODE_HAS_PROP(DT_NODELABEL(enet), rdc)
|
2024-04-24 11:00:34 +08:00
|
|
|
periphConfig.periph = kRDC_Periph_ENET1;
|
|
|
|
periphConfig.policy = RDC_DT_VAL(enet);
|
2024-08-26 19:12:31 +08:00
|
|
|
RDC_SetPeriphAccessConfig(rdc_inst, &periphConfig);
|
2024-04-24 11:00:34 +08:00
|
|
|
#endif
|
2024-12-12 15:46:20 +08:00
|
|
|
|
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(i2c3)) && DT_NODE_HAS_PROP(DT_NODELABEL(i2c3), rdc)
|
|
|
|
periphConfig.periph = kRDC_Periph_I2C3;
|
|
|
|
periphConfig.policy = RDC_DT_VAL(i2c3);
|
|
|
|
RDC_SetPeriphAccessConfig(rdc_inst, &periphConfig);
|
|
|
|
#endif
|
2024-01-21 21:58:31 +08:00
|
|
|
}
|
2024-08-26 19:12:31 +08:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define soc_rdc_init() do { } while (false)
|
|
|
|
|
|
|
|
#endif
|
2024-01-21 21:58:31 +08:00
|
|
|
|
2025-01-27 16:13:43 -06:00
|
|
|
__weak void soc_clock_init(void)
|
2024-12-12 15:46:20 +08:00
|
|
|
{
|
|
|
|
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(i2c3))
|
|
|
|
/* Set I2C source to SysPLL1 Div5 160MHZ */
|
|
|
|
CLOCK_SetRootMux(kCLOCK_RootI2c3, kCLOCK_I2cRootmuxSysPll1Div5);
|
|
|
|
/* Set root clock to 160MHZ / 10 = 16MHZ */
|
|
|
|
CLOCK_SetRootDivider(kCLOCK_RootI2c3, 1U, 10U);
|
|
|
|
CLOCK_EnableClock(kCLOCK_I2c3);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2024-09-10 09:42:40 -04:00
|
|
|
void soc_prep_hook(void)
|
2024-01-21 21:58:31 +08:00
|
|
|
{
|
|
|
|
soc_rdc_init();
|
2024-12-12 15:46:20 +08:00
|
|
|
soc_clock_init();
|
2024-01-21 21:58:31 +08:00
|
|
|
}
|