Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2001 Dave Jones, Arjan van de ven. |
| 3 | * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> |
| 4 | * |
| 5 | * Licensed under the terms of the GNU GPL License version 2. |
| 6 | * Based upon reverse engineered information, and on Intel documentation |
| 7 | * for chipsets ICH2-M and ICH3-M. |
| 8 | * |
| 9 | * Many thanks to Ducrot Bruno for finding and fixing the last |
| 10 | * "missing link" for ICH2-M/ICH3-M support, and to Thomas Winkler |
| 11 | * for extensive testing. |
| 12 | * |
| 13 | * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* |
| 14 | */ |
| 15 | |
| 16 | |
| 17 | /********************************************************************* |
| 18 | * SPEEDSTEP - DEFINITIONS * |
| 19 | *********************************************************************/ |
| 20 | |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/cpufreq.h> |
| 25 | #include <linux/pci.h> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 26 | #include <linux/sched.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Andi Kleen | fa8031a | 2012-01-26 00:09:12 +0100 | [diff] [blame] | 28 | #include <asm/cpu_device_id.h> |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include "speedstep-lib.h" |
| 31 | |
| 32 | |
| 33 | /* speedstep_chipset: |
| 34 | * It is necessary to know which chipset is used. As accesses to |
| 35 | * this device occur at various places in this module, we need a |
| 36 | * static struct pci_dev * pointing to that device. |
| 37 | */ |
| 38 | static struct pci_dev *speedstep_chipset_dev; |
| 39 | |
| 40 | |
| 41 | /* speedstep_processor |
| 42 | */ |
Rusty Russell | 1cce76c | 2009-11-17 14:39:53 -0800 | [diff] [blame] | 43 | static enum speedstep_processor speedstep_processor; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Mattia Dongili | 9a7d82a | 2005-11-30 22:00:59 +0100 | [diff] [blame] | 45 | static u32 pmbase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | /* |
| 48 | * There are only two frequency states for each processor. Values |
| 49 | * are in kHz for the time being. |
| 50 | */ |
| 51 | static struct cpufreq_frequency_table speedstep_freqs[] = { |
Viresh Kumar | 7f4b046 | 2014-03-28 19:11:47 +0530 | [diff] [blame] | 52 | {0, SPEEDSTEP_HIGH, 0}, |
| 53 | {0, SPEEDSTEP_LOW, 0}, |
| 54 | {0, 0, CPUFREQ_TABLE_END}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | /** |
Mattia Dongili | 9a7d82a | 2005-11-30 22:00:59 +0100 | [diff] [blame] | 59 | * speedstep_find_register - read the PMBASE address |
| 60 | * |
| 61 | * Returns: -ENODEV if no register could be found |
| 62 | */ |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 63 | static int speedstep_find_register(void) |
Mattia Dongili | 9a7d82a | 2005-11-30 22:00:59 +0100 | [diff] [blame] | 64 | { |
| 65 | if (!speedstep_chipset_dev) |
| 66 | return -ENODEV; |
| 67 | |
| 68 | /* get PMBASE */ |
| 69 | pci_read_config_dword(speedstep_chipset_dev, 0x40, &pmbase); |
| 70 | if (!(pmbase & 0x01)) { |
| 71 | printk(KERN_ERR "speedstep-ich: could not find speedstep register\n"); |
| 72 | return -ENODEV; |
| 73 | } |
| 74 | |
| 75 | pmbase &= 0xFFFFFFFE; |
| 76 | if (!pmbase) { |
| 77 | printk(KERN_ERR "speedstep-ich: could not find speedstep register\n"); |
| 78 | return -ENODEV; |
| 79 | } |
| 80 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 81 | pr_debug("pmbase is 0x%x\n", pmbase); |
Mattia Dongili | 9a7d82a | 2005-11-30 22:00:59 +0100 | [diff] [blame] | 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | * speedstep_set_state - set the SpeedStep state |
| 87 | * @state: new processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH) |
| 88 | * |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 89 | * Tries to change the SpeedStep state. Can be called from |
| 90 | * smp_call_function_single. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | */ |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 92 | static void speedstep_set_state(unsigned int state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | u8 pm2_blk; |
| 95 | u8 value; |
| 96 | unsigned long flags; |
| 97 | |
Mattia Dongili | 9a7d82a | 2005-11-30 22:00:59 +0100 | [diff] [blame] | 98 | if (state > 0x1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | return; |
| 100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | /* Disable IRQs */ |
| 102 | local_irq_save(flags); |
| 103 | |
| 104 | /* read state */ |
| 105 | value = inb(pmbase + 0x50); |
| 106 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 107 | pr_debug("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
| 109 | /* write new state */ |
| 110 | value &= 0xFE; |
| 111 | value |= state; |
| 112 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 113 | pr_debug("writing 0x%x to pmbase 0x%x + 0x50\n", value, pmbase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | /* Disable bus master arbitration */ |
| 116 | pm2_blk = inb(pmbase + 0x20); |
| 117 | pm2_blk |= 0x01; |
| 118 | outb(pm2_blk, (pmbase + 0x20)); |
| 119 | |
| 120 | /* Actual transition */ |
| 121 | outb(value, (pmbase + 0x50)); |
| 122 | |
| 123 | /* Restore bus master arbitration */ |
| 124 | pm2_blk &= 0xfe; |
| 125 | outb(pm2_blk, (pmbase + 0x20)); |
| 126 | |
| 127 | /* check if transition was successful */ |
| 128 | value = inb(pmbase + 0x50); |
| 129 | |
| 130 | /* Enable IRQs */ |
| 131 | local_irq_restore(flags); |
| 132 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 133 | pr_debug("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 135 | if (state == (value & 0x1)) |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 136 | pr_debug("change to %u MHz succeeded\n", |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 137 | speedstep_get_frequency(speedstep_processor) / 1000); |
| 138 | else |
| 139 | printk(KERN_ERR "cpufreq: change failed - I/O error\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | return; |
| 142 | } |
| 143 | |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 144 | /* Wrapper for smp_call_function_single. */ |
| 145 | static void _speedstep_set_state(void *_state) |
| 146 | { |
| 147 | speedstep_set_state(*(unsigned int *)_state); |
| 148 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
| 151 | * speedstep_activate - activate SpeedStep control in the chipset |
| 152 | * |
| 153 | * Tries to activate the SpeedStep status and control registers. |
| 154 | * Returns -EINVAL on an unsupported chipset, and zero on success. |
| 155 | */ |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 156 | static int speedstep_activate(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | { |
| 158 | u16 value = 0; |
| 159 | |
| 160 | if (!speedstep_chipset_dev) |
| 161 | return -EINVAL; |
| 162 | |
| 163 | pci_read_config_word(speedstep_chipset_dev, 0x00A0, &value); |
| 164 | if (!(value & 0x08)) { |
| 165 | value |= 0x08; |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 166 | pr_debug("activating SpeedStep (TM) registers\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | pci_write_config_word(speedstep_chipset_dev, 0x00A0, value); |
| 168 | } |
| 169 | |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | |
| 174 | /** |
| 175 | * speedstep_detect_chipset - detect the Southbridge which contains SpeedStep logic |
| 176 | * |
| 177 | * Detects ICH2-M, ICH3-M and ICH4-M so far. The pci_dev points to |
| 178 | * the LPC bridge / PM module which contains all power-management |
| 179 | * functions. Returns the SPEEDSTEP_CHIPSET_-number for the detected |
| 180 | * chipset, or zero on failure. |
| 181 | */ |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 182 | static unsigned int speedstep_detect_chipset(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | { |
| 184 | speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, |
| 185 | PCI_DEVICE_ID_INTEL_82801DB_12, |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 186 | PCI_ANY_ID, PCI_ANY_ID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | NULL); |
| 188 | if (speedstep_chipset_dev) |
| 189 | return 4; /* 4-M */ |
| 190 | |
| 191 | speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, |
| 192 | PCI_DEVICE_ID_INTEL_82801CA_12, |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 193 | PCI_ANY_ID, PCI_ANY_ID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | NULL); |
| 195 | if (speedstep_chipset_dev) |
| 196 | return 3; /* 3-M */ |
| 197 | |
| 198 | |
| 199 | speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, |
| 200 | PCI_DEVICE_ID_INTEL_82801BA_10, |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 201 | PCI_ANY_ID, PCI_ANY_ID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | NULL); |
| 203 | if (speedstep_chipset_dev) { |
| 204 | /* speedstep.c causes lockups on Dell Inspirons 8000 and |
| 205 | * 8100 which use a pretty old revision of the 82815 |
Masanari Iida | c03c301 | 2012-07-18 09:09:27 +0900 | [diff] [blame] | 206 | * host bridge. Abort on these systems. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | */ |
| 208 | static struct pci_dev *hostbridge; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
| 210 | hostbridge = pci_get_subsys(PCI_VENDOR_ID_INTEL, |
| 211 | PCI_DEVICE_ID_INTEL_82815_MC, |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 212 | PCI_ANY_ID, PCI_ANY_ID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | NULL); |
| 214 | |
| 215 | if (!hostbridge) |
| 216 | return 2; /* 2-M */ |
| 217 | |
Auke Kok | 44c1013 | 2007-06-08 15:46:36 -0700 | [diff] [blame] | 218 | if (hostbridge->revision < 5) { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 219 | pr_debug("hostbridge does not support speedstep\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | speedstep_chipset_dev = NULL; |
| 221 | pci_dev_put(hostbridge); |
| 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | pci_dev_put(hostbridge); |
| 226 | return 2; /* 2-M */ |
| 227 | } |
| 228 | |
| 229 | return 0; |
| 230 | } |
| 231 | |
Rusty Russell | 8dca15e | 2009-11-02 23:35:30 -0800 | [diff] [blame] | 232 | static void get_freq_data(void *_speed) |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 233 | { |
Rusty Russell | 8dca15e | 2009-11-02 23:35:30 -0800 | [diff] [blame] | 234 | unsigned int *speed = _speed; |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 235 | |
Rusty Russell | 8dca15e | 2009-11-02 23:35:30 -0800 | [diff] [blame] | 236 | *speed = speedstep_get_frequency(speedstep_processor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | static unsigned int speedstep_get(unsigned int cpu) |
| 240 | { |
Rusty Russell | 8dca15e | 2009-11-02 23:35:30 -0800 | [diff] [blame] | 241 | unsigned int speed; |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 242 | |
| 243 | /* You're supposed to ensure CPU is online. */ |
Rusty Russell | 8dca15e | 2009-11-02 23:35:30 -0800 | [diff] [blame] | 244 | if (smp_call_function_single(cpu, get_freq_data, &speed, 1) != 0) |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 245 | BUG(); |
| 246 | |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 247 | pr_debug("detected %u kHz as current frequency\n", speed); |
Rusty Russell | 8dca15e | 2009-11-02 23:35:30 -0800 | [diff] [blame] | 248 | return speed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | /** |
| 252 | * speedstep_target - set a new CPUFreq policy |
| 253 | * @policy: new policy |
Viresh Kumar | 9c0ebcf | 2013-10-25 19:45:48 +0530 | [diff] [blame] | 254 | * @index: index of target frequency |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | * |
| 256 | * Sets a new CPUFreq policy. |
| 257 | */ |
Viresh Kumar | 9c0ebcf | 2013-10-25 19:45:48 +0530 | [diff] [blame] | 258 | static int speedstep_target(struct cpufreq_policy *policy, unsigned int index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | { |
Viresh Kumar | 9c0ebcf | 2013-10-25 19:45:48 +0530 | [diff] [blame] | 260 | unsigned int policy_cpu; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 262 | policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
Viresh Kumar | 9c0ebcf | 2013-10-25 19:45:48 +0530 | [diff] [blame] | 264 | smp_call_function_single(policy_cpu, _speedstep_set_state, &index, |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 265 | true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 271 | struct get_freqs { |
| 272 | struct cpufreq_policy *policy; |
| 273 | int ret; |
| 274 | }; |
| 275 | |
| 276 | static void get_freqs_on_cpu(void *_get_freqs) |
| 277 | { |
| 278 | struct get_freqs *get_freqs = _get_freqs; |
| 279 | |
| 280 | get_freqs->ret = |
| 281 | speedstep_get_freqs(speedstep_processor, |
| 282 | &speedstep_freqs[SPEEDSTEP_LOW].frequency, |
| 283 | &speedstep_freqs[SPEEDSTEP_HIGH].frequency, |
| 284 | &get_freqs->policy->cpuinfo.transition_latency, |
| 285 | &speedstep_set_state); |
| 286 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
| 288 | static int speedstep_cpu_init(struct cpufreq_policy *policy) |
| 289 | { |
Viresh Kumar | 4b15768 | 2013-10-03 20:29:04 +0530 | [diff] [blame] | 290 | unsigned int policy_cpu; |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 291 | struct get_freqs gf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
| 293 | /* only run on CPU to be set, or on its sibling */ |
| 294 | #ifdef CONFIG_SMP |
Rusty Russell | 7ad728f | 2009-03-13 14:49:50 +1030 | [diff] [blame] | 295 | cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | #endif |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 297 | policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | |
Mattia Dongili | 1a10760 | 2005-12-02 21:59:41 +0100 | [diff] [blame] | 299 | /* detect low and high frequency and transition latency */ |
Rusty Russell | 394122a | 2009-06-11 22:59:58 +0930 | [diff] [blame] | 300 | gf.policy = policy; |
| 301 | smp_call_function_single(policy_cpu, get_freqs_on_cpu, &gf, 1); |
| 302 | if (gf.ret) |
| 303 | return gf.ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
Viresh Kumar | 5f3a2d3 | 2013-09-16 18:56:38 +0530 | [diff] [blame] | 305 | return cpufreq_table_validate_and_show(policy, speedstep_freqs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | |
Linus Torvalds | 221dee2 | 2007-02-26 14:55:48 -0800 | [diff] [blame] | 309 | static struct cpufreq_driver speedstep_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | .name = "speedstep-ich", |
Viresh Kumar | 3be1394 | 2013-10-03 20:28:28 +0530 | [diff] [blame] | 311 | .verify = cpufreq_generic_frequency_table_verify, |
Viresh Kumar | 9c0ebcf | 2013-10-25 19:45:48 +0530 | [diff] [blame] | 312 | .target_index = speedstep_target, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | .init = speedstep_cpu_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | .get = speedstep_get, |
Viresh Kumar | 3be1394 | 2013-10-03 20:28:28 +0530 | [diff] [blame] | 315 | .attr = cpufreq_generic_attr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | }; |
| 317 | |
Andi Kleen | fa8031a | 2012-01-26 00:09:12 +0100 | [diff] [blame] | 318 | static const struct x86_cpu_id ss_smi_ids[] = { |
| 319 | { X86_VENDOR_INTEL, 6, 0xb, }, |
| 320 | { X86_VENDOR_INTEL, 6, 0x8, }, |
| 321 | { X86_VENDOR_INTEL, 15, 2 }, |
| 322 | {} |
| 323 | }; |
| 324 | #if 0 |
| 325 | /* Autoload or not? Do not for now. */ |
| 326 | MODULE_DEVICE_TABLE(x86cpu, ss_smi_ids); |
| 327 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | |
| 329 | /** |
| 330 | * speedstep_init - initializes the SpeedStep CPUFreq driver |
| 331 | * |
| 332 | * Initializes the SpeedStep support. Returns -ENODEV on unsupported |
| 333 | * devices, -EINVAL on problems during initiatization, and zero on |
| 334 | * success. |
| 335 | */ |
| 336 | static int __init speedstep_init(void) |
| 337 | { |
Andi Kleen | fa8031a | 2012-01-26 00:09:12 +0100 | [diff] [blame] | 338 | if (!x86_match_cpu(ss_smi_ids)) |
| 339 | return -ENODEV; |
| 340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | /* detect processor */ |
| 342 | speedstep_processor = speedstep_detect_processor(); |
| 343 | if (!speedstep_processor) { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 344 | pr_debug("Intel(R) SpeedStep(TM) capable processor " |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 345 | "not found\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | return -ENODEV; |
| 347 | } |
| 348 | |
| 349 | /* detect chipset */ |
| 350 | if (!speedstep_detect_chipset()) { |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 351 | pr_debug("Intel(R) SpeedStep(TM) for this chipset not " |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 352 | "(yet) available.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | return -ENODEV; |
| 354 | } |
| 355 | |
| 356 | /* activate speedstep support */ |
| 357 | if (speedstep_activate()) { |
| 358 | pci_dev_put(speedstep_chipset_dev); |
| 359 | return -EINVAL; |
| 360 | } |
| 361 | |
Mattia Dongili | 9a7d82a | 2005-11-30 22:00:59 +0100 | [diff] [blame] | 362 | if (speedstep_find_register()) |
| 363 | return -ENODEV; |
| 364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | return cpufreq_register_driver(&speedstep_driver); |
| 366 | } |
| 367 | |
| 368 | |
| 369 | /** |
| 370 | * speedstep_exit - unregisters SpeedStep support |
| 371 | * |
| 372 | * Unregisters SpeedStep support. |
| 373 | */ |
| 374 | static void __exit speedstep_exit(void) |
| 375 | { |
| 376 | pci_dev_put(speedstep_chipset_dev); |
| 377 | cpufreq_unregister_driver(&speedstep_driver); |
| 378 | } |
| 379 | |
| 380 | |
Dave Jones | bbfebd6 | 2009-01-17 23:55:22 -0500 | [diff] [blame] | 381 | MODULE_AUTHOR("Dave Jones <davej@redhat.com>, " |
| 382 | "Dominik Brodowski <linux@brodo.de>"); |
| 383 | MODULE_DESCRIPTION("Speedstep driver for Intel mobile processors on chipsets " |
| 384 | "with ICH-M southbridges."); |
| 385 | MODULE_LICENSE("GPL"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
| 387 | module_init(speedstep_init); |
| 388 | module_exit(speedstep_exit); |