aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorSteven J. Hill <Steven.Hill@imgtec.com>2013-04-10 17:28:36 -0400
committerRalf Baechle <ralf@linux-mips.org>2013-05-09 11:55:20 -0400
commitdfa762e1c31c30607e4e5259f287dd3e174cbcc3 (patch)
treeb23b7335ac92646a29df85c897b5f4783944dc5b /arch/mips
parent28ea215186d365408756577e9e612ee334e26f8e (diff)
MIPS: Refactor GIC clocksource code.
Reorganize some of the GIC clocksource driver code. Below is a list of the various changes. * No longer select CSRC_GIC by default for Malta platform. * Limit choice for either the GIC or R4K clocksource, not both. * Change location in Makefile. * Created new 'gic_read_count' function in common 'irq-gic.c' file. * Change 'git_hpt_read' function in 'csrc-gic.c' to use new function. * Surround GIC specific code in Malta platform code with #ifdef's. * Only initialize the GIC clocksource if it was selected. Original code called it unconditionally if a GIC was found. Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/mips/include/asm/gic.h4
-rw-r--r--arch/mips/kernel/Makefile2
-rw-r--r--arch/mips/kernel/csrc-gic.c13
-rw-r--r--arch/mips/kernel/irq-gic.c16
-rw-r--r--arch/mips/mti-malta/malta-time.c37
6 files changed, 48 insertions, 25 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 79bc56c78cdb..4b623056470e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -337,6 +337,7 @@ config MIPS_SEAD3
337 select BOOT_RAW 337 select BOOT_RAW
338 select CEVT_R4K 338 select CEVT_R4K
339 select CSRC_R4K 339 select CSRC_R4K
340 select CSRC_GIC
340 select CPU_MIPSR2_IRQ_VI 341 select CPU_MIPSR2_IRQ_VI
341 select CPU_MIPSR2_IRQ_EI 342 select CPU_MIPSR2_IRQ_EI
342 select DMA_NONCOHERENT 343 select DMA_NONCOHERENT
diff --git a/arch/mips/include/asm/gic.h b/arch/mips/include/asm/gic.h
index f1a1e986d86b..6aa68ffad33c 100644
--- a/arch/mips/include/asm/gic.h
+++ b/arch/mips/include/asm/gic.h
@@ -359,6 +359,9 @@ struct gic_shared_intr_map {
359/* Mapped interrupt to pin X, then GIC will generate the vector (X+1). */ 359/* Mapped interrupt to pin X, then GIC will generate the vector (X+1). */
360#define GIC_PIN_TO_VEC_OFFSET (1) 360#define GIC_PIN_TO_VEC_OFFSET (1)
361 361
362#include <linux/clocksource.h>
363#include <linux/irq.h>
364
362extern unsigned int gic_present; 365extern unsigned int gic_present;
363extern unsigned int gic_frequency; 366extern unsigned int gic_frequency;
364extern unsigned long _gic_base; 367extern unsigned long _gic_base;
@@ -372,6 +375,7 @@ extern void gic_init(unsigned long gic_base_addr,
372 375
373extern void gic_clocksource_init(unsigned int); 376extern void gic_clocksource_init(unsigned int);
374extern unsigned int gic_get_int(void); 377extern unsigned int gic_get_int(void);
378extern cycle_t gic_read_count(void);
375extern void gic_send_ipi(unsigned int intr); 379extern void gic_send_ipi(unsigned int intr);
376extern unsigned int plat_ipi_call_int_xlate(unsigned int); 380extern unsigned int plat_ipi_call_int_xlate(unsigned int);
377extern unsigned int plat_ipi_resched_int_xlate(unsigned int); 381extern unsigned int plat_ipi_resched_int_xlate(unsigned int);
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index de75fb50562b..bab8b16706ca 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -23,11 +23,11 @@ obj-$(CONFIG_CEVT_GT641XX) += cevt-gt641xx.o
23obj-$(CONFIG_CEVT_SB1250) += cevt-sb1250.o 23obj-$(CONFIG_CEVT_SB1250) += cevt-sb1250.o
24obj-$(CONFIG_CEVT_TXX9) += cevt-txx9.o 24obj-$(CONFIG_CEVT_TXX9) += cevt-txx9.o
25obj-$(CONFIG_CSRC_BCM1480) += csrc-bcm1480.o 25obj-$(CONFIG_CSRC_BCM1480) += csrc-bcm1480.o
26obj-$(CONFIG_CSRC_GIC) += csrc-gic.o
26obj-$(CONFIG_CSRC_IOASIC) += csrc-ioasic.o 27obj-$(CONFIG_CSRC_IOASIC) += csrc-ioasic.o
27obj-$(CONFIG_CSRC_POWERTV) += csrc-powertv.o 28obj-$(CONFIG_CSRC_POWERTV) += csrc-powertv.o
28obj-$(CONFIG_CSRC_R4K) += csrc-r4k.o 29obj-$(CONFIG_CSRC_R4K) += csrc-r4k.o
29obj-$(CONFIG_CSRC_SB1250) += csrc-sb1250.o 30obj-$(CONFIG_CSRC_SB1250) += csrc-sb1250.o
30obj-$(CONFIG_CSRC_GIC) += csrc-gic.o
31obj-$(CONFIG_SYNC_R4K) += sync-r4k.o 31obj-$(CONFIG_SYNC_R4K) += sync-r4k.o
32 32
33obj-$(CONFIG_STACKTRACE) += stacktrace.o 33obj-$(CONFIG_STACKTRACE) += stacktrace.o
diff --git a/arch/mips/kernel/csrc-gic.c b/arch/mips/kernel/csrc-gic.c
index 5dca24bce51b..e02620901117 100644
--- a/arch/mips/kernel/csrc-gic.c
+++ b/arch/mips/kernel/csrc-gic.c
@@ -5,23 +5,14 @@
5 * 5 *
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. 6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 */ 7 */
8#include <linux/clocksource.h>
9#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/time.h>
10 10
11#include <asm/time.h>
12#include <asm/gic.h> 11#include <asm/gic.h>
13 12
14static cycle_t gic_hpt_read(struct clocksource *cs) 13static cycle_t gic_hpt_read(struct clocksource *cs)
15{ 14{
16 unsigned int hi, hi2, lo; 15 return gic_read_count();
17
18 do {
19 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_63_32), hi);
20 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_31_00), lo);
21 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_63_32), hi2);
22 } while (hi2 != hi);
23
24 return (((cycle_t) hi) << 32) + lo;
25} 16}
26 17
27static struct clocksource gic_clocksource = { 18static struct clocksource gic_clocksource = {
diff --git a/arch/mips/kernel/irq-gic.c b/arch/mips/kernel/irq-gic.c
index eaf7c1eb873e..6a476e1d41eb 100644
--- a/arch/mips/kernel/irq-gic.c
+++ b/arch/mips/kernel/irq-gic.c
@@ -10,6 +10,7 @@
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/smp.h> 11#include <linux/smp.h>
12#include <linux/irq.h> 12#include <linux/irq.h>
13#include <linux/clocksource.h>
13 14
14#include <asm/io.h> 15#include <asm/io.h>
15#include <asm/gic.h> 16#include <asm/gic.h>
@@ -32,6 +33,21 @@ static struct gic_pcpu_mask pcpu_masks[NR_CPUS];
32static struct gic_pending_regs pending_regs[NR_CPUS]; 33static struct gic_pending_regs pending_regs[NR_CPUS];
33static struct gic_intrmask_regs intrmask_regs[NR_CPUS]; 34static struct gic_intrmask_regs intrmask_regs[NR_CPUS];
34 35
36#ifdef CONFIG_CSRC_GIC
37cycle_t gic_read_count(void)
38{
39 unsigned int hi, hi2, lo;
40
41 do {
42 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_63_32), hi);
43 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_31_00), lo);
44 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_63_32), hi2);
45 } while (hi2 != hi);
46
47 return (((cycle_t) hi) << 32) + lo;
48}
49#endif
50
35unsigned int gic_get_timer_pending(void) 51unsigned int gic_get_timer_pending(void)
36{ 52{
37 unsigned int vpe_pending; 53 unsigned int vpe_pending;
diff --git a/arch/mips/mti-malta/malta-time.c b/arch/mips/mti-malta/malta-time.c
index 381ad062f192..79e5169eabd3 100644
--- a/arch/mips/mti-malta/malta-time.c
+++ b/arch/mips/mti-malta/malta-time.c
@@ -71,7 +71,9 @@ static void __init estimate_frequencies(void)
71{ 71{
72 unsigned long flags; 72 unsigned long flags;
73 unsigned int count, start; 73 unsigned int count, start;
74#ifdef CONFIG_IRQ_GIC
74 unsigned int giccount = 0, gicstart = 0; 75 unsigned int giccount = 0, gicstart = 0;
76#endif
75 77
76 local_irq_save(flags); 78 local_irq_save(flags);
77 79
@@ -81,26 +83,32 @@ static void __init estimate_frequencies(void)
81 83
82 /* Initialize counters. */ 84 /* Initialize counters. */
83 start = read_c0_count(); 85 start = read_c0_count();
86#ifdef CONFIG_IRQ_GIC
84 if (gic_present) 87 if (gic_present)
85 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_31_00), gicstart); 88 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_31_00), gicstart);
89#endif
86 90
87 /* Read counter exactly on falling edge of update flag. */ 91 /* Read counter exactly on falling edge of update flag. */
88 while (CMOS_READ(RTC_REG_A) & RTC_UIP); 92 while (CMOS_READ(RTC_REG_A) & RTC_UIP);
89 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP)); 93 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
90 94
91 count = read_c0_count(); 95 count = read_c0_count();
96#ifdef CONFIG_IRQ_GIC
92 if (gic_present) 97 if (gic_present)
93 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_31_00), giccount); 98 GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_31_00), giccount);
99#endif
94 100
95 local_irq_restore(flags); 101 local_irq_restore(flags);
96 102
97 count -= start; 103 count -= start;
98 if (gic_present)
99 giccount -= gicstart;
100
101 mips_hpt_frequency = count; 104 mips_hpt_frequency = count;
102 if (gic_present) 105
106#ifdef CONFIG_IRQ_GIC
107 if (gic_present) {
108 giccount -= gicstart;
103 gic_frequency = giccount; 109 gic_frequency = giccount;
110 }
111#endif
104} 112}
105 113
106void read_persistent_clock(struct timespec *ts) 114void read_persistent_clock(struct timespec *ts)
@@ -156,24 +164,27 @@ void __init plat_time_init(void)
156 (prid != (PRID_COMP_MIPS | PRID_IMP_25KF))) 164 (prid != (PRID_COMP_MIPS | PRID_IMP_25KF)))
157 freq *= 2; 165 freq *= 2;
158 freq = freqround(freq, 5000); 166 freq = freqround(freq, 5000);
159 pr_debug("CPU frequency %d.%02d MHz\n", freq/1000000, 167 printk("CPU frequency %d.%02d MHz\n", freq/1000000,
160 (freq%1000000)*100/1000000); 168 (freq%1000000)*100/1000000);
161 cpu_khz = freq / 1000; 169 cpu_khz = freq / 1000;
162 170
163 if (gic_present) { 171 mips_scroll_message();
164 freq = freqround(gic_frequency, 5000);
165 pr_debug("GIC frequency %d.%02d MHz\n", freq/1000000,
166 (freq%1000000)*100/1000000);
167 gic_clocksource_init(gic_frequency);
168 } else
169 init_r4k_clocksource();
170 172
171#ifdef CONFIG_I8253 173#ifdef CONFIG_I8253
172 /* Only Malta has a PIT. */ 174 /* Only Malta has a PIT. */
173 setup_pit_timer(); 175 setup_pit_timer();
174#endif 176#endif
175 177
176 mips_scroll_message(); 178#ifdef CONFIG_IRQ_GIC
179 if (gic_present) {
180 freq = freqround(gic_frequency, 5000);
181 printk("GIC frequency %d.%02d MHz\n", freq/1000000,
182 (freq%1000000)*100/1000000);
183#ifdef CONFIG_CSRC_GIC
184 gic_clocksource_init(gic_frequency);
185#endif
186 }
187#endif
177 188
178 plat_perf_setup(); 189 plat_perf_setup();
179} 190}