ARM: u300: add the COH 901 318 DMAC to device tree
Subsystems (4)
PATCH 19/23 ARM: u300: add the COH 901 318 DMAC to device tree
From: Linus Walleij <[email protected]>
This adds the COH 901 318 DMA controller to the U300 device tree. All devices now converted to device tree so far will start to find their DMA channels.
Note that the U300 is not yet using the device tree to obtain DMA channels, but this is a first step.
--- arch/arm/boot/dts/ste-u300.dts | 7 +++++++ arch/arm/mach-u300/core.c | 2 ++ 2 files changed, 9 insertions(+)
arch/arm/boot/dts/ste-u300.dts +7 -0
@@ -68,6 +68,13 @@ interrupts = <10>; }; + dmac: dmac at c00020000 { + compatible = "stericsson,coh901318"; + reg = <0xc0020000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <2>; + }; + i2c0: i2c at c0004000 { compatible = "st,ddci2c"; reg = <0xc0004000 0x1000>;
arch/arm/mach-u300/core.c +2 -0
@@ -713,6 +713,8 @@ static struct of_dev_auxdata u300_auxdata_lookup[] __initdata = { "coh901327_wdog", NULL),OF_DEV_AUXDATA ("stericsson,coh901331" ,U300_RTC_BASE ,"rtc-coh901331" ,NULL ), +OF_DEV_AUXDATA ("stericsson,coh901318" ,U300_DMAC_BASE , +"coh901318" ,NULL ),OF_DEV_AUXDATA ("arm,primecell" ,U300_UART0_BASE ,"uart0" , &uart0_plat_data), OF_DEV_AUXDATA("arm,primecell", U300_UART1_BASE,
Signature · 1 line
1.7.11.3
PATCH 19/23 ARM: u300: add the COH 901 318 DMAC to device tree
Quoted 8 lines · Linus Walleij
From: Linus Walleij <[email protected]>
This adds the COH 901 318 DMA controller to the U300 device tree. All devices now converted to device tree so far will start to find their DMA channels.
Note that the U300 is not yet using the device tree to obtain DMA channels, but this is a first step.
I think you definitely should implement the entire binding at once. It should be really trivial for this driver, see the patch below. I did not even build test it, but I'm sure you'll figure out the rest.
8<-----
Subject: dma: coh901318: implement of_dma_controller API
This provides a simple xlate and filter function pair for the coh901318 dma engine. Every request line is tied to one channel here, so this is really trivial: the only information we need to pass is the channel number.
---
drivers/dma/coh901318.c +36 -0
@@ -1788,6 +1788,35 @@ bool coh901318_filter_id(struct dma_chan *chan, void *chan_id) }EXPORT_SYMBOL (coh901318_filter_id); +struct coh901318_filter_args { +struct coh901318_base *base; +unsigned int ch_nr; +}; + +static bool coh901318_filter_base_and_id (struct dma_chan *chan,void *data) +{ +struct coh901318_filter_args *args = data; + +if (&args->base->dma_slave == chan->device && + args->ch_nr ==to_coh901318_chan (chan)->id) +return true; + +return false; +} + +static struct dma_chan *coh901318_xlate (struct of_phandle_args *dma_spec, +struct of_dma *ofdma) +{ +struct coh901318_filter_args args = { + .base = ofdma->of_dma_data, + .ch_nr = dma_spec->args[0 ], + }; +dma_cap_mask_t cap; +dma_cap_zero (cap); +dma_cap_set (DMA_SLAVE , cap); + +return dma_request_channel (cap, coh901318_filter_base_and_id, args); +}/* * DMA channel allocation */
@@ -2735,12 +2764,18 @@ static int __init coh901318_probe(struct platform_device *pdev)if (err) goto err_register_memcpy; + ret =of_dma_controller_register (pdev->dev.of_node, coh901318_xlate, base); +if (err) + goto err_register_of_dma; +platform_set_drvdata (pdev, base);dev_info (&pdev->dev,"Initialized COH901318 DMA on virtual base 0x%08x\n" , (u32 ) base->virtbase);return err; + err_register_of_dma: +dma_async_device_unregister (&base->dma_memcpy); err_register_memcpy:dma_async_device_unregister (&base->dma_slave); err_register_slave:
@@ -2752,6 +2787,7 @@ static int __exit coh901318_remove(struct platform_device *pdev) {struct coh901318_base *base =platform_get_drvdata (pdev); +of_dma_controller_free (pdev->dev.of_node);dma_async_device_unregister (&base->dma_memcpy);dma_async_device_unregister (&base->dma_slave);coh901318_pool_destroy (&base->pool);