ep93xx DMA patches
Subsystems (7)
cover ep93xx DMA patches
Hello all,
Motivation of this series was to add DMA support for the ep93xx SPI driver. However, current platform DMA code didn't support the M2M channels which were required for SPI (and IDE) peripherals.
Ryan Mallon suggested that maybe we should integrate both M2M and M2P code under the dmaengine API. The purpose of this series is to do just that and convert all the existing users to use that new API.
Patches 1-4 add dmaengine driver and convert the existing users to dmaengine API. The last patch adds DMA support for the SPI driver.
I've been testing these on TS-7260 (ep9302) connected to SPI EEPROM, and Sim.One (ep9307) with mmc_spi and AC'97 audio.
memcpy() testing has been done by running drivers/dma/dmatest.ko.
Regards,
MW
Mika Westerberg (5):
dmaengine: add ep93xx DMA support
ep93xx: add dmaengine platform code
ASoC: ep93xx: convert to use the DMA engine API
ep93xx: remove the old M2P DMA code
spi/ep93xx: add DMA support
Documentation/spi/ep93xx_spi | 10 + arch/arm/mach-ep93xx/Makefile | 2 +- arch/arm/mach-ep93xx/core.c | 6 +- arch/arm/mach-ep93xx/dma-m2p.c | 411 ------- arch/arm/mach-ep93xx/dma.c | 108 ++ arch/arm/mach-ep93xx/include/mach/dma.h | 190 ++--- arch/arm/mach-ep93xx/include/mach/ep93xx_spi.h | 2 + drivers/dma/Kconfig | 7 + drivers/dma/Makefile | 1 + drivers/dma/ep93xx_dma.c | 1356 ++++++++++++++++++++++++ drivers/spi/ep93xx_spi.c | 303 +++++- sound/soc/ep93xx/ep93xx-ac97.c | 4 +- sound/soc/ep93xx/ep93xx-i2s.c | 4 +- sound/soc/ep93xx/ep93xx-pcm.c | 137 ++-- 14 files changed, 1929 insertions(+), 612 deletions(-) delete mode 100644 arch/arm/mach-ep93xx/dma-m2p.c create mode 100644 arch/arm/mach-ep93xx/dma.c create mode 100644 drivers/dma/ep93xx_dma.c
Signature · 1 line
1.7.4.4
PATCH 1/5 dmaengine: add ep93xx DMA support
The ep93xx DMA controller has 10 independent memory to peripheral (M2P) channels, and 2 dedicated memory to memory (M2M) channels. M2M channels can also be used by SPI and IDE to perform DMA transfers to/from their memory mapped FIFOs.
This driver supports both M2P and M2M channels with DMA_SLAVE, DMA_CYCLIC and DMA_MEMCPY (M2M only) capabilities.
--- arch/arm/mach-ep93xx/include/mach/dma.h | 87 ++ drivers/dma/Kconfig | 7 + drivers/dma/Makefile | 1 + drivers/dma/ep93xx_dma.c | 1356 +++++++++++++++++++++++++++++++ 4 files changed, 1451 insertions(+), 0 deletions(-) create mode 100644 drivers/dma/ep93xx_dma.c
arch/arm/mach-ep93xx/include/mach/dma.h +87 -0
@@ -15,6 +15,8 @@#include <linux/list.h> #include <linux/types.h> +#include <linux/dmaengine.h> +#include <linux/dma-mapping.h> /** * struct ep93xx_dma_buffer - Information about a buffer to be transferred
@@ -146,4 +148,89 @@ void ep93xx_dma_m2p_submit_recursive(struct ep93xx_dma_m2p_client *m2p,*/ void ep93xx_dma_m2p_flush (struct ep93xx_dma_m2p_client *m2p); +/* +* M2P channels. +* +* Note that these values are also directly used for setting the PPALLOC +* register. +*/ +#define EP93XX_DMA_I2S1 0 +#define EP93XX_DMA_I2S2 1 +#define EP93XX_DMA_AAC1 2 +#define EP93XX_DMA_AAC2 3 +#define EP93XX_DMA_AAC3 4 +#define EP93XX_DMA_I2S3 5 +#define EP93XX_DMA_UART1 6 +#define EP93XX_DMA_UART2 7 +#define EP93XX_DMA_UART3 8 +#define EP93XX_DMA_IRDA 9 +/* M2M channels */ +#define EP93XX_DMA_SSP 10 +#define EP93XX_DMA_IDE 11 + +/** +* struct ep93xx_dma_data - configuration data for the EP93xx dmaengine +* @port: peripheral which is requesting the channel +* @direction: TX/RX channel +* @name: optional name for the channel, this is displayed in /proc/interrupts +* +* This information is passed as private channel parameter in a filter +* function. Note that this is only needed for slave/cyclic channels. For +* memcpy channels %NULL data should be passed. +*/ +struct ep93xx_dma_data { +int port; +enum dma_data_direction direction; +const char *name; +}; + +/** +* struct ep93xx_dma_chan_data - platform specific data for a DMA channel +* @name: name of the channel, used for getting the right clock for the channel +* @base: mapped registers +* @irq: interrupt number used by this channel +*/ +struct ep93xx_dma_chan_data { +const char *name; +void __iomem *base; +int irq; +}; + +/** +* struct ep93xx_dma_platform_data - platform data for the dmaengine driver +* @channels: array of channels which are passed to the driver +* @num_channels: number of channels in the array +* +* This structure is passed to the DMA engine driver via platform data. For +* M2P channels, contract is that even channels are for TX and odd for RX. +* There is no requirement for the M2M channels. +*/ +struct ep93xx_dma_platform_data { +struct ep93xx_dma_chan_data *channels; +size_t num_channels; +}; + +static inline bool ep93xx_dma_chan_is_m2p (struct dma_chan *chan) +{ +return !strcmp (dev_name (chan->device->dev),"ep93xx-dma-m2p" ); +} + +/** +* ep93xx_dma_chan_direction - returns direction the channel can be used +* @chan: channel +* +* This function can be used in filter functions to find out whether the +* channel supports given DMA direction. Only M2P channels have such +* limitation, for M2M channels the direction is configurable. +*/ +static inline enum dma_data_direction +ep93xx_dma_chan_direction (struct dma_chan *chan) +{ +if (!ep93xx_dma_chan_is_m2p (chan)) +return DMA_NONE ; + +/* even channels are for TX, odd for RX */ +return (chan->chan_id %2 ==0 ) ?DMA_TO_DEVICE :DMA_FROM_DEVICE ; +} +#endif /* __ASM_ARCH_DMA_H */
drivers/dma/Kconfig +7 -0
@@ -235,6 +235,13 @@ config MXS_DMA Support the MXS DMA engine. This engine including APBH-DMA and APBX-DMA is integrated into Freescale i.MX23/28 chips. +config EP93XX_DMA + bool "Cirrus Logic EP93xx DMA support" + depends on ARCH_EP93XX + select DMA_ENGINE + help + Enable support for the Cirrus Logic EP93xx M2P/M2M DMA controller. + config DMA_ENGINE bool
drivers/dma/Makefile +1 -0
@@ -25,3 +25,4 @@ obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o obj-$(CONFIG_PL330_DMA) += pl330.o obj-$(CONFIG_PCH_DMA) += pch_dma.o obj-$(CONFIG_AMBA_PL08X) += amba-pl08x.o +obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o
drivers/dma/ep93xx_dma.c new file +1356 -0
1,356 lines not on this page · raw message
Signature · 1 line
1.7.4.4
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 8 lines · Mika Westerberg
The ep93xx DMA controller has 10 independent memory to peripheral (M2P) channels, and 2 dedicated memory to memory (M2M) channels. M2M channels can also be used by SPI and IDE to perform DMA transfers to/from their memory mapped FIFOs.
This driver supports both M2P and M2M channels with
DMA_SLAVE,DMA_CYCLICandDMA_MEMCPY(M2M only) capabilities.
Which tree are these patches going thru?
Signature · 1 line
~Vinod
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 2 lines · Vinod
Which tree are these patches going thru?
I was hoping that the dmaengine driver itself would go via dmaengine tree (is it you or Dan who maintain it?) and rest of the patches probably through their respective trees. However, since there are dependencies between the patches, I'm not entirely sure how to proceed with these. Any ideas appreciated :)
Fortunately arch/arm/configs/ep93xx_defconfig doesn't have audio nor SPI enabled by default so it shouldn't matter if the patches go out of order to the mainline.
Thanks,
MW
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 8 lines · Mika Westerberg
Quoted 2 lines · Vinod
Which tree are these patches going thru?
I was hoping that the dmaengine driver itself would go via dmaengine tree (is it you or Dan who maintain it?) and rest of the patches probably through their respective trees. However, since there are dependencies between the patches, I'm not entirely sure how to proceed with these. Any ideas appreciated :)
Okay, I can take the DMA one only.
It stoo late for .40, I can take it for .41 or whatever that turns out to be
Quoted 3 lines
Fortunately
arch/arm/configs/ep93xx_defconfigdoesn't have audio nor SPI enabled by default so it shouldn't matter if the patches go out of order to the mainline.
Signature · 1 line
~Vinod
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 11 lines · Vinod
Quoted 8 lines · Mika Westerberg
Quoted 2 lines · Vinod
Which tree are these patches going thru?
I was hoping that the dmaengine driver itself would go via dmaengine tree (is it you or Dan who maintain it?) and rest of the patches probably through their respective trees. However, since there are dependencies between the patches, I'm not entirely sure how to proceed with these. Any ideas appreciated :)
Okay, I can take the DMA one only.
It stoo late for .40, I can take it for .41 or whatever that turns out to be
Great, thanks.
I'll send updated version of the patches soon where I have gathered all the acks and updated Ryan's email address.
RE: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 10 lines · Mika Westerberg
Quoted 9 lines · Vinod
Quoted 8 lines · Mika Westerberg
Quoted 2 lines · Vinod
Which tree are these patches going thru?
I was hoping that the dmaengine driver itself would go via dmaengine tree (is it you or Dan who maintain it?) and rest of the patches probably through their respective trees. However, since there are dependencies between the patches, I'm not entirely sure how to proceed with these. Any ideas appreciated :)
Quoted 7 lines
Quoted 2 lines
Okay, I can take the DMA one only.
It stoo late for .40, I can take it for .41 or whatever that turns out to beGreat, thanks.
I'll send updated version of the patches soon where I have gathered all the acks and updated Ryan's email address.
Mika,
I'll try to test the patches on my setup today.
Regards,
Hartley
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
In reply to Mika Westerberg2011/5/22 Mika Westerberg <[email protected]>:
Quoted 4 lines
The ep93xx DMA controller has 10 independent memory to peripheral (M2P) channels, and 2 dedicated memory to memory (M2M) channels. M2M channels can also be used by SPI and IDE to perform DMA transfers to/from their memory mapped FIFOs.
No so much a review comment as an observation: I opposed the merge of the EP93xx SPI driver in drivers/spi/ep93xx_spi.c on the grounds that it was close enough to amba-pl022.c that it could use that driver instead.
One of the arguments against was that you were going to do custom DMA and stuff. Now you're using the DMAengine, so can you please reconsider refactoring amba-pl022.c to suit your needs and you'll get DMA support for free mor or less.
Yours,
Linus Walleij
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 7 lines · Linus Walleij
2011/5/22 Mika Westerberg <[email protected]>:
Quoted 4 lines
The ep93xx DMA controller has 10 independent memory to peripheral (M2P) channels, and 2 dedicated memory to memory (M2M) channels. M2M channels can also be used by SPI and IDE to perform DMA transfers to/from their memory mapped FIFOs.
Quoted 8 lines
No so much a review comment as an observation: I opposed the merge of the EP93xx SPI driver in
drivers/spi/ep93xx_spi.con the grounds that it was close enough toamba-pl022.cthat it could use that driver instead.One of the arguments against was that you were going to do custom DMA and stuff. Now you're using the DMAengine, so can you please reconsider refactoring
amba-pl022.cto suit your needs and you'll get DMA support for free mor or less.
Linus is the dma IP same as existing ones?
In that case we shouldn't have a new driver for same IP.
Signature · 1 line
~Vinod
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
2011/5/25 Koul, Vinod <[email protected]>:
Quoted 12 lines · Linus Walleij
Quoted 11 lines
2011/5/22 Mika Westerberg <[email protected]>:
Quoted 4 lines
The ep93xx DMA controller has 10 independent memory to peripheral (M2P) channels, and 2 dedicated memory to memory (M2M) channels. M2M channels can also be used by SPI and IDE to perform DMA transfers to/from their memory mapped FIFOs.
No so much a review comment as an observation: I opposed the merge of the EP93xx SPI driver in
drivers/spi/ep93xx_spi.con the grounds that it was close enough toamba-pl022.cthat it could use that driver instead.
Quoted 7 lines
Quoted 4 lines
One of the arguments against was that you were going to do custom DMA and stuff. Now you're using the DMAengine, so can you please reconsider refactoring
amba-pl022.cto suit your needs and you'll get DMA support for free mor or less.Linus is the dma IP same as existing ones?
In that case we shouldn't have a new driver for same IP.
Nope, not as far as I can tell. The fear of this IP being an amba-pl08x.c already hit med so I checked the register map, but it appears to be unique. I haven't compared it to amba-pl330.c though.
Yours,
Linus Walleij
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
In reply to Linus WalleijQuoted 4 lines · Linus Walleij
No so much a review comment as an observation: I opposed the merge of the EP93xx SPI driver in
drivers/spi/ep93xx_spi.con the grounds that it was close enough toamba-pl022.cthat it could use that driver instead.
I re-checked the specs and indeed, as discussed previously, it is clear that Cirrus (or ARM) copied the interface from other. Even the wording in the document is identical in many places. However, in ep93xx User's Guide, there is no mention about SSP being AMBA PrimeCell peripheral. For UARTs it is mentioned... go figure.
There are differences also, some of the bits in control registers are in different places. Interrupt registers are completely different and there is no DMA control register at all. The same things we discussed before.
Quoted 4 lines
One of the arguments against was that you were going to do custom DMA and stuff. Now you're using the DMAengine, so can you please reconsider refactoring
amba-pl022.cto suit your needs and you'll get DMA support for free mor or less.
Back then, it wasn't known how the M2M DMA interface (the one used by SSP and IDE) was going to be implemented. Now that the dmaengine has become de facto API, it is clear that any "new" DMA implementations should implement that instead of some home grown API. Initially my M2M DMA experiments were just like their M2P counterparts but Ryan suggested dmaengine approach.
IMHO it is better to have ep93xx implementation on its own driver since it is not a real AMBA PL022 peripheral but some weird hack made by Cirrus (although my opinions are bit biased).
Thanks,
MW
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
2011/5/25 Mika Westerberg <[email protected]>:
Quoted 9 lines
I re-checked the specs and indeed, as discussed previously, it is clear that Cirrus (or ARM) copied the interface from other. Even the wording in the document is identical in many places. However, in ep93xx User's Guide, there is no mention about SSP being AMBA PrimeCell peripheral. For UARTs it is mentioned... go figure.
There are differences also, some of the bits in control registers are in different places. Interrupt registers are completely different and there is no DMA control register at all. The same things we discussed before.
But it really does not matter. The amba-pl022.c driver has all the same deviations for things called "PL023" that are not pure PL022 either. I just made the driver a bit more flexible, supporting both.
If the people doing drivers/usb/musb/* had done the same thing we would have had what, 5 drivers for similar hardware?
Quoted 2 lines
Back then, it wasn't known how the M2M DMA interface (the one used by SSP and IDE) was going to be implemented.
But I knew, having just written the needed extensions to dmaengine. And I said so. But I realize I'm maybe not considered an authoritative source on the subject, and I'm biased.
Quoted 3 lines
IMHO it is better to have ep93xx implementation on its own driver since it is not a real AMBA PL022 peripheral but some weird hack made by Cirrus (although my opinions are bit biased).
I disagree because it's IMO at first sight no more deviant than our "PL023" variants that still use the same pl022 driver.
Is there some inexepensive hardware with EP93xx I can get to fix this myself?
Yours,
Linus Walleij
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 7 lines · Linus Walleij
Quoted 4 lines
IMHO it is better to have ep93xx implementation on its own driver since it is not a real AMBA PL022 peripheral but some weird hack made by Cirrus (although my opinions are bit biased).
I disagree because it's IMO at first sight no more deviant than our "PL023" variants that still use the same pl022 driver.
Ok.
Do you think that we can go forward with this patch series if I drop the last patch (spi/ep93xx: add DMA support)? This way we will have dmaengine implementation in place, whatever SPI driver we choose to use with ep93xx.
We can then try to use amba-pl022 driver with ep93xx and see if it works or not, and how much work is needed. I would like some comments from Hartley and Ryan also.
Quoted 2 lines
Is there some inexepensive hardware with EP93xx I can get to fix this myself?
Check for example Technologic Systems (embeddedarm.com), I have their TS-7260 board which has ep9302.
Ryan Mallon
Acked-byRe: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 11 lines · Mika Westerberg
Quoted 7 lines · Linus Walleij
Quoted 4 lines
IMHO it is better to have ep93xx implementation on its own driver since it is not a real AMBA PL022 peripheral but some weird hack made by Cirrus (although my opinions are bit biased).
I disagree because it's IMO at first sight no more deviant than our "PL023" variants that still use the same pl022 driver.
Ok.
Quoted 7 lines
Do you think that we can go forward with this patch series if I drop the last patch (spi/ep93xx: add DMA support)? This way we will have dmaengine implementation in place, whatever SPI driver we choose to use with ep93xx.
We can then try to use amba-pl022 driver with ep93xx and see if it works or not, and how much work is needed. I would like some comments from Hartley and Ryan also.
I think if we can modify the amba-pl022 driver, without it turning into a mess, then we should do that. The ep93xx doesn't really see much attention, so sharing the code base wherever possible should hopefully get better review and testing.
The rest of the patch series is fine by me. You can have my
for the ep93xx core and old dma implementation removal parts.
~Ryan
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
In reply to Mika WesterbergQuoted 3 lines · Mika Westerberg
Do you think that we can go forward with this patch series if I drop the last patch (spi/ep93xx: add DMA support)? This way we will have dmaengine implementation in place, whatever SPI driver we choose to use with ep93xx.
Yes and you don't have to drop any DMA support for the existing driver for me alone, now that it's in the tree it should be maintained. I only wanted to raise the issue of code duplication, not block any patches.
Quoted 3 lines
We can then try to use amba-pl022 driver with ep93xx and see if it works or not, and how much work is needed. I would like some comments from Hartley and Ryan also.
Sure.
Thanks,
Linus Walleij
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 9 lines · Linus Walleij
Quoted 3 lines · Mika Westerberg
Do you think that we can go forward with this patch series if I drop the last patch (spi/ep93xx: add DMA support)? This way we will have dmaengine implementation in place, whatever SPI driver we choose to use with ep93xx.
Yes and you don't have to drop any DMA support for the existing driver for me alone, now that it's in the tree it should be maintained. I only wanted to raise the issue of code duplication, not block any patches.
Ok, so I'll keep the last patch for now.
BTW: if we get amba-pl022 driver to work with ep93xx, do you have any ideas how to proceed from there? I mean, should we convert existing users to use that driver instead and finally remove the ep93xx_spi driver?
RE: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 11 lines · Mika Westerberg
Quoted 9 lines · Linus Walleij
Quoted 3 lines · Mika Westerberg
Do you think that we can go forward with this patch series if I drop the last patch (spi/ep93xx: add DMA support)? This way we will have dmaengine implementation in place, whatever SPI driver we choose to use with ep93xx.
Yes and you don't have to drop any DMA support for the existing driver for me alone, now that it's in the tree it should be maintained. I only wanted to raise the issue of code duplication, not block any patches.
Quoted 5 lines
Ok, so I'll keep the last patch for now.
BTW: if we get amba-pl022 driver to work with ep93xx, do you have any ideas how to proceed from there? I mean, should we convert existing users to use that driver instead and finally remove the
ep93xx_spidriver?
I think the biggest hurdle with using the amba-pl022 driver is that the ep93xx spi peripheral does not have the registers with the pid and cid id's. Without those I don't think the amba bus driver will be able to match the device to the driver.
Regards,
Hartley
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 4 lines · H Hartley Sweeten
I think the biggest hurdle with using the amba-pl022 driver is that the ep93xx spi peripheral does not have the registers with the pid and cid id's. Without those I don't think the amba bus driver will be able to match the device to the driver.
I've just committed Linus' patches to allow a provided ID to override what the bus code finds.
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
In reply to H Hartley Sweeten2011/5/26 H Hartley Sweeten <[email protected]>:
Quoted 4 lines
I think the biggest hurdle with using the amba-pl022 driver is that the ep93xx spi peripheral does not have the registers with the pid and cid id's. ?Without those I don't think the amba bus driver will be able to match the device to the driver.
This is not a problem. We have this code to dynamically create and register a device with a specific periphid on ux500. It worked even before my recent patches to amba's bus.c if you have only zeroes in these registers:
struct amba_device *
dbx500_add_amba_device(const char *name, resource_size_t base,
int irq, void *pdata, unsigned int periphid)
{
struct amba_device *dev;
int ret;
dev = kzalloc(sizeof *dev, GFP_KERNEL);
if (!dev)
return ERR_PTR(-ENOMEM);
dev->dev.init_name = name;
dev->res.start = base;
dev->res.end = base + SZ_4K - 1;
dev->res.flags = IORESOURCE_MEM;
dev->dma_mask = DMA_BIT_MASK(32);
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
dev->irq[0] = irq;
dev->irq[1] = NO_IRQ;
dev->periphid = periphid;
dev->dev.platform_data = pdata;
ret = amba_device_register(dev, &iomem_resource);
if (ret) {
kfree(dev);
return ERR_PTR(ret);
}
return dev;
}I'd recommend coming up with some clever numbering scheme with invented vendor ID.
Yours,
Linus Walleij
RE: [PATCH 1/5] dmaengine: add ep93xx DMA support
In reply to Mika WesterbergQuoted 20 lines · Mika Westerberg
The ep93xx DMA controller has 10 independent memory to peripheral (M2P) channels, and 2 dedicated memory to memory (M2M) channels. M2M channels can also be used by SPI and IDE to perform DMA transfers to/from their memory mapped FIFOs.
This driver supports both M2P and M2M channels with
DMA_SLAVE,DMA_CYCLICandDMA_MEMCPY(M2M only) capabilities.Signed-off-by Mika Westerberg <[email protected]>Cc Dan Williams <[email protected]>Cc Vinod Koul <[email protected]>--- arch/arm/mach-ep93xx/include/mach/dma.h | 87 ++ drivers/dma/Kconfig | 7 + drivers/dma/Makefile | 1 + drivers/dma/ep93xx_dma.c | 1356 +++++++++++++++++++++++++++++++ 4 files changed, 1451 insertions(+), 0 deletions(-) create mode 100644 drivers/dma/ep93xx_dma.c
[snip]
Quoted 7 lines
drivers/dma/Kconfig +0
-0@@ -235,6 +235,13 @@ config MXS_DMA Support the MXS DMA engine. This engine including APBH-DMA and APBX-DMA is integrated into Freescale i.MX23/28 chips.
drivers/dma/Kconfig config MXS_DMA · line 246
Quoted 10 lines
drivers/dma/Kconfig +7
-0+config EP93XX_DMA + bool "Cirrus Logic EP93xx DMA support" + depends on ARCH_EP93XX + select DMA_ENGINE + help + Enable support for the Cirrus Logic EP93xx M2P/M2M DMA controller. + config DMA_ENGINE bool
The old dma-m2p support was always builtin. Should ARCH_EP93XX select EP93XX_DMA to keep this, or should it be added to the ep93xx_defconfig? Ryan, what do you think?
[snip]
Quoted 21 lines
drivers/dma/ep93xx_dma.c new file +15
-0@@ -0,0 +1,1356 @@ +/* +* Driver for the Cirrus Logic EP93xx DMA Controller +* +* Copyright (C) 2011 Mika Westerberg +* +* DMA M2P implementation is based on the original +* arch/arm/mach-ep93xx/dma-m2p.c which has following copyrights: +* +* Copyright (C) 2006 Lennert Buytenhek <[email protected]> +* Copyright (C) 2006 Applied Data Systems +* Copyright (C) 2009 Ryan Mallon <[email protected]> +* +* This driver is based on dw_dmac and amba-pl08x drivers. +* +* This program is free software; you can redistribute it and/or modify
drivers/dma/ep93xx_dma.c line 25
Quoted 10 lines
drivers/dma/ep93xx_dma.c new file +10
-0+* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#include <linux/clk.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/dmaengine.h> +#include <linux/moduleparam.h>
Unnecessary header.
The reset looks fine to me.
Re: [PATCH 1/5] dmaengine: add ep93xx DMA support
Quoted 13 lines · H Hartley Sweeten
drivers/dma/Kconfig config MXS_DMA · line 246
Quoted 10 lines
drivers/dma/Kconfig +7
-0+config EP93XX_DMA + bool "Cirrus Logic EP93xx DMA support" + depends on ARCH_EP93XX + select DMA_ENGINE + help + Enable support for the Cirrus Logic EP93xx M2P/M2M DMA controller. + config DMA_ENGINE boolThe old dma-m2p support was always builtin. Should
ARCH_EP93XXselectEP93XX_DMAto keep this, or should it be added to theep93xx_defconfig?
There are no users for the DMA in ep93xx_defconfig so I think that it shouldn't be selected by default. I was planning to change platform code to be conditionally compiled, like:
arch/arm/mach-ep93xx/Makefile:
+obj-$(CONFIG_EP93XX_DMA) += dma.o
Any objections?
PATCH 2/5 ep93xx: add dmaengine platform code
In reply to Mika WesterbergAdd platform support code for the new EP93xx dmaengine driver.
--- arch/arm/mach-ep93xx/Makefile | 2 +- arch/arm/mach-ep93xx/dma.c | 108 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 1 deletions(-) create mode 100644 arch/arm/mach-ep93xx/dma.c
arch/arm/mach-ep93xx/Makefile +1 -1
@@ -1,7 +1,7 @@ # # Makefile for the linux kernel. # -obj-y := core.o clock.o dma-m2p.o gpio.o +obj-y := core.o clock.o dma-m2p.o dma.o gpio.o obj-m := obj-n := obj- :=
arch/arm/mach-ep93xx/dma.c new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
1.7.4.4
RE: [PATCH 2/5] ep93xx: add dmaengine platform code
Quoted 9 lines · Mika Westerberg
Add platform support code for the new EP93xx dmaengine driver.
Signed-off-by Mika Westerberg <[email protected]>--- arch/arm/mach-ep93xx/Makefile | 2 +- arch/arm/mach-ep93xx/dma.c | 108 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 1 deletions(-) create mode 100644 arch/arm/mach-ep93xx/dma.c
PATCH 3/5 ASoC: ep93xx: convert to use the DMA engine API
In reply to Mika WesterbergNow that we have the EP93xx DMA engine driver in place, we convert the ASoC drivers (I2S, AC97 and PCM) to take advantage of this new API. There are no functional changes.
--- sound/soc/ep93xx/ep93xx-ac97.c | 4 +- sound/soc/ep93xx/ep93xx-i2s.c | 4 +- sound/soc/ep93xx/ep93xx-pcm.c | 137 ++++++++++++++++++++++----------------- 3 files changed, 81 insertions(+), 64 deletions(-)
sound/soc/ep93xx/ep93xx-ac97.c +2 -2
@@ -106,12 +106,12 @@ static struct ep93xx_ac97_info *ep93xx_ac97_info;static struct ep93xx_pcm_dma_params ep93xx_ac97_pcm_out = { .name ="ac97-pcm-out" , - .dma_port =EP93XX_DMA_M2P_PORT_AAC1 , + .dma_port =EP93XX_DMA_AAC1 , };static struct ep93xx_pcm_dma_params ep93xx_ac97_pcm_in = { .name ="ac97-pcm-in" , - .dma_port =EP93XX_DMA_M2P_PORT_AAC1 , + .dma_port =EP93XX_DMA_AAC1 , }; static inline unsigned ep93xx_ac97_read_reg(struct ep93xx_ac97_info *info,
sound/soc/ep93xx/ep93xx-i2s.c +2 -2
@@ -70,11 +70,11 @@ struct ep93xx_i2s_info {struct ep93xx_pcm_dma_params ep93xx_i2s_dma_params[] = { [SNDRV_PCM_STREAM_PLAYBACK ] = { .name ="i2s-pcm-out" , - .dma_port =EP93XX_DMA_M2P_PORT_I2S1 , + .dma_port =EP93XX_DMA_I2S1 , }, [SNDRV_PCM_STREAM_CAPTURE ] = { .name ="i2s-pcm-in" , - .dma_port =EP93XX_DMA_M2P_PORT_I2S1 , + .dma_port =EP93XX_DMA_I2S1 , }, };
sound/soc/ep93xx/ep93xx-pcm.c +77 -60
211 lines not on this page · raw message
Signature · 1 line
1.7.4.4
Re: [PATCH 3/5] ASoC: ep93xx: convert to use the DMA engine API
Quoted 3 lines · Mika Westerberg
Now that we have the EP93xx DMA engine driver in place, we convert the ASoC drivers (I2S, AC97 and PCM) to take advantage of this new API. There are no functional changes.
Given that dmaengine is a standard API I'm wondering if we'll be able to make some sort of generic dmaengine DMA driver for ASoC that could be shared more widely.
Liam Girdwood
Acked-byRe: [PATCH 3/5] ASoC: ep93xx: convert to use the DMA engine API
Quoted 10 lines · Mark Brown
Quoted 3 lines · Mika Westerberg
Now that we have the EP93xx DMA engine driver in place, we convert the ASoC drivers (I2S, AC97 and PCM) to take advantage of this new API. There are no functional changes.
Acked-by Mark Brown <[email protected]>Given that dmaengine is a standard API I'm wondering if we'll be able to make some sort of generic dmaengine DMA driver for ASoC that could be shared more widely.
Agreed and
RE: [PATCH 3/5] ASoC: ep93xx: convert to use the DMA engine API
In reply to Mika WesterbergQuoted 8 lines · Mika Westerberg
Now that we have the EP93xx DMA engine driver in place, we convert the ASoC drivers (I2S, AC97 and PCM) to take advantage of this new API. There are no functional changes.
Signed-off-by Mika Westerberg <[email protected]>Cc Liam Girdwood <[email protected]>Cc Mark Brown <[email protected]>
PATCH 4/5 ep93xx: remove the old M2P DMA code
In reply to Mika WesterbergSince we have converted all existing users of the old DMA API to use the DMA engine API the old code can be dropped.
--- arch/arm/mach-ep93xx/Makefile | 2 +- arch/arm/mach-ep93xx/dma-m2p.c | 411 ------------------------------- arch/arm/mach-ep93xx/include/mach/dma.h | 143 ----------- 3 files changed, 1 insertions(+), 555 deletions(-) delete mode 100644 arch/arm/mach-ep93xx/dma-m2p.c
arch/arm/mach-ep93xx/Makefile +1 -1
@@ -1,7 +1,7 @@ # # Makefile for the linux kernel. # -obj-y := core.o clock.o dma-m2p.o dma.o gpio.o +obj-y := core.o clock.o dma.o gpio.o obj-m := obj-n := obj- :=
arch/arm/mach-ep93xx/dma-m2p.c deleted +0 -411
411 lines not on this page · raw message
arch/arm/mach-ep93xx/include/mach/dma.h +0 -143
153 lines not on this page · raw message
Signature · 1 line
1.7.4.4
RE: [PATCH 4/5] ep93xx: remove the old M2P DMA code
Quoted 11 lines · Mika Westerberg
Since we have converted all existing users of the old DMA API to use the DMA engine API the old code can be dropped.
Signed-off-by Mika Westerberg <[email protected]>--- arch/arm/mach-ep93xx/Makefile | 2 +- arch/arm/mach-ep93xx/dma-m2p.c | 411 ------------------------------- arch/arm/mach-ep93xx/include/mach/dma.h | 143 ----------- 3 files changed, 1 insertions(+), 555 deletions(-) delete mode 100644 arch/arm/mach-ep93xx/dma-m2p.c
Other than my comment in patch 1/5 about the old driver being builtin...
PATCH 5/5 spi/ep93xx: add DMA support
In reply to Mika WesterbergThis patch adds DMA support for the EP93xx SPI driver. By default the DMA is not enabled but it can be enabled by setting ep93xx_spi_info.use_dma to true in board configuration file.
Note that the SPI driver still uses PIO for small transfers (<= 8 bytes) for performance reasons.
--- Documentation/spi/ep93xx_spi | 10 + arch/arm/mach-ep93xx/core.c | 6 +- arch/arm/mach-ep93xx/include/mach/ep93xx_spi.h | 2 + drivers/spi/ep93xx_spi.c | 303 +++++++++++++++++++++++- 4 files changed, 308 insertions(+), 13 deletions(-)
Documentation/spi/ep93xx_spi +10 -0
@@ -88,6 +88,16 @@ static void __init ts72xx_init_machine(void) ARRAY_SIZE(ts72xx_spi_devices)); } +The driver can use DMA for the transfers also. In this case ts72xx_spi_info +becomes: + +static struct ep93xx_spi_info ts72xx_spi_info = { + .num_chipselect = ARRAY_SIZE(ts72xx_spi_devices), + .use_dma = true; +}; + +Note that CONFIG_DMA_ENGINE and CONFIG_EP93XX_DMA should be enabled as well. + Thanks to ========= Martin Guy, H. Hartley Sweeten and others who helped me during development of
arch/arm/mach-ep93xx/core.c +5 -1
@@ -488,11 +488,15 @@ static struct resource ep93xx_spi_resources[] = { }, }; +static u64 ep93xx_spi_dma_mask =DMA_BIT_MASK (32 ); +static struct platform_device ep93xx_spi_device = { .name ="ep93xx-spi" , .id =0 , .dev = { - .platform_data = &ep93xx_spi_master_data, + .platform_data = &ep93xx_spi_master_data, + .coherent_dma_mask =DMA_BIT_MASK (32 ), + .dma_mask = &ep93xx_spi_dma_mask, }, .num_resources =ARRAY_SIZE (ep93xx_spi_resources), .resource = ep93xx_spi_resources,
arch/arm/mach-ep93xx/include/mach/ep93xx_spi.h +2 -0
@@ -7,9 +7,11 @@ struct spi_device;* struct ep93xx_spi_info - EP93xx specific SPI descriptor * @num_chipselect: number of chip selects on this board, must be * at least one +* @use_dma: use DMA for the transfers */ struct ep93xx_spi_info {int num_chipselect; +bool use_dma; };/**
drivers/spi/ep93xx_spi.c +291 -12
403 lines not on this page · raw message
Signature · 1 line
1.7.4.4
RE: [PATCH 5/5] spi/ep93xx: add DMA support
Quoted 24 lines · Mika Westerberg
This patch adds DMA support for the EP93xx SPI driver. By default the DMA is not enabled but it can be enabled by setting ep93xx_spi_info.use_dma to true in board configuration file.
Note that the SPI driver still uses PIO for small transfers (<= 8 bytes) for performance reasons.
Signed-off-by Mika Westerberg <[email protected]>Cc Grant Likely <[email protected]>--- Documentation/spi/ep93xx_spi | 10 + arch/arm/mach-ep93xx/core.c | 6 +- arch/arm/mach-ep93xx/include/mach/ep93xx_spi.h | 2 + drivers/spi/ep93xx_spi.c | 303 +++++++++++++++++++++++- 4 files changed, 308 insertions(+), 13 deletions(-)Documentation/spi/ep93xx_spi +0
-0@@ -88,6 +88,16 @@ static void __init ts72xx_init_machine(void) ARRAY_SIZE(ts72xx_spi_devices)); }
Documentation/spi/ep93xx_spi static void __init ts72xx_init_machine(void) · line 99
Quoted 10 lines
Documentation/spi/ep93xx_spi +9
-0+The driver can use DMA for the transfers also. In this case ts72xx_spi_info +becomes: + +static struct ep93xx_spi_info ts72xx_spi_info = { + .num_chipselect = ARRAY_SIZE(ts72xx_spi_devices), + .use_dma = true; +}; + +Note that CONFIG_DMA_ENGINE and CONFIG_EP93XX_DMA should be enabled as well.
CONFIG_DMA_ENGINE is selected by CONFIG_EP93XX_DMA and it's hidden for that matter. Remove that part of the comment.
The reset looks good.
Quoted 39 lines · Mika Westerberg
Hello all,
Motivation of this series was to add DMA support for the ep93xx SPI driver. However, current platform DMA code didn't support the M2M channels which were required for SPI (and IDE) peripherals.
Ryan Mallon suggested that maybe we should integrate both M2M and M2P code under the dmaengine API. The purpose of this series is to do just that and convert all the existing users to use that new API.
Patches 1-4 add dmaengine driver and convert the existing users to dmaengine API. The last patch adds DMA support for the SPI driver.
I've been testing these on TS-7260 (ep9302) connected to SPI EEPROM, and Sim.One (ep9307) with
mmc_spiand AC'97 audio.
memcpy()testing has been done by runningdrivers/dma/dmatest.ko.Regards,
MWMika Westerberg (5):
dmaengine: add ep93xx DMA support
ep93xx: add dmaengine platform code
ASoC: ep93xx: convert to use the DMA engine API
ep93xx: remove the old M2P DMA code
spi/ep93xx: add DMA supportDocumentation/spi/ep93xx_spi | 10 + arch/arm/mach-ep93xx/Makefile | 2 +- arch/arm/mach-ep93xx/core.c | 6 +- arch/arm/mach-ep93xx/dma-m2p.c | 411 ------- arch/arm/mach-ep93xx/dma.c | 108 ++ arch/arm/mach-ep93xx/include/mach/dma.h | 190 ++--- arch/arm/mach-ep93xx/include/mach/ep93xx_spi.h | 2 + drivers/dma/Kconfig | 7 + drivers/dma/Makefile | 1 + drivers/dma/ep93xx_dma.c | 1356 ++++++++++++++++++++++++
Quoted 8 lines
drivers/spi/ep93xx_spi.c | 303 +++++- sound/soc/ep93xx/ep93xx-ac97.c | 4 +- sound/soc/ep93xx/ep93xx-i2s.c | 4 +- sound/soc/ep93xx/ep93xx-pcm.c | 137 ++-- 14 files changed, 1929 insertions(+), 612 deletions(-) delete mode 100644 arch/arm/mach-ep93xx/dma-m2p.c create mode 100644 arch/arm/mach-ep93xx/dma.c create mode 100644 drivers/dma/ep93xx_dma.c
Mika,
Thanks for posting this. I'll try to do some testing and feedback later this week.
One positive, it looks like this will result in a small reduction in the LOC for arch/arm/mach-ep93xx. That might help in getting this merged. ;-)
Regards,
Hartley
Quoted 13 lines · Mika Westerberg
Hello all,
Motivation of this series was to add DMA support for the ep93xx SPI driver. However, current platform DMA code didn't support the M2M channels which were required for SPI (and IDE) peripherals.
Ryan Mallon suggested that maybe we should integrate both M2M and M2P code under the dmaengine API. The purpose of this series is to do just that and convert all the existing users to use that new API.
Patches 1-4 add dmaengine driver and convert the existing users to dmaengine API. The last patch adds DMA support for the SPI driver.
Quoted 7 lines
I've been testing these on TS-7260 (ep9302) connected to SPI EEPROM, and Sim.One (ep9307) with
mmc_spiand AC'97 audio.
memcpy()testing has been done by runningdrivers/dma/dmatest.ko.Regards,
MW
Hi Mika,
I've had a quick look through the patch series, and I can't see any problems with it. Thanks especially for the thorough documentation in the code. Unfortunately I don't have access to any ep93xx hardware at the moment to do testing. Does anybody else have hardware with I2S audio to test? It sounds like the SPI code is pretty well tested already?
Like Hartley said, it looks like this reduces the size of arch/arm/mach-ep93xx and gets rid of our custom DMA implementation, so we would really like this to get merged.
Also, can you please update my email in the patches to "rmallon at gmail.com" (add my Signed-off-by if you want).
Thanks,
~Ryan
Quoted 27 lines
Mika Westerberg (5):
dmaengine: add ep93xx DMA support
ep93xx: add dmaengine platform code
ASoC: ep93xx: convert to use the DMA engine API
ep93xx: remove the old M2P DMA code
spi/ep93xx: add DMA supportDocumentation/spi/ep93xx_spi | 10 + arch/arm/mach-ep93xx/Makefile | 2 +- arch/arm/mach-ep93xx/core.c | 6 +- arch/arm/mach-ep93xx/dma-m2p.c | 411 ------- arch/arm/mach-ep93xx/dma.c | 108 ++ arch/arm/mach-ep93xx/include/mach/dma.h | 190 ++--- arch/arm/mach-ep93xx/include/mach/ep93xx_spi.h | 2 + drivers/dma/Kconfig | 7 + drivers/dma/Makefile | 1 + drivers/dma/ep93xx_dma.c | 1356 ++++++++++++++++++++++++ drivers/spi/ep93xx_spi.c | 303 +++++- sound/soc/ep93xx/ep93xx-ac97.c | 4 +- sound/soc/ep93xx/ep93xx-i2s.c | 4 +- sound/soc/ep93xx/ep93xx-pcm.c | 137 ++-- 14 files changed, 1929 insertions(+), 612 deletions(-) delete mode 100644 arch/arm/mach-ep93xx/dma-m2p.c create mode 100644 arch/arm/mach-ep93xx/dma.c create mode 100644 drivers/dma/ep93xx_dma.c
Quoted 2 lines · Ryan Mallon
It sounds like the SPI code is pretty well tested already?
Yes, the SPI code should be pretty well tested.
Quoted 2 lines
Also, can you please update my email in the patches to "rmallon at gmail.com" (add my Signed-off-by if you want).
Will do.
Thanks,
MW