007-amp_timer.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. From 1dffe06838c26b7c3fc99f9ddb7db78e378f6908 Mon Sep 17 00:00:00 2001
  2. From: Daniel Hellstrom <[email protected]>
  3. Date: Wed, 22 Sep 2010 13:21:13 +0200
  4. Subject: [PATCH] SPARC/LEON: added support for selecting Timer Core and Timer within core, useful for AMP systems.
  5. Signed-off-by: Daniel Hellstrom <[email protected]>
  6. ---
  7. arch/sparc/kernel/leon_kernel.c | 41 +++++++++++++++++++++++++-------------
  8. 1 files changed, 27 insertions(+), 14 deletions(-)
  9. --- a/arch/sparc/kernel/leon_kernel.c
  10. +++ b/arch/sparc/kernel/leon_kernel.c
  11. @@ -23,15 +23,16 @@
  12. #include "prom.h"
  13. #include "irq.h"
  14. -struct leon3_irqctrl_regs_map *leon3_irqctrl_regs; /* interrupt controller base address, initialized by amba_init() */
  15. -struct leon3_gptimer_regs_map *leon3_gptimer_regs; /* timer controller base address, initialized by amba_init() */
  16. +struct leon3_irqctrl_regs_map *leon3_irqctrl_regs = NULL; /* interrupt controller base address, initialized by amba_init() */
  17. +struct leon3_gptimer_regs_map *leon3_gptimer_regs = NULL; /* timer controller base address, initialized by amba_init() */
  18. struct amba_apb_device leon_percpu_timer_dev[16];
  19. int leondebug_irq_disable;
  20. int leon_debug_irqout;
  21. static int dummy_master_l10_counter;
  22. -unsigned long leon3_gptimer_irq; /* interrupt controller irq number, initialized by amba_init() */
  23. +unsigned long leon3_gptimer_irq = 0; /* interrupt controller irq number, initialized by amba_init() */
  24. +unsigned long leon3_gptimer_idx = 0; /* Timer Index (starting at 0) with Timer Core */
  25. unsigned int sparc_leon_eirq;
  26. #define LEON_IMASK ((&leon3_irqctrl_regs->mask[0]))
  27. @@ -109,6 +110,7 @@ void __init leon_init_timers(irq_handler
  28. struct property *pp;
  29. int len;
  30. int cpu, icsel;
  31. + int ampopts;
  32. leondebug_irq_disable = 0;
  33. leon_debug_irqout = 0;
  34. @@ -124,24 +126,35 @@ void __init leon_init_timers(irq_handler
  35. }
  36. /* Find GPTIMER Timer Registers base address otherwise bail out. */
  37. - if (rootnp && (np=of_find_node_by_name(rootnp, "GAISLER_GPTIMER"))) {
  38. + np = rootnp;
  39. + while (np && (np=of_find_node_by_name(np, "GAISLER_GPTIMER"))) {
  40. + ampopts = 0;
  41. + pp = of_find_property(np, "ampopts", &len);
  42. + if ( pp && ((ampopts = *(int *)pp->value) == 0) ) {
  43. + /* Skip this instance, resource already allocated by other OS */
  44. + continue;
  45. + }
  46. + /* Select Timer-Instance on Timer Core. Default is zero */
  47. + leon3_gptimer_idx = ampopts & 0x7;
  48. +
  49. pp = of_find_property(np, "reg", &len);
  50. if (pp)
  51. leon3_gptimer_regs = *(struct leon3_gptimer_regs_map **)pp->value;
  52. pp = of_find_property(np, "interrupts", &len);
  53. if (pp)
  54. leon3_gptimer_irq = *(unsigned int *)pp->value;
  55. + break;
  56. }
  57. if (leon3_gptimer_regs && leon3_irqctrl_regs && leon3_gptimer_irq) {
  58. - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].val, 0);
  59. - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].rld,
  60. + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].val, 0);
  61. + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].rld,
  62. (((1000000 / 100) - 1)));
  63. - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, 0);
  64. + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl, 0);
  65. #ifdef CONFIG_SMP
  66. leon_percpu_timer_dev[0].start = (int)leon3_gptimer_regs;
  67. - leon_percpu_timer_dev[0].irq = leon3_gptimer_irq+1;
  68. + leon_percpu_timer_dev[0].irq = leon3_gptimer_irq+1+leon3_gptimer_idx;
  69. if (!(LEON3_BYPASS_LOAD_PA(&leon3_gptimer_regs->config) &
  70. (1<<LEON3_GPTIMER_SEPIRQ))) {
  71. @@ -149,9 +162,9 @@ void __init leon_init_timers(irq_handler
  72. BUG();
  73. }
  74. - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].val, 0);
  75. - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].rld, (((1000000/100) - 1)));
  76. - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0);
  77. + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].val, 0);
  78. + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].rld, (((1000000/100) - 1)));
  79. + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].ctrl, 0);
  80. # endif
  81. /* The IRQ controller may (if implemented) consist of multiple
  82. @@ -178,7 +191,7 @@ void __init leon_init_timers(irq_handler
  83. BUG();
  84. }
  85. - irq = request_irq(leon3_gptimer_irq,
  86. + irq = request_irq(leon3_gptimer_irq+leon3_gptimer_idx,
  87. counter_fn,
  88. (IRQF_DISABLED | SA_STATIC_ALLOC), "timer", NULL);
  89. @@ -210,13 +223,13 @@ void __init leon_init_timers(irq_handler
  90. # endif
  91. if (leon3_gptimer_regs) {
  92. - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl,
  93. + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl,
  94. LEON3_GPTIMER_EN |
  95. LEON3_GPTIMER_RL |
  96. LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN);
  97. #ifdef CONFIG_SMP
  98. - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl,
  99. + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].ctrl,
  100. LEON3_GPTIMER_EN |
  101. LEON3_GPTIMER_RL |
  102. LEON3_GPTIMER_LD |