Skip to content

Commit

Permalink
MIPS: Malta: Use gic_read_count() to read GIC timer
Browse files Browse the repository at this point in the history
Instead of reading the GIC registers directly, use the interface the GIC
driver already exposes for reading the global timer.  Also get rid of
the unnecessary #ifdefs.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Qais Yousef <qais.yousef@imgtec.com>
Cc: John Crispin <blogic@openwrt.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/8123/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Andrew Bresticker authored and Ralf Baechle committed Nov 24, 2014
1 parent a393d93 commit 7d9ad5d
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions arch/mips/mti-malta/malta-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ static void __init estimate_frequencies(void)
{
unsigned long flags;
unsigned int count, start;
#ifdef CONFIG_MIPS_GIC
unsigned int giccount = 0, gicstart = 0;
#endif
cycle_t giccount = 0, gicstart = 0;

#if defined(CONFIG_KVM_GUEST) && CONFIG_KVM_GUEST_TIMER_FREQ
mips_hpt_frequency = CONFIG_KVM_GUEST_TIMER_FREQ * 1000000;
Expand All @@ -87,32 +85,26 @@ static void __init estimate_frequencies(void)

/* Initialize counters. */
start = read_c0_count();
#ifdef CONFIG_MIPS_GIC
if (gic_present)
GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_31_00), gicstart);
#endif
gicstart = gic_read_count();

/* Read counter exactly on falling edge of update flag. */
while (CMOS_READ(RTC_REG_A) & RTC_UIP);
while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));

count = read_c0_count();
#ifdef CONFIG_MIPS_GIC
if (gic_present)
GICREAD(GIC_REG(SHARED, GIC_SH_COUNTER_31_00), giccount);
#endif
giccount = gic_read_count();

local_irq_restore(flags);

count -= start;
mips_hpt_frequency = count;

#ifdef CONFIG_MIPS_GIC
if (gic_present) {
giccount -= gicstart;
gic_frequency = giccount;
}
#endif
}

void read_persistent_clock(struct timespec *ts)
Expand Down

0 comments on commit 7d9ad5d

Please sign in to comment.