[PATCH v6 03/10] ARM: edma: add AM33XX support to the private EDMA API
Adds support for parsing the TI EDMA DT data into the required EDMA private API platform data. Enables runtime PM support to initialize the EDMA hwmod. Adds AM33XX EMDA crossbar event mux support. Signed-off-by: Matt Porter Acked-by: Sekhar Nori --- arch/arm/common/edma.c | 314 ++-- arch/arm/plat-omap/Kconfig |1 + include/linux/platform_data/edma.h |1 + 3 files changed, 307 insertions(+), 9 deletions(-) diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index 2dce245..beeb1d2 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -24,6 +24,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include @@ -723,6 +730,9 @@ EXPORT_SYMBOL(edma_free_channel); */ int edma_alloc_slot(unsigned ctlr, int slot) { + if (!edma_cc[ctlr]) + return -EINVAL; + if (slot >= 0) slot = EDMA_CHAN_SLOT(slot); @@ -1366,31 +1376,291 @@ void edma_clear_event(unsigned channel) EXPORT_SYMBOL(edma_clear_event); /*---*/ +static int edma_of_read_u32_to_s8_array(const struct device_node *np, +const char *propname, s8 *out_values, +size_t sz) +{ + struct property *prop = of_find_property(np, propname, NULL); + const __be32 *val; + + if (!prop) + return -EINVAL; + if (!prop->value) + return -ENODATA; + if ((sz * sizeof(u32)) > prop->length) + return -EOVERFLOW; + + val = prop->value; + + while (sz--) + *out_values++ = (s8)(be32_to_cpup(val++) & 0xff); + + /* Terminate it */ + *out_values++ = -1; + *out_values++ = -1; + + return 0; +} + +static int edma_of_read_u32_to_s16_array(const struct device_node *np, +const char *propname, s16 *out_values, +size_t sz) +{ + struct property *prop = of_find_property(np, propname, NULL); + const __be32 *val; + + if (!prop) + return -EINVAL; + if (!prop->value) + return -ENODATA; + if ((sz * sizeof(u32)) > prop->length) + return -EOVERFLOW; + + val = prop->value; + + while (sz--) + *out_values++ = (s16)(be32_to_cpup(val++) & 0x); + + /* Terminate it */ + *out_values++ = -1; + *out_values++ = -1; + + return 0; +} + +static int edma_xbar_event_map(struct device *dev, + struct device_node *node, + struct edma_soc_info *pdata, int len) +{ + int ret = 0; + int i; + struct resource res; + void *xbar; + const s16 (*xbar_chans)[2]; + u32 shift, offset, mux; + + xbar_chans = devm_kzalloc(dev, + len/sizeof(s16) + 2*sizeof(s16), + GFP_KERNEL); + if (!xbar_chans) + return -ENOMEM; + + ret = of_address_to_resource(node, 1, &res); + if (IS_ERR_VALUE(ret)) + return -EIO; + + xbar = devm_ioremap(dev, res.start, resource_size(&res)); + if (!xbar) + return -ENOMEM; + + ret = edma_of_read_u32_to_s16_array(node, + "ti,edma-xbar-event-map", + (s16 *)xbar_chans, + len/sizeof(u32)); + if (IS_ERR_VALUE(ret)) + return -EIO; + + for (i = 0; xbar_chans[i][0] != -1; i++) { + shift = (xbar_chans[i][1] % 4) * 8; + offset = xbar_chans[i][1] >> 2; + offset <<= 2; + mux = readl((void *)((u32)xbar + offset)); + mux &= ~(0xff << shift); + mux |= xbar_chans[i][0] << shift; + writel(mux, (void *)((u32)xbar + offset)); + } + + pdata->xbar_chans = xbar_chans; + + return 0; +} + +static int edma_of_parse_dt(struct device *dev, + struct device_node *node, + struct edma_soc_info *pdata) +{ + int ret = 0; + u32 value; + struct property *prop; + size_t sz; + struct edma_rsv_info *rsv_info; + const s16 (*rsv_chans)[2], (*rsv_slots)[2]; + const s8 (*queue_tc_map)[2], (*queue_priority_map)[2]; + + memset(pdata, 0, sizeof(struct edma_soc_info)); + + ret = of_property_read_u32(node, "dma-channels", &value); + if (ret < 0) + return ret; + pdata->n_channel = value; + + ret = of_property_read_u32(node, "ti,edma-regions", &value); + if (ret < 0) + return ret; + pdata->n_region = value; + + ret = of_property_read_
Re: [PATCH v6 03/10] ARM: edma: add AM33XX support to the private EDMA API
On Wednesday 30 January 2013, Matt Porter wrote: > + dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap); > + of_dma_controller_register(dev->of_node, > + of_dma_simple_xlate, > + &edma_filter_info); > + } How do you actually deal with the problem mentioned by Padma, that the filter function does not know which edma instance it is looking at? If you assume that there can only be a single edma instance in the system, that is probably a limitation that should be documented somewhere, and ideally the probe() function should check for that. Arnd ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
Re: [PATCH v6 03/10] ARM: edma: add AM33XX support to the private EDMA API
On Wed, Jan 30, 2013 at 09:32:58AM +, Arnd Bergmann wrote: > On Wednesday 30 January 2013, Matt Porter wrote: > > + dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap); > > + of_dma_controller_register(dev->of_node, > > + of_dma_simple_xlate, > > + &edma_filter_info); > > + } > > How do you actually deal with the problem mentioned by Padma, that > the filter function does not know which edma instance it is looking > at? If you assume that there can only be a single edma instance in > the system, that is probably a limitation that should be documented > somewhere, and ideally the probe() function should check for that. I make an assumption of one edma instance in the system in the case of DT being populated. This is always true right now as the only SoC with two EDMA controllers in existence is Davinci DA850. Until recently, Davinci had no DT support. Given the steady work being done today on DT support for DA850, it'll probably be something needed in 3.10. I will add a comment and check in probe() to capture this assumption and then plan to update separately to support DA850 booting from DT. -Matt ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
Re: [PATCH v6 03/10] ARM: edma: add AM33XX support to the private EDMA API
On Thursday 31 January 2013, Matt Porter wrote: > On Wed, Jan 30, 2013 at 09:32:58AM +, Arnd Bergmann wrote: > > On Wednesday 30 January 2013, Matt Porter wrote: > > > + dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap); > > > + of_dma_controller_register(dev->of_node, > > > + of_dma_simple_xlate, > > > + &edma_filter_info); > > > + } > > > > How do you actually deal with the problem mentioned by Padma, that > > the filter function does not know which edma instance it is looking > > at? If you assume that there can only be a single edma instance in > > the system, that is probably a limitation that should be documented > > somewhere, and ideally the probe() function should check for that. > > I make an assumption of one edma instance in the system in the case of > DT being populated. This is always true right now as the only SoC with > two EDMA controllers in existence is Davinci DA850. Until recently, > Davinci had no DT support. Given the steady work being done today on DT > support for DA850, it'll probably be something needed in 3.10. > > I will add a comment and check in probe() to capture this assumption > and then plan to update separately to support DA850 booting from DT. Ok, sounds good. Hopefully by then we will already have a nicer way to write an xlate function that does not rely on a filter function. Arnd ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
Re: [PATCH v6 03/10] ARM: edma: add AM33XX support to the private EDMA API
On Thu, Jan 31, 2013 at 08:58:39PM +, Arnd Bergmann wrote: > On Thursday 31 January 2013, Matt Porter wrote: > > On Wed, Jan 30, 2013 at 09:32:58AM +, Arnd Bergmann wrote: > > > On Wednesday 30 January 2013, Matt Porter wrote: > > > > + dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap); > > > > + of_dma_controller_register(dev->of_node, > > > > + of_dma_simple_xlate, > > > > + &edma_filter_info); > > > > + } > > > > > > How do you actually deal with the problem mentioned by Padma, that > > > the filter function does not know which edma instance it is looking > > > at? If you assume that there can only be a single edma instance in > > > the system, that is probably a limitation that should be documented > > > somewhere, and ideally the probe() function should check for that. > > > > I make an assumption of one edma instance in the system in the case of > > DT being populated. This is always true right now as the only SoC with > > two EDMA controllers in existence is Davinci DA850. Until recently, > > Davinci had no DT support. Given the steady work being done today on DT > > support for DA850, it'll probably be something needed in 3.10. > > > > I will add a comment and check in probe() to capture this assumption > > and then plan to update separately to support DA850 booting from DT. > > Ok, sounds good. Hopefully by then we will already have a nicer > way to write an xlate function that does not rely on a filter > function. Yes, it would be nice to avoid what Padma had to do. I should have mentioned also that the second EDMA on DA850 has no DMA events of immediate use on it anyway. All the in-kernel users use events on the first controller, except for the second MMC instance. That's only used for a wl12xx module on the EVM and that driver has no DT support so it doesn't matter yet in the DT case. Because of this, DA850 can actually add EDMA DT support immediately (on top of this series) and add DMA support to the DT support already posted for the Davinci SPI and MMC client drivers. -Matt ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
Re: [PATCH v6 03/10] ARM: edma: add AM33XX support to the private EDMA API
On Thu, 2013-01-31 at 16:42 -0500, Matt Porter wrote: > On Thu, Jan 31, 2013 at 08:58:39PM +, Arnd Bergmann wrote: > > On Thursday 31 January 2013, Matt Porter wrote: > > > On Wed, Jan 30, 2013 at 09:32:58AM +, Arnd Bergmann wrote: > > > > On Wednesday 30 January 2013, Matt Porter wrote: > > > > > + dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap); > > > > > + of_dma_controller_register(dev->of_node, > > > > > + of_dma_simple_xlate, > > > > > + &edma_filter_info); > > > > > + } > > > > > > > > How do you actually deal with the problem mentioned by Padma, that > > > > the filter function does not know which edma instance it is looking > > > > at? If you assume that there can only be a single edma instance in > > > > the system, that is probably a limitation that should be documented > > > > somewhere, and ideally the probe() function should check for that. > > > > > > I make an assumption of one edma instance in the system in the case of > > > DT being populated. This is always true right now as the only SoC with > > > two EDMA controllers in existence is Davinci DA850. Until recently, > > > Davinci had no DT support. Given the steady work being done today on DT > > > support for DA850, it'll probably be something needed in 3.10. > > > > > > I will add a comment and check in probe() to capture this assumption > > > and then plan to update separately to support DA850 booting from DT. > > > > Ok, sounds good. Hopefully by then we will already have a nicer > > way to write an xlate function that does not rely on a filter > > function. > > Yes, it would be nice to avoid what Padma had to do. I should have > mentioned also that the second EDMA on DA850 has no DMA events of > immediate use on it anyway. All the in-kernel users use events on the > first controller, except for the second MMC instance. That's only used > for a wl12xx module on the EVM and that driver has no DT support so it > doesn't matter yet in the DT case. Because of this, DA850 can actually > add EDMA DT support immediately (on top of this series) and add DMA > support to the DT support already posted for the Davinci SPI and MMC > client drivers. I haven't followed this whole discussion in details, but please notice that I'm aiming to get DT support for the WiLink modules (wlcore, wl12xx...) for 3.10. ;) -- Cheers, Luca. ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
Re: [PATCH v6 03/10] ARM: edma: add AM33XX support to the private EDMA API
On Fri, Feb 01, 2013 at 08:01:41AM +0200, Luciano Coelho wrote: > On Thu, 2013-01-31 at 16:42 -0500, Matt Porter wrote: > > On Thu, Jan 31, 2013 at 08:58:39PM +, Arnd Bergmann wrote: > > > On Thursday 31 January 2013, Matt Porter wrote: > > > > On Wed, Jan 30, 2013 at 09:32:58AM +, Arnd Bergmann wrote: > > > > > On Wednesday 30 January 2013, Matt Porter wrote: > > > > > > + dma_cap_set(DMA_SLAVE, edma_filter_info.dma_cap); > > > > > > + of_dma_controller_register(dev->of_node, > > > > > > + of_dma_simple_xlate, > > > > > > + &edma_filter_info); > > > > > > + } > > > > > > > > > > How do you actually deal with the problem mentioned by Padma, that > > > > > the filter function does not know which edma instance it is looking > > > > > at? If you assume that there can only be a single edma instance in > > > > > the system, that is probably a limitation that should be documented > > > > > somewhere, and ideally the probe() function should check for that. > > > > > > > > I make an assumption of one edma instance in the system in the case of > > > > DT being populated. This is always true right now as the only SoC with > > > > two EDMA controllers in existence is Davinci DA850. Until recently, > > > > Davinci had no DT support. Given the steady work being done today on DT > > > > support for DA850, it'll probably be something needed in 3.10. > > > > > > > > I will add a comment and check in probe() to capture this assumption > > > > and then plan to update separately to support DA850 booting from DT. > > > > > > Ok, sounds good. Hopefully by then we will already have a nicer > > > way to write an xlate function that does not rely on a filter > > > function. > > > > Yes, it would be nice to avoid what Padma had to do. I should have > > mentioned also that the second EDMA on DA850 has no DMA events of > > immediate use on it anyway. All the in-kernel users use events on the > > first controller, except for the second MMC instance. That's only used > > for a wl12xx module on the EVM and that driver has no DT support so it > > doesn't matter yet in the DT case. Because of this, DA850 can actually > > add EDMA DT support immediately (on top of this series) and add DMA > > support to the DT support already posted for the Davinci SPI and MMC > > client drivers. > > I haven't followed this whole discussion in details, but please notice > that I'm aiming to get DT support for the WiLink modules (wlcore, > wl12xx...) for 3.10. ;) Great, looks like we'll all be synced then. ;) -Matt ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source