Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 71594
b: refs/heads/master
c: 93c846f
h: refs/heads/master
v: v3
  • Loading branch information
Ralf Baechle committed Oct 19, 2007
1 parent 9929ed0 commit 6f4dc54
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 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: f887b93e17448552eb6761d21277c33177bb904b
refs/heads/master: 93c846f9047f392fc2335668a5234edfbddb7cdc
39 changes: 31 additions & 8 deletions trunk/arch/mips/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,48 @@ struct clocksource clocksource_mips = {
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

static void __init init_mips_clocksource(void)
void __init clocksource_set_clock(struct clocksource *cs, unsigned int clock)
{
u64 temp;
u32 shift;

if (!mips_hpt_frequency || clocksource_mips.read == null_hpt_read)
return;
/* Find a shift value */
for (shift = 32; shift > 0; shift--) {
temp = (u64) NSEC_PER_SEC << shift;
do_div(temp, clock);
if ((temp >> 32) == 0)
break;
}
cs->shift = shift;
cs->mult = (u32) temp;
}

void __cpuinit clockevent_set_clock(struct clock_event_device *cd,
unsigned int clock)
{
u64 temp;
u32 shift;

/* Calclate a somewhat reasonable rating value */
clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
/* Find a shift value */
for (shift = 32; shift > 0; shift--) {
temp = (u64) NSEC_PER_SEC << shift;
do_div(temp, mips_hpt_frequency);
do_div(temp, clock);
if ((temp >> 32) == 0)
break;
}
clocksource_mips.shift = shift;
clocksource_mips.mult = (u32)temp;
cd->shift = shift;
cd->mult = (u32) temp;
}

static void __init init_mips_clocksource(void)
{
if (!mips_hpt_frequency || clocksource_mips.read == null_hpt_read)
return;

/* Calclate a somewhat reasonable rating value */
clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;

clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);

clocksource_register(&clocksource_mips);
}
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/asm-mips/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/ptrace.h>
#include <linux/rtc.h>
#include <linux/spinlock.h>
#include <linux/clockchips.h>
#include <linux/clocksource.h>

extern spinlock_t rtc_lock;
Expand Down Expand Up @@ -83,4 +84,8 @@ static inline void mips_clockevent_init(void)
}
#endif

extern void clocksource_set_clock(struct clocksource *cs, unsigned int clock);
extern void clockevent_set_clock(struct clock_event_device *cd,
unsigned int clock);

#endif /* _ASM_TIME_H */

0 comments on commit 6f4dc54

Please sign in to comment.