Skip to content
Merged
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
23 changes: 8 additions & 15 deletions components/drivers/dma/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,11 @@ rt_err_t rt_dma_prep_single(struct rt_dma_chan *chan,
}

static struct rt_dma_controller *ofw_find_dma_controller(struct rt_device *dev,
const char *name)
const char *name, struct rt_ofw_cell_args *args)
{
struct rt_dma_controller *ctrl = RT_NULL;
#ifdef RT_USING_OFW
int index;
rt_err_t err;
struct rt_ofw_cell_args dma_args = {};
struct rt_ofw_node *np = dev->ofw_node, *ctrl_np;

if (!np)
Expand All @@ -469,9 +467,9 @@ static struct rt_dma_controller *ofw_find_dma_controller(struct rt_device *dev,
return RT_NULL;
}

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

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

ctrl = rt_ofw_data(ctrl_np);
rt_ofw_node_put(ctrl_np);

if (ctrl && ctrl->ops->ofw_parse)
{
if ((err = ctrl->ops->ofw_parse(ctrl, &dma_args)))
{
ctrl = rt_err_ptr(err);
}
}
}
#endif /* RT_USING_OFW */
return ctrl;
}

struct rt_dma_chan *rt_dma_chan_request(struct rt_device *dev, const char *name)
{
void *fw_data = RT_NULL;
struct rt_dma_chan *chan;
struct rt_ofw_cell_args dma_args;
struct rt_dma_controller *ctrl = RT_NULL;

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

if (name)
{
ctrl = ofw_find_dma_controller(dev, name);
fw_data = &dma_args;
ctrl = ofw_find_dma_controller(dev, name, &dma_args);
}
else
{
Expand All @@ -531,7 +524,7 @@ struct rt_dma_chan *rt_dma_chan_request(struct rt_device *dev, const char *name)

if (ctrl->ops->request_chan)
{
chan = ctrl->ops->request_chan(ctrl, dev);
chan = ctrl->ops->request_chan(ctrl, dev, fw_data);
}
else
{
Expand Down
10 changes: 8 additions & 2 deletions components/drivers/dma/dma_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,14 @@ static void *dma_alloc(struct rt_device *dev, rt_size_t size,

rt_list_for_each_entry(pool, &dma_pool_nodes, list)
{
if ((flags & RT_DMA_F_DEVICE) &&
(!(pool->flags & RT_DMA_F_DEVICE) || pool->dev != dev))
if (pool->flags & RT_DMA_F_DEVICE)
{
if (!(flags & RT_DMA_F_DEVICE) || pool->dev != dev)
{
continue;
}
}
else if ((flags & RT_DMA_F_DEVICE))
{
continue;
}
Expand Down
5 changes: 2 additions & 3 deletions components/drivers/include/drivers/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ struct rt_dma_controller

struct rt_dma_controller_ops
{
struct rt_dma_chan *(*request_chan)(struct rt_dma_controller *ctrl, struct rt_device *slave);
struct rt_dma_chan *(*request_chan)(struct rt_dma_controller *ctrl,
struct rt_device *slave, void *fw_data);
rt_err_t (*release_chan)(struct rt_dma_chan *chan);

rt_err_t (*start)(struct rt_dma_chan *chan);
Expand All @@ -107,8 +108,6 @@ struct rt_dma_controller_ops
rt_err_t (*prep_single)(struct rt_dma_chan *chan,
rt_ubase_t dma_buf_addr, rt_size_t buf_len,
enum rt_dma_transfer_direction dir);

rt_err_t (*ofw_parse)(struct rt_dma_controller *ctrl, struct rt_ofw_cell_args *dma_args);
};

struct rt_dma_chan
Expand Down