4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
6
6
7
- #define DT_DRV_COMPAT nxp_rtxxx_dsp_ctrl
8
-
9
7
#include <zephyr/drivers/misc/nxp_rtxxx_dsp_ctrl/nxp_rtxxx_dsp_ctrl.h>
10
8
#include <zephyr/dt-bindings/misc/nxp_rtxxx_dsp_ctrl.h>
11
9
12
10
#include <fsl_device_registers.h>
13
11
#include <fsl_dsp.h>
14
12
#include <fsl_clock.h>
13
+ #include <fsl_power.h>
15
14
16
15
#include <errno.h>
17
16
#include <zephyr/init.h>
@@ -24,26 +23,28 @@ struct nxp_rtxxx_dsp_ctrl_region {
24
23
};
25
24
26
25
struct nxp_rtxxx_dsp_ctrl_config {
27
- SYSCTL0_Type * sysctl ;
26
+ volatile uint32_t * reg_dspstall ;
28
27
struct nxp_rtxxx_dsp_ctrl_region regions [NXP_RTXXX_DSP_REGION_MAX ];
29
28
};
30
29
31
30
static void dsp_ctrl_enable (const struct device * dev )
32
31
{
33
- SYSCTL0_Type * sysctl = ((struct nxp_rtxxx_dsp_ctrl_config * )dev -> config )-> sysctl ;
32
+ const struct nxp_rtxxx_dsp_ctrl_config * cfg =
33
+ (const struct nxp_rtxxx_dsp_ctrl_config * )dev -> config ;
34
34
35
- sysctl -> DSPSTALL = 0 ;
35
+ * cfg -> reg_dspstall = 0 ;
36
36
}
37
37
38
38
static void dsp_ctrl_disable (const struct device * dev )
39
39
{
40
- SYSCTL0_Type * sysctl = ((struct nxp_rtxxx_dsp_ctrl_config * )dev -> config )-> sysctl ;
40
+ const struct nxp_rtxxx_dsp_ctrl_config * cfg =
41
+ (const struct nxp_rtxxx_dsp_ctrl_config * )dev -> config ;
41
42
42
- sysctl -> DSPSTALL = 1 ;
43
+ * cfg -> reg_dspstall = 1 ;
43
44
}
44
45
45
46
static int dsp_ctrl_load_section (const struct device * dev , const void * base , size_t length ,
46
- enum nxp_rtxxx_dsp_ctrl_section_type section )
47
+ enum nxp_rtxxx_dsp_ctrl_section_type section )
47
48
{
48
49
if (section >= NXP_RTXXX_DSP_REGION_MAX ) {
49
50
return - EINVAL ;
@@ -78,41 +79,57 @@ static int dsp_ctrl_load_section(const struct device *dev, const void *base, siz
78
79
return 0 ;
79
80
}
80
81
81
- static int nxp_rtxxx_dsp_ctrl_init (const struct device * dev )
82
- {
83
- /*
84
- * Initialize clocks associated with the DSP.
85
- * Taken from DSP examples for the MIMXRT685-EVK in the MCUXpresso SDK.
86
- */
87
- CLOCK_InitSysPfd (kCLOCK_Pfd1 , 16 );
88
- CLOCK_AttachClk (kDSP_PLL_to_DSP_MAIN_CLK );
89
- CLOCK_SetClkDiv (kCLOCK_DivDspCpuClk , 1 );
90
- CLOCK_SetClkDiv (kCLOCK_DivDspRamClk , 2 );
91
-
92
- DSP_Init ();
93
-
94
- return 0 ;
95
- }
96
-
97
82
static struct nxp_rtxxx_dsp_ctrl_api nxp_rtxxx_dsp_ctrl_api = {
98
83
.load_section = dsp_ctrl_load_section ,
99
84
.enable = dsp_ctrl_enable ,
100
85
.disable = dsp_ctrl_disable
101
86
};
102
87
103
- #define NXP_RTXXX_DSP_SECTION (child_node_id , n ) \
104
- [DT_PROP(child_node_id, type)] = { \
105
- .base = (void *)DT_REG_ADDR(child_node_id), \
106
- .length = DT_REG_SIZE(child_node_id) \
107
- },
88
+ #define NXP_RTXXX_DSP_SECTION (child_node_id , n ) \
89
+ [DT_PROP(child_node_id, type)] = {.base = (void *)DT_REG_ADDR(child_node_id), \
90
+ .length = DT_REG_SIZE(child_node_id)},
108
91
109
- #define NXP_RTXXX_DSP_CTRL (n ) \
110
- static const struct nxp_rtxxx_dsp_ctrl_config nxp_rtxxx_dsp_ctrl_##n##_config = { \
111
- .sysctl = (SYSCTL0_Type *)DT_REG_ADDR(DT_INST_PHANDLE(n, sysctl)), \
112
- .regions = {DT_INST_FOREACH_CHILD_VARGS(n, NXP_RTXXX_DSP_SECTION, n)}}; \
92
+ #define NXP_RTXXX_DSP_CTRL (n , dspstall ) \
93
+ static const struct nxp_rtxxx_dsp_ctrl_config nxp_rtxxx_dsp_ctrl_##n##_config = { \
94
+ .reg_dspstall = (dspstall), \
95
+ .regions = {DT_INST_FOREACH_CHILD_VARGS(n, NXP_RTXXX_DSP_SECTION, n)}}; \
113
96
\
114
- DEVICE_DT_INST_DEFINE(n, nxp_rtxxx_dsp_ctrl_init , NULL, NULL, \
115
- &nxp_rtxxx_dsp_ctrl_##n##_config, PRE_KERNEL_1, \
97
+ DEVICE_DT_INST_DEFINE(n, nxp_rtxxx_dsp_ctrl_##n##_init , NULL, NULL, \
98
+ &nxp_rtxxx_dsp_ctrl_##n##_config, PRE_KERNEL_1, \
116
99
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &nxp_rtxxx_dsp_ctrl_api);
117
100
118
- DT_INST_FOREACH_STATUS_OKAY (NXP_RTXXX_DSP_CTRL );
101
+ /* VARIANT: nxp,rt600-dsp-ctrl */
102
+ #define NXP_RTXXX_DSP_CTRL_RT600_HIFI4 (n ) \
103
+ static int nxp_rtxxx_dsp_ctrl_##n##_init(const struct device *dev) \
104
+ { \
105
+ CLOCK_InitSysPfd(kCLOCK_Pfd1, 16); \
106
+ CLOCK_AttachClk(kDSP_PLL_to_DSP_MAIN_CLK); \
107
+ CLOCK_SetClkDiv(kCLOCK_DivDspCpuClk, 1); \
108
+ CLOCK_SetClkDiv(kCLOCK_DivDspRamClk, 2); \
109
+ \
110
+ DSP_Init(); \
111
+ return 0; \
112
+ } \
113
+ NXP_RTXXX_DSP_CTRL(n, &((SYSCTL0_Type *)DT_REG_ADDR(DT_INST_PHANDLE(n, sysctl)))->DSPSTALL)
114
+ #define DT_DRV_COMPAT nxp_rt600_dsp_ctrl
115
+ DT_INST_FOREACH_STATUS_OKAY (NXP_RTXXX_DSP_CTRL_RT600_HIFI4 );
116
+
117
+ /* VARIANT: nxp,rt700-dsp-ctrl-hifi4 */
118
+ #undef DT_DRV_COMPAT
119
+ #define NXP_RTXXX_DSP_CTRL_RT700_HIFI4 (n ) \
120
+ static int nxp_rtxxx_dsp_ctrl_##n##_init(const struct device *dev) \
121
+ { \
122
+ PMC0->PDRUNCFG2 &= ~0x0003C000U; /* power up dsp used SRAM. */ \
123
+ PMC0 -> PDRUNCFG3 &= ~0x0003C000U ; \
124
+ POWER_DisablePD (kPDRUNCFG_PD_VDD2_DSP ); \
125
+ POWER_ApplyPD ( ); \
126
+ \
127
+ CLOCK_SetClkDiv (kCLOCK_DivDspClk , 1U ); \
128
+ CLOCK_AttachClk (kFRO0_DIV1_to_DSP ); \
129
+ \
130
+ DSP_Init (); \
131
+ return 0 ; \
132
+ } \
133
+ NXP_RTXXX_DSP_CTRL (n , & ((SYSCON0_Type * )DT_REG_ADDR (DT_INST_PHANDLE (n , sysctl )))-> DSPSTALL )
134
+ #define DT_DRV_COMPAT nxp_rt700_dsp_ctrl_hifi4
135
+ DT_INST_FOREACH_STATUS_OKAY (NXP_RTXXX_DSP_CTRL_RT700_HIFI4 );
0 commit comments