Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 81803
b: refs/heads/master
c: 36a90f2
h: refs/heads/master
i:
  81801: 01e41a4
  81799: b04a190
v: v3
  • Loading branch information
Greg Ungerer authored and Linus Torvalds committed Feb 1, 2008
1 parent 4de0598 commit 77cb2d6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f6efaf62bbb67ad564862a1131c365c3c55f6242
refs/heads/master: 36a90f26aa24c58e5279786340beb9f5bea39361
56 changes: 43 additions & 13 deletions trunk/arch/m68knommu/platform/68328/timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/clocksource.h>
#include <asm/setup.h>
#include <asm/system.h>
#include <asm/pgtable.h>
Expand Down Expand Up @@ -51,6 +52,19 @@
#define TICKS_PER_JIFFY 10
#endif

static u32 m68328_tick_cnt;

/***************************************************************************/

static irqreturn_t hw_tick(int irq, void *dummy)
{
/* Reset Timer1 */
TSTAT &= 0;

m68328_tick_cnt += TICKS_PER_JIFFY;
return arch_timer_interrupt(irq, dummy);
}

/***************************************************************************/

static irqreturn_t hw_tick(int irq, void *dummy)
Expand All @@ -69,6 +83,33 @@ static struct irqaction m68328_timer_irq = {
.handler = hw_tick,
};

/***************************************************************************/

static cycle_t m68328_read_clk(void)
{
unsigned long flags;
u32 cycles;

local_irq_save(flags);
cycles = m68328_tick_cnt + TCN;
local_irq_restore(flags);

return cycles;
}

/***************************************************************************/

static struct clocksource m68328_clk = {
.name = "timer",
.rating = 250,
.read = m68328_read_clk,
.shift = 20,
.mask = CLOCKSOURCE_MASK(32),
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

/***************************************************************************/

void hw_timer_init(void)
{
/* disable timer 1 */
Expand All @@ -84,19 +125,8 @@ void hw_timer_init(void)

/* Enable timer 1 */
TCTL |= TCTL_TEN;
}

/***************************************************************************/

unsigned long hw_timer_offset(void)
{
unsigned long ticks = TCN, offset = 0;

/* check for pending interrupt */
if (ticks < (TICKS_PER_JIFFY >> 1) && (ISR & (1 << TMR_IRQ_NUM)))
offset = 1000000 / HZ;
ticks = (ticks * 1000000 / HZ) / TICKS_PER_JIFFY;
return ticks + offset;
m68328_clk.mult = clocksource_hz2mult(TICKS_PER_JIFFY*HZ, m68328_clk.shift);
clocksource_register(&m68328_clk);
}

/***************************************************************************/
Expand Down

0 comments on commit 77cb2d6

Please sign in to comment.