.. | .. |
---|
6 | 6 | * Copyright (C) 2007 by Ralf Baechle |
---|
7 | 7 | */ |
---|
8 | 8 | #include <linux/clocksource.h> |
---|
| 9 | +#include <linux/cpufreq.h> |
---|
9 | 10 | #include <linux/init.h> |
---|
10 | 11 | #include <linux/sched_clock.h> |
---|
11 | 12 | |
---|
.. | .. |
---|
65 | 66 | return false; |
---|
66 | 67 | } |
---|
67 | 68 | |
---|
| 69 | +#ifdef CONFIG_CPU_FREQ |
---|
| 70 | + |
---|
| 71 | +static bool __read_mostly r4k_clock_unstable; |
---|
| 72 | + |
---|
| 73 | +static void r4k_clocksource_unstable(char *reason) |
---|
| 74 | +{ |
---|
| 75 | + if (r4k_clock_unstable) |
---|
| 76 | + return; |
---|
| 77 | + |
---|
| 78 | + r4k_clock_unstable = true; |
---|
| 79 | + |
---|
| 80 | + pr_info("R4K timer is unstable due to %s\n", reason); |
---|
| 81 | + |
---|
| 82 | + clocksource_mark_unstable(&clocksource_mips); |
---|
| 83 | +} |
---|
| 84 | + |
---|
| 85 | +static int r4k_cpufreq_callback(struct notifier_block *nb, |
---|
| 86 | + unsigned long val, void *data) |
---|
| 87 | +{ |
---|
| 88 | + if (val == CPUFREQ_POSTCHANGE) |
---|
| 89 | + r4k_clocksource_unstable("CPU frequency change"); |
---|
| 90 | + |
---|
| 91 | + return 0; |
---|
| 92 | +} |
---|
| 93 | + |
---|
| 94 | +static struct notifier_block r4k_cpufreq_notifier = { |
---|
| 95 | + .notifier_call = r4k_cpufreq_callback, |
---|
| 96 | +}; |
---|
| 97 | + |
---|
| 98 | +static int __init r4k_register_cpufreq_notifier(void) |
---|
| 99 | +{ |
---|
| 100 | + return cpufreq_register_notifier(&r4k_cpufreq_notifier, |
---|
| 101 | + CPUFREQ_TRANSITION_NOTIFIER); |
---|
| 102 | + |
---|
| 103 | +} |
---|
| 104 | +core_initcall(r4k_register_cpufreq_notifier); |
---|
| 105 | + |
---|
| 106 | +#endif /* !CONFIG_CPU_FREQ */ |
---|
| 107 | + |
---|
68 | 108 | int __init init_r4k_clocksource(void) |
---|
69 | 109 | { |
---|
70 | 110 | if (!cpu_has_counter || !mips_hpt_frequency) |
---|
.. | .. |
---|
78 | 118 | * by the VDSO (HWREna is configured by configure_hwrena()). |
---|
79 | 119 | */ |
---|
80 | 120 | if (cpu_has_mips_r2_r6 && rdhwr_count_usable()) |
---|
81 | | - clocksource_mips.archdata.vdso_clock_mode = VDSO_CLOCK_R4K; |
---|
| 121 | + clocksource_mips.vdso_clock_mode = VDSO_CLOCKMODE_R4K; |
---|
82 | 122 | |
---|
83 | 123 | clocksource_register_hz(&clocksource_mips, mips_hpt_frequency); |
---|
84 | 124 | |
---|