1 /* 2 * Copyright 2024 NXP 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <stdio.h> 8 #include <zephyr/init.h> 9 #include <zephyr/kernel.h> 10 #include <zephyr/device.h> 11 #include <zephyr/dt-bindings/rdc/imx_rdc.h> 12 #include <fsl_common.h> 13 #include <fsl_rdc.h> 14 15 #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(rdc)) 16 17 #define rdc_inst ((RDC_Type *)DT_REG_ADDR(DT_NODELABEL(rdc))) 18 19 /* set RDC permission for peripherals */ soc_rdc_init(void)20static void soc_rdc_init(void) 21 { 22 rdc_domain_assignment_t assignment = {0}; 23 rdc_periph_access_config_t periphConfig; 24 25 RDC_Init(rdc_inst); 26 assignment.domainId = A53_DOMAIN_ID; 27 RDC_SetMasterDomainAssignment(rdc_inst, kRDC_Master_A53, &assignment); 28 29 RDC_GetDefaultPeriphAccessConfig(&periphConfig); 30 31 #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart2)) && DT_NODE_HAS_PROP(DT_NODELABEL(uart2), rdc) 32 periphConfig.periph = kRDC_Periph_UART2; 33 periphConfig.policy = RDC_DT_VAL(uart2); 34 RDC_SetPeriphAccessConfig(rdc_inst, &periphConfig); 35 #endif 36 37 #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart4)) && DT_NODE_HAS_PROP(DT_NODELABEL(uart4), rdc) 38 periphConfig.periph = kRDC_Periph_UART4; 39 periphConfig.policy = RDC_DT_VAL(uart4); 40 RDC_SetPeriphAccessConfig(rdc_inst, &periphConfig); 41 #endif 42 43 #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet)) && DT_NODE_HAS_PROP(DT_NODELABEL(enet), rdc) 44 periphConfig.periph = kRDC_Periph_ENET1; 45 periphConfig.policy = RDC_DT_VAL(enet); 46 RDC_SetPeriphAccessConfig(rdc_inst, &periphConfig); 47 #endif 48 } 49 #else 50 51 #define soc_rdc_init() do { } while (false) 52 53 #endif 54 soc_prep_hook(void)55void soc_prep_hook(void) 56 { 57 soc_rdc_init(); 58 } 59