f6ff89804ffa51e3af32ed774a9c259b3cf8a2c0
[openwrt.git] / target / linux / ramips / patches-3.10 / 0001-MIPS-use-set_mode-to-enable-disable-the-cevt-r4k-irq.patch
1 From a1f29e15505226c6bc3a714daf91edccfc3a9e13 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 14 Jul 2013 23:08:11 +0200
4 Subject: [PATCH 01/33] MIPS: use set_mode() to enable/disable the cevt-r4k
5  irq
6
7  Signed-off-by: John Crispin <blogic@openwrt.org>
8 ---
9  arch/mips/kernel/cevt-r4k.c |   39 ++++++++++++++++++++++++++-------------
10  1 file changed, 26 insertions(+), 13 deletions(-)
11
12 --- a/arch/mips/kernel/cevt-r4k.c
13 +++ b/arch/mips/kernel/cevt-r4k.c
14 @@ -38,12 +38,6 @@ static int mips_next_event(unsigned long
15  
16  #endif /* CONFIG_MIPS_MT_SMTC */
17  
18 -void mips_set_clock_mode(enum clock_event_mode mode,
19 -                               struct clock_event_device *evt)
20 -{
21 -       /* Nothing to do ...  */
22 -}
23 -
24  DEFINE_PER_CPU(struct clock_event_device, mips_clockevent_device);
25  int cp0_timer_irq_installed;
26  
27 @@ -90,6 +84,32 @@ struct irqaction c0_compare_irqaction =
28         .name = "timer",
29  };
30  
31 +void mips_set_clock_mode(enum clock_event_mode mode,
32 +                               struct clock_event_device *evt)
33 +{
34 +       switch (mode) {
35 +       case CLOCK_EVT_MODE_ONESHOT:
36 +               if (cp0_timer_irq_installed)
37 +                       break;
38 +
39 +               cp0_timer_irq_installed = 1;
40 +
41 +               setup_irq(evt->irq, &c0_compare_irqaction);
42 +               break;
43 +
44 +       case CLOCK_EVT_MODE_SHUTDOWN:
45 +               if (!cp0_timer_irq_installed)
46 +                       break;
47 +
48 +               cp0_timer_irq_installed = 0;
49 +               free_irq(evt->irq, &c0_compare_irqaction);
50 +               break;
51 +
52 +       default:
53 +               pr_err("Unhandeled mips clock_mode\n");
54 +               break;
55 +       }
56 +}
57  
58  void mips_event_handler(struct clock_event_device *dev)
59  {
60 @@ -215,13 +235,6 @@ int __cpuinit r4k_clockevent_init(void)
61  #endif
62         clockevents_register_device(cd);
63  
64 -       if (cp0_timer_irq_installed)
65 -               return 0;
66 -
67 -       cp0_timer_irq_installed = 1;
68 -
69 -       setup_irq(irq, &c0_compare_irqaction);
70 -
71         return 0;
72  }
73