Skip to content

Commit

Permalink
Merge tag 'swarren-for-3.9-arm-timer-rework' of git://git.kernel.org/…
Browse files Browse the repository at this point in the history
…pub/scm/linux/kernel/git/swarren/linux-tegra into next/cleanup

From Stephen Warren:
ARM/...: timer and clock events cleanup, and remove struct sys_timer

This branch contains a number of cleanups and unifications to various
timer- clock-events- and ARM timer code. The main points are:

1) Convert arch_gettimeoffset to a pointer, so that architectures with
   multiple timer implementations can simply set this standard pointer
   rather than maintaining their own arch-specific pointers for the
   same purpose. Various architectures are converted to using this new
   feature.

2) Conversion of ARM timer implementations to use clock_event_devices's
   suspend/resume operations, rather than the ARM-specific sys_timer
   versions. Thus, the ARM code begins to use more common infra-structure
   rather than arch-specific code.

3) Removal of ARM's struct sys_timer completely, now that everything uses
   common code.

4) Introduction of drivers/clocksource/clksrc-of.c, which allows ARM clock
   source implementations to be moved into drivers/clocksource, with the
   need to add SoC-specific header files for each timer initialization
   function; instead, all enabled implementations are registered into a
   table which a single core function iterates over, and calls the
   relevant initialization functions based on device tree. At least the
   Tegra and BCM2835 clocksource implementations will use this feature in
   the 3.9 kernel cycle.

* tag 'swarren-for-3.9-arm-timer-rework' of git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra:
  clocksource: add common of_clksrc_init() function
  ARM: delete struct sys_timer
  ARM: remove struct sys_timer suspend and resume fields
  ARM: samsung: register syscore_ops for timer resume directly
  ARM: ux500: convert timer suspend/resume to clock_event_device
  ARM: sa1100: convert timer suspend/resume to clock_event_device
  ARM: pxa: convert timer suspend/resume to clock_event_device
  ARM: at91: convert timer suspend/resume to clock_event_device
  ARM: set arch_gettimeoffset directly
  m68k: set arch_gettimeoffset directly
  time: convert arch_gettimeoffset to a pointer
  cris: move usec/nsec conversion to do_slow_gettimeoffset

Signed-off-by: Olof Johansson <olof@lixom.net>
  • Loading branch information
Olof Johansson committed Jan 8, 2013
2 parents d1c3ed6 + ae278a9 commit 9813027
Show file tree
Hide file tree
Showing 529 changed files with 937 additions and 1,508 deletions.
3 changes: 1 addition & 2 deletions arch/arm/include/asm/mach/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

struct tag;
struct meminfo;
struct sys_timer;
struct pt_regs;
struct smp_operations;
#ifdef CONFIG_SMP
Expand Down Expand Up @@ -48,7 +47,7 @@ struct machine_desc {
void (*map_io)(void);/* IO mapping function */
void (*init_early)(void);
void (*init_irq)(void);
struct sys_timer *timer; /* system tick timer */
void (*init_time)(void);
void (*init_machine)(void);
void (*init_late)(void);
#ifdef CONFIG_MULTI_IRQ_HANDLER
Expand Down
30 changes: 0 additions & 30 deletions arch/arm/include/asm/mach/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,6 @@
#ifndef __ASM_ARM_MACH_TIME_H
#define __ASM_ARM_MACH_TIME_H

/*
* This is our kernel timer structure.
*
* - init
* Initialise the kernels jiffy timer source, claim interrupt
* using setup_irq. This is called early on during initialisation
* while interrupts are still disabled on the local CPU.
* - suspend
* Suspend the kernel jiffy timer source, if necessary. This
* is called with interrupts disabled, after all normal devices
* have been suspended. If no action is required, set this to
* NULL.
* - resume
* Resume the kernel jiffy timer source, if necessary. This
* is called with interrupts disabled before any normal devices
* are resumed. If no action is required, set this to NULL.
* - offset
* Return the timer offset in microseconds since the last timer
* interrupt. Note: this must take account of any unprocessed
* timer interrupt which may be pending.
*/
struct sys_timer {
void (*init)(void);
void (*suspend)(void);
void (*resume)(void);
#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
unsigned long (*offset)(void);
#endif
};

extern void timer_tick(void);

struct timespec;
Expand Down
53 changes: 1 addition & 52 deletions arch/arm/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <linux/timex.h>
#include <linux/errno.h>
#include <linux/profile.h>
#include <linux/syscore_ops.h>
#include <linux/timer.h>
#include <linux/irq.h>

Expand All @@ -31,11 +30,6 @@
#include <asm/mach/arch.h>
#include <asm/mach/time.h>

/*
* Our system timer.
*/
static struct sys_timer *system_timer;

#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) || \
defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE)
/* this needs a better home */
Expand Down Expand Up @@ -69,16 +63,6 @@ unsigned long profile_pc(struct pt_regs *regs)
EXPORT_SYMBOL(profile_pc);
#endif

#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
u32 arch_gettimeoffset(void)
{
if (system_timer->offset != NULL)
return system_timer->offset() * 1000;

return 0;
}
#endif /* CONFIG_ARCH_USES_GETTIMEOFFSET */

#ifndef CONFIG_GENERIC_CLOCKEVENTS
/*
* Kernel system timer support.
Expand Down Expand Up @@ -129,43 +113,8 @@ int __init register_persistent_clock(clock_access_fn read_boot,
return -EINVAL;
}

#if defined(CONFIG_PM) && !defined(CONFIG_GENERIC_CLOCKEVENTS)
static int timer_suspend(void)
{
if (system_timer->suspend)
system_timer->suspend();

return 0;
}

static void timer_resume(void)
{
if (system_timer->resume)
system_timer->resume();
}
#else
#define timer_suspend NULL
#define timer_resume NULL
#endif

static struct syscore_ops timer_syscore_ops = {
.suspend = timer_suspend,
.resume = timer_resume,
};

static int __init timer_init_syscore_ops(void)
{
register_syscore_ops(&timer_syscore_ops);

return 0;
}

device_initcall(timer_init_syscore_ops);

void __init time_init(void)
{
system_timer = machine_desc->timer;
system_timer->init();
machine_desc->init_time();
sched_clock_postinit();
}

5 changes: 0 additions & 5 deletions arch/arm/mach-at91/at91rm9200_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,3 @@ void __init at91rm9200_timer_init(void)
/* register clocksource */
clocksource_register_hz(&clk32k, AT91_SLOW_CLOCK);
}

struct sys_timer at91rm9200_timer = {
.init = at91rm9200_timer_init,
};

53 changes: 27 additions & 26 deletions arch/arm/mach-at91/at91sam926x_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,38 @@ pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
}
}

static void at91sam926x_pit_suspend(struct clock_event_device *cedev)
{
/* Disable timer */
pit_write(AT91_PIT_MR, 0);
}

static void at91sam926x_pit_reset(void)
{
/* Disable timer and irqs */
pit_write(AT91_PIT_MR, 0);

/* Clear any pending interrupts, wait for PIT to stop counting */
while (PIT_CPIV(pit_read(AT91_PIT_PIVR)) != 0)
cpu_relax();

/* Start PIT but don't enable IRQ */
pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
}

static void at91sam926x_pit_resume(struct clock_event_device *cedev)
{
at91sam926x_pit_reset();
}

static struct clock_event_device pit_clkevt = {
.name = "pit",
.features = CLOCK_EVT_FEAT_PERIODIC,
.shift = 32,
.rating = 100,
.set_mode = pit_clkevt_mode,
.suspend = at91sam926x_pit_suspend,
.resume = at91sam926x_pit_resume,
};


Expand Down Expand Up @@ -150,19 +176,6 @@ static struct irqaction at91sam926x_pit_irq = {
.irq = NR_IRQS_LEGACY + AT91_ID_SYS,
};

static void at91sam926x_pit_reset(void)
{
/* Disable timer and irqs */
pit_write(AT91_PIT_MR, 0);

/* Clear any pending interrupts, wait for PIT to stop counting */
while (PIT_CPIV(pit_read(AT91_PIT_PIVR)) != 0)
cpu_relax();

/* Start PIT but don't enable IRQ */
pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
}

#ifdef CONFIG_OF
static struct of_device_id pit_timer_ids[] = {
{ .compatible = "atmel,at91sam9260-pit" },
Expand Down Expand Up @@ -211,7 +224,7 @@ static int __init of_at91sam926x_pit_init(void)
/*
* Set up both clocksource and clockevent support.
*/
static void __init at91sam926x_pit_init(void)
void __init at91sam926x_pit_init(void)
{
unsigned long pit_rate;
unsigned bits;
Expand Down Expand Up @@ -250,12 +263,6 @@ static void __init at91sam926x_pit_init(void)
clockevents_register_device(&pit_clkevt);
}

static void at91sam926x_pit_suspend(void)
{
/* Disable timer */
pit_write(AT91_PIT_MR, 0);
}

void __init at91sam926x_ioremap_pit(u32 addr)
{
#if defined(CONFIG_OF)
Expand All @@ -272,9 +279,3 @@ void __init at91sam926x_ioremap_pit(u32 addr)
if (!pit_base_addr)
panic("Impossible to ioremap PIT\n");
}

struct sys_timer at91sam926x_timer = {
.init = at91sam926x_pit_init,
.suspend = at91sam926x_pit_suspend,
.resume = at91sam926x_pit_reset,
};
13 changes: 5 additions & 8 deletions arch/arm/mach-at91/at91x40_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
#define AT91_TC_CLK1BASE 0x40
#define AT91_TC_CLK2BASE 0x80

static unsigned long at91x40_gettimeoffset(void)
static u32 at91x40_gettimeoffset(void)
{
return (at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 / (AT91X40_MASTER_CLOCK / 128));
return (at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 /
(AT91X40_MASTER_CLOCK / 128)) * 1000;
}

static irqreturn_t at91x40_timer_interrupt(int irq, void *dev_id)
Expand All @@ -64,6 +65,8 @@ void __init at91x40_timer_init(void)
{
unsigned int v;

arch_gettimeoffset = at91x40_gettimeoffset;

at91_tc_write(AT91_TC_BCR, 0);
v = at91_tc_read(AT91_TC_BMR);
v = (v & ~AT91_TC_TC1XC1S) | AT91_TC_TC1XC1S_NONE;
Expand All @@ -79,9 +82,3 @@ void __init at91x40_timer_init(void)

at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CCR, (AT91_TC_SWTRG | AT91_TC_CLKEN));
}

struct sys_timer at91x40_timer = {
.init = at91x40_timer_init,
.offset = at91x40_gettimeoffset,
};

2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-1arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void __init onearm_board_init(void)

MACHINE_START(ONEARM, "Ajeco 1ARM single board computer")
/* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
.timer = &at91rm9200_timer,
.init_time = at91rm9200_timer_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = onearm_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-afeb-9260v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static void __init afeb9260_board_init(void)

MACHINE_START(AFEB9260, "Custom afeb9260 board")
/* Maintainer: Sergey Lapin <slapin@ossfans.org> */
.timer = &at91sam926x_timer,
.init_time = at91sam926x_pit_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = afeb9260_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-cam60.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static void __init cam60_board_init(void)

MACHINE_START(CAM60, "KwikByte CAM60")
/* Maintainer: KwikByte */
.timer = &at91sam926x_timer,
.init_time = at91sam926x_pit_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = cam60_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-carmeva.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static void __init carmeva_board_init(void)

MACHINE_START(CARMEVA, "Carmeva")
/* Maintainer: Conitec Datasystems */
.timer = &at91rm9200_timer,
.init_time = at91rm9200_timer_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = carmeva_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-cpu9krea.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ MACHINE_START(CPUAT9260, "Eukrea CPU9260")
MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")
#endif
/* Maintainer: Eric Benard - EUKREA Electromatique */
.timer = &at91sam926x_timer,
.init_time = at91sam926x_pit_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = cpu9krea_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-cpuat91.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static void __init cpuat91_board_init(void)

MACHINE_START(CPUAT91, "Eukrea")
/* Maintainer: Eric Benard - EUKREA Electromatique */
.timer = &at91rm9200_timer,
.init_time = at91rm9200_timer_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = cpuat91_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-csb337.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static void __init csb337_board_init(void)

MACHINE_START(CSB337, "Cogent CSB337")
/* Maintainer: Bill Gatliff */
.timer = &at91rm9200_timer,
.init_time = at91rm9200_timer_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = csb337_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-csb637.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static void __init csb637_board_init(void)

MACHINE_START(CSB637, "Cogent CSB637")
/* Maintainer: Bill Gatliff */
.timer = &at91rm9200_timer,
.init_time = at91rm9200_timer_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = csb637_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static const char *at91_dt_board_compat[] __initdata = {

DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)")
/* Maintainer: Atmel */
.timer = &at91sam926x_timer,
.init_time = at91sam926x_pit_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = at91_dt_initialize,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-eb01.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void __init at91eb01_init_early(void)

MACHINE_START(AT91EB01, "Atmel AT91 EB01")
/* Maintainer: Greg Ungerer <gerg@snapgear.com> */
.timer = &at91x40_timer,
.init_time = at91x40_timer_init,
.handle_irq = at91_aic_handle_irq,
.init_early = at91eb01_init_early,
.init_irq = at91eb01_init_irq,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-eb9200.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void __init eb9200_board_init(void)
}

MACHINE_START(ATEB9200, "Embest ATEB9200")
.timer = &at91rm9200_timer,
.init_time = at91rm9200_timer_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = eb9200_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-ecbat91.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static void __init ecb_at91board_init(void)

MACHINE_START(ECBAT91, "emQbit's ECB_AT91")
/* Maintainer: emQbit.com */
.timer = &at91rm9200_timer,
.init_time = at91rm9200_timer_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = ecb_at91init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-eco920.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static void __init eco920_board_init(void)

MACHINE_START(ECO920, "eco920")
/* Maintainer: Sascha Hauer */
.timer = &at91rm9200_timer,
.init_time = at91rm9200_timer_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = eco920_init_early,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/board-flexibity.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static void __init flexibity_board_init(void)

MACHINE_START(FLEXIBITY, "Flexibity Connect")
/* Maintainer: Maxim Osipov */
.timer = &at91sam926x_timer,
.init_time = at91sam926x_pit_init,
.map_io = at91_map_io,
.handle_irq = at91_aic_handle_irq,
.init_early = flexibity_init_early,
Expand Down
Loading

0 comments on commit 9813027

Please sign in to comment.