Skip to content

Commit 3d6223c

Browse files
committed
Merge pull request #1153 from notro/dma2835
Use bcm2835-dma
2 parents 0c19499 + abe38c6 commit 3d6223c

File tree

7 files changed

+264
-57
lines changed

7 files changed

+264
-57
lines changed

arch/arm/configs/bcm2709_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ CONFIG_RTC_DRV_DS3234=m
10491049
CONFIG_RTC_DRV_PCF2123=m
10501050
CONFIG_RTC_DRV_RX4581=m
10511051
CONFIG_DMADEVICES=y
1052+
CONFIG_DMA_BCM2835=y
10521053
CONFIG_DMA_BCM2708=y
10531054
CONFIG_UIO=m
10541055
CONFIG_UIO_PDRV_GENIRQ=m

arch/arm/configs/bcm2835_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ CONFIG_RTC_DRV_DS3234=m
10411041
CONFIG_RTC_DRV_PCF2123=m
10421042
CONFIG_RTC_DRV_RX4581=m
10431043
CONFIG_DMADEVICES=y
1044+
CONFIG_DMA_BCM2835=y
10441045
CONFIG_DMA_BCM2708=y
10451046
CONFIG_UIO=m
10461047
CONFIG_UIO_PDRV_GENIRQ=m

arch/arm/configs/bcmrpi_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ CONFIG_RTC_DRV_DS3234=m
10421042
CONFIG_RTC_DRV_PCF2123=m
10431043
CONFIG_RTC_DRV_RX4581=m
10441044
CONFIG_DMADEVICES=y
1045+
CONFIG_DMA_BCM2835=y
10451046
CONFIG_DMA_BCM2708=y
10461047
CONFIG_UIO=m
10471048
CONFIG_UIO_PDRV_GENIRQ=m

drivers/dma/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ config DMA_OMAP
348348

349349
config DMA_BCM2835
350350
tristate "BCM2835 DMA engine support"
351-
depends on ARCH_BCM2835
351+
depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709
352352
select DMA_ENGINE
353353
select DMA_VIRTUAL_CHANNELS
354354

drivers/dma/bcm2708-dmaengine.c

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -280,53 +280,35 @@ extern int bcm_dma_chan_free(int channel)
280280
}
281281
EXPORT_SYMBOL_GPL(bcm_dma_chan_free);
282282

283-
static int bcm_dmaman_probe(struct platform_device *pdev)
283+
int bcm_dmaman_probe(struct platform_device *pdev, void __iomem *base,
284+
u32 chans_available)
284285
{
285286
struct device *dev = &pdev->dev;
286287
struct vc_dmaman *dmaman;
287-
struct resource *r;
288-
void __iomem *dma_base;
289-
uint32_t val;
290-
291-
if (!of_property_read_u32(dev->of_node,
292-
"brcm,dma-channel-mask", &val))
293-
dmachans = val;
294-
else if (dmachans == -1)
295-
dmachans = DEFAULT_DMACHAN_BITMAP;
296288

297289
dmaman = devm_kzalloc(dev, sizeof(*dmaman), GFP_KERNEL);
298290
if (!dmaman)
299291
return -ENOMEM;
300292

301293
mutex_init(&dmaman->lock);
302-
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
303-
dma_base = devm_ioremap_resource(dev, r);
304-
if (IS_ERR(dma_base))
305-
return PTR_ERR(dma_base);
306-
307-
vc_dmaman_init(dmaman, dma_base, dmachans);
294+
vc_dmaman_init(dmaman, base, chans_available);
308295
g_dmaman = dmaman;
309296
dmaman_dev = dev;
310297

311298
dev_info(dev, "DMA legacy API manager at %p, dmachans=0x%x\n",
312-
dma_base, dmachans);
299+
base, chans_available);
313300

314301
return 0;
315302
}
303+
EXPORT_SYMBOL(bcm_dmaman_probe);
316304

317-
static int bcm_dmaman_remove(struct platform_device *pdev)
305+
int bcm_dmaman_remove(struct platform_device *pdev)
318306
{
319307
dmaman_dev = NULL;
320308

321309
return 0;
322310
}
323-
324-
#else /* CONFIG_DMA_BCM2708_LEGACY */
325-
326-
static int bcm_dmaman_remove(struct platform_device *pdev)
327-
{
328-
return 0;
329-
}
311+
EXPORT_SYMBOL(bcm_dmaman_remove);
330312

331313
#endif /* CONFIG_DMA_BCM2708_LEGACY */
332314

@@ -1043,7 +1025,7 @@ static void bcm2835_dma_free(struct bcm2835_dmadev *od)
10431025
}
10441026

10451027
static const struct of_device_id bcm2835_dma_of_match[] = {
1046-
{ .compatible = "brcm,bcm2835-dma", },
1028+
{ .compatible = "brcm,bcm2708-dma", },
10471029
{},
10481030
};
10491031
MODULE_DEVICE_TABLE(of, bcm2835_dma_of_match);
@@ -1067,11 +1049,9 @@ static struct dma_chan *bcm2835_dma_xlate(struct of_phandle_args *spec,
10671049
static int bcm2835_dma_probe(struct platform_device *pdev)
10681050
{
10691051
struct bcm2835_dmadev *od;
1070-
#ifndef CONFIG_DMA_BCM2708_LEGACY
10711052
struct resource *res;
10721053
void __iomem *base;
10731054
uint32_t chans_available;
1074-
#endif
10751055
int rc;
10761056
int i;
10771057
int irq;
@@ -1088,6 +1068,11 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
10881068
if (!pdev->dev.dma_mask)
10891069
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
10901070

1071+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1072+
base = devm_ioremap_resource(&pdev->dev, res);
1073+
if (IS_ERR(base))
1074+
return PTR_ERR(base);
1075+
10911076
#ifdef CONFIG_DMA_BCM2708_LEGACY
10921077

10931078
rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
@@ -1100,7 +1085,13 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
11001085
if (!od)
11011086
return -ENOMEM;
11021087

1103-
rc = bcm_dmaman_probe(pdev);
1088+
if (!of_property_read_u32(pdev->dev.of_node,
1089+
"brcm,dma-channel-mask", &chans_available))
1090+
dmachans = chans_available;
1091+
else if (dmachans == -1)
1092+
dmachans = DEFAULT_DMACHAN_BITMAP;
1093+
1094+
rc = bcm_dmaman_probe(pdev, base, dmachans);
11041095
if (rc)
11051096
return rc;
11061097

@@ -1174,15 +1165,8 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
11741165
pdev->dev.dma_parms = &od->dma_parms;
11751166
dma_set_max_seg_size(&pdev->dev, 0x3FFFFFFF);
11761167

1177-
1178-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1179-
base = devm_ioremap_resource(&pdev->dev, res);
1180-
if (IS_ERR(base))
1181-
return PTR_ERR(base);
1182-
11831168
od->base = base;
11841169

1185-
11861170
dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
11871171
dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask);
11881172
dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask);

0 commit comments

Comments
 (0)