311-MIPS-use-set_mode-to-enable-disable-the-cevt-r4k-irq.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. From ce3d4a4111a5f7e6b4e74bceae5faa6ce388e8ec Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  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. Signed-off-by: John Crispin <[email protected]>
  7. ---
  8. arch/mips/ralink/Kconfig | 5 +++++
  9. 1 file changed, 5 insertions(+)
  10. --- a/arch/mips/ralink/Kconfig
  11. +++ b/arch/mips/ralink/Kconfig
  12. @@ -1,12 +1,17 @@
  13. # SPDX-License-Identifier: GPL-2.0
  14. if RALINK
  15. +config CEVT_SYSTICK_QUIRK
  16. + bool
  17. + default n
  18. +
  19. config CLKEVT_RT3352
  20. bool
  21. depends on SOC_RT305X || SOC_MT7620
  22. default y
  23. select TIMER_OF
  24. select CLKSRC_MMIO
  25. + select CEVT_SYSTICK_QUIRK
  26. config RALINK_ILL_ACC
  27. bool
  28. --- a/arch/mips/kernel/cevt-r4k.c
  29. +++ b/arch/mips/kernel/cevt-r4k.c
  30. @@ -16,6 +16,31 @@
  31. #include <asm/time.h>
  32. #include <asm/cevt-r4k.h>
  33. +#ifdef CONFIG_CEVT_SYSTICK_QUIRK
  34. +static int mips_state_oneshot(struct clock_event_device *evt)
  35. +{
  36. + unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED;
  37. + if (!cp0_timer_irq_installed) {
  38. + cp0_timer_irq_installed = 1;
  39. + if (request_irq(evt->irq, c0_compare_interrupt, flags, "timer",
  40. + c0_compare_interrupt))
  41. + pr_err("Failed to request irq %d (timer)\n", evt->irq);
  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. + free_irq(evt->irq, NULL);
  52. + }
  53. +
  54. + return 0;
  55. +}
  56. +#endif
  57. +
  58. static int mips_next_event(unsigned long delta,
  59. struct clock_event_device *evt)
  60. {
  61. @@ -292,7 +317,9 @@ core_initcall(r4k_register_cpufreq_notif
  62. int r4k_clockevent_init(void)
  63. {
  64. +#ifndef CONFIG_CEVT_SYSTICK_QUIRK
  65. unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED;
  66. +#endif
  67. unsigned int cpu = smp_processor_id();
  68. struct clock_event_device *cd;
  69. unsigned int irq, min_delta;
  70. @@ -322,11 +349,16 @@ int r4k_clockevent_init(void)
  71. cd->rating = 300;
  72. cd->irq = irq;
  73. cd->cpumask = cpumask_of(cpu);
  74. +#ifdef CONFIG_CEVT_SYSTICK_QUIRK
  75. + cd->set_state_shutdown = mips_state_shutdown;
  76. + cd->set_state_oneshot = mips_state_oneshot;
  77. +#endif
  78. cd->set_next_event = mips_next_event;
  79. cd->event_handler = mips_event_handler;
  80. clockevents_config_and_register(cd, mips_hpt_frequency, min_delta, 0x7fffffff);
  81. +#ifndef CONFIG_CEVT_SYSTICK_QUIRK
  82. if (cp0_timer_irq_installed)
  83. return 0;
  84. @@ -335,6 +367,7 @@ int r4k_clockevent_init(void)
  85. if (request_irq(irq, c0_compare_interrupt, flags, "timer",
  86. c0_compare_interrupt))
  87. pr_err("Failed to request irq %d (timer)\n", irq);
  88. +#endif
  89. return 0;
  90. }