From b539699a989a51557b1593c1136a40d504d71e8a Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Thu, 28 Oct 2021 13:49:26 -0500 Subject: [PATCH] drivers: dma: Refactor drivers to use shared init priority Refactors all of the DMA drivers to use a shared driver class initialization priority configuration, CONFIG_DMA_INIT_PRIORITY, to allow configuring DMA drivers separately from other devices. This is similar to other driver classes like I2C and SPI. Most drivers previously used CONFIG_KERNEL_INIT_PRIORITY_DEFAULT or CONFIG_KERNEL_INIT_PRIORITY_DEVICE, therefore the default for this new option is the lower of the two, which means earlier initialization. Signed-off-by: Maureen Helm --- drivers/dma/Kconfig | 6 ++++++ drivers/dma/dma_dw.c | 2 +- drivers/dma/dma_iproc_pax_v1.c | 2 +- drivers/dma/dma_iproc_pax_v2.c | 2 +- drivers/dma/dma_mcux_edma.c | 2 +- drivers/dma/dma_mcux_lpc.c | 2 +- drivers/dma/dma_nios2_msgdma.c | 2 +- drivers/dma/dma_pl330.c | 2 +- drivers/dma/dma_sam0.c | 2 +- drivers/dma/dma_sam_xdmac.c | 2 +- drivers/dma/dma_stm32.c | 2 +- drivers/dma/dmamux_stm32.c | 2 +- 12 files changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 4c6ac81ae4..8e6b047c79 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -16,6 +16,12 @@ config DMA_64BIT When this option is true, 64 bit source and dest DMA addresses are supported. +config DMA_INIT_PRIORITY + int "DMA init priority" + default KERNEL_INIT_PRIORITY_DEFAULT + help + DMA driver device initialization priority. + module = DMA module-str = dma source "subsys/logging/Kconfig.template.log_config" diff --git a/drivers/dma/dma_dw.c b/drivers/dma/dma_dw.c index 58e3afc325..45b4f8684e 100644 --- a/drivers/dma/dma_dw.c +++ b/drivers/dma/dma_dw.c @@ -413,7 +413,7 @@ static const struct dma_driver_api dw_dma_driver_api = { NULL, \ &dw_dma##inst##_data, \ &dw_dma##inst##_config, POST_KERNEL, \ - CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ + CONFIG_DMA_INIT_PRIORITY, \ &dw_dma_driver_api); \ \ static void dw_dma##inst##_irq_config(void) \ diff --git a/drivers/dma/dma_iproc_pax_v1.c b/drivers/dma/dma_iproc_pax_v1.c index 1fdffa9e9d..3e99678e0b 100644 --- a/drivers/dma/dma_iproc_pax_v1.c +++ b/drivers/dma/dma_iproc_pax_v1.c @@ -995,5 +995,5 @@ DEVICE_DT_INST_DEFINE(0, &pax_dma_data, &pax_dma_cfg, POST_KERNEL, - CONFIG_KERNEL_INIT_PRIORITY_DEVICE, + CONFIG_DMA_INIT_PRIORITY, &pax_dma_driver_api); diff --git a/drivers/dma/dma_iproc_pax_v2.c b/drivers/dma/dma_iproc_pax_v2.c index f8894b8c6f..7ea14d3b4f 100644 --- a/drivers/dma/dma_iproc_pax_v2.c +++ b/drivers/dma/dma_iproc_pax_v2.c @@ -1111,5 +1111,5 @@ DEVICE_DT_INST_DEFINE(0, &pax_dma_data, &pax_dma_cfg, POST_KERNEL, - CONFIG_KERNEL_INIT_PRIORITY_DEVICE, + CONFIG_DMA_INIT_PRIORITY, &pax_dma_driver_api); diff --git a/drivers/dma/dma_mcux_edma.c b/drivers/dma/dma_mcux_edma.c index 03c397dfd0..b608269a7f 100644 --- a/drivers/dma/dma_mcux_edma.c +++ b/drivers/dma/dma_mcux_edma.c @@ -456,7 +456,7 @@ struct dma_mcux_edma_data dma_data; */ DEVICE_DT_INST_DEFINE(0, &dma_mcux_edma_init, NULL, &dma_data, &dma_config_0, POST_KERNEL, - CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &dma_mcux_edma_api); + CONFIG_DMA_INIT_PRIORITY, &dma_mcux_edma_api); void dma_imx_config_func_0(const struct device *dev) { diff --git a/drivers/dma/dma_mcux_lpc.c b/drivers/dma/dma_mcux_lpc.c index 9c034121dc..dce3236e19 100644 --- a/drivers/dma/dma_mcux_lpc.c +++ b/drivers/dma/dma_mcux_lpc.c @@ -561,7 +561,7 @@ static const struct dma_mcux_lpc_config dma_##n##_config = { \ &dma_mcux_lpc_init, \ NULL, \ &dma_data_##n, &dma_##n##_config,\ - POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,\ + POST_KERNEL, CONFIG_DMA_INIT_PRIORITY, \ &dma_mcux_lpc_api); \ \ DMA_MCUX_LPC_CONFIG_FUNC(n) \ diff --git a/drivers/dma/dma_nios2_msgdma.c b/drivers/dma/dma_nios2_msgdma.c index 306d6346f0..49d438d37d 100644 --- a/drivers/dma/dma_nios2_msgdma.c +++ b/drivers/dma/dma_nios2_msgdma.c @@ -235,4 +235,4 @@ static struct nios2_msgdma_dev_cfg dma0_nios2_config = { DEVICE_DT_INST_DEFINE(0, &nios2_msgdma0_initialize, NULL, NULL, &dma0_nios2_config, POST_KERNEL, - CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &nios2_msgdma_driver_api); + CONFIG_DMA_INIT_PRIORITY, &nios2_msgdma_driver_api); diff --git a/drivers/dma/dma_pl330.c b/drivers/dma/dma_pl330.c index dc04d93dfd..2a09d901d2 100644 --- a/drivers/dma/dma_pl330.c +++ b/drivers/dma/dma_pl330.c @@ -590,5 +590,5 @@ static struct dma_pl330_dev_data pl330_data; DEVICE_DT_INST_DEFINE(0, &dma_pl330_initialize, NULL, &pl330_data, &pl330_config, - POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, + POST_KERNEL, CONFIG_DMA_INIT_PRIORITY, &pl330_driver_api); diff --git a/drivers/dma/dma_sam0.c b/drivers/dma/dma_sam0.c index 0edf802520..b6490ff661 100644 --- a/drivers/dma/dma_sam0.c +++ b/drivers/dma/dma_sam0.c @@ -459,4 +459,4 @@ static const struct dma_driver_api dma_sam0_api = { DEVICE_DT_INST_DEFINE(0, &dma_sam0_init, NULL, &dmac_data, NULL, PRE_KERNEL_1, - CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &dma_sam0_api); + CONFIG_DMA_INIT_PRIORITY, &dma_sam0_api); diff --git a/drivers/dma/dma_sam_xdmac.c b/drivers/dma/dma_sam_xdmac.c index 3e28db6e88..36a47bd4ed 100644 --- a/drivers/dma/dma_sam_xdmac.c +++ b/drivers/dma/dma_sam_xdmac.c @@ -380,4 +380,4 @@ static struct sam_xdmac_dev_data dma0_sam_data; DEVICE_DT_INST_DEFINE(0, &sam_xdmac_initialize, NULL, &dma0_sam_data, &dma0_sam_config, POST_KERNEL, - CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &sam_xdmac_driver_api); + CONFIG_DMA_INIT_PRIORITY, &sam_xdmac_driver_api); diff --git a/drivers/dma/dma_stm32.c b/drivers/dma/dma_stm32.c index c2a6aff1e3..b1ad48f2eb 100644 --- a/drivers/dma/dma_stm32.c +++ b/drivers/dma/dma_stm32.c @@ -682,7 +682,7 @@ DEVICE_DT_INST_DEFINE(index, \ &dma_stm32_init, \ NULL, \ &dma_stm32_data_##index, &dma_stm32_config_##index, \ - PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + PRE_KERNEL_1, CONFIG_DMA_INIT_PRIORITY, \ &dma_funcs) #ifdef CONFIG_DMA_STM32_SHARED_IRQS diff --git a/drivers/dma/dmamux_stm32.c b/drivers/dma/dmamux_stm32.c index 73e849edc3..e969eb63bd 100644 --- a/drivers/dma/dmamux_stm32.c +++ b/drivers/dma/dmamux_stm32.c @@ -316,7 +316,7 @@ DEVICE_DT_INST_DEFINE(index, \ &dmamux_stm32_init, \ NULL, \ &dmamux_stm32_data_##index, &dmamux_stm32_config_##index,\ - PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + PRE_KERNEL_1, CONFIG_DMA_INIT_PRIORITY, \ &dma_funcs); DT_INST_FOREACH_STATUS_OKAY(DMAMUX_INIT)