Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f1bdc18 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'timers-clocksource-for-linus' of...

Merge branch 'timers-clocksource-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'timers-clocksource-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  clocksource: convert mips to generic i8253 clocksource
  clocksource: convert x86 to generic i8253 clocksource
  clocksource: convert footbridge to generic i8253 clocksource
  clocksource: add common i8253 PIT clocksource
  blackfin: convert to clocksource_register_hz
  mips: convert to clocksource_register_hz/khz
  sparc: convert to clocksource_register_hz/khz
  alpha: convert to clocksource_register_hz
  microblaze: convert to clocksource_register_hz/khz
  ia64: convert to clocksource_register_hz/khz
  x86: Convert remaining x86 clocksources to clocksource_register_hz/khz
  Make clocksource name const
parents 80fe02b5 a18f22a9
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
#ifndef __ASMARM_I8253_H
#define __ASMARM_I8253_H

/* i8253A PIT registers */
#define PIT_MODE	0x43
#define PIT_CH0		0x40

#define PIT_LATCH	((PIT_TICK_RATE + HZ / 2) / HZ)

extern raw_spinlock_t i8253_lock;

#define outb_pit	outb_p
#define inb_pit		inb_p

#endif
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ menu "Footbridge Implementations"

config ARCH_CATS
	bool "CATS"
	select CLKSRC_I8253
	select FOOTBRIDGE_HOST
	select ISA
	select ISA_DMA
@@ -59,6 +60,7 @@ config ARCH_EBSA285_HOST

config ARCH_NETWINDER
	bool "NetWinder"
	select CLKSRC_I8253
	select FOOTBRIDGE_HOST
	select ISA
	select ISA_DMA
+4 −41
Original line number Diff line number Diff line
@@ -10,53 +10,16 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/timex.h>

#include <asm/irq.h>

#include <asm/i8253.h>
#include <asm/mach/time.h>

#include "common.h"

#define PIT_MODE	0x43
#define PIT_CH0		0x40

#define PIT_LATCH	((PIT_TICK_RATE + HZ / 2) / HZ)

static cycle_t pit_read(struct clocksource *cs)
{
	unsigned long flags;
	static int old_count;
	static u32 old_jifs;
	int count;
	u32 jifs;

	raw_local_irq_save(flags);

	jifs = jiffies;
	outb_p(0x00, PIT_MODE);		/* latch the count */
	count = inb_p(PIT_CH0);		/* read the latched count */
	count |= inb_p(PIT_CH0) << 8;

	if (count > old_count && jifs == old_jifs)
		count = old_count;

	old_count = count;
	old_jifs = jifs;

	raw_local_irq_restore(flags);

	count = (PIT_LATCH - 1) - count;

	return (cycle_t)(jifs * PIT_LATCH) + count;
}

static struct clocksource pit_cs = {
	.name		= "pit",
	.rating		= 110,
	.read		= pit_read,
	.mask		= CLOCKSOURCE_MASK(32),
};
DEFINE_RAW_SPINLOCK(i8253_lock);

static void pit_set_mode(enum clock_event_mode mode,
	struct clock_event_device *evt)
@@ -121,7 +84,7 @@ static void __init isa_timer_init(void)
	pit_ce.max_delta_ns = clockevent_delta2ns(0x7fff, &pit_ce);
	pit_ce.min_delta_ns = clockevent_delta2ns(0x000f, &pit_ce);

	clocksource_register_hz(&pit_cs, PIT_TICK_RATE);
	clocksource_i8253_init();

	setup_irq(pit_ce.irq, &pit_timer_irq);
	clockevents_register_device(&pit_ce);
+2 −33
Original line number Diff line number Diff line
@@ -23,29 +23,6 @@
#include <asm/gptimers.h>
#include <asm/nmi.h>

/* Accelerators for sched_clock()
 * convert from cycles(64bits) => nanoseconds (64bits)
 *  basic equation:
 *		ns = cycles / (freq / ns_per_sec)
 *		ns = cycles * (ns_per_sec / freq)
 *		ns = cycles * (10^9 / (cpu_khz * 10^3))
 *		ns = cycles * (10^6 / cpu_khz)
 *
 *	Then we use scaling math (suggested by george@mvista.com) to get:
 *		ns = cycles * (10^6 * SC / cpu_khz) / SC
 *		ns = cycles * cyc2ns_scale / SC
 *
 *	And since SC is a constant power of two, we can convert the div
 *  into a shift.
 *
 *  We can use khz divisor instead of mhz to keep a better precision, since
 *  cyc2ns_scale is limited to 10^6 * 2^10, which fits in 32 bits.
 *  (mathieu.desnoyers@polymtl.ca)
 *
 *			-johnstul@us.ibm.com "math is hard, lets go shopping!"
 */

#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */

#if defined(CONFIG_CYCLES_CLOCKSOURCE)

@@ -63,7 +40,6 @@ static struct clocksource bfin_cs_cycles = {
	.rating		= 400,
	.read		= bfin_read_cycles,
	.mask		= CLOCKSOURCE_MASK(64),
	.shift		= CYC2NS_SCALE_FACTOR,
	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
};

@@ -75,10 +51,7 @@ static inline unsigned long long bfin_cs_cycles_sched_clock(void)

static int __init bfin_cs_cycles_init(void)
{
	bfin_cs_cycles.mult = \
		clocksource_hz2mult(get_cclk(), bfin_cs_cycles.shift);

	if (clocksource_register(&bfin_cs_cycles))
	if (clocksource_register_hz(&bfin_cs_cycles, get_cclk()))
		panic("failed to register clocksource");

	return 0;
@@ -111,7 +84,6 @@ static struct clocksource bfin_cs_gptimer0 = {
	.rating		= 350,
	.read		= bfin_read_gptimer0,
	.mask		= CLOCKSOURCE_MASK(32),
	.shift		= CYC2NS_SCALE_FACTOR,
	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
};

@@ -125,10 +97,7 @@ static int __init bfin_cs_gptimer0_init(void)
{
	setup_gptimer0();

	bfin_cs_gptimer0.mult = \
		clocksource_hz2mult(get_sclk(), bfin_cs_gptimer0.shift);

	if (clocksource_register(&bfin_cs_gptimer0))
	if (clocksource_register_hz(&bfin_cs_gptimer0, get_sclk()))
		panic("failed to register clocksource");

	return 0;
+1 −5
Original line number Diff line number Diff line
@@ -31,8 +31,6 @@ static struct clocksource clocksource_cyclone = {
        .rating         = 300,
        .read           = read_cyclone,
        .mask           = (1LL << 40) - 1,
        .mult           = 0, /*to be calculated*/
        .shift          = 16,
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
};

@@ -118,9 +116,7 @@ int __init init_cyclone_clock(void)
	/* initialize last tick */
	cyclone_mc = cyclone_timer;
	clocksource_cyclone.fsys_mmio = cyclone_timer;
	clocksource_cyclone.mult = clocksource_hz2mult(CYCLONE_TIMER_FREQ,
						clocksource_cyclone.shift);
	clocksource_register(&clocksource_cyclone);
	clocksource_register_hz(&clocksource_cyclone, CYCLONE_TIMER_FREQ);

	return 0;
}
Loading