18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * (C) 2001 Dave Jones, Arjan van de ven. 48c2ecf20Sopenharmony_ci * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Based upon reverse engineered information, and on Intel documentation 78c2ecf20Sopenharmony_ci * for chipsets ICH2-M and ICH3-M. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Many thanks to Ducrot Bruno for finding and fixing the last 108c2ecf20Sopenharmony_ci * "missing link" for ICH2-M/ICH3-M support, and to Thomas Winkler 118c2ecf20Sopenharmony_ci * for extensive testing. 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous* 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/********************************************************************* 188c2ecf20Sopenharmony_ci * SPEEDSTEP - DEFINITIONS * 198c2ecf20Sopenharmony_ci *********************************************************************/ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#include <linux/kernel.h> 248c2ecf20Sopenharmony_ci#include <linux/module.h> 258c2ecf20Sopenharmony_ci#include <linux/init.h> 268c2ecf20Sopenharmony_ci#include <linux/cpufreq.h> 278c2ecf20Sopenharmony_ci#include <linux/pci.h> 288c2ecf20Sopenharmony_ci#include <linux/sched.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include <asm/cpu_device_id.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#include "speedstep-lib.h" 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* speedstep_chipset: 368c2ecf20Sopenharmony_ci * It is necessary to know which chipset is used. As accesses to 378c2ecf20Sopenharmony_ci * this device occur at various places in this module, we need a 388c2ecf20Sopenharmony_ci * static struct pci_dev * pointing to that device. 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_cistatic struct pci_dev *speedstep_chipset_dev; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* speedstep_processor 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_cistatic enum speedstep_processor speedstep_processor; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistatic u32 pmbase; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* 508c2ecf20Sopenharmony_ci * There are only two frequency states for each processor. Values 518c2ecf20Sopenharmony_ci * are in kHz for the time being. 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_cistatic struct cpufreq_frequency_table speedstep_freqs[] = { 548c2ecf20Sopenharmony_ci {0, SPEEDSTEP_HIGH, 0}, 558c2ecf20Sopenharmony_ci {0, SPEEDSTEP_LOW, 0}, 568c2ecf20Sopenharmony_ci {0, 0, CPUFREQ_TABLE_END}, 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/** 618c2ecf20Sopenharmony_ci * speedstep_find_register - read the PMBASE address 628c2ecf20Sopenharmony_ci * 638c2ecf20Sopenharmony_ci * Returns: -ENODEV if no register could be found 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_cistatic int speedstep_find_register(void) 668c2ecf20Sopenharmony_ci{ 678c2ecf20Sopenharmony_ci if (!speedstep_chipset_dev) 688c2ecf20Sopenharmony_ci return -ENODEV; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci /* get PMBASE */ 718c2ecf20Sopenharmony_ci pci_read_config_dword(speedstep_chipset_dev, 0x40, &pmbase); 728c2ecf20Sopenharmony_ci if (!(pmbase & 0x01)) { 738c2ecf20Sopenharmony_ci pr_err("could not find speedstep register\n"); 748c2ecf20Sopenharmony_ci return -ENODEV; 758c2ecf20Sopenharmony_ci } 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci pmbase &= 0xFFFFFFFE; 788c2ecf20Sopenharmony_ci if (!pmbase) { 798c2ecf20Sopenharmony_ci pr_err("could not find speedstep register\n"); 808c2ecf20Sopenharmony_ci return -ENODEV; 818c2ecf20Sopenharmony_ci } 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci pr_debug("pmbase is 0x%x\n", pmbase); 848c2ecf20Sopenharmony_ci return 0; 858c2ecf20Sopenharmony_ci} 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/** 888c2ecf20Sopenharmony_ci * speedstep_set_state - set the SpeedStep state 898c2ecf20Sopenharmony_ci * @state: new processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH) 908c2ecf20Sopenharmony_ci * 918c2ecf20Sopenharmony_ci * Tries to change the SpeedStep state. Can be called from 928c2ecf20Sopenharmony_ci * smp_call_function_single. 938c2ecf20Sopenharmony_ci */ 948c2ecf20Sopenharmony_cistatic void speedstep_set_state(unsigned int state) 958c2ecf20Sopenharmony_ci{ 968c2ecf20Sopenharmony_ci u8 pm2_blk; 978c2ecf20Sopenharmony_ci u8 value; 988c2ecf20Sopenharmony_ci unsigned long flags; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci if (state > 0x1) 1018c2ecf20Sopenharmony_ci return; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci /* Disable IRQs */ 1048c2ecf20Sopenharmony_ci local_irq_save(flags); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci /* read state */ 1078c2ecf20Sopenharmony_ci value = inb(pmbase + 0x50); 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci pr_debug("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci /* write new state */ 1128c2ecf20Sopenharmony_ci value &= 0xFE; 1138c2ecf20Sopenharmony_ci value |= state; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci pr_debug("writing 0x%x to pmbase 0x%x + 0x50\n", value, pmbase); 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci /* Disable bus master arbitration */ 1188c2ecf20Sopenharmony_ci pm2_blk = inb(pmbase + 0x20); 1198c2ecf20Sopenharmony_ci pm2_blk |= 0x01; 1208c2ecf20Sopenharmony_ci outb(pm2_blk, (pmbase + 0x20)); 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci /* Actual transition */ 1238c2ecf20Sopenharmony_ci outb(value, (pmbase + 0x50)); 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci /* Restore bus master arbitration */ 1268c2ecf20Sopenharmony_ci pm2_blk &= 0xfe; 1278c2ecf20Sopenharmony_ci outb(pm2_blk, (pmbase + 0x20)); 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci /* check if transition was successful */ 1308c2ecf20Sopenharmony_ci value = inb(pmbase + 0x50); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci /* Enable IRQs */ 1338c2ecf20Sopenharmony_ci local_irq_restore(flags); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci pr_debug("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value); 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci if (state == (value & 0x1)) 1388c2ecf20Sopenharmony_ci pr_debug("change to %u MHz succeeded\n", 1398c2ecf20Sopenharmony_ci speedstep_get_frequency(speedstep_processor) / 1000); 1408c2ecf20Sopenharmony_ci else 1418c2ecf20Sopenharmony_ci pr_err("change failed - I/O error\n"); 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci return; 1448c2ecf20Sopenharmony_ci} 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci/* Wrapper for smp_call_function_single. */ 1478c2ecf20Sopenharmony_cistatic void _speedstep_set_state(void *_state) 1488c2ecf20Sopenharmony_ci{ 1498c2ecf20Sopenharmony_ci speedstep_set_state(*(unsigned int *)_state); 1508c2ecf20Sopenharmony_ci} 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci/** 1538c2ecf20Sopenharmony_ci * speedstep_activate - activate SpeedStep control in the chipset 1548c2ecf20Sopenharmony_ci * 1558c2ecf20Sopenharmony_ci * Tries to activate the SpeedStep status and control registers. 1568c2ecf20Sopenharmony_ci * Returns -EINVAL on an unsupported chipset, and zero on success. 1578c2ecf20Sopenharmony_ci */ 1588c2ecf20Sopenharmony_cistatic int speedstep_activate(void) 1598c2ecf20Sopenharmony_ci{ 1608c2ecf20Sopenharmony_ci u16 value = 0; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci if (!speedstep_chipset_dev) 1638c2ecf20Sopenharmony_ci return -EINVAL; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci pci_read_config_word(speedstep_chipset_dev, 0x00A0, &value); 1668c2ecf20Sopenharmony_ci if (!(value & 0x08)) { 1678c2ecf20Sopenharmony_ci value |= 0x08; 1688c2ecf20Sopenharmony_ci pr_debug("activating SpeedStep (TM) registers\n"); 1698c2ecf20Sopenharmony_ci pci_write_config_word(speedstep_chipset_dev, 0x00A0, value); 1708c2ecf20Sopenharmony_ci } 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci return 0; 1738c2ecf20Sopenharmony_ci} 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/** 1778c2ecf20Sopenharmony_ci * speedstep_detect_chipset - detect the Southbridge which contains SpeedStep logic 1788c2ecf20Sopenharmony_ci * 1798c2ecf20Sopenharmony_ci * Detects ICH2-M, ICH3-M and ICH4-M so far. The pci_dev points to 1808c2ecf20Sopenharmony_ci * the LPC bridge / PM module which contains all power-management 1818c2ecf20Sopenharmony_ci * functions. Returns the SPEEDSTEP_CHIPSET_-number for the detected 1828c2ecf20Sopenharmony_ci * chipset, or zero on failure. 1838c2ecf20Sopenharmony_ci */ 1848c2ecf20Sopenharmony_cistatic unsigned int speedstep_detect_chipset(void) 1858c2ecf20Sopenharmony_ci{ 1868c2ecf20Sopenharmony_ci speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 1878c2ecf20Sopenharmony_ci PCI_DEVICE_ID_INTEL_82801DB_12, 1888c2ecf20Sopenharmony_ci PCI_ANY_ID, PCI_ANY_ID, 1898c2ecf20Sopenharmony_ci NULL); 1908c2ecf20Sopenharmony_ci if (speedstep_chipset_dev) 1918c2ecf20Sopenharmony_ci return 4; /* 4-M */ 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 1948c2ecf20Sopenharmony_ci PCI_DEVICE_ID_INTEL_82801CA_12, 1958c2ecf20Sopenharmony_ci PCI_ANY_ID, PCI_ANY_ID, 1968c2ecf20Sopenharmony_ci NULL); 1978c2ecf20Sopenharmony_ci if (speedstep_chipset_dev) 1988c2ecf20Sopenharmony_ci return 3; /* 3-M */ 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 2028c2ecf20Sopenharmony_ci PCI_DEVICE_ID_INTEL_82801BA_10, 2038c2ecf20Sopenharmony_ci PCI_ANY_ID, PCI_ANY_ID, 2048c2ecf20Sopenharmony_ci NULL); 2058c2ecf20Sopenharmony_ci if (speedstep_chipset_dev) { 2068c2ecf20Sopenharmony_ci /* speedstep.c causes lockups on Dell Inspirons 8000 and 2078c2ecf20Sopenharmony_ci * 8100 which use a pretty old revision of the 82815 2088c2ecf20Sopenharmony_ci * host bridge. Abort on these systems. 2098c2ecf20Sopenharmony_ci */ 2108c2ecf20Sopenharmony_ci struct pci_dev *hostbridge; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci hostbridge = pci_get_subsys(PCI_VENDOR_ID_INTEL, 2138c2ecf20Sopenharmony_ci PCI_DEVICE_ID_INTEL_82815_MC, 2148c2ecf20Sopenharmony_ci PCI_ANY_ID, PCI_ANY_ID, 2158c2ecf20Sopenharmony_ci NULL); 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci if (!hostbridge) 2188c2ecf20Sopenharmony_ci return 2; /* 2-M */ 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci if (hostbridge->revision < 5) { 2218c2ecf20Sopenharmony_ci pr_debug("hostbridge does not support speedstep\n"); 2228c2ecf20Sopenharmony_ci speedstep_chipset_dev = NULL; 2238c2ecf20Sopenharmony_ci pci_dev_put(hostbridge); 2248c2ecf20Sopenharmony_ci return 0; 2258c2ecf20Sopenharmony_ci } 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci pci_dev_put(hostbridge); 2288c2ecf20Sopenharmony_ci return 2; /* 2-M */ 2298c2ecf20Sopenharmony_ci } 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci return 0; 2328c2ecf20Sopenharmony_ci} 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistatic void get_freq_data(void *_speed) 2358c2ecf20Sopenharmony_ci{ 2368c2ecf20Sopenharmony_ci unsigned int *speed = _speed; 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci *speed = speedstep_get_frequency(speedstep_processor); 2398c2ecf20Sopenharmony_ci} 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_cistatic unsigned int speedstep_get(unsigned int cpu) 2428c2ecf20Sopenharmony_ci{ 2438c2ecf20Sopenharmony_ci unsigned int speed; 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci /* You're supposed to ensure CPU is online. */ 2468c2ecf20Sopenharmony_ci BUG_ON(smp_call_function_single(cpu, get_freq_data, &speed, 1)); 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci pr_debug("detected %u kHz as current frequency\n", speed); 2498c2ecf20Sopenharmony_ci return speed; 2508c2ecf20Sopenharmony_ci} 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci/** 2538c2ecf20Sopenharmony_ci * speedstep_target - set a new CPUFreq policy 2548c2ecf20Sopenharmony_ci * @policy: new policy 2558c2ecf20Sopenharmony_ci * @index: index of target frequency 2568c2ecf20Sopenharmony_ci * 2578c2ecf20Sopenharmony_ci * Sets a new CPUFreq policy. 2588c2ecf20Sopenharmony_ci */ 2598c2ecf20Sopenharmony_cistatic int speedstep_target(struct cpufreq_policy *policy, unsigned int index) 2608c2ecf20Sopenharmony_ci{ 2618c2ecf20Sopenharmony_ci unsigned int policy_cpu; 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask); 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci smp_call_function_single(policy_cpu, _speedstep_set_state, &index, 2668c2ecf20Sopenharmony_ci true); 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci return 0; 2698c2ecf20Sopenharmony_ci} 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_cistruct get_freqs { 2738c2ecf20Sopenharmony_ci struct cpufreq_policy *policy; 2748c2ecf20Sopenharmony_ci int ret; 2758c2ecf20Sopenharmony_ci}; 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_cistatic void get_freqs_on_cpu(void *_get_freqs) 2788c2ecf20Sopenharmony_ci{ 2798c2ecf20Sopenharmony_ci struct get_freqs *get_freqs = _get_freqs; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci get_freqs->ret = 2828c2ecf20Sopenharmony_ci speedstep_get_freqs(speedstep_processor, 2838c2ecf20Sopenharmony_ci &speedstep_freqs[SPEEDSTEP_LOW].frequency, 2848c2ecf20Sopenharmony_ci &speedstep_freqs[SPEEDSTEP_HIGH].frequency, 2858c2ecf20Sopenharmony_ci &get_freqs->policy->cpuinfo.transition_latency, 2868c2ecf20Sopenharmony_ci &speedstep_set_state); 2878c2ecf20Sopenharmony_ci} 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_cistatic int speedstep_cpu_init(struct cpufreq_policy *policy) 2908c2ecf20Sopenharmony_ci{ 2918c2ecf20Sopenharmony_ci unsigned int policy_cpu; 2928c2ecf20Sopenharmony_ci struct get_freqs gf; 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci /* only run on CPU to be set, or on its sibling */ 2958c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP 2968c2ecf20Sopenharmony_ci cpumask_copy(policy->cpus, topology_sibling_cpumask(policy->cpu)); 2978c2ecf20Sopenharmony_ci#endif 2988c2ecf20Sopenharmony_ci policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask); 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci /* detect low and high frequency and transition latency */ 3018c2ecf20Sopenharmony_ci gf.policy = policy; 3028c2ecf20Sopenharmony_ci smp_call_function_single(policy_cpu, get_freqs_on_cpu, &gf, 1); 3038c2ecf20Sopenharmony_ci if (gf.ret) 3048c2ecf20Sopenharmony_ci return gf.ret; 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci policy->freq_table = speedstep_freqs; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci return 0; 3098c2ecf20Sopenharmony_ci} 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_cistatic struct cpufreq_driver speedstep_driver = { 3138c2ecf20Sopenharmony_ci .name = "speedstep-ich", 3148c2ecf20Sopenharmony_ci .verify = cpufreq_generic_frequency_table_verify, 3158c2ecf20Sopenharmony_ci .target_index = speedstep_target, 3168c2ecf20Sopenharmony_ci .init = speedstep_cpu_init, 3178c2ecf20Sopenharmony_ci .get = speedstep_get, 3188c2ecf20Sopenharmony_ci .attr = cpufreq_generic_attr, 3198c2ecf20Sopenharmony_ci}; 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_cistatic const struct x86_cpu_id ss_smi_ids[] = { 3228c2ecf20Sopenharmony_ci X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, 0x8, 0), 3238c2ecf20Sopenharmony_ci X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, 0xb, 0), 3248c2ecf20Sopenharmony_ci X86_MATCH_VENDOR_FAM_MODEL(INTEL, 15, 0x2, 0), 3258c2ecf20Sopenharmony_ci {} 3268c2ecf20Sopenharmony_ci}; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci/** 3298c2ecf20Sopenharmony_ci * speedstep_init - initializes the SpeedStep CPUFreq driver 3308c2ecf20Sopenharmony_ci * 3318c2ecf20Sopenharmony_ci * Initializes the SpeedStep support. Returns -ENODEV on unsupported 3328c2ecf20Sopenharmony_ci * devices, -EINVAL on problems during initiatization, and zero on 3338c2ecf20Sopenharmony_ci * success. 3348c2ecf20Sopenharmony_ci */ 3358c2ecf20Sopenharmony_cistatic int __init speedstep_init(void) 3368c2ecf20Sopenharmony_ci{ 3378c2ecf20Sopenharmony_ci if (!x86_match_cpu(ss_smi_ids)) 3388c2ecf20Sopenharmony_ci return -ENODEV; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci /* detect processor */ 3418c2ecf20Sopenharmony_ci speedstep_processor = speedstep_detect_processor(); 3428c2ecf20Sopenharmony_ci if (!speedstep_processor) { 3438c2ecf20Sopenharmony_ci pr_debug("Intel(R) SpeedStep(TM) capable processor " 3448c2ecf20Sopenharmony_ci "not found\n"); 3458c2ecf20Sopenharmony_ci return -ENODEV; 3468c2ecf20Sopenharmony_ci } 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_ci /* detect chipset */ 3498c2ecf20Sopenharmony_ci if (!speedstep_detect_chipset()) { 3508c2ecf20Sopenharmony_ci pr_debug("Intel(R) SpeedStep(TM) for this chipset not " 3518c2ecf20Sopenharmony_ci "(yet) available.\n"); 3528c2ecf20Sopenharmony_ci return -ENODEV; 3538c2ecf20Sopenharmony_ci } 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci /* activate speedstep support */ 3568c2ecf20Sopenharmony_ci if (speedstep_activate()) { 3578c2ecf20Sopenharmony_ci pci_dev_put(speedstep_chipset_dev); 3588c2ecf20Sopenharmony_ci return -EINVAL; 3598c2ecf20Sopenharmony_ci } 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci if (speedstep_find_register()) 3628c2ecf20Sopenharmony_ci return -ENODEV; 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci return cpufreq_register_driver(&speedstep_driver); 3658c2ecf20Sopenharmony_ci} 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci/** 3698c2ecf20Sopenharmony_ci * speedstep_exit - unregisters SpeedStep support 3708c2ecf20Sopenharmony_ci * 3718c2ecf20Sopenharmony_ci * Unregisters SpeedStep support. 3728c2ecf20Sopenharmony_ci */ 3738c2ecf20Sopenharmony_cistatic void __exit speedstep_exit(void) 3748c2ecf20Sopenharmony_ci{ 3758c2ecf20Sopenharmony_ci pci_dev_put(speedstep_chipset_dev); 3768c2ecf20Sopenharmony_ci cpufreq_unregister_driver(&speedstep_driver); 3778c2ecf20Sopenharmony_ci} 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ciMODULE_AUTHOR("Dave Jones, Dominik Brodowski <linux@brodo.de>"); 3818c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Speedstep driver for Intel mobile processors on chipsets " 3828c2ecf20Sopenharmony_ci "with ICH-M southbridges."); 3838c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_cimodule_init(speedstep_init); 3868c2ecf20Sopenharmony_cimodule_exit(speedstep_exit); 387