Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 70915
b: refs/heads/master
c: b0d4056
h: refs/heads/master
i:
  70913: 49bd35a
  70911: 47c2e5f
v: v3
  • Loading branch information
Ralf Baechle committed Oct 17, 2007
1 parent 8d2c3ed commit d13dde7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 60b0d65541b581955279221e060f8a0a221151b4
refs/heads/master: b0d4056dd6f16eca63114d0c252b214449a13cca
47 changes: 47 additions & 0 deletions trunk/arch/mips/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,50 @@ static void mips_event_handler(struct clock_event_device *dev)
{
}

/*
* FIXME: This doesn't hold for the relocated E9000 compare interrupt.
*/
static int c0_compare_int_pending(void)
{
return (read_c0_cause() >> cp0_compare_irq) & 0x100;
}

static int c0_compare_int_usable(void)
{
const unsigned int delta = 0x300000;
unsigned int cnt;

/*
* IP7 already pending? Try to clear it by acking the timer.
*/
if (c0_compare_int_pending()) {
write_c0_compare(read_c0_compare());
irq_disable_hazard();
if (c0_compare_int_pending())
return 0;
}

cnt = read_c0_count();
cnt += delta;
write_c0_compare(cnt);

while ((long)(read_c0_count() - cnt) <= 0)
; /* Wait for expiry */

if (!c0_compare_int_pending())
return 0;

write_c0_compare(read_c0_compare());
irq_disable_hazard();
if (c0_compare_int_pending())
return 0;

/*
* Feels like a real count / compare timer.
*/
return 1;
}

void __cpuinit mips_clockevent_init(void)
{
uint64_t mips_freq = mips_hpt_frequency;
Expand All @@ -412,6 +456,9 @@ void __cpuinit mips_clockevent_init(void)
return;
#endif

if (!c0_compare_int_usable())
return;

cd = &per_cpu(mips_clockevent_device, cpu);

cd->name = "MIPS";
Expand Down

0 comments on commit d13dde7

Please sign in to comment.