Skip to content

Commit 0011e85

Browse files
VitekSTfabiobaltieri
authored andcommitted
drivers: nxp,rtxxx-dsp-ctl: Extend to mimxrt798s/hifi4
Rework the driver so that it can cover multiple variants. Add variant DT bindings. Change the compatible name for the mimxrt685s/cm33 DT. This needed to be done because the hardware initialisation routines (power, clocks, ...) are different from mimxrt685s/hifi4 to mimxrt798s/hifi4. The same is expected for the /hifi1 domain. Signed-off-by: Vit Stanicek <[email protected]>
1 parent 40f0842 commit 0011e85

File tree

6 files changed

+73
-38
lines changed

6 files changed

+73
-38
lines changed

drivers/misc/nxp_rtxxx_dsp_ctrl/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
config NXP_RTXXX_DSP_CTRL
55
bool "NXP i.MX RTxxx DSP control"
6-
depends on DT_HAS_NXP_RTXXX_DSP_CTRL_ENABLED
6+
depends on DT_HAS_NXP_RT600_DSP_CTRL_ENABLED || DT_HAS_NXP_RT700_DSP_CTRL_HIFI4_ENABLED
77
default y
88
help
99
Enables a DSP control driver for NXP i.MX RTxxx devices.

drivers/misc/nxp_rtxxx_dsp_ctrl/nxp_rtxxx_dsp_ctrl.c

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#define DT_DRV_COMPAT nxp_rtxxx_dsp_ctrl
8-
97
#include <zephyr/drivers/misc/nxp_rtxxx_dsp_ctrl/nxp_rtxxx_dsp_ctrl.h>
108
#include <zephyr/dt-bindings/misc/nxp_rtxxx_dsp_ctrl.h>
119

1210
#include <fsl_device_registers.h>
1311
#include <fsl_dsp.h>
1412
#include <fsl_clock.h>
13+
#include <fsl_power.h>
1514

1615
#include <errno.h>
1716
#include <zephyr/init.h>
@@ -24,26 +23,28 @@ struct nxp_rtxxx_dsp_ctrl_region {
2423
};
2524

2625
struct nxp_rtxxx_dsp_ctrl_config {
27-
SYSCTL0_Type *sysctl;
26+
volatile uint32_t *reg_dspstall;
2827
struct nxp_rtxxx_dsp_ctrl_region regions[NXP_RTXXX_DSP_REGION_MAX];
2928
};
3029

3130
static void dsp_ctrl_enable(const struct device *dev)
3231
{
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;
3434

35-
sysctl->DSPSTALL = 0;
35+
*cfg->reg_dspstall = 0;
3636
}
3737

3838
static void dsp_ctrl_disable(const struct device *dev)
3939
{
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;
4142

42-
sysctl->DSPSTALL = 1;
43+
*cfg->reg_dspstall = 1;
4344
}
4445

4546
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)
4748
{
4849
if (section >= NXP_RTXXX_DSP_REGION_MAX) {
4950
return -EINVAL;
@@ -78,41 +79,57 @@ static int dsp_ctrl_load_section(const struct device *dev, const void *base, siz
7879
return 0;
7980
}
8081

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-
9782
static struct nxp_rtxxx_dsp_ctrl_api nxp_rtxxx_dsp_ctrl_api = {
9883
.load_section = dsp_ctrl_load_section,
9984
.enable = dsp_ctrl_enable,
10085
.disable = dsp_ctrl_disable
10186
};
10287

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)},
10891

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)}}; \
11396
\
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, \
11699
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &nxp_rtxxx_dsp_ctrl_api);
117100

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);

dts/arm/nxp/nxp_rt6xx_common.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#address-cells = <1>;
5555
#size-cells = <1>;
5656

57-
compatible = "nxp,rtxxx-dsp-ctrl";
57+
compatible = "nxp,rt600-dsp-ctrl";
5858
sysctl = <&sysctl0>;
5959

6060
status = "disabled";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
include: ["nxp,rtxxx-dsp-ctrl.yaml"]
5+
6+
compatible: "nxp,rt600-dsp-ctrl"
7+
description: NXP i.MX RTxxx DSP control driver (i.MX RT600 HiFi 4 DSP)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
include: ["nxp,rtxxx-dsp-ctrl.yaml"]
5+
6+
compatible: "nxp,rt700-dsp-ctrl-hifi4"
7+
description: NXP i.MX RTxxx DSP control driver (i.MX RT700 HiFi 4 DSP)

dts/bindings/misc/nxp,rtxxx-dsp-ctrl.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Copyright (c) 2025 NXP
22
# SPDX-License-Identifier: Apache-2.0
33

4+
# As Zephyr doesn't (yet) support driver variants as Linux does, this file
5+
# contains common definitions for each variant of the i.MX RTxxx DSP control
6+
# driver. This file is then included in each particular binding.
7+
48
include: [base.yaml]
59

610
compatible: "nxp,rtxxx-dsp-ctrl"

0 commit comments

Comments
 (0)