Skip to content

Commit 72a78a2

Browse files
GuEe-GUIRbb666
authored andcommitted
[DM/DMA] merge ofw_parse and request_chan
Work together can make DMA engine device drivers knows how want a chan easy. Signed-off-by: GuEe-GUI <[email protected]>
1 parent 8f39277 commit 72a78a2

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

components/drivers/dma/dma.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,11 @@ rt_err_t rt_dma_prep_single(struct rt_dma_chan *chan,
448448
}
449449

450450
static struct rt_dma_controller *ofw_find_dma_controller(struct rt_device *dev,
451-
const char *name)
451+
const char *name, struct rt_ofw_cell_args *args)
452452
{
453453
struct rt_dma_controller *ctrl = RT_NULL;
454454
#ifdef RT_USING_OFW
455455
int index;
456-
rt_err_t err;
457-
struct rt_ofw_cell_args dma_args = {};
458456
struct rt_ofw_node *np = dev->ofw_node, *ctrl_np;
459457

460458
if (!np)
@@ -469,9 +467,9 @@ static struct rt_dma_controller *ofw_find_dma_controller(struct rt_device *dev,
469467
return RT_NULL;
470468
}
471469

472-
if (!rt_ofw_parse_phandle_cells(np, "dmas", "#dma-cells", index, &dma_args))
470+
if (!rt_ofw_parse_phandle_cells(np, "dmas", "#dma-cells", index, args))
473471
{
474-
ctrl_np = dma_args.data;
472+
ctrl_np = args->data;
475473

476474
if (!rt_ofw_data(ctrl_np))
477475
{
@@ -480,22 +478,16 @@ static struct rt_dma_controller *ofw_find_dma_controller(struct rt_device *dev,
480478

481479
ctrl = rt_ofw_data(ctrl_np);
482480
rt_ofw_node_put(ctrl_np);
483-
484-
if (ctrl && ctrl->ops->ofw_parse)
485-
{
486-
if ((err = ctrl->ops->ofw_parse(ctrl, &dma_args)))
487-
{
488-
ctrl = rt_err_ptr(err);
489-
}
490-
}
491481
}
492482
#endif /* RT_USING_OFW */
493483
return ctrl;
494484
}
495485

496486
struct rt_dma_chan *rt_dma_chan_request(struct rt_device *dev, const char *name)
497487
{
488+
void *fw_data = RT_NULL;
498489
struct rt_dma_chan *chan;
490+
struct rt_ofw_cell_args dma_args;
499491
struct rt_dma_controller *ctrl = RT_NULL;
500492

501493
if (!dev)
@@ -505,7 +497,8 @@ struct rt_dma_chan *rt_dma_chan_request(struct rt_device *dev, const char *name)
505497

506498
if (name)
507499
{
508-
ctrl = ofw_find_dma_controller(dev, name);
500+
fw_data = &dma_args;
501+
ctrl = ofw_find_dma_controller(dev, name, &dma_args);
509502
}
510503
else
511504
{
@@ -531,7 +524,7 @@ struct rt_dma_chan *rt_dma_chan_request(struct rt_device *dev, const char *name)
531524

532525
if (ctrl->ops->request_chan)
533526
{
534-
chan = ctrl->ops->request_chan(ctrl, dev);
527+
chan = ctrl->ops->request_chan(ctrl, dev, fw_data);
535528
}
536529
else
537530
{

components/drivers/include/drivers/dma.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ struct rt_dma_controller
9090

9191
struct rt_dma_controller_ops
9292
{
93-
struct rt_dma_chan *(*request_chan)(struct rt_dma_controller *ctrl, struct rt_device *slave);
93+
struct rt_dma_chan *(*request_chan)(struct rt_dma_controller *ctrl,
94+
struct rt_device *slave, void *fw_data);
9495
rt_err_t (*release_chan)(struct rt_dma_chan *chan);
9596

9697
rt_err_t (*start)(struct rt_dma_chan *chan);
@@ -107,8 +108,6 @@ struct rt_dma_controller_ops
107108
rt_err_t (*prep_single)(struct rt_dma_chan *chan,
108109
rt_ubase_t dma_buf_addr, rt_size_t buf_len,
109110
enum rt_dma_transfer_direction dir);
110-
111-
rt_err_t (*ofw_parse)(struct rt_dma_controller *ctrl, struct rt_ofw_cell_args *dma_args);
112111
};
113112

114113
struct rt_dma_chan

0 commit comments

Comments
 (0)