Release 4.7 drivers/cpufreq/speedstep-ich.c
/*
* (C) 2001 Dave Jones, Arjan van de ven.
* (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
*
* Licensed under the terms of the GNU GPL License version 2.
* Based upon reverse engineered information, and on Intel documentation
* for chipsets ICH2-M and ICH3-M.
*
* Many thanks to Ducrot Bruno for finding and fixing the last
* "missing link" for ICH2-M/ICH3-M support, and to Thomas Winkler
* for extensive testing.
*
* BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous*
*/
/*********************************************************************
* SPEEDSTEP - DEFINITIONS *
*********************************************************************/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/cpufreq.h>
#include <linux/pci.h>
#include <linux/sched.h>
#include <asm/cpu_device_id.h>
#include "speedstep-lib.h"
/* speedstep_chipset:
* It is necessary to know which chipset is used. As accesses to
* this device occur at various places in this module, we need a
* static struct pci_dev * pointing to that device.
*/
static struct pci_dev *speedstep_chipset_dev;
/* speedstep_processor
*/
static enum speedstep_processor speedstep_processor;
static u32 pmbase;
/*
* There are only two frequency states for each processor. Values
* are in kHz for the time being.
*/
static struct cpufreq_frequency_table speedstep_freqs[] = {
{0, SPEEDSTEP_HIGH, 0},
{0, SPEEDSTEP_LOW, 0},
{0, 0, CPUFREQ_TABLE_END},
};
/**
* speedstep_find_register - read the PMBASE address
*
* Returns: -ENODEV if no register could be found
*/
static int speedstep_find_register(void)
{
if (!speedstep_chipset_dev)
return -ENODEV;
/* get PMBASE */
pci_read_config_dword(speedstep_chipset_dev, 0x40, &pmbase);
if (!(pmbase & 0x01)) {
pr_err("could not find speedstep register\n");
return -ENODEV;
}
pmbase &= 0xFFFFFFFE;
if (!pmbase) {
pr_err("could not find speedstep register\n");
return -ENODEV;
}
pr_debug("pmbase is 0x%x\n", pmbase);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dominik brodowski | dominik brodowski | 49 | 62.82% | 2 | 40.00% |
mattia dongili | mattia dongili | 25 | 32.05% | 1 | 20.00% |
joe perches | joe perches | 4 | 5.13% | 2 | 40.00% |
| Total | 78 | 100.00% | 5 | 100.00% |
/**
* speedstep_set_state - set the SpeedStep state
* @state: new processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH)
*
* Tries to change the SpeedStep state. Can be called from
* smp_call_function_single.
*/
static void speedstep_set_state(unsigned int state)
{
u8 pm2_blk;
u8 value;
unsigned long flags;
if (state > 0x1)
return;
/* Disable IRQs */
local_irq_save(flags);
/* read state */
value = inb(pmbase + 0x50);
pr_debug("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value);
/* write new state */
value &= 0xFE;
value |= state;
pr_debug("writing 0x%x to pmbase 0x%x + 0x50\n", value, pmbase);
/* Disable bus master arbitration */
pm2_blk = inb(pmbase + 0x20);
pm2_blk |= 0x01;
outb(pm2_blk, (pmbase + 0x20));
/* Actual transition */
outb(value, (pmbase + 0x50));
/* Restore bus master arbitration */
pm2_blk &= 0xfe;
outb(pm2_blk, (pmbase + 0x20));
/* check if transition was successful */
value = inb(pmbase + 0x50);
/* Enable IRQs */
local_irq_restore(flags);
pr_debug("read at pmbase 0x%x + 0x50 returned 0x%x\n", pmbase, value);
if (state == (value & 0x1))
pr_debug("change to %u MHz succeeded\n",
speedstep_get_frequency(speedstep_processor) / 1000);
else
pr_err("change failed - I/O error\n");
return;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dominik brodowski | dominik brodowski | 141 | 79.66% | 4 | 40.00% |
mattia dongili | mattia dongili | 26 | 14.69% | 1 | 10.00% |
dave jones | dave jones | 8 | 4.52% | 3 | 30.00% |
joe perches | joe perches | 2 | 1.13% | 2 | 20.00% |
| Total | 177 | 100.00% | 10 | 100.00% |
/* Wrapper for smp_call_function_single. */
static void _speedstep_set_state(void *_state)
{
speedstep_set_state(*(unsigned int *)_state);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
rusty russell | rusty russell | 21 | 100.00% | 1 | 100.00% |
| Total | 21 | 100.00% | 1 | 100.00% |
/**
* speedstep_activate - activate SpeedStep control in the chipset
*
* Tries to activate the SpeedStep status and control registers.
* Returns -EINVAL on an unsupported chipset, and zero on success.
*/
static int speedstep_activate(void)
{
u16 value = 0;
if (!speedstep_chipset_dev)
return -EINVAL;
pci_read_config_word(speedstep_chipset_dev, 0x00A0, &value);
if (!(value & 0x08)) {
value |= 0x08;
pr_debug("activating SpeedStep (TM) registers\n");
pci_write_config_word(speedstep_chipset_dev, 0x00A0, value);
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dominik brodowski | dominik brodowski | 58 | 90.62% | 2 | 50.00% |
dave jones | dave jones | 6 | 9.38% | 2 | 50.00% |
| Total | 64 | 100.00% | 4 | 100.00% |
/**
* speedstep_detect_chipset - detect the Southbridge which contains SpeedStep logic
*
* Detects ICH2-M, ICH3-M and ICH4-M so far. The pci_dev points to
* the LPC bridge / PM module which contains all power-management
* functions. Returns the SPEEDSTEP_CHIPSET_-number for the detected
* chipset, or zero on failure.
*/
static unsigned int speedstep_detect_chipset(void)
{
speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82801DB_12,
PCI_ANY_ID, PCI_ANY_ID,
NULL);
if (speedstep_chipset_dev)
return 4; /* 4-M */
speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82801CA_12,
PCI_ANY_ID, PCI_ANY_ID,
NULL);
if (speedstep_chipset_dev)
return 3; /* 3-M */
speedstep_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82801BA_10,
PCI_ANY_ID, PCI_ANY_ID,
NULL);
if (speedstep_chipset_dev) {
/* speedstep.c causes lockups on Dell Inspirons 8000 and
* 8100 which use a pretty old revision of the 82815
* host bridge. Abort on these systems.
*/
static struct pci_dev *hostbridge;
hostbridge = pci_get_subsys(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82815_MC,
PCI_ANY_ID, PCI_ANY_ID,
NULL);
if (!hostbridge)
return 2; /* 2-M */
if (hostbridge->revision < 5) {
pr_debug("hostbridge does not support speedstep\n");
speedstep_chipset_dev = NULL;
pci_dev_put(hostbridge);
return 0;
}
pci_dev_put(hostbridge);
return 2; /* 2-M */
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dave jones | dave jones | 82 | 56.16% | 3 | 33.33% |
dominik brodowski | dominik brodowski | 46 | 31.51% | 3 | 33.33% |
greg kroah-hartman | greg kroah-hartman | 14 | 9.59% | 1 | 11.11% |
auke kok | auke kok | 3 | 2.05% | 1 | 11.11% |
masanari iida | masanari iida | 1 | 0.68% | 1 | 11.11% |
| Total | 146 | 100.00% | 9 | 100.00% |
static void get_freq_data(void *_speed)
{
unsigned int *speed = _speed;
*speed = speedstep_get_frequency(speedstep_processor);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
rusty russell | rusty russell | 13 | 52.00% | 2 | 33.33% |
dave jones | dave jones | 11 | 44.00% | 3 | 50.00% |
mike travis | mike travis | 1 | 4.00% | 1 | 16.67% |
| Total | 25 | 100.00% | 6 | 100.00% |
static unsigned int speedstep_get(unsigned int cpu)
{
unsigned int speed;
/* You're supposed to ensure CPU is online. */
if (smp_call_function_single(cpu, get_freq_data, &speed, 1) != 0)
BUG();
pr_debug("detected %u kHz as current frequency\n", speed);
return speed;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
rusty russell | rusty russell | 28 | 62.22% | 2 | 40.00% |
dave jones | dave jones | 13 | 28.89% | 1 | 20.00% |
mike travis | mike travis | 3 | 6.67% | 1 | 20.00% |
dominik brodowski | dominik brodowski | 1 | 2.22% | 1 | 20.00% |
| Total | 45 | 100.00% | 5 | 100.00% |
/**
* speedstep_target - set a new CPUFreq policy
* @policy: new policy
* @index: index of target frequency
*
* Sets a new CPUFreq policy.
*/
static int speedstep_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned int policy_cpu;
policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask);
smp_call_function_single(policy_cpu, _speedstep_set_state, &index,
true);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dominik brodowski | dominik brodowski | 23 | 51.11% | 5 | 45.45% |
rusty russell | rusty russell | 12 | 26.67% | 1 | 9.09% |
dave jones | dave jones | 7 | 15.56% | 3 | 27.27% |
viresh kumar | viresh kumar | 2 | 4.44% | 1 | 9.09% |
mike travis | mike travis | 1 | 2.22% | 1 | 9.09% |
| Total | 45 | 100.00% | 11 | 100.00% |
struct get_freqs {
struct cpufreq_policy *policy;
int ret;
};
static void get_freqs_on_cpu(void *_get_freqs)
{
struct get_freqs *get_freqs = _get_freqs;
get_freqs->ret =
speedstep_get_freqs(speedstep_processor,
&speedstep_freqs[SPEEDSTEP_LOW].frequency,
&speedstep_freqs[SPEEDSTEP_HIGH].frequency,
&get_freqs->policy->cpuinfo.transition_latency,
&speedstep_set_state);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
rusty russell | rusty russell | 54 | 100.00% | 1 | 100.00% |
| Total | 54 | 100.00% | 1 | 100.00% |
static int speedstep_cpu_init(struct cpufreq_policy *policy)
{
unsigned int policy_cpu;
struct get_freqs gf;
/* only run on CPU to be set, or on its sibling */
#ifdef CONFIG_SMP
cpumask_copy(policy->cpus, topology_sibling_cpumask(policy->cpu));
#endif
policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask);
/* detect low and high frequency and transition latency */
gf.policy = policy;
smp_call_function_single(policy_cpu, get_freqs_on_cpu, &gf, 1);
if (gf.ret)
return gf.ret;
return cpufreq_table_validate_and_show(policy, speedstep_freqs);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dave jones | dave jones | 32 | 36.36% | 6 | 35.29% |
rusty russell | rusty russell | 28 | 31.82% | 2 | 11.76% |
dominik brodowski | dominik brodowski | 20 | 22.73% | 4 | 23.53% |
mike travis | mike travis | 3 | 3.41% | 2 | 11.76% |
viresh kumar | viresh kumar | 2 | 2.27% | 1 | 5.88% |
mattia dongili | mattia dongili | 2 | 2.27% | 1 | 5.88% |
bartosz golaszewski | bartosz golaszewski | 1 | 1.14% | 1 | 5.88% |
| Total | 88 | 100.00% | 17 | 100.00% |
static struct cpufreq_driver speedstep_driver = {
.name = "speedstep-ich",
.verify = cpufreq_generic_frequency_table_verify,
.target_index = speedstep_target,
.init = speedstep_cpu_init,
.get = speedstep_get,
.attr = cpufreq_generic_attr,
};
static const struct x86_cpu_id ss_smi_ids[] = {
{ X86_VENDOR_INTEL, 6, 0xb, },
{ X86_VENDOR_INTEL, 6, 0x8, },
{ X86_VENDOR_INTEL, 15, 2 },
{}
};
#if 0
/* Autoload or not? Do not for now. */
MODULE_DEVICE_TABLE(x86cpu, ss_smi_ids);
#endif
/**
* speedstep_init - initializes the SpeedStep CPUFreq driver
*
* Initializes the SpeedStep support. Returns -ENODEV on unsupported
* devices, -EINVAL on problems during initiatization, and zero on
* success.
*/
static int __init speedstep_init(void)
{
if (!x86_match_cpu(ss_smi_ids))
return -ENODEV;
/* detect processor */
speedstep_processor = speedstep_detect_processor();
if (!speedstep_processor) {
pr_debug("Intel(R) SpeedStep(TM) capable processor "
"not found\n");
return -ENODEV;
}
/* detect chipset */
if (!speedstep_detect_chipset()) {
pr_debug("Intel(R) SpeedStep(TM) for this chipset not "
"(yet) available.\n");
return -ENODEV;
}
/* activate speedstep support */
if (speedstep_activate()) {
pci_dev_put(speedstep_chipset_dev);
return -EINVAL;
}
if (speedstep_find_register())
return -ENODEV;
return cpufreq_register_driver(&speedstep_driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dominik brodowski | dominik brodowski | 47 | 48.96% | 4 | 40.00% |
dave jones | dave jones | 21 | 21.88% | 3 | 30.00% |
andi kleen | andi kleen | 12 | 12.50% | 1 | 10.00% |
mattia dongili | mattia dongili | 9 | 9.38% | 1 | 10.00% |
greg kroah-hartman | greg kroah-hartman | 7 | 7.29% | 1 | 10.00% |
| Total | 96 | 100.00% | 10 | 100.00% |
/**
* speedstep_exit - unregisters SpeedStep support
*
* Unregisters SpeedStep support.
*/
static void __exit speedstep_exit(void)
{
pci_dev_put(speedstep_chipset_dev);
cpufreq_unregister_driver(&speedstep_driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dominik brodowski | dominik brodowski | 15 | 75.00% | 2 | 66.67% |
greg kroah-hartman | greg kroah-hartman | 5 | 25.00% | 1 | 33.33% |
| Total | 20 | 100.00% | 3 | 100.00% |
MODULE_AUTHOR("Dave Jones, Dominik Brodowski <linux@brodo.de>");
MODULE_DESCRIPTION("Speedstep driver for Intel mobile processors on chipsets "
"with ICH-M southbridges.");
MODULE_LICENSE("GPL");
module_init(speedstep_init);
module_exit(speedstep_exit);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dominik brodowski | dominik brodowski | 504 | 47.19% | 8 | 17.78% |
dave jones | dave jones | 198 | 18.54% | 16 | 35.56% |
rusty russell | rusty russell | 173 | 16.20% | 4 | 8.89% |
mattia dongili | mattia dongili | 67 | 6.27% | 2 | 4.44% |
andi kleen | andi kleen | 57 | 5.34% | 1 | 2.22% |
greg kroah-hartman | greg kroah-hartman | 26 | 2.43% | 1 | 2.22% |
viresh kumar | viresh kumar | 14 | 1.31% | 4 | 8.89% |
joe perches | joe perches | 13 | 1.22% | 2 | 4.44% |
mike travis | mike travis | 8 | 0.75% | 3 | 6.67% |
alexey dobriyan | alexey dobriyan | 3 | 0.28% | 1 | 2.22% |
auke kok | auke kok | 3 | 0.28% | 1 | 2.22% |
bartosz golaszewski | bartosz golaszewski | 1 | 0.09% | 1 | 2.22% |
masanari iida | masanari iida | 1 | 0.09% | 1 | 2.22% |
| Total | 1068 | 100.00% | 45 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.