Skip to content

Commit b60b4be

Browse files
committed
drivers: dma: nios2_msgdma: Conver to devicetree
Conver the NIOS-II mSGDMA driver to be devicetree based. Add node for dma controller into nios2f.dtsi. Signed-off-by: Kumar Gala <[email protected]>
1 parent 651e4ac commit b60b4be

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

drivers/dma/dma_nios2_msgdma.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#define DT_DRV_COMPAT altr_msgdma
8+
79
#include <device.h>
810
#include <errno.h>
911
#include <init.h>
@@ -40,7 +42,7 @@ static void nios2_msgdma_isr(void *arg)
4042
struct nios2_msgdma_dev_cfg *cfg = DEV_CFG(dev);
4143

4244
/* Call Altera HAL driver ISR */
43-
alt_handle_irq(cfg->msgdma_dev, MSGDMA_0_CSR_IRQ);
45+
alt_handle_irq(cfg->msgdma_dev, DT_INST_IRQN(0));
4446
}
4547

4648
static void nios2_msgdma_callback(void *context)
@@ -205,9 +207,6 @@ static const struct dma_driver_api nios2_msgdma_driver_api = {
205207
.stop = nios2_msgdma_transfer_stop,
206208
};
207209

208-
/* DMA0 */
209-
DEVICE_DECLARE(dma0_nios2);
210-
211210
static int nios2_msgdma0_initialize(const struct device *dev)
212211
{
213212
struct nios2_msgdma_dev_cfg *dev_cfg = DEV_CFG(dev);
@@ -217,12 +216,12 @@ static int nios2_msgdma0_initialize(const struct device *dev)
217216
/* Initialize semaphore */
218217
k_sem_init(&dev_cfg->sem_lock, 1, 1);
219218

220-
alt_msgdma_init(dev_cfg->msgdma_dev, 0, MSGDMA_0_CSR_IRQ);
219+
alt_msgdma_init(dev_cfg->msgdma_dev, 0, DT_INST_IRQN(0));
221220

222-
IRQ_CONNECT(MSGDMA_0_CSR_IRQ, CONFIG_DMA_0_IRQ_PRI,
223-
nios2_msgdma_isr, DEVICE_GET(dma0_nios2), 0);
221+
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(inst, priority),
222+
nios2_msgdma_isr, DEVICE_DT_INST_GET(0), 0);
224223

225-
irq_enable(MSGDMA_0_CSR_IRQ);
224+
irq_enable(DT_INST_IRQN(0));
226225

227226
return 0;
228227
}
@@ -234,6 +233,6 @@ static struct nios2_msgdma_dev_cfg dma0_nios2_config = {
234233
.msgdma_dev = &msgdma_dev0,
235234
};
236235

237-
DEVICE_DEFINE(dma0_nios2, CONFIG_DMA_0_NAME, &nios2_msgdma0_initialize,
236+
DEVICE_DT_INST_DEFINE(0, &nios2_msgdma0_initialize,
238237
device_pm_control_nop, NULL, &dma0_nios2_config, POST_KERNEL,
239238
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &nios2_msgdma_driver_api);

dts/bindings/dma/altr,msgdma.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2021 Linaro Limited
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: Altera mSGDMA (Modular Scatter-Gather DMA)
5+
6+
compatible: "altr,msgdma"
7+
8+
include: dma-controller.yaml
9+
10+
properties:
11+
reg:
12+
required: true
13+
14+
interrupts:
15+
required: true
16+
17+
"#dma-cells":
18+
const: 0

dts/nios2/nios2f.dtsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@
5151
#size-cells = <0>;
5252
reg = <0x100200 0x400>;
5353
label = "I2C_0";
54+
};
5455

56+
dma: dma@100200 {
57+
compatible = "altr,msgdma";
58+
reg = <0x1002c0 0x30>;
59+
label = "DMA_0";
60+
interrupts = <3 3>;
61+
#dma-cells = <0>;
5562
};
5663
};
5764
};

tests/boards/altera_max10/msgdma/src/dma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ void test_msgdma(void)
4444
static uint32_t chan_id;
4545
int i;
4646

47-
dma = device_get_binding(CONFIG_DMA_0_NAME);
48-
zassert_true(dma != NULL, "DMA_0 device not found!!");
47+
dma = DEVICE_DT_GET(DT_NODELABEL(dma));
48+
__ASSERT_NO_MSG(device_is_ready(dma));
4949

5050
/* Init tx buffer */
5151
for (i = 0; i < DMA_BUFF_SIZE; i++) {

0 commit comments

Comments
 (0)