Skip to content

Commit

Permalink
[CPUFREQ] Recalibrate cpu_khz [2/2]
Browse files Browse the repository at this point in the history
Some cpufreq drivers (at that time, only powernow-k7) need to recalibrate the
cpu_khz at runtime.

Signed-off-by: Bruno Ducrot <ducrot@poupinou.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dave Jones <davej@redhat.com>
  • Loading branch information
Dave Jones committed Jun 1, 2005
1 parent 91350ed commit c5d28fb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/i386/kernel/timers/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <linux/timex.h>
#include <linux/errno.h>
#include <linux/jiffies.h>
#include <linux/module.h>

#include <asm/io.h>
#include <asm/timer.h>
Expand All @@ -24,7 +25,7 @@

#define CALIBRATE_TIME (5 * 1000020/HZ)

unsigned long __init calibrate_tsc(void)
unsigned long calibrate_tsc(void)
{
mach_prepare_counter();

Expand Down Expand Up @@ -139,7 +140,7 @@ unsigned long __init calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr)
#endif

/* calculate cpu_khz */
void __init init_cpu_khz(void)
void init_cpu_khz(void)
{
if (cpu_has_tsc) {
unsigned long tsc_quotient = calibrate_tsc();
Expand All @@ -158,3 +159,4 @@ void __init init_cpu_khz(void)
}
}
}

20 changes: 20 additions & 0 deletions arch/i386/kernel/timers/timer_tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,26 @@ core_initcall(cpufreq_tsc);
static inline void cpufreq_delayed_get(void) { return; }
#endif

int recalibrate_cpu_khz(void)
{
#ifndef CONFIG_SMP
unsigned long cpu_khz_old = cpu_khz;

if (cpu_has_tsc) {
init_cpu_khz();
cpu_data[0].loops_per_jiffy =
cpufreq_scale(cpu_data[0].loops_per_jiffy,
cpu_khz_old,
cpu_khz);
return 0;
} else
return -ENODEV;
#else
return -ENODEV;
#endif
}
EXPORT_SYMBOL(recalibrate_cpu_khz);

static void mark_offset_tsc(void)
{
unsigned long lost,delay;
Expand Down
1 change: 1 addition & 0 deletions include/asm-i386/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern struct init_timer_opts timer_cyclone_init;

extern unsigned long calibrate_tsc(void);
extern void init_cpu_khz(void);
extern int recalibrate_cpu_khz(void);
#ifdef CONFIG_HPET_TIMER
extern struct init_timer_opts timer_hpet_init;
extern unsigned long calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr);
Expand Down

0 comments on commit c5d28fb

Please sign in to comment.