This source file includes following definitions.
- read_pmtmr
- cpufreq_test_tsc
- cpufreq_none
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/acpi.h>
30 #include <asm/io.h>
31
32 static int pm_tmr_ioport = 0;
33
34
35 static u32 read_pmtmr(void)
36 {
37 u32 v1=0,v2=0,v3=0;
38
39
40
41
42
43 do {
44 v1 = inl(pm_tmr_ioport);
45 v2 = inl(pm_tmr_ioport);
46 v3 = inl(pm_tmr_ioport);
47 } while ((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1)
48 || (v3 > v1 && v3 < v2));
49
50
51 return (v2 & 0xFFFFFF);
52 }
53
54 static int __init cpufreq_test_tsc(void)
55 {
56 u32 now, then, diff;
57 u64 now_tsc, then_tsc, diff_tsc;
58 int i;
59
60
61
62
63
64 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
65
66 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
67 ACPI_ADR_SPACE_SYSTEM_IO)
68 return 0;
69
70 pm_tmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
71
72
73
74
75
76 if (!pm_tmr_ioport)
77 pm_tmr_ioport = acpi_gbl_FADT.pm_timer_block;
78 } else {
79
80 pm_tmr_ioport = acpi_gbl_FADT.pm_timer_block;
81 }
82
83 printk(KERN_DEBUG "start--> \n");
84 then = read_pmtmr();
85 then_tsc = rdtsc();
86 for (i=0;i<20;i++) {
87 mdelay(100);
88 now = read_pmtmr();
89 now_tsc = rdtsc();
90 diff = (now - then) & 0xFFFFFF;
91 diff_tsc = now_tsc - then_tsc;
92 printk(KERN_DEBUG "t1: %08u t2: %08u diff_pmtmr: %08u diff_tsc: %016llu\n", then, now, diff, diff_tsc);
93 then = now;
94 then_tsc = now_tsc;
95 }
96 printk(KERN_DEBUG "<-- end \n");
97 return -ENODEV;
98 }
99
100 static void __exit cpufreq_none(void)
101 {
102 return;
103 }
104
105 module_init(cpufreq_test_tsc)
106 module_exit(cpufreq_none)
107
108
109 MODULE_AUTHOR("Dominik Brodowski");
110 MODULE_DESCRIPTION("Verify the TSC cpufreq notifier working correctly -- needs ACPI-enabled system");
111 MODULE_LICENSE ("GPL");