kernel: update 3.10 to 3.10.3
[15.05/openwrt.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 --- a/arch/mips/jz4740/clock.c
17 +++ b/arch/mips/jz4740/clock.c
18 @@ -921,4 +921,4 @@ static int jz4740_clock_init(void)
19  
20         return 0;
21  }
22 -arch_initcall(jz4740_clock_init);
23 +postcore_initcall(jz4740_clock_init);
24 --- a/arch/mips/jz4740/dma.c
25 +++ b/arch/mips/jz4740/dma.c
26 @@ -16,6 +16,7 @@
27  #include <linux/kernel.h>
28  #include <linux/module.h>
29  #include <linux/spinlock.h>
30 +#include <linux/clk.h>
31  #include <linux/interrupt.h>
32  
33  #include <linux/dma-mapping.h>
34 @@ -268,6 +269,7 @@ static irqreturn_t jz4740_dma_irq(int ir
35  
36  static int jz4740_dma_init(void)
37  {
38 +       struct clk *clk;
39         unsigned int ret;
40  
41         jz4740_dma_base = ioremap(JZ4740_DMAC_BASE_ADDR, 0x400);
42 @@ -277,11 +279,29 @@ static int jz4740_dma_init(void)
43  
44         spin_lock_init(&jz4740_dma_lock);
45  
46 -       ret = request_irq(JZ4740_IRQ_DMAC, jz4740_dma_irq, 0, "DMA", NULL);
47 +       clk = clk_get(NULL, "dma");
48 +       if (IS_ERR(clk)) {
49 +               ret = PTR_ERR(clk);
50 +               printk(KERN_ERR "JZ4740 DMA: Failed to request clock: %d\n",
51 +                               ret);
52 +               goto err_iounmap;
53 +       }
54  
55 -       if (ret)
56 +       ret = request_irq(JZ4740_IRQ_DMAC, jz4740_dma_irq, 0, "DMA", NULL);
57 +       if (ret) {
58                 printk(KERN_ERR "JZ4740 DMA: Failed to request irq: %d\n", ret);
59 +               goto err_clkput;
60 +       }
61 +
62 +       clk_enable(clk);
63 +
64 +       return 0;
65 +
66 +err_clkput:
67 +       clk_put(clk);
68  
69 +err_iounmap:
70 +       iounmap(jz4740_dma_base);
71         return ret;
72  }
73  arch_initcall(jz4740_dma_init);