Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bcm2835-dma #1153

Merged
merged 7 commits into from
Oct 9, 2015
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
1 change: 1 addition & 0 deletions arch/arm/configs/bcm2709_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ CONFIG_RTC_DRV_DS3234=m
CONFIG_RTC_DRV_PCF2123=m
CONFIG_RTC_DRV_RX4581=m
CONFIG_DMADEVICES=y
CONFIG_DMA_BCM2835=y
CONFIG_DMA_BCM2708=y
CONFIG_UIO=m
CONFIG_UIO_PDRV_GENIRQ=m
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/bcm2835_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ CONFIG_RTC_DRV_DS3234=m
CONFIG_RTC_DRV_PCF2123=m
CONFIG_RTC_DRV_RX4581=m
CONFIG_DMADEVICES=y
CONFIG_DMA_BCM2835=y
CONFIG_DMA_BCM2708=y
CONFIG_UIO=m
CONFIG_UIO_PDRV_GENIRQ=m
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/bcmrpi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ CONFIG_RTC_DRV_DS3234=m
CONFIG_RTC_DRV_PCF2123=m
CONFIG_RTC_DRV_RX4581=m
CONFIG_DMADEVICES=y
CONFIG_DMA_BCM2835=y
CONFIG_DMA_BCM2708=y
CONFIG_UIO=m
CONFIG_UIO_PDRV_GENIRQ=m
Expand Down
2 changes: 1 addition & 1 deletion drivers/dma/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ config DMA_OMAP

config DMA_BCM2835
tristate "BCM2835 DMA engine support"
depends on ARCH_BCM2835
depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709
select DMA_ENGINE
select DMA_VIRTUAL_CHANNELS

Expand Down
56 changes: 20 additions & 36 deletions drivers/dma/bcm2708-dmaengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,53 +280,35 @@ extern int bcm_dma_chan_free(int channel)
}
EXPORT_SYMBOL_GPL(bcm_dma_chan_free);

static int bcm_dmaman_probe(struct platform_device *pdev)
int bcm_dmaman_probe(struct platform_device *pdev, void __iomem *base,
u32 chans_available)
{
struct device *dev = &pdev->dev;
struct vc_dmaman *dmaman;
struct resource *r;
void __iomem *dma_base;
uint32_t val;

if (!of_property_read_u32(dev->of_node,
"brcm,dma-channel-mask", &val))
dmachans = val;
else if (dmachans == -1)
dmachans = DEFAULT_DMACHAN_BITMAP;

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

mutex_init(&dmaman->lock);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
dma_base = devm_ioremap_resource(dev, r);
if (IS_ERR(dma_base))
return PTR_ERR(dma_base);

vc_dmaman_init(dmaman, dma_base, dmachans);
vc_dmaman_init(dmaman, base, chans_available);
g_dmaman = dmaman;
dmaman_dev = dev;

dev_info(dev, "DMA legacy API manager at %p, dmachans=0x%x\n",
dma_base, dmachans);
base, chans_available);

return 0;
}
EXPORT_SYMBOL(bcm_dmaman_probe);

static int bcm_dmaman_remove(struct platform_device *pdev)
int bcm_dmaman_remove(struct platform_device *pdev)
{
dmaman_dev = NULL;

return 0;
}

#else /* CONFIG_DMA_BCM2708_LEGACY */

static int bcm_dmaman_remove(struct platform_device *pdev)
{
return 0;
}
EXPORT_SYMBOL(bcm_dmaman_remove);

#endif /* CONFIG_DMA_BCM2708_LEGACY */

Expand Down Expand Up @@ -1043,7 +1025,7 @@ static void bcm2835_dma_free(struct bcm2835_dmadev *od)
}

static const struct of_device_id bcm2835_dma_of_match[] = {
{ .compatible = "brcm,bcm2835-dma", },
{ .compatible = "brcm,bcm2708-dma", },
{},
};
MODULE_DEVICE_TABLE(of, bcm2835_dma_of_match);
Expand All @@ -1067,11 +1049,9 @@ static struct dma_chan *bcm2835_dma_xlate(struct of_phandle_args *spec,
static int bcm2835_dma_probe(struct platform_device *pdev)
{
struct bcm2835_dmadev *od;
#ifndef CONFIG_DMA_BCM2708_LEGACY
struct resource *res;
void __iomem *base;
uint32_t chans_available;
#endif
int rc;
int i;
int irq;
Expand All @@ -1088,6 +1068,11 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base))
return PTR_ERR(base);

#ifdef CONFIG_DMA_BCM2708_LEGACY

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

rc = bcm_dmaman_probe(pdev);
if (!of_property_read_u32(pdev->dev.of_node,
"brcm,dma-channel-mask", &chans_available))
dmachans = chans_available;
else if (dmachans == -1)
dmachans = DEFAULT_DMACHAN_BITMAP;

rc = bcm_dmaman_probe(pdev, base, dmachans);
if (rc)
return rc;

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


res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base))
return PTR_ERR(base);

od->base = base;


dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask);
dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask);
Expand Down
Loading