From a3323b72b964471650a6128de4e10f8e88d47ae1 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 3 Nov 2009 14:42:04 +0000 Subject: [PATCH 1/9] ARM: SMDK6410: Configure GPIO pull up for WM835x IRQ line When used with the WM1190-EV1 board we can use the internal pull up resistor of the CPU to provide the required pull for the IRQ line. Without this interrupts from the WM835x don't work in the default WM1190-EV1 hardwaer configuration. Signed-off-by: Mark Brown Signed-off-by: Ben Dooks --- arch/arm/mach-s3c6410/mach-smdk6410.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/mach-s3c6410/mach-smdk6410.c b/arch/arm/mach-s3c6410/mach-smdk6410.c index ea51dbe76e3e..9f1a21462620 100644 --- a/arch/arm/mach-s3c6410/mach-smdk6410.c +++ b/arch/arm/mach-s3c6410/mach-smdk6410.c @@ -320,6 +320,9 @@ static int __init smdk6410_wm8350_init(struct wm8350 *wm8350) { int i; + /* Configure the IRQ line */ + s3c_gpio_setpull(S3C64XX_GPN(12), S3C_GPIO_PULL_UP); + /* Instantiate the regulators */ for (i = 0; i < ARRAY_SIZE(wm1190_regulators); i++) wm8350_register_regulator(wm8350, From c7a19787195fcc90aabc3a71f29647ba9a443efe Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 3 Nov 2009 14:42:10 +0000 Subject: [PATCH 2/9] ARM: SMDK6410: Allocate more GPIO space for WM1190-EV1 The WM835x has some GPIOs on it, allocate some space so we can use them with gpiolib. Signed-off-by: Mark Brown Signed-off-by: Ben Dooks --- arch/arm/mach-s3c6410/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-s3c6410/Kconfig b/arch/arm/mach-s3c6410/Kconfig index 53fc3ff657f7..72d4b11b2077 100644 --- a/arch/arm/mach-s3c6410/Kconfig +++ b/arch/arm/mach-s3c6410/Kconfig @@ -77,6 +77,7 @@ config SMDK6410_WM1190_EV1 depends on MACH_SMDK6410 select REGULATOR select REGULATOR_WM8350 + select S3C24XX_GPIO_EXTRA64 select MFD_WM8350_I2C select MFD_WM8350_CONFIG_MODE_0 select MFD_WM8350_CONFIG_MODE_3 From 54489cd46a3a268ed981c681726c6d690883f076 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Wed, 4 Nov 2009 13:13:29 +0100 Subject: [PATCH 3/9] ARM: S3C64XX: Remove duplicate s3c_dma_has_circular() definition for S3C64xx. This patch removes the duplicated s3c_dma_has_circular() definition and so fixes compilation for S3C64xx. Signed-off-by: Maurus Cuelenaere Signed-off-by: Ben Dooks --- arch/arm/mach-s3c6400/include/mach/dma.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/arm/mach-s3c6400/include/mach/dma.h b/arch/arm/mach-s3c6400/include/mach/dma.h index 004edab23954..1067619f0ba0 100644 --- a/arch/arm/mach-s3c6400/include/mach/dma.h +++ b/arch/arm/mach-s3c6400/include/mach/dma.h @@ -68,11 +68,6 @@ static __inline__ int s3c_dma_has_circular(void) #define S3C2410_DMAF_CIRCULAR (1 << 0) -static inline bool s3c_dma_has_circular(void) -{ - return false; -} - #include #endif /* __ASM_ARCH_IRQ_H */ From b3c5496fbfc2e5f64bb85b142615717850fee980 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 9 Nov 2009 23:45:47 +0000 Subject: [PATCH 4/9] ARM: S3C64XX: Tidy definition and comments in s3c_dma_has_circular() The recent changes to arch/arm/mach-s3c6400/include/mach/dma.h have left an out of date comment in there as well as accidentally changing the type of the function. Fix the commit 54489cd46a3a268ed981c681726c6d690883f076 Signed-off-by: Ben Dooks --- arch/arm/mach-s3c6400/include/mach/dma.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-s3c6400/include/mach/dma.h b/arch/arm/mach-s3c6400/include/mach/dma.h index 1067619f0ba0..6723860748be 100644 --- a/arch/arm/mach-s3c6400/include/mach/dma.h +++ b/arch/arm/mach-s3c6400/include/mach/dma.h @@ -58,12 +58,9 @@ enum dma_ch { DMACH_MAX /* the end */ }; -static __inline__ int s3c_dma_has_circular(void) +static __inline__ bool s3c_dma_has_circular(void) { - /* we will be supporting ciruclar buffers as soon as we have DMA - * engine support. - */ - return 1; + return true; } #define S3C2410_DMAF_CIRCULAR (1 << 0) From 210012a6cd8770a73d1aa74b742667b462d04511 Mon Sep 17 00:00:00 2001 From: Jassi Brar Date: Thu, 5 Nov 2009 13:44:20 +0900 Subject: [PATCH 5/9] ARM: S3C64XX: DMA: Protect buffer pointers while manipulation Ensure the DMA buffer points are not updated from another source during the process of enquing a buffer. Signed-off-by: Jassi Brar [ben-linux@fluff.org: Updated patch comment] Signed-off-by: Ben Dooks --- arch/arm/plat-s3c64xx/dma.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/plat-s3c64xx/dma.c b/arch/arm/plat-s3c64xx/dma.c index 266a10745a85..6fa706f0f42a 100644 --- a/arch/arm/plat-s3c64xx/dma.c +++ b/arch/arm/plat-s3c64xx/dma.c @@ -339,6 +339,7 @@ int s3c2410_dma_enqueue(unsigned int channel, void *id, struct s3c64xx_dma_buff *next; struct s3c64xx_dma_buff *buff; struct pl080s_lli *lli; + unsigned long flags; int ret; WARN_ON(!chan); @@ -366,6 +367,8 @@ int s3c2410_dma_enqueue(unsigned int channel, void *id, s3c64xx_dma_fill_lli(chan, lli, data, size); + local_irq_save(flags); + if ((next = chan->next) != NULL) { struct s3c64xx_dma_buff *end = chan->end; struct pl080s_lli *endlli = end->lli; @@ -397,6 +400,8 @@ int s3c2410_dma_enqueue(unsigned int channel, void *id, s3c64xx_lli_to_regs(chan, lli); } + local_irq_restore(flags); + show_lli(lli); dbg_showchan(chan); From 6d0b8627d545aed7d4bcaad2156b6cb95e105715 Mon Sep 17 00:00:00 2001 From: Jassi Brar Date: Thu, 5 Nov 2009 13:44:26 +0900 Subject: [PATCH 6/9] ARM: S3C64XX: DMA: Unify callback functions for success/failure Replace s3c64xx_dma_tcirq and s3c64xx_dma_errirq with the common s3c64xx_dma_buffdone. Signed-off-by: Jassi Brar Signed-off-by: Ben Dooks --- arch/arm/plat-s3c64xx/dma.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/arch/arm/plat-s3c64xx/dma.c b/arch/arm/plat-s3c64xx/dma.c index 6fa706f0f42a..5a08a86419dd 100644 --- a/arch/arm/plat-s3c64xx/dma.c +++ b/arch/arm/plat-s3c64xx/dma.c @@ -565,26 +565,11 @@ int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *client) EXPORT_SYMBOL(s3c2410_dma_free); - -static void s3c64xx_dma_tcirq(struct s3c64xx_dmac *dmac, int offs) -{ - struct s3c2410_dma_chan *chan = dmac->channels + offs; - - /* note, we currently do not bother to work out which buffer - * or buffers have been completed since the last tc-irq. */ - - if (chan->callback_fn) - (chan->callback_fn)(chan, chan->curr->pw, 0, S3C2410_RES_OK); -} - -static void s3c64xx_dma_errirq(struct s3c64xx_dmac *dmac, int offs) -{ - printk(KERN_DEBUG "%s: offs %d\n", __func__, offs); -} - static irqreturn_t s3c64xx_dma_irq(int irq, void *pw) { struct s3c64xx_dmac *dmac = pw; + struct s3c2410_dma_chan *chan; + enum s3c2410_dma_buffresult res; u32 tcstat, errstat; u32 bit; int offs; @@ -593,15 +578,22 @@ static irqreturn_t s3c64xx_dma_irq(int irq, void *pw) errstat = readl(dmac->regs + PL080_ERR_STATUS); for (offs = 0, bit = 1; offs < 8; offs++, bit <<= 1) { + + if (!(errstat & bit) && !(tcstat & bit)) + continue; + + chan = dmac->channels + offs; + res = S3C2410_RES_ERR; + if (tcstat & bit) { writel(bit, dmac->regs + PL080_TC_CLEAR); - s3c64xx_dma_tcirq(dmac, offs); + res = S3C2410_RES_OK; } - if (errstat & bit) { - s3c64xx_dma_errirq(dmac, offs); + if (errstat & bit) writel(bit, dmac->regs + PL080_ERR_CLEAR); - } + + s3c64xx_dma_bufffdone(chan, chan->curr, res); } return IRQ_HANDLED; From 7507f39c57d4a285aea11c379fbc65c2b3f375ef Mon Sep 17 00:00:00 2001 From: Jassi Brar Date: Thu, 5 Nov 2009 13:44:45 +0900 Subject: [PATCH 7/9] ARM: S3C64XX: DMA: Make src and dst transfer size same Some devices don't seem to work if the source and desitnation transfer widths are not same. For example, SPI dma xfers, with 8bits/word, don't work without this patch. Signed-off-by: Jassi Brar Signed-off-by: Ben Dooks --- arch/arm/plat-s3c64xx/dma.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm/plat-s3c64xx/dma.c b/arch/arm/plat-s3c64xx/dma.c index 5a08a86419dd..a94281bb84d6 100644 --- a/arch/arm/plat-s3c64xx/dma.c +++ b/arch/arm/plat-s3c64xx/dma.c @@ -151,8 +151,6 @@ static void s3c64xx_dma_fill_lli(struct s3c2410_dma_chan *chan, src = chan->dev_addr; dst = data; control0 = PL080_CONTROL_SRC_AHB2; - control0 |= (u32)chan->hw_width << PL080_CONTROL_SWIDTH_SHIFT; - control0 |= 2 << PL080_CONTROL_DWIDTH_SHIFT; control0 |= PL080_CONTROL_DST_INCR; break; @@ -160,8 +158,6 @@ static void s3c64xx_dma_fill_lli(struct s3c2410_dma_chan *chan, src = data; dst = chan->dev_addr; control0 = PL080_CONTROL_DST_AHB2; - control0 |= (u32)chan->hw_width << PL080_CONTROL_DWIDTH_SHIFT; - control0 |= 2 << PL080_CONTROL_SWIDTH_SHIFT; control0 |= PL080_CONTROL_SRC_INCR; break; default: @@ -173,6 +169,8 @@ static void s3c64xx_dma_fill_lli(struct s3c2410_dma_chan *chan, control1 = size >> chan->hw_width; /* size in no of xfers */ control0 |= PL080_CONTROL_PROT_SYS; /* always in priv. mode */ control0 |= PL080_CONTROL_TC_IRQ_EN; /* always fire IRQ */ + control0 |= (u32)chan->hw_width << PL080_CONTROL_DWIDTH_SHIFT; + control0 |= (u32)chan->hw_width << PL080_CONTROL_SWIDTH_SHIFT; lli->src_addr = src; lli->dst_addr = dst; From 9b08284bf22f438baa2d6b68015ff17ddb431a61 Mon Sep 17 00:00:00 2001 From: Jassi Brar Date: Thu, 5 Nov 2009 13:44:33 +0900 Subject: [PATCH 8/9] ARM: S3C64XX: DMA: Callback with correct buffer pointer buffdone callback should be called per buffer request with pointer to the latest serviced request. 'next' should point to the one next to currently active. Signed-off-by: Jassi Brar Signed-off-by: Ben Dooks --- arch/arm/plat-s3c64xx/dma.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/arch/arm/plat-s3c64xx/dma.c b/arch/arm/plat-s3c64xx/dma.c index a94281bb84d6..7d12eb8fa58d 100644 --- a/arch/arm/plat-s3c64xx/dma.c +++ b/arch/arm/plat-s3c64xx/dma.c @@ -576,6 +576,7 @@ static irqreturn_t s3c64xx_dma_irq(int irq, void *pw) errstat = readl(dmac->regs + PL080_ERR_STATUS); for (offs = 0, bit = 1; offs < 8; offs++, bit <<= 1) { + struct s3c64xx_dma_buff *buff; if (!(errstat & bit) && !(tcstat & bit)) continue; @@ -591,7 +592,33 @@ static irqreturn_t s3c64xx_dma_irq(int irq, void *pw) if (errstat & bit) writel(bit, dmac->regs + PL080_ERR_CLEAR); - s3c64xx_dma_bufffdone(chan, chan->curr, res); + /* 'next' points to the buffer that is next to the + * currently active buffer. + * For CIRCULAR queues, 'next' will be same as 'curr' + * when 'end' is the active buffer. + */ + buff = chan->curr; + while (buff && buff != chan->next + && buff->next != chan->next) + buff = buff->next; + + if (!buff) + BUG(); + + if (buff == chan->next) + buff = chan->end; + + s3c64xx_dma_bufffdone(chan, buff, res); + + /* Update 'next' */ + buff = chan->next; + if (chan->next == chan->end) { + chan->next = chan->curr; + if (!(chan->flags & S3C2410_DMAF_CIRCULAR)) + chan->end = NULL; + } else { + chan->next = buff->next; + } } return IRQ_HANDLED; From 336b1a3181d81db85c0af3d0c18fe0a04b4d5126 Mon Sep 17 00:00:00 2001 From: Jassi Brar Date: Thu, 5 Nov 2009 13:44:39 +0900 Subject: [PATCH 9/9] ARM: S3C64XX: DMA: Free node for non-circular queues We need to free the buff and lli nodes if the buffer queue is not CIRCULAR. Signed-off-by: Jassi Brar Signed-off-by: Ben Dooks --- arch/arm/plat-s3c64xx/dma.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/plat-s3c64xx/dma.c b/arch/arm/plat-s3c64xx/dma.c index 7d12eb8fa58d..d554b936fcfb 100644 --- a/arch/arm/plat-s3c64xx/dma.c +++ b/arch/arm/plat-s3c64xx/dma.c @@ -610,6 +610,12 @@ static irqreturn_t s3c64xx_dma_irq(int irq, void *pw) s3c64xx_dma_bufffdone(chan, buff, res); + /* Free the node and update curr, if non-circular queue */ + if (!(chan->flags & S3C2410_DMAF_CIRCULAR)) { + chan->curr = buff->next; + s3c64xx_dma_freebuff(buff); + } + /* Update 'next' */ buff = chan->next; if (chan->next == chan->end) {