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

Commit 23c197b7 authored by Stephen Warren's avatar Stephen Warren
Browse files

ARM: set arch_gettimeoffset directly



remove ARM's struct sys_timer .offset function pointer, and instead
directly set the arch_gettimeoffset function pointer when the timer
driver is initialized. This requires multiplying all function results
by 1000, since the removed arm_gettimeoffset() did this. Also,
s/unsigned long/u32/ just to make the function prototypes exactly
match that of arch_gettimeoffset.

Cc: Russell King <linux@arm.linux.org.uk>
Cc: Andrew Victor <linux@maxim.org.za>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ryan Mallon <rmallon@gmail.com>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
parent c8d5ba18
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -35,9 +35,6 @@ 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);
+0 −14
Original line number Diff line number Diff line
@@ -69,16 +69,6 @@ unsigned long profile_pc(struct pt_regs *regs)
EXPORT_SYMBOL(profile_pc);
#endif

#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
static u32 arm_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.
@@ -164,10 +154,6 @@ device_initcall(timer_init_syscore_ops);

void __init time_init(void)
{
#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
	arch_gettimeoffset = arm_gettimeoffset;
#endif

	system_timer = machine_desc->timer;
	system_timer->init();
	sched_clock_postinit();
+5 −3
Original line number Diff line number Diff line
@@ -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)
@@ -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;
@@ -82,6 +85,5 @@ void __init at91x40_timer_init(void)

struct sys_timer at91x40_timer = {
	.init	= at91x40_timer_init,
	.offset	= at91x40_gettimeoffset,
};
+4 −3
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ static void __init ebsa110_init_early(void)
 * interrupt, then the PIT counter will roll over (ie, be negative).
 * This actually works out to be convenient.
 */
static unsigned long ebsa110_gettimeoffset(void)
static u32 ebsa110_gettimeoffset(void)
{
	unsigned long offset, count;

@@ -181,7 +181,7 @@ static unsigned long ebsa110_gettimeoffset(void)
	 */
	offset = offset * (1000000 / HZ) / COUNT;

	return offset;
	return offset * 1000;
}

static irqreturn_t
@@ -215,6 +215,8 @@ static struct irqaction ebsa110_timer_irq = {
 */
static void __init ebsa110_timer_init(void)
{
	arch_gettimeoffset = ebsa110_gettimeoffset;

	/*
	 * Timer 1, mode 2, LSB/MSB
	 */
@@ -227,7 +229,6 @@ static void __init ebsa110_timer_init(void)

static struct sys_timer ebsa110_timer = {
	.init		= ebsa110_timer_init,
	.offset		= ebsa110_gettimeoffset,
};

static struct plat_serial8250_port serial_platform_data[] = {
+18 −11
Original line number Diff line number Diff line
@@ -140,11 +140,29 @@ static struct irqaction ep93xx_timer_irq = {
	.handler	= ep93xx_timer_interrupt,
};

static u32 ep93xx_gettimeoffset(void)
{
	int offset;

	offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time;

	/*
	 * Timer 4 is based on a 983.04 kHz reference clock,
	 * so dividing by 983040 gives the fraction of a second,
	 * so dividing by 0.983040 converts to uS.
	 * Refactor the calculation to avoid overflow.
	 * Finally, multiply by 1000 to give nS.
	 */
	return (offset + (53 * offset / 3072)) * 1000;
}

static void __init ep93xx_timer_init(void)
{
	u32 tmode = EP93XX_TIMER123_CONTROL_MODE |
		    EP93XX_TIMER123_CONTROL_CLKSEL;

	arch_gettimeoffset = ep93xx_gettimeoffset;

	/* Enable periodic HZ timer.  */
	__raw_writel(tmode, EP93XX_TIMER1_CONTROL);
	__raw_writel(TIMER1_RELOAD, EP93XX_TIMER1_LOAD);
@@ -158,19 +176,8 @@ static void __init ep93xx_timer_init(void)
	setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq);
}

static unsigned long ep93xx_gettimeoffset(void)
{
	int offset;

	offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time;

	/* Calculate (1000000 / 983040) * offset.  */
	return offset + (53 * offset / 3072);
}

struct sys_timer ep93xx_timer = {
	.init		= ep93xx_timer_init,
	.offset		= ep93xx_gettimeoffset,
};


Loading