Skip to contentSkip to conversation

ARM: S3C24XX: add dmaengine based dma-driver

PATCH Superseded Heiko Stübner 5 participants 13 messages Aug 14, 2013 – Aug 21, 2013

Subsystems (5)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover ARM: S3C24XX: add dmaengine based dma-driver

This series tries to provide a basic dmaengine driver for the s3c24xx SoCs to subsequently retire the old one with custom API.

Since v1 three big changes happened (appart from fixing received comments):

For one the limitation of sg-lists to 1 element is gone.Secondly the specifics of the virtual channels (target bus, handshake, etc) are not encoded with channel ids but in the platformdata - making a later dt binding easier, as these informations can there be gathered by the xlate function. And lastly I also added a preliminary mechanism to handle the specific needs for the earlier variants of the driver.

While s3c2443 and later can use any channel for any peripheral with just marking the target-peripheral-id in a register, earlier SoCs can only use specific channels and the target-ids also vary depending on the channel.

Therefore on newer SoCs the chansel element only needs to contain the requested target-id, while on the older variants use it to encode both the valid channels and the channel-specific peripheral-id.

On affected SoCs the target-id is always 3 bit wide, so we use these and an additional 4th bit to hold the valid state. As the older SoCs all have 4 dma channels this can live happily in an u16 element.

The s3c24xx series will most likely not see any new offspring, but even if it happens any new model will probably use the newer more flexible variant of the dma controller, so this should not restrict anything in the future.

Example:
SDI is valid on channels 0, 2 and 3 - with varying hw request sources. For it the chansel field would look like

 ((BIT(3) | 1) << 3 * 4) | // channel 3, with request source 1
 ((BIT(3) | 2) << 2 * 4) | // channel 2, with request source 2
 ((BIT(3) | 2) << 0 * 4)   // channel 0, with request source 2

Heiko Stuebner (4):
ARM: S3C24XX: number the dma clocks
dmaengine: add driver for Samsung s3c24xx SoCs
ARM: S3C24XX: add platform-devices for new dma driver for s3c2412 and

    s3c2443

ARM: SAMSUNG: set s3c24xx_dma_filter for s3c64xx-spi0 device

 arch/arm/mach-s3c24xx/clock-s3c2412.c     |    8 +-
 arch/arm/mach-s3c24xx/common-s3c2443.c    |   12 +-
 arch/arm/mach-s3c24xx/common.c            |  106 +++
 arch/arm/mach-s3c24xx/common.h            |    3 +
 arch/arm/mach-s3c24xx/mach-jive.c         |    1 +
 arch/arm/mach-s3c24xx/mach-smdk2413.c     |    1 +
 arch/arm/mach-s3c24xx/mach-smdk2416.c     |    1 +
 arch/arm/mach-s3c24xx/mach-smdk2443.c     |    1 +
 arch/arm/mach-s3c24xx/mach-vstms.c        |    1 +
 arch/arm/plat-samsung/devs.c              |    5 +-
 drivers/dma/Kconfig                       |   12 +
 drivers/dma/Makefile                      |    1 +
 drivers/dma/s3c24xx-dma.c                 | 1255 +++++++++++++++++++++++++++++
 include/linux/platform_data/dma-s3c24xx.h |   43 +
 14 files changed, 1439 insertions(+), 11 deletions(-)
 create mode 100644 drivers/dma/s3c24xx-dma.c
 create mode 100644 include/linux/platform_data/dma-s3c24xx.h
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/4 ARM: S3C24XX: number the dma clocks

Each dma channel has its own clock. The upcoming dma driver wants to handle these itself and therefore needs to be able to get the correct clock for a channel.

Therefore rename the dma clocks to "dma.X" for s3c2412, s3c2416 and s3c2443. This does not change the behaviour for the old dma driver at all, as all dma clocks are still always on and not handled by the old dma driver at all.

are always enabled in the original code.

---
 arch/arm/mach-s3c24xx/clock-s3c2412.c  |    8 ++++----
 arch/arm/mach-s3c24xx/common-s3c2443.c |   12 ++++++------
 2 files changed, 10 insertions(+), 10 deletions(-)
arch/arm/mach-s3c24xx/clock-s3c2412.c +4 -4
index 2cc017d..26e2bdc 100644
@@ -484,22 +484,22 @@ static struct clk init_clocks_disable[] = {
 
 static struct clk init_clocks[] = {
 	{
-		.name		= "dma",
+		.name		= "dma.0",
 		.parent		= &clk_h,
 		.enable		= s3c2412_clkcon_enable,
 		.ctrlbit	= S3C2412_CLKCON_DMA0,
 	}, {
-		.name		= "dma",
+		.name		= "dma.1",
 		.parent		= &clk_h,
 		.enable		= s3c2412_clkcon_enable,
 		.ctrlbit	= S3C2412_CLKCON_DMA1,
 	}, {
-		.name		= "dma",
+		.name		= "dma.2",
 		.parent		= &clk_h,
 		.enable		= s3c2412_clkcon_enable,
 		.ctrlbit	= S3C2412_CLKCON_DMA2,
 	}, {
-		.name		= "dma",
+		.name		= "dma.3",
 		.parent		= &clk_h,
 		.enable		= s3c2412_clkcon_enable,
 		.ctrlbit	= S3C2412_CLKCON_DMA3,
arch/arm/mach-s3c24xx/common-s3c2443.c +6 -6
index f6b9f2e..65d3eef 100644
@@ -438,32 +438,32 @@ static struct clk init_clocks_off[] = {
 
 static struct clk init_clocks[] = {
 	{
-		.name		= "dma",
+		.name		= "dma.0",
 		.parent		= &clk_h,
 		.enable		= s3c2443_clkcon_enable_h,
 		.ctrlbit	= S3C2443_HCLKCON_DMA0,
 	}, {
-		.name		= "dma",
+		.name		= "dma.1",
 		.parent		= &clk_h,
 		.enable		= s3c2443_clkcon_enable_h,
 		.ctrlbit	= S3C2443_HCLKCON_DMA1,
 	}, {
-		.name		= "dma",
+		.name		= "dma.2",
 		.parent		= &clk_h,
 		.enable		= s3c2443_clkcon_enable_h,
 		.ctrlbit	= S3C2443_HCLKCON_DMA2,
 	}, {
-		.name		= "dma",
+		.name		= "dma.3",
 		.parent		= &clk_h,
 		.enable		= s3c2443_clkcon_enable_h,
 		.ctrlbit	= S3C2443_HCLKCON_DMA3,
 	}, {
-		.name		= "dma",
+		.name		= "dma.4",
 		.parent		= &clk_h,
 		.enable		= s3c2443_clkcon_enable_h,
 		.ctrlbit	= S3C2443_HCLKCON_DMA4,
 	}, {
-		.name		= "dma",
+		.name		= "dma.5",
 		.parent		= &clk_h,
 		.enable		= s3c2443_clkcon_enable_h,
 		.ctrlbit	= S3C2443_HCLKCON_DMA5,
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH v2 1/4] ARM: S3C24XX: number the dma clocks

Quoted 4 lines · Heiko Stübner

Each dma channel has its own clock. The upcoming dma driver wants to handle these itself and therefore needs to be able to get the correct clock for a channel.

Quoted 8 lines

Therefore rename the dma clocks to "dma.X" for s3c2412, s3c2416 and s3c2443. This does not change the behaviour for the old dma driver at all, as all dma clocks are still always on and not handled by the old dma driver at all.

are always enabled in the original code.
---

There is some noise at the end of your commit message.

Yours,
Linus Walleij

#3 lore raw

PATCH v2 2/4 dmaengine: add driver for Samsung s3c24xx SoCs

In reply to Heiko Stübner

This adds a new driver to support the s3c24xx dma using the dmaengine and makes the old one in mach-s3c24xx obsolete in the long run.

Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the slave_sg one.

The driver supports both the method for requesting the peripheral used by SoCs before the S3C2443 and the different method for S3C2443 and later.

On earlier SoCs the hardware channels usable for specific peripherals is constrainted while on later SoCs all channels can be used for any peripheral.

Tested on a s3c2416-based board, memcpy using the dmatest module and slave_sg partially using the spi-s3c64xx driver.

---
changes since v1:
- address comments from Linus Walleij
- support sg-lists with more than 1 element
- add support for earlier s3c24xx SoCs
- redo the channeldata definitions:
- no need for static ids for the virtual channels
- provide a way to encode constraints for earlier variants
- better base for later dt bindings

@LinusW: I didn't keep your ack, due to the bigger changes, but feel free
to re-ack if it still looks alright :-)

 drivers/dma/Kconfig                       |   12 +
 drivers/dma/Makefile                      |    1 +
 drivers/dma/s3c24xx-dma.c                 | 1255 +++++++++++++++++++++++++++++
 include/linux/platform_data/dma-s3c24xx.h |   43 +
 4 files changed, 1311 insertions(+)
 create mode 100644 drivers/dma/s3c24xx-dma.c
 create mode 100644 include/linux/platform_data/dma-s3c24xx.h
drivers/dma/Kconfig +12 -0
index 6825957..27729c8 100644
@@ -154,6 +154,18 @@ config TEGRA20_APB_DMA
 	  This DMA controller transfers data from memory to peripheral fifo
 	  or vice versa. It does not support memory to memory data transfer.
 
+config S3C24XX_DMAC
+	tristate "Samsung S3C24XX DMA support"
+	depends on ARCH_S3C24XX && !S3C24XX_DMA
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	help
+	  Support for the Samsung S3C24XX DMA controller driver. The
+	  DMA controller is having multiple DMA channels which can be
+	  configured for different peripherals like audio, UART, SPI.
+	  The DMA controller can transfer data from memory to peripheral,
+	  periphal to memory, periphal to periphal and memory to memory.
+
 source "drivers/dma/sh/Kconfig"
 
 config COH901318
drivers/dma/Makefile +1 -0
index 5e0f2ef..5c1655a 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_SIRF_DMA) += sirf-dma.o
 obj-$(CONFIG_TI_EDMA) += edma.o
 obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o
 obj-$(CONFIG_TEGRA20_APB_DMA) += tegra20-apb-dma.o
+obj-$(CONFIG_S3C24XX_DMAC) += s3c24xx-dma.o
 obj-$(CONFIG_PL330_DMA) += pl330.o
 obj-$(CONFIG_PCH_DMA) += pch_dma.o
 obj-$(CONFIG_AMBA_PL08X) += amba-pl08x.o
drivers/dma/s3c24xx-dma.c new file +1255 -0

1,255 lines not on this page · raw message

include/linux/platform_data/dma-s3c24xx.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#4 lore raw

Re: [PATCH v2 2/4] dmaengine: add driver for Samsung s3c24xx SoCs

Quoted 8 lines · Heiko Stübner

This adds a new driver to support the s3c24xx dma using the dmaengine and makes the old one in mach-s3c24xx obsolete in the long run.

Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the slave_sg one.

If that is the case why cant we have this driver supported from pl08x driver? If the delta is only mapping then can that be seprated or both mapping hanlded? Maybe you and Linus have already though about that?

Quoted 50 lines

The driver supports both the method for requesting the peripheral used by SoCs before the S3C2443 and the different method for S3C2443 and later.

On earlier SoCs the hardware channels usable for specific peripherals is constrainted while on later SoCs all channels can be used for any peripheral.

Tested on a s3c2416-based board, memcpy using the dmatest module and slave_sg partially using the spi-s3c64xx driver.

drivers/dma/s3c24xx-dma.c new file +39 -0
+#define DISRC			(0x00)
+#define DISRCC			(0x04)
+#define DISRCC_INC_INCREMENT	(0 << 0)
+#define DISRCC_INC_FIXED	(1 << 0)
+#define DISRCC_LOC_AHB		(0 << 1)
+#define DISRCC_LOC_APB		(1 << 1)
+
+#define DIDST			(0x08)
+#define DIDSTC			(0x0C)
+#define DIDSTC_INC_INCREMENT	(0 << 0)
+#define DIDSTC_INC_FIXED	(1 << 0)
+#define DIDSTC_LOC_AHB		(0 << 1)
+#define DIDSTC_LOC_APB		(1 << 1)
+#define DIDSTC_INT_TC0		(0 << 2)
+#define DIDSTC_INT_RELOAD	(1 << 2)
+
+#define DCON			(0x10)
+
+#define DCON_TC_MASK		0xfffff
+#define DCON_DSZ_BYTE		(0 << 20)
+#define DCON_DSZ_HALFWORD	(1 << 20)
+#define DCON_DSZ_WORD		(2 << 20)
+#define DCON_DSZ_MASK		(3 << 20)
+#define DCON_DSZ_SHIFT		20
+#define DCON_AUTORELOAD		(0 << 22)
+#define DCON_NORELOAD		(1 << 22)
+#define DCON_HWTRIG		(1 << 23)
+#define DCON_HWSRC_SHIFT	24
+#define DCON_SERV_SINGLE	(0 << 27)
+#define DCON_SERV_WHOLE		(1 << 27)
+#define DCON_TSZ_UNIT		(0 << 28)
+#define DCON_TSZ_BURST4		(1 << 28)
+#define DCON_INT		(1 << 29)
+#define DCON_SYNC_PCLK		(0 << 30)
+#define DCON_SYNC_HCLK		(1 << 30)
+#define DCON_DEMAND		(0 << 31)
+#define DCON_HANDSHAKE		(1 << 31)
+
+#define DSTAT			(0x14)

drivers/dma/s3c24xx-dma.c line 94

Quoted 10 lines
drivers/dma/s3c24xx-dma.c new file +10 -0
+#define DSTAT_STAT_BUSY		(1 << 20)
+#define DSTAT_CURRTC_MASK	0xfffff
+
+#define DMASKTRIG		(0x20)
+#define DMASKTRIG_STOP		(1 << 2)
+#define DMASKTRIG_ON		(1 << 1)
+#define DMASKTRIG_SWTRIG	(1 << 0)
+
+#define DMAREQSEL		(0x24)
+#define DMAREQSEL_HW		(1 << 0)

This is proper namespacing...

drivers/dma/s3c24xx-dma.c line 380

Quoted 12 lines
drivers/dma/s3c24xx-dma.c new file +12 -0
+static int s3c24xx_dma_set_runtime_config(struct s3c24xx_dma_chan *s3cchan,
+				  struct dma_slave_config *config)
+{
+	if (!s3cchan->slave)
+		return -EINVAL;
+
+	/* Reject definitely invalid configurations */
+	if (config->src_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES ||
+	    config->dst_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES)
+		return -EINVAL;
+
+	s3cchan->cfg = *config;

you are takinga ref to client pointer without a clue on when that would be freed. I dont think its a good idea!

drivers/dma/s3c24xx-dma.c line 661

Quoted 12 lines
drivers/dma/s3c24xx-dma.c new file +12 -0
+static irqreturn_t s3c24xx_dma_irq(int irq, void *data)
+{
+	struct s3c24xx_dma_phy *phy = data;
+	struct s3c24xx_dma_chan *s3cchan = phy->serving;
+	struct s3c24xx_txd *txd;
+
+	dev_dbg(&phy->host->pdev->dev, "interrupt on channel %d\n", phy->id);
+
+	if (!s3cchan) {
+		dev_err(&phy->host->pdev->dev, "interrupt on unused channel %d\n",
+			phy->id);
+		return IRQ_NONE;

hmmm, these channles belong to you. So if one of them is behvaing badly, then not handling the interrupt will make things worse...

~Vinod

#5 lore raw

Re: [PATCH v2 2/4] dmaengine: add driver for Samsung s3c24xx SoCs

Quoted 12 lines · On Monday 19 of August 2013 10:18:12 Vinod Koul wrote:
Quoted 10 lines · Heiko Stübner

This adds a new driver to support the s3c24xx dma using the dmaengine and makes the old one in mach-s3c24xx obsolete in the long run.

Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones.
The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition
to the slave_sg one.

Quoted 3 lines

If that is the case why cant we have this driver supported from pl08x driver? If the delta is only mapping then can that be seprated or both mapping hanlded? Maybe you and Linus have already though about that?

Well, the similarity here is only conceptual. Both controllers are completely different in terms of their programming interfaces, not even mentioning that s3c24xx-dma doesn't support LLIs and this must be handled in software.

Best regards,
Tomasz

#6 lore raw

Re: [PATCH v2 2/4] dmaengine: add driver for Samsung s3c24xx SoCs

In reply to Vinod Koul

Hi Vinod,

Am Montag, 19. August 2013, 06:48:12 schrieb Vinod Koul:

Quoted 10 lines · Heiko Stübner
Quoted 8 lines

This adds a new driver to support the s3c24xx dma using the dmaengine and makes the old one in mach-s3c24xx obsolete in the long run.

Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the slave_sg one.

Quoted 3 lines

If that is the case why cant we have this driver supported from pl08x driver? If the delta is only mapping then can that be seprated or both mapping hanlded? Maybe you and Linus have already though about that?

Yes we have ... As Tomasz has already written the hardware itself is very much different. It's only the concept of mapping virtual channels to physical channels that is somehow similar.

It seems my patch message is lacking in making this clearer ;-) .

Quoted 56 lines
Quoted 56 lines

The driver supports both the method for requesting the peripheral used by SoCs before the S3C2443 and the different method for S3C2443 and later.

On earlier SoCs the hardware channels usable for specific peripherals is constrainted while on later SoCs all channels can be used for any peripheral.

Tested on a s3c2416-based board, memcpy using the dmatest module and slave_sg partially using the spi-s3c64xx driver.

drivers/dma/s3c24xx-dma.c new file +43 -0
+#define DISRC			(0x00)
+#define DISRCC			(0x04)
+#define DISRCC_INC_INCREMENT	(0 << 0)
+#define DISRCC_INC_FIXED	(1 << 0)
+#define DISRCC_LOC_AHB		(0 << 1)
+#define DISRCC_LOC_APB		(1 << 1)
+
+#define DIDST			(0x08)
+#define DIDSTC			(0x0C)
+#define DIDSTC_INC_INCREMENT	(0 << 0)
+#define DIDSTC_INC_FIXED	(1 << 0)
+#define DIDSTC_LOC_AHB		(0 << 1)
+#define DIDSTC_LOC_APB		(1 << 1)
+#define DIDSTC_INT_TC0		(0 << 2)
+#define DIDSTC_INT_RELOAD	(1 << 2)
+
+#define DCON			(0x10)
+
+#define DCON_TC_MASK		0xfffff
+#define DCON_DSZ_BYTE		(0 << 20)
+#define DCON_DSZ_HALFWORD	(1 << 20)
+#define DCON_DSZ_WORD		(2 << 20)
+#define DCON_DSZ_MASK		(3 << 20)
+#define DCON_DSZ_SHIFT		20
+#define DCON_AUTORELOAD		(0 << 22)
+#define DCON_NORELOAD		(1 << 22)
+#define DCON_HWTRIG		(1 << 23)
+#define DCON_HWSRC_SHIFT	24
+#define DCON_SERV_SINGLE	(0 << 27)
+#define DCON_SERV_WHOLE		(1 << 27)
+#define DCON_TSZ_UNIT		(0 << 28)
+#define DCON_TSZ_BURST4		(1 << 28)
+#define DCON_INT		(1 << 29)
+#define DCON_SYNC_PCLK		(0 << 30)
+#define DCON_SYNC_HCLK		(1 << 30)
+#define DCON_DEMAND		(0 << 31)
+#define DCON_HANDSHAKE		(1 << 31)
+
+#define DSTAT			(0x14)
+#define DSTAT_STAT_BUSY		(1 << 20)
+#define DSTAT_CURRTC_MASK	0xfffff
+
+#define DMASKTRIG		(0x20)
Quoted 8 lines

drivers/dma/s3c24xx-dma.c line 94

Quoted 6 lines
drivers/dma/s3c24xx-dma.c new file +6 -0
+#define DMASKTRIG_STOP		(1 << 2)
+#define DMASKTRIG_ON		(1 << 1)
+#define DMASKTRIG_SWTRIG	(1 << 0)
+
+#define DMAREQSEL		(0x24)
+#define DMAREQSEL_HW		(1 << 0)

This is proper namespacing...

Hmm, I don't understand meaning of this sentence. Is it a suggestion to change anything?

Quoted 7 lines
Quoted 7 lines

+static int s3c24xx_dma_set_runtime_config(struct s3c24xx_dma_chan
*s3cchan, + struct dma_slave_config *config)

drivers/dma/s3c24xx-dma.c new file +5 -0
+{
+	if (!s3cchan->slave)
+		return -EINVAL;
+
+	/* Reject definitely invalid configurations */
Quoted 8 lines

drivers/dma/s3c24xx-dma.c line 380

Quoted 5 lines
drivers/dma/s3c24xx-dma.c new file +5 -0
+	if (config->src_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES ||
+	    config->dst_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES)
+		return -EINVAL;
+
+	s3cchan->cfg = *config;

you are takinga ref to client pointer without a clue on when that would be freed. I dont think its a good idea!

hmm, the config pointer is dereferenced here and its data thus copyied into s3cchan->cfg, so no reference to the origial config pointer is kept.

Quoted 10 lines

drivers/dma/s3c24xx-dma.c

Quoted 10 lines
drivers/dma/s3c24xx-dma.c new file +10 -0
+static irqreturn_t s3c24xx_dma_irq(int irq, void *data)
+{
+	struct s3c24xx_dma_phy *phy = data;
+	struct s3c24xx_dma_chan *s3cchan = phy->serving;
+	struct s3c24xx_txd *txd;
+
+	dev_dbg(&phy->host->pdev->dev, "interrupt on channel %d\n", phy->id);
+
+	if (!s3cchan) {
+		dev_err(&phy->host->pdev->dev, "interrupt on unused channel 

%d\n",

Quoted 5 lines

drivers/dma/s3c24xx-dma.c line 661

Quoted 2 lines
drivers/dma/s3c24xx-dma.c new file +2 -0
+			phy->id);
+		return IRQ_NONE;

hmmm, these channles belong to you. So if one of them is behvaing badly, then not handling the interrupt will make things worse...

hmm ... I'm not sure what a valid handling would be for this.

The interrupt is only asserted when a transfer is completed - there are no other interrupt-triggers. But when phy->serving is NULL, this also means that the clock of the channel is disabled at this time. So this _should_ never happen.

And as written above, the interrupt is only triggered when a transfer was completed and the channel is idle again, so if there is no virtual channel being served, there is nothing else to do.

Thanks
Heiko

#7 lore raw

Re: [PATCH v2 2/4] dmaengine: add driver for Samsung s3c24xx SoCs

Quoted 17 lines · Heiko Stübner

Hi Vinod,

Am Montag, 19. August 2013, 06:48:12 schrieb Vinod Koul:

Quoted 10 lines · Heiko Stübner
Quoted 8 lines

This adds a new driver to support the s3c24xx dma using the dmaengine and makes the old one in mach-s3c24xx obsolete in the long run.

Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the slave_sg one.

Quoted 3 lines

If that is the case why cant we have this driver supported from pl08x driver? If the delta is only mapping then can that be seprated or both mapping hanlded? Maybe you and Linus have already though about that?

Quoted 5 lines

Yes we have ... As Tomasz has already written the hardware itself is very much different. It's only the concept of mapping virtual channels to physical channels that is somehow similar.

It seems my patch message is lacking in making this clearer ;-) .

The above made me believ they are similar contrlllers with differnt mapping!, hence the question...

Quoted 11 lines
Quoted 8 lines

drivers/dma/s3c24xx-dma.c line 94

Quoted 6 lines
drivers/dma/s3c24xx-dma.c new file +6 -0
+#define DMASKTRIG_STOP		(1 << 2)
+#define DMASKTRIG_ON		(1 << 1)
+#define DMASKTRIG_SWTRIG	(1 << 0)
+
+#define DMAREQSEL		(0x24)
+#define DMAREQSEL_HW		(1 << 0)

This is proper namespacing...

Hmm, I don't understand meaning of this sentence. Is it a suggestion to change anything?

Sorry above should be read as "this need proper namespacing". The macros like DMAREQSEL asre farliy egneric and can collide with others. SO the recommendation is to use something like S3_DMAREQSEL etc

Quoted 17 lines
Quoted 10 lines

drivers/dma/s3c24xx-dma.c

Quoted 10 lines
drivers/dma/s3c24xx-dma.c new file +10 -0
+static irqreturn_t s3c24xx_dma_irq(int irq, void *data)
+{
+	struct s3c24xx_dma_phy *phy = data;
+	struct s3c24xx_dma_chan *s3cchan = phy->serving;
+	struct s3c24xx_txd *txd;
+
+	dev_dbg(&phy->host->pdev->dev, "interrupt on channel %d\n", phy->id);
+
+	if (!s3cchan) {
+		dev_err(&phy->host->pdev->dev, "interrupt on unused channel 

%d\n",

Quoted 5 lines

drivers/dma/s3c24xx-dma.c line 661

Quoted 2 lines
drivers/dma/s3c24xx-dma.c new file +2 -0
+			phy->id);
+		return IRQ_NONE;

hmmm, these channles belong to you. So if one of them is behvaing badly, then not handling the interrupt will make things worse...

Quoted 6 lines

hmm ... I'm not sure what a valid handling would be for this.

The interrupt is only asserted when a transfer is completed - there are no other interrupt-triggers. But when phy->serving is NULL, this also means that the clock of the channel is disabled at this time. So this _should_ never happen.

if that is the case we dont need above, but you added that just for the small iota of if

Quoted 3 lines

And as written above, the interrupt is only triggered when a transfer was completed and the channel is idle again, so if there is no virtual channel being served, there is nothing else to do.

But if we do get such an interrupt, it means:
a) bug in SW
b) erratic hw behaviour

if you handle and dump the issue at least you have recovered. Rather than returning and controller asserting interrupt again and again as it is not cleared.

~Vinod

#8 lore raw

Re: [PATCH v2 2/4] dmaengine: add driver for Samsung s3c24xx SoCs

In reply to Vinod Koul
Quoted 11 lines · Vinod Koul
Quoted 5 lines · Heiko Stübner

Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the slave_sg one.

If that is the case why cant we have this driver supported from pl08x driver? If the delta is only mapping then can that be seprated or both mapping hanlded? Maybe you and Linus have already though about that?

I took a look at the register list and couldn't find a way to save code by trying to shoehorn it into the PL08x, the registers and bit layouts are totally different. IIRC this driver does not
have LLIs either so it's quite different and would look strange.

Yours,
Linus Walleij

#9 lore raw

PATCH v2 3/4 ARM: S3C24XX: add platform-devices for new dma driver for s3c2412 and s3c2443

In reply to Heiko Stübner

This includes defining the mapping for the request sources.

---
changes since v1:
- follow new pdata definition

 arch/arm/mach-s3c24xx/common.c        |  106 +++++++++++++++++++++++++++++++++
 arch/arm/mach-s3c24xx/common.h        |    3 +
 arch/arm/mach-s3c24xx/mach-jive.c     |    1 +
 arch/arm/mach-s3c24xx/mach-smdk2413.c |    1 +
 arch/arm/mach-s3c24xx/mach-smdk2416.c |    1 +
 arch/arm/mach-s3c24xx/mach-smdk2443.c |    1 +
 arch/arm/mach-s3c24xx/mach-vstms.c    |    1 +
 7 files changed, 114 insertions(+)
arch/arm/mach-s3c24xx/common.c +106 -0
index c157103..6e19167 100644
@@ -30,6 +30,7 @@
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/platform_data/dma-s3c24xx.h>
 
 #include <mach/hardware.h>
 #include <mach/regs-clock.h>
@@ -43,6 +44,7 @@
 
 #include <mach/regs-gpio.h>
 #include <plat/regs-serial.h>
+#include <mach/dma.h>
 
 #include <plat/cpu.h>
 #include <plat/devs.h>
@@ -302,3 +304,107 @@ void __init_or_cpufreq s3c24xx_setup_clocks(unsigned long fclk,
 	clk_p.rate = pclk;
 	clk_f.rate = fclk;
 }
+
+#if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2412) || \
+    defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442)
+static struct resource s3c2410_dma_resource[] = {
+	[0] = DEFINE_RES_MEM(S3C24XX_PA_DMA, S3C24XX_SZ_DMA),
+	[1] = DEFINE_RES_IRQ(IRQ_DMA0),
+	[2] = DEFINE_RES_IRQ(IRQ_DMA1),
+	[3] = DEFINE_RES_IRQ(IRQ_DMA2),
+	[4] = DEFINE_RES_IRQ(IRQ_DMA3),
+};
+#endif
+
+#ifdef CONFIG_CPU_S3C2412
+static struct s3c24xx_dma_channel s3c2412_dma_channels[DMACH_MAX] = {
+	[DMACH_XD0] = { S3C24XX_DMA_AHB, true, 17 },
+	[DMACH_XD1] = { S3C24XX_DMA_AHB, true, 18 },
+	[DMACH_SDI] = { S3C24XX_DMA_APB, false, 10 },
+	[DMACH_SPI0_RX] = { S3C24XX_DMA_APB, true, 1 },
+	[DMACH_SPI0_TX] = { S3C24XX_DMA_APB, true, 0 },
+	[DMACH_SPI1_RX] = { S3C24XX_DMA_APB, true, 3 },
+	[DMACH_SPI1_TX] = { S3C24XX_DMA_APB, true, 2 },
+	[DMACH_UART0] = { S3C24XX_DMA_APB, true, 19 },
+	[DMACH_UART1] = { S3C24XX_DMA_APB, true, 21 },
+	[DMACH_UART2] = { S3C24XX_DMA_APB, true, 23 },
+	[DMACH_UART0_SRC2] = { S3C24XX_DMA_APB, true, 20 },
+	[DMACH_UART1_SRC2] = { S3C24XX_DMA_APB, true, 22 },
+	[DMACH_UART2_SRC2] = { S3C24XX_DMA_APB, true, 24 },
+	[DMACH_TIMER] = { S3C24XX_DMA_APB, true, 9 },
+	[DMACH_I2S_IN] = { S3C24XX_DMA_APB, true, 5 },
+	[DMACH_I2S_OUT] = { S3C24XX_DMA_APB, true, 4 },
+	[DMACH_USB_EP1] = { S3C24XX_DMA_APB, true, 13 },
+	[DMACH_USB_EP2] = { S3C24XX_DMA_APB, true, 14 },
+	[DMACH_USB_EP3] = { S3C24XX_DMA_APB, true, 15 },
+	[DMACH_USB_EP4] = { S3C24XX_DMA_APB, true, 16 },
+};
+
+static struct s3c24xx_dma_platdata s3c2412_dma_platdata = {
+	.num_phy_channels = 4,
+	.channels = s3c2412_dma_channels,
+	.num_channels = DMACH_MAX,
+};
+
+struct platform_device s3c2412_device_dma = {
+	.name		= "s3c2412-dma",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(s3c2410_dma_resource),
+	.resource	= s3c2410_dma_resource,
+	.dev	= {
+		.platform_data	= &s3c2412_dma_platdata,
+	},
+};
+#endif
+
+#if defined(CONFIG_CPUS_3C2443) || defined(CONFIG_CPU_S3C2416)
+static struct resource s3c2443_dma_resource[] = {
+	[0] = DEFINE_RES_MEM(S3C24XX_PA_DMA, S3C24XX_SZ_DMA),
+	[1] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA0),
+	[2] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA1),
+	[3] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA2),
+	[4] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA3),
+	[5] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA4),
+	[6] = DEFINE_RES_IRQ(IRQ_S3C2443_DMA5),
+};
+
+static struct s3c24xx_dma_channel s3c2443_dma_channels[DMACH_MAX] = {
+	[DMACH_XD0] = { S3C24XX_DMA_AHB, true, 17 },
+	[DMACH_XD1] = { S3C24XX_DMA_AHB, true, 18 },
+	[DMACH_SDI] = { S3C24XX_DMA_APB, false, 10 },
+	[DMACH_SPI0_RX] = { S3C24XX_DMA_APB, true, 1 },
+	[DMACH_SPI0_TX] = { S3C24XX_DMA_APB, true, 0 },
+	[DMACH_SPI1_RX] = { S3C24XX_DMA_APB, true, 3 },
+	[DMACH_SPI1_TX] = { S3C24XX_DMA_APB, true, 2 },
+	[DMACH_UART0] = { S3C24XX_DMA_APB, true, 19 },
+	[DMACH_UART1] = { S3C24XX_DMA_APB, true, 21 },
+	[DMACH_UART2] = { S3C24XX_DMA_APB, true, 23 },
+	[DMACH_UART3] = { S3C24XX_DMA_APB, true, 25 },
+	[DMACH_UART0_SRC2] = { S3C24XX_DMA_APB, true, 20 },
+	[DMACH_UART1_SRC2] = { S3C24XX_DMA_APB, true, 22 },
+	[DMACH_UART2_SRC2] = { S3C24XX_DMA_APB, true, 24 },
+	[DMACH_UART3_SRC2] = { S3C24XX_DMA_APB, true, 26 },
+	[DMACH_TIMER] = { S3C24XX_DMA_APB, true, 9 },
+	[DMACH_I2S_IN] = { S3C24XX_DMA_APB, true, 5 },
+	[DMACH_I2S_OUT] = { S3C24XX_DMA_APB, true, 4 },
+	[DMACH_PCM_IN] = { S3C24XX_DMA_APB, true, 28 },
+	[DMACH_PCM_OUT] = { S3C24XX_DMA_APB, true, 27 },
+	[DMACH_MIC_IN] = { S3C24XX_DMA_APB, true, 29 },
+};
+
+static struct s3c24xx_dma_platdata s3c2443_dma_platdata = {
+	.num_phy_channels = 6,
+	.channels = s3c2443_dma_channels,
+	.num_channels = DMACH_MAX,
+};
+
+struct platform_device s3c2443_device_dma = {
+	.name		= "s3c2443-dma",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(s3c2443_dma_resource),
+	.resource	= s3c2443_dma_resource,
+	.dev	= {
+		.platform_data	= &s3c2443_dma_platdata,
+	},
+};
+#endif
arch/arm/mach-s3c24xx/common.h +3 -0
index 84b2806..fe07189 100644
@@ -109,4 +109,7 @@ extern void s3c2443_init_irq(void);
 
 extern struct syscore_ops s3c24xx_irq_syscore_ops;
 
+extern struct platform_device s3c2412_device_dma;
+extern struct platform_device s3c2443_device_dma;
+
 #endif /* __ARCH_ARM_MACH_S3C24XX_COMMON_H */
arch/arm/mach-s3c24xx/mach-jive.c +1 -0
index a45fcd8..43c23e2 100644
@@ -466,6 +466,7 @@ static struct platform_device *jive_devices[] __initdata = {
 	&jive_device_wm8750,
 	&s3c_device_nand,
 	&s3c_device_usbgadget,
+	&s3c2412_device_dma,
 };
 
 static struct s3c2410_udc_mach_info jive_udc_cfg __initdata = {
arch/arm/mach-s3c24xx/mach-smdk2413.c +1 -0
index 8146e92..c9d31ef 100644
@@ -89,6 +89,7 @@ static struct platform_device *smdk2413_devices[] __initdata = {
 	&s3c_device_i2c0,
 	&s3c_device_iis,
 	&s3c_device_usbgadget,
+	&s3c2412_device_dma,
 };
 
 static void __init smdk2413_fixup(struct tag *tags, char **cmdline,
arch/arm/mach-s3c24xx/mach-smdk2416.c +1 -0
index cb46847..f88e672 100644
@@ -215,6 +215,7 @@ static struct platform_device *smdk2416_devices[] __initdata = {
 	&s3c_device_hsmmc0,
 	&s3c_device_hsmmc1,
 	&s3c_device_usb_hsudc,
+	&s3c2443_device_dma,
 };
 
 static void __init smdk2416_map_io(void)
arch/arm/mach-s3c24xx/mach-smdk2443.c +1 -0
index 9435c3b..d9933fc 100644
@@ -115,6 +115,7 @@ static struct platform_device *smdk2443_devices[] __initdata = {
 #ifdef CONFIG_SND_SOC_SMDK2443_WM9710
 	&s3c_device_ac97,
 #endif
+	&s3c2443_device_dma,
 };
 
 static void __init smdk2443_map_io(void)
arch/arm/mach-s3c24xx/mach-vstms.c +1 -0
index b665884..f7ec9c5 100644
@@ -126,6 +126,7 @@ static struct platform_device *vstms_devices[] __initdata = {
 	&s3c_device_iis,
 	&s3c_device_rtc,
 	&s3c_device_nand,
+	&s3c2412_device_dma,
 };
 
 static void __init vstms_fixup(struct tag *tags, char **cmdline,
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH v2 4/4 ARM: SAMSUNG: set s3c24xx_dma_filter for s3c64xx-spi0 device

In reply to Heiko Stübner

The spi-s3c64xx device is also used on the s3c2416 and s3c2443 SoCs. The driver also already uses only generic dma-engine operations.

Therefore add another elif to set the s3c24xx filter.

---
 arch/arm/plat-samsung/devs.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/plat-samsung/devs.c +4 -1
index 0f9c3f4..fab458f 100644
@@ -32,6 +32,7 @@
 #include <linux/ioport.h>
 #include <linux/platform_data/s3c-hsudc.h>
 #include <linux/platform_data/s3c-hsotg.h>
+#include <linux/platform_data/dma-s3c24xx.h>
 
 #include <media/s5p_hdmi.h>
 
@@ -1513,8 +1514,10 @@ void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
 	pd.num_cs = num_cs;
 	pd.src_clk_nr = src_clk_nr;
 	pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio;
-#ifdef CONFIG_PL330_DMA
+#if defined(CONFIG_PL330_DMA)
 	pd.filter = pl330_filter;
+#elif defined(CONFIG_S3C24XX_DMAC)
+	pd.filter = s3c24xx_dma_filter;
 #endif
 
 	s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi0);
Signature · 1 line
1.7.10.4
#12 lore raw
In reply to Heiko Stübner
Quoted 60 lines · Heiko Stübner

This series tries to provide a basic dmaengine driver for the s3c24xx SoCs to subsequently retire the old one with custom API.

Since v1 three big changes happened (appart from fixing received comments):

For one the limitation of sg-lists to 1 element is gone.Secondly the specifics of the virtual channels (target bus, handshake, etc) are not encoded with channel ids but in the platformdata - making a later dt binding easier, as these informations can there be gathered by the xlate function. And lastly I also added a preliminary mechanism to handle the specific needs for the earlier variants of the driver.

While s3c2443 and later can use any channel for any peripheral with just marking the target-peripheral-id in a register, earlier SoCs can only use specific channels and the target-ids also vary depending on the channel.

Therefore on newer SoCs the chansel element only needs to contain the requested target-id, while on the older variants use it to encode both the valid channels and the channel-specific peripheral-id.

On affected SoCs the target-id is always 3 bit wide, so we use these and an additional 4th bit to hold the valid state. As the older SoCs all have 4 dma channels this can live happily in an u16 element.

The s3c24xx series will most likely not see any new offspring, but even if it happens any new model will probably use the newer more flexible variant of the dma controller, so this should not restrict anything in the future.

Example:
SDI is valid on channels 0, 2 and 3 - with varying hw request sources. For it the chansel field would look like

  ((BIT(3) | 1)<<  3 * 4) | // channel 3, with request source 1
  ((BIT(3) | 2)<<  2 * 4) | // channel 2, with request source 2
  ((BIT(3) | 2)<<  0 * 4)   // channel 0, with request source 2

Heiko Stuebner (4):
ARM: S3C24XX: number the dma clocks
dmaengine: add driver for Samsung s3c24xx SoCs
ARM: S3C24XX: add platform-devices for new dma driver for s3c2412 and

     s3c2443

ARM: SAMSUNG: set s3c24xx_dma_filter for s3c64xx-spi0 device

  arch/arm/mach-s3c24xx/clock-s3c2412.c     |    8 +-
  arch/arm/mach-s3c24xx/common-s3c2443.c    |   12 +-
  arch/arm/mach-s3c24xx/common.c            |  106 +++
  arch/arm/mach-s3c24xx/common.h            |    3 +
  arch/arm/mach-s3c24xx/mach-jive.c         |    1 +
  arch/arm/mach-s3c24xx/mach-smdk2413.c     |    1 +
  arch/arm/mach-s3c24xx/mach-smdk2416.c     |    1 +
  arch/arm/mach-s3c24xx/mach-smdk2443.c     |    1 +
  arch/arm/mach-s3c24xx/mach-vstms.c        |    1 +
  arch/arm/plat-samsung/devs.c              |    5 +-
  drivers/dma/Kconfig                       |   12 +
  drivers/dma/Makefile                      |    1 +
  drivers/dma/s3c24xx-dma.c                 | 1255 +++++++++++++++++++++++++++++
  include/linux/platform_data/dma-s3c24xx.h |   43 +
  14 files changed, 1439 insertions(+), 11 deletions(-)
Quoted 3 lines

create mode 100644 drivers/dma/s3c24xx-dma.c create mode 100644 include/linux/platform_data/dma-s3c24xx.h

Looks good to me, but I need ack from Vinod, dma maintainer.

Vinod, if you're OK on this, please let us know so that I could take this whole series into samsung tree.

Thanks,
Kukjin