xburst: Add 3.10 support
[openwrt/svn-archive/archive.git] / target / linux / xburst / patches-3.10 / 013-MIPS-JZ4740-Acquire-and-enable-DMA-controller-clock.patch
1 From b1ab71156cd49b2389397d3be54b93fe394a1cb2 Mon Sep 17 00:00:00 2001
2 From: Maarten ter Huurne <maarten@treewalker.org>
3 Date: Tue, 9 Oct 2012 13:09:57 +0200
4 Subject: [PATCH 13/16] MIPS: JZ4740: Acquire and enable DMA controller clock
5
6 Previously, it was assumed that the DMA controller clock is not gated
7 when the kernel starts running. While that is the power-on state, it is
8 safer to not rely on that.
9
10 Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
11 ---
12 arch/mips/jz4740/clock.c | 2 +-
13 arch/mips/jz4740/dma.c | 24 ++++++++++++++++++++++--
14 2 files changed, 23 insertions(+), 3 deletions(-)
15
16 diff --git a/arch/mips/jz4740/clock.c b/arch/mips/jz4740/clock.c
17 index 1b5f554..b3eba60 100644
18 --- a/arch/mips/jz4740/clock.c
19 +++ b/arch/mips/jz4740/clock.c
20 @@ -921,4 +921,4 @@ static int jz4740_clock_init(void)
21
22 return 0;
23 }
24 -arch_initcall(jz4740_clock_init);
25 +postcore_initcall(jz4740_clock_init);
26 diff --git a/arch/mips/jz4740/dma.c b/arch/mips/jz4740/dma.c
27 index 317ec6f..fb5266c 100644
28 --- a/arch/mips/jz4740/dma.c
29 +++ b/arch/mips/jz4740/dma.c
30 @@ -16,6 +16,7 @@
31 #include <linux/kernel.h>
32 #include <linux/module.h>
33 #include <linux/spinlock.h>
34 +#include <linux/clk.h>
35 #include <linux/interrupt.h>
36
37 #include <linux/dma-mapping.h>
38 @@ -268,6 +269,7 @@ static irqreturn_t jz4740_dma_irq(int irq, void *dev_id)
39
40 static int jz4740_dma_init(void)
41 {
42 + struct clk *clk;
43 unsigned int ret;
44
45 jz4740_dma_base = ioremap(JZ4740_DMAC_BASE_ADDR, 0x400);
46 @@ -277,11 +279,29 @@ static int jz4740_dma_init(void)
47
48 spin_lock_init(&jz4740_dma_lock);
49
50 - ret = request_irq(JZ4740_IRQ_DMAC, jz4740_dma_irq, 0, "DMA", NULL);
51 + clk = clk_get(NULL, "dma");
52 + if (IS_ERR(clk)) {
53 + ret = PTR_ERR(clk);
54 + printk(KERN_ERR "JZ4740 DMA: Failed to request clock: %d\n",
55 + ret);
56 + goto err_iounmap;
57 + }
58
59 - if (ret)
60 + ret = request_irq(JZ4740_IRQ_DMAC, jz4740_dma_irq, 0, "DMA", NULL);
61 + if (ret) {
62 printk(KERN_ERR "JZ4740 DMA: Failed to request irq: %d\n", ret);
63 + goto err_clkput;
64 + }
65 +
66 + clk_enable(clk);
67 +
68 + return 0;
69 +
70 +err_clkput:
71 + clk_put(clk);
72
73 +err_iounmap:
74 + iounmap(jz4740_dma_base);
75 return ret;
76 }
77 arch_initcall(jz4740_dma_init);
78 --
79 1.7.10.4
80