ramips: fix subtarget kernel version assignment (only mt7621 is ready for now)
[openwrt.git] / target / linux / ramips / patches-4.3 / 0005-MIPS-use-set_mode-to-enable-disable-the-cevt-r4k-irq.patch
1 From ce3d4a4111a5f7e6b4e74bceae5faa6ce388e8ec 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 05/53] 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/ralink/Kconfig |    5 +++++
10  1 file changed, 5 insertions(+)
11
12 --- a/arch/mips/ralink/Kconfig
13 +++ b/arch/mips/ralink/Kconfig
14 @@ -1,11 +1,16 @@
15  if RALINK
16  
17 +config CEVT_SYSTICK_QUIRK
18 +       bool
19 +       default n
20 +
21  config CLKEVT_RT3352
22         bool
23         depends on SOC_RT305X || SOC_MT7620
24         default y
25         select CLKSRC_OF
26         select CLKSRC_MMIO
27 +       select CEVT_SYSTICK_QUIRK
28  
29  config RALINK_ILL_ACC
30         bool
31 --- a/arch/mips/kernel/cevt-r4k.c
32 +++ b/arch/mips/kernel/cevt-r4k.c
33 @@ -15,6 +15,26 @@
34  #include <asm/time.h>
35  #include <asm/cevt-r4k.h>
36  
37 +static int mips_state_oneshot(struct clock_event_device *evt)
38 +{
39 +       if (!cp0_timer_irq_installed) {
40 +               cp0_timer_irq_installed = 1;
41 +               setup_irq(evt->irq, &c0_compare_irqaction);
42 +       }
43 +
44 +       return 0;
45 +}
46 +
47 +static int mips_state_shutdown(struct clock_event_device *evt)
48 +{
49 +       if (cp0_timer_irq_installed) {
50 +               cp0_timer_irq_installed = 0;
51 +               remove_irq(evt->irq, &c0_compare_irqaction);
52 +       }
53 +
54 +       return 0;
55 +}
56 +
57  static int mips_next_event(unsigned long delta,
58                            struct clock_event_device *evt)
59  {
60 @@ -208,18 +228,21 @@ int r4k_clockevent_init(void)
61         cd->rating              = 300;
62         cd->irq                 = irq;
63         cd->cpumask             = cpumask_of(cpu);
64 +       cd->set_state_shutdown  = mips_state_shutdown;
65 +       cd->set_state_oneshot   = mips_state_oneshot;
66         cd->set_next_event      = mips_next_event;
67         cd->event_handler       = mips_event_handler;
68  
69         clockevents_register_device(cd);
70  
71 +#ifndef CONFIG_CEVT_SYSTICK_QUIRK
72         if (cp0_timer_irq_installed)
73                 return 0;
74  
75         cp0_timer_irq_installed = 1;
76  
77         setup_irq(irq, &c0_compare_irqaction);
78 -
79 +#endif
80         return 0;
81  }
82