Skip to content

Commit c4994a9

Browse files
Liyu-xi-anvinodkoul
authored andcommitted
dmaengine: k3dma: Add support for dma-channel-mask
Add dma-channel-mask as a property for k3dma, it defines available dma channels which a non-secure mode driver can use. One sample usage of this is in Hi3660 SoC. DMA channel 0 is reserved to lpm3, which is a coprocessor for power management. So as a result, any request in kernel (which runs on main processor and in non-secure mode) should start from at least channel 1. Cc: Dan Williams <dan.j.williams@intel.com> Cc: Vinod Koul <vkoul@kernel.org> Cc: Tanglei Han <hantanglei@huawei.com> Cc: Zhuangluan Su <suzhuangluan@hisilicon.com> Cc: Ryan Grachek <ryan@edited.us> Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Cc: Guodong Xu <guodong.xu@linaro.org> Cc: dmaengine@vger.kernel.org Signed-off-by: Li Yu <liyu65@hisilicon.com> [jstultz: Reworked to use a channel mask] Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 1200e07 commit c4994a9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

drivers/dma/k3dma.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct k3_dma_dev {
111111
struct dma_pool *pool;
112112
u32 dma_channels;
113113
u32 dma_requests;
114+
u32 dma_channel_mask;
114115
unsigned int irq;
115116
};
116117

@@ -319,6 +320,9 @@ static void k3_dma_tasklet(unsigned long arg)
319320
/* check new channel request in d->chan_pending */
320321
spin_lock_irq(&d->lock);
321322
for (pch = 0; pch < d->dma_channels; pch++) {
323+
if (!(d->dma_channel_mask & (1 << pch)))
324+
continue;
325+
322326
p = &d->phy[pch];
323327

324328
if (p->vchan == NULL && !list_empty(&d->chan_pending)) {
@@ -336,6 +340,9 @@ static void k3_dma_tasklet(unsigned long arg)
336340
spin_unlock_irq(&d->lock);
337341

338342
for (pch = 0; pch < d->dma_channels; pch++) {
343+
if (!(d->dma_channel_mask & (1 << pch)))
344+
continue;
345+
339346
if (pch_alloc & (1 << pch)) {
340347
p = &d->phy[pch];
341348
c = p->vchan;
@@ -856,6 +863,13 @@ static int k3_dma_probe(struct platform_device *op)
856863
"dma-channels", &d->dma_channels);
857864
of_property_read_u32((&op->dev)->of_node,
858865
"dma-requests", &d->dma_requests);
866+
ret = of_property_read_u32((&op->dev)->of_node,
867+
"dma-channel-mask", &d->dma_channel_mask);
868+
if (ret) {
869+
dev_warn(&op->dev,
870+
"dma-channel-mask doesn't exist, considering all as available.\n");
871+
d->dma_channel_mask = (u32)~0UL;
872+
}
859873
}
860874

861875
if (!(soc_data->flags & K3_FLAG_NOCLK)) {
@@ -887,8 +901,12 @@ static int k3_dma_probe(struct platform_device *op)
887901
return -ENOMEM;
888902

889903
for (i = 0; i < d->dma_channels; i++) {
890-
struct k3_dma_phy *p = &d->phy[i];
904+
struct k3_dma_phy *p;
905+
906+
if (!(d->dma_channel_mask & BIT(i)))
907+
continue;
891908

909+
p = &d->phy[i];
892910
p->idx = i;
893911
p->base = d->base + i * 0x40;
894912
}

0 commit comments

Comments
 (0)