Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert NXP EDMA compats by version to property #79872

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/build/kconfig/preprocessor-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ while the ``*_hex`` version returns a hexadecimal value starting with ``0x``.
$(dt_chosen_reg_addr_int,<property in /chosen>[,<index>,<unit>])
$(dt_chosen_reg_size_hex,<property in /chosen>[,<index>,<unit>])
$(dt_chosen_reg_size_int,<property in /chosen>[,<index>,<unit>])
$(dt_compat_any_has_prop,<compatible string>,<prop>)
$(dt_compat_any_has_prop,<compatible string>,<prop>[,<value>])
$(dt_compat_any_on_bus,<compatible string>,<prop>)
$(dt_compat_enabled,<compatible string>)
$(dt_compat_on_bus,<compatible string>,<bus>)
Expand Down
9 changes: 6 additions & 3 deletions drivers/dma/Kconfig.mcux_edma
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@
# Copyright (c) 2020, NXP
# SPDX-License-Identifier: Apache-2.0

EDMA_COMPAT := $(DT_COMPAT_NXP_MCUX_EDMA)
REV_PROP := nxp,version

config DMA_MCUX_EDMA
bool "MCUX DMA driver"
default y
depends on DT_HAS_NXP_MCUX_EDMA_ENABLED
depends on $(dt_compat_any_has_prop,$(EDMA_COMPAT),$(REV_PROP),2)
imply NOCACHE_MEMORY if HAS_MCUX_CACHE
help
DMA driver for MCUX series SoCs.

config DMA_MCUX_EDMA_V3
bool "MCUX DMA v3 driver"
default y
depends on DT_HAS_NXP_MCUX_EDMA_V3_ENABLED
depends on $(dt_compat_any_has_prop,$(EDMA_COMPAT),$(REV_PROP),3)
help
DMA version 3 driver for MCUX series SoCs.

config DMA_MCUX_EDMA_V4
bool "MCUX DMA v4 driver"
default y
depends on DT_HAS_NXP_MCUX_EDMA_V4_ENABLED
depends on $(dt_compat_any_has_prop,$(EDMA_COMPAT),$(REV_PROP),4)
help
DMA version 4 driver for MCUX series SoCs.

Expand Down
20 changes: 6 additions & 14 deletions drivers/dma/dma_mcux_edma.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @brief Common part of DMA drivers for imx rt series.
*/

#define DT_DRV_COMPAT nxp_mcux_edma

#include <errno.h>
#include <soc.h>
#include <zephyr/init.h>
Expand All @@ -23,18 +25,10 @@
#include <zephyr/logging/log.h>
#include <zephyr/irq.h>

#ifdef CONFIG_DMA_MCUX_EDMA
#define DT_DRV_COMPAT nxp_mcux_edma
#elif CONFIG_DMA_MCUX_EDMA_V3
#define DT_DRV_COMPAT nxp_mcux_edma_v3
#elif CONFIG_DMA_MCUX_EDMA_V4
#define DT_DRV_COMPAT nxp_mcux_edma_v4
#endif

LOG_MODULE_REGISTER(dma_mcux_edma, CONFIG_DMA_LOG_LEVEL);

#define HAS_CHANNEL_GAP(n) DT_INST_NODE_HAS_PROP(n, channel_gap) ||
#define HAS_CHANNEL_GAP(n) DT_INST_PROP(n, channel_gap) ||
#define DMA_MCUX_HAS_CHANNEL_GAP (DT_INST_FOREACH_STATUS_OKAY(HAS_CHANNEL_GAP) 0)

Check notice on line 31 in drivers/dma/dma_mcux_edma.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/dma/dma_mcux_edma.c:31 -#define HAS_CHANNEL_GAP(n) DT_INST_PROP(n, channel_gap) || +#define HAS_CHANNEL_GAP(n) DT_INST_PROP(n, channel_gap) ||

struct dma_mcux_edma_config {
DMA_Type *base;
Expand Down Expand Up @@ -675,12 +669,12 @@
LISTIFY(NUM_IRQS_WITHOUT_ERROR_IRQ(n), \
DMA_MCUX_EDMA_IRQ_CONFIG, (;), n) \
\
IF_ENABLED(UTIL_NOT(DT_INST_NODE_HAS_PROP(n, no_error_irq)), \
IF_ENABLED(UTIL_NOT(DT_INST_PROP(n, no_error_irq)), \
(IRQ_CONFIG(n, NUM_IRQS_WITHOUT_ERROR_IRQ(n), \
dma_mcux_edma_error_irq_handler))) \
\
LOG_DBG("install irq done"); \
}

Check notice on line 677 in drivers/dma/dma_mcux_edma.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/dma/dma_mcux_edma.c:677 -#define DMA_MCUX_EDMA_CONFIG_FUNC(n) \ - LISTIFY(NUM_IRQS_WITHOUT_ERROR_IRQ(n), DMA_MCUX_EDMA_IRQ_DEFINE, (), n) \ - static void dma_imx_config_func_##n(const struct device *dev) \ - { \ - ARG_UNUSED(dev); \ - \ +#define DMA_MCUX_EDMA_CONFIG_FUNC(n) \ + LISTIFY(NUM_IRQS_WITHOUT_ERROR_IRQ(n), DMA_MCUX_EDMA_IRQ_DEFINE, (), n) \ + static void dma_imx_config_func_##n(const struct device *dev) \ + { \ + ARG_UNUSED(dev); \ + \ LISTIFY(NUM_IRQS_WITHOUT_ERROR_IRQ(n), \ - DMA_MCUX_EDMA_IRQ_CONFIG, (;), n) \ - \ + DMA_MCUX_EDMA_IRQ_CONFIG, (;), n) \ + \ IF_ENABLED(UTIL_NOT(DT_INST_PROP(n, no_error_irq)), \ (IRQ_CONFIG(n, NUM_IRQS_WITHOUT_ERROR_IRQ(n), \ - dma_mcux_edma_error_irq_handler))) \ - \ - LOG_DBG("install irq done"); \ + dma_mcux_edma_error_irq_handler))) \ + \ + LOG_DBG("install irq done"); \

#if DMA_MCUX_HAS_CHANNEL_GAP
#define DMA_MCUX_EDMA_CHANNEL_GAP(n) \
Expand Down Expand Up @@ -715,7 +709,7 @@
*/
#define DMA_INIT(n) \
DMAMUX_BASE_INIT_DEFINE(n) \
static void dma_imx_config_func_##n(const struct device *dev); \
DMA_MCUX_EDMA_CONFIG_FUNC(n) \
static const struct dma_mcux_edma_config dma_config_##n = { \
.base = (DMA_Type *)DT_INST_REG_ADDR(n), \
DMAMUX_BASE_INIT(n) \
Expand All @@ -732,8 +726,6 @@
&dma_mcux_edma_init, NULL, \
&dma_data_##n, &dma_config_##n, \
PRE_KERNEL_1, CONFIG_DMA_INIT_PRIORITY, \
&dma_mcux_edma_api); \
\
DMA_MCUX_EDMA_CONFIG_FUNC(n);
&dma_mcux_edma_api);

Check notice on line 730 in drivers/dma/dma_mcux_edma.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/dma/dma_mcux_edma.c:730 -#define DMA_INIT(n) \ - DMAMUX_BASE_INIT_DEFINE(n) \ - DMA_MCUX_EDMA_CONFIG_FUNC(n) \ - static const struct dma_mcux_edma_config dma_config_##n = { \ - .base = (DMA_Type *)DT_INST_REG_ADDR(n), \ - DMAMUX_BASE_INIT(n) \ - .dma_channels = DT_INST_PROP(n, dma_channels), \ - CHANNELS_PER_MUX(n) \ - .irq_config_func = dma_imx_config_func_##n, \ - .dmamux_reg_offset = DT_INST_PROP(n, dmamux_reg_offset), \ - DMA_MCUX_EDMA_CHANNEL_GAP(n) \ - }; \ - \ - struct dma_mcux_edma_data dma_data_##n; \ - \ - DEVICE_DT_INST_DEFINE(n, \ - &dma_mcux_edma_init, NULL, \ - &dma_data_##n, &dma_config_##n, \ - PRE_KERNEL_1, CONFIG_DMA_INIT_PRIORITY, \ - &dma_mcux_edma_api); +#define DMA_INIT(n) \ + DMAMUX_BASE_INIT_DEFINE(n) \ + DMA_MCUX_EDMA_CONFIG_FUNC(n) \ + static const struct dma_mcux_edma_config dma_config_##n = { \ + .base = (DMA_Type *)DT_INST_REG_ADDR(n), \ + DMAMUX_BASE_INIT(n).dma_channels = DT_INST_PROP(n, dma_channels), \ + CHANNELS_PER_MUX(n).irq_config_func = dma_imx_config_func_##n, \ + .dmamux_reg_offset = DT_INST_PROP(n, dmamux_reg_offset), \ + DMA_MCUX_EDMA_CHANNEL_GAP(n)}; \ + \ + struct dma_mcux_edma_data dma_data_##n; \ + \ + DEVICE_DT_INST_DEFINE(n, &dma_mcux_edma_init, NULL, &dma_data_##n, &dma_config_##n, \ + PRE_KERNEL_1, CONFIG_DMA_INIT_PRIORITY, &dma_mcux_edma_api);
DT_INST_FOREACH_STATUS_OKAY(DMA_INIT)
1 change: 1 addition & 0 deletions dts/arm/nxp/nxp_k6x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
edma0: dma-controller@40008000 {
#dma-cells = <2>;
compatible = "nxp,mcux-edma";
nxp,version = <2>;
dma-channels = <16>;
dma-requests = <64>;
nxp,mem2mem;
Expand Down
1 change: 1 addition & 0 deletions dts/arm/nxp/nxp_k8x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@
edma0: dma-controller@40008000 {
#dma-cells = <2>;
compatible = "nxp,mcux-edma";
nxp,version = <2>;
dma-channels = <16>;
dma-requests = <64>;
nxp,mem2mem;
Expand Down
1 change: 1 addition & 0 deletions dts/arm/nxp/nxp_ke1xf.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
soc {
edma: dma-controller@40008000 {
compatible = "nxp,mcux-edma";
nxp,version = <2>;
dma-channels = <16>;
dma-requests = <64>;
nxp,mem2mem;
Expand Down
1 change: 1 addition & 0 deletions dts/arm/nxp/nxp_ke1xz.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@

edma: dma-controller@40008000 {
compatible = "nxp,mcux-edma";
nxp,version = <2>;
dma-channels = <8>;
dma-requests = <64>;
nxp,mem2mem;
Expand Down
6 changes: 4 additions & 2 deletions dts/arm/nxp/nxp_mcxn23x_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@

edma0: dma-controller@80000 {
#dma-cells = <2>;
compatible = "nxp,mcux-edma-v4";
compatible = "nxp,mcux-edma";
nxp,version = <4>;
dma-channels = <16>;
dma-requests = <120>;

Expand All @@ -471,7 +472,8 @@

edma1: dma-controller@a0000 {
#dma-cells = <2>;
compatible = "nxp,mcux-edma-v4";
compatible = "nxp,mcux-edma";
nxp,version = <4>;
dma-channels = <16>;
dma-requests = <120>;

Expand Down
6 changes: 4 additions & 2 deletions dts/arm/nxp/nxp_mcxn94x_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@

edma0: dma-controller@80000 {
#dma-cells = <2>;
compatible = "nxp,mcux-edma-v4";
compatible = "nxp,mcux-edma";
nxp,version = <4>;
dma-channels = <16>;
dma-requests = <120>;

Expand All @@ -546,7 +547,8 @@

edma1: dma-controller@a0000 {
#dma-cells = <2>;
compatible = "nxp,mcux-edma-v4";
compatible = "nxp,mcux-edma";
nxp,version = <4>;
dma-channels = <16>;
dma-requests = <120>;

Expand Down
1 change: 1 addition & 0 deletions dts/arm/nxp/nxp_rt10xx.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@
edma0: dma-controller@400e8000 {
#dma-cells = <2>;
compatible = "nxp,mcux-edma";
nxp,version = <2>;
dma-channels = <32>;
dma-requests = <128>;
nxp,mem2mem;
Expand Down
2 changes: 2 additions & 0 deletions dts/arm/nxp/nxp_rt11xx.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@
edma0: dma-controller@40070000 {
#dma-cells = <2>;
compatible = "nxp,mcux-edma";
nxp,version = <2>;
dma-channels = <32>;
dma-requests = <208>;
nxp,mem2mem;
Expand All @@ -1067,6 +1068,7 @@
edma_lpsr0: dma-controller@40c14000 {
#dma-cells = <2>;
compatible = "nxp,mcux-edma";
nxp,version = <2>;
dma-channels = <32>;
dma-requests = <208>;
nxp,mem2mem;
Expand Down
3 changes: 2 additions & 1 deletion dts/arm/nxp/nxp_s32k344_m7.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@
};

edma0: dma-controller@4020c000 {
compatible = "nxp,mcux-edma-v3";
compatible = "nxp,mcux-edma";
nxp,version = <3>;
reg = <0x4020c000 0x3000>, <0x40280000 0x4000>, <0x40284000 0x4000>;
dma-channels = <32>;
dma-requests = <64>;
Expand Down
14 changes: 0 additions & 14 deletions dts/bindings/dma/nxp,mcux-edma-v3.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions dts/bindings/dma/nxp,mcux-edma-v4.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions dts/bindings/dma/nxp,mcux-edma.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ properties:
Describes an offset between two channels share the same interrupt entry.
Default value means each channel has separate interrupt entry.
no-error-irq:
type: boolean
description: |
If the SoCs don't have a separate interrupt id for error IRQ.
nxp,version:
type: int
enum:
- 2
- 3
- 4
description: |
eDMA IP revision number.
"#dma-cells":
type: int
required: true
Expand Down
21 changes: 13 additions & 8 deletions scripts/kconfig/kconfigfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def dt_compat_enabled(kconf, _, compat):

def dt_compat_on_bus(kconf, _, compat, bus):
"""
This function takes a 'compat' and returns "y" if we find an "enabled"
This function takes a 'compat' and returns "y" if we find an enabled
compatible node in the EDT which is on bus 'bus'. It returns "n" otherwise.
"""
if doc_mode or edt is None:
Expand All @@ -751,10 +751,13 @@ def dt_compat_on_bus(kconf, _, compat, bus):

return "n"

def dt_compat_any_has_prop(kconf, _, compat, prop):
def dt_compat_any_has_prop(kconf, _, compat, prop, value=None):
"""
This function takes a 'compat' and a 'prop' and returns "y" if any
node with compatible 'compat' also has a valid property 'prop'.
This function takes a 'compat', a 'prop', and a 'value'.
If value=None, the function returns "y" if any
enabled node with compatible 'compat' also has a valid property 'prop'.
If value is given, the function returns "y" if any enabled node with compatible 'compat'
also has a valid property 'prop' with value 'value'.
It returns "n" otherwise.
"""
if doc_mode or edt is None:
Expand All @@ -763,8 +766,10 @@ def dt_compat_any_has_prop(kconf, _, compat, prop):
if compat in edt.compat2okay:
for node in edt.compat2okay[compat]:
if prop in node.props:
return "y"

if value is None:
return "y"
elif str(node.props[prop].val) == value:
return "y"
return "n"

def dt_nodelabel_has_compat(kconf, _, label, compat):
Expand Down Expand Up @@ -805,7 +810,7 @@ def dt_node_has_compat(kconf, _, path, compat):

def dt_nodelabel_enabled_with_compat(kconf, _, label, compat):
"""
This function takes a 'label' and returns "y" if an "enabled" node with
This function takes a 'label' and returns "y" if an enabled node with
such label can be found in the EDT and that node is compatible with the
provided 'compat', otherwise it returns "n".
"""
Expand Down Expand Up @@ -1000,7 +1005,7 @@ def inc_dec(kconf, name, *args):
"dt_has_compat": (dt_has_compat, 1, 1),
"dt_compat_enabled": (dt_compat_enabled, 1, 1),
"dt_compat_on_bus": (dt_compat_on_bus, 2, 2),
"dt_compat_any_has_prop": (dt_compat_any_has_prop, 2, 2),
"dt_compat_any_has_prop": (dt_compat_any_has_prop, 2, 3),
"dt_chosen_label": (dt_chosen_label, 1, 1),
"dt_chosen_enabled": (dt_chosen_enabled, 1, 1),
"dt_chosen_path": (dt_chosen_path, 1, 1),
Expand Down
Loading