drivers: dma_mcux_lpc: Change init level

Change init level of the mcux lpc dma driver to be
PRE_KERNEL_1 because some other hardware drivers
used on the same platforms as the lpc dma will be
dependent on the LPC DMA and are also initialized
in PRE_KERNEL_1, such as the Flexcomm UART driver
when using UART_ASYNC_API.

Therefore, remove k_malloc from init function and
make those variables statically defined instead of
heap allocated.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
Declan Snyder 2023-05-16 17:46:58 -05:00 committed by David Leach
commit 32da420126

View file

@ -488,34 +488,13 @@ static int dma_mcux_lpc_init(const struct device *dev)
{
const struct dma_mcux_lpc_config *config = dev->config;
struct dma_mcux_lpc_dma_data *data = dev->data;
int size_channel_data;
int total_dma_channels;
/* Array to store DMA channel data */
size_channel_data =
sizeof(struct call_back) * config->num_of_channels;
data->data_cb = k_malloc(size_channel_data);
if (!data->data_cb) {
LOG_ERR("HEAP_MEM_POOL_SIZE is too small");
return -ENOMEM;
}
memset(data->data_cb, 0, size_channel_data);
#if defined FSL_FEATURE_DMA_NUMBER_OF_CHANNELS
total_dma_channels = FSL_FEATURE_DMA_NUMBER_OF_CHANNELS;
#else
total_dma_channels = FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(DEV_BASE(dev));
#endif
/*
* This array is used to hold the index associated with the array
* holding channel data
*/
data->channel_index = k_malloc(sizeof(uint32_t) * total_dma_channels);
if (!data->channel_index) {
LOG_ERR("HEAP_MEM_POOL_SIZE is too small");
return -ENOMEM;
}
/*
* Initialize to -1 to indicate dma channel does not have a slot
@ -527,7 +506,6 @@ static int dma_mcux_lpc_init(const struct device *dev)
data->num_channels_used = 0;
DMA_Init(DEV_BASE(dev));
INPUTMUX_Init(INPUTMUX);
@ -564,19 +542,33 @@ static const struct dma_mcux_lpc_config dma_##n##_config = { \
IRQ_FUNC_INIT \
}
#ifdef FSL_FEATURE_DMA_NUMBER_OF_CHANNELS
#define TOTAL_DMA_CHANNELS FSL_FEATURE_DMA_NUMBER_OF_CHANNELS
#else
#define TOTAL_DMA_CHANNELS FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn \
((DMA_Type *)DT_INST_REG_ADDR(n))
#endif
#define DMA_INIT(n) \
\
static const struct dma_mcux_lpc_config dma_##n##_config;\
static const struct dma_mcux_lpc_config dma_##n##_config; \
\
static struct dma_mcux_lpc_dma_data dma_data_##n = { \
.data_cb = NULL, \
static struct call_back dma_##n##_data_cb_arr \
[DT_INST_PROP(n, dma_channels)] = {0}; \
\
static uint32_t \
dma_##n##_channel_index_arr[TOTAL_DMA_CHANNELS] = {0}; \
\
static struct dma_mcux_lpc_dma_data dma_data_##n = { \
.data_cb = dma_##n##_data_cb_arr, \
.channel_index = dma_##n##_channel_index_arr, \
}; \
\
DEVICE_DT_INST_DEFINE(n, \
&dma_mcux_lpc_init, \
NULL, \
&dma_data_##n, &dma_##n##_config,\
POST_KERNEL, CONFIG_DMA_INIT_PRIORITY, \
PRE_KERNEL_1, CONFIG_DMA_INIT_PRIORITY, \
&dma_mcux_lpc_api); \
\
DMA_MCUX_LPC_CONFIG_FUNC(n) \