2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This file was based upon code in Powertweak Linux (http://powertweak.sf.net)
|
2009-01-18 13:00:04 +08:00
|
|
|
* (C) 2000-2003 Dave Jones, Arjan van de Ven, Janne Pänkälä,
|
|
|
|
* Dominik Brodowski.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Licensed under the terms of the GNU GPL License version 2.
|
|
|
|
*
|
|
|
|
* BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2006-02-28 13:43:23 +08:00
|
|
|
#include <linux/module.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/cpufreq.h>
|
|
|
|
#include <linux/ioport.h>
|
2008-07-29 03:08:16 +08:00
|
|
|
#include <linux/timex.h>
|
|
|
|
#include <linux/io.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-26 07:09:12 +08:00
|
|
|
#include <asm/cpu_device_id.h>
|
2009-01-18 13:00:04 +08:00
|
|
|
#include <asm/msr.h>
|
|
|
|
|
2008-07-29 03:08:16 +08:00
|
|
|
#define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long
|
|
|
|
as it is unused */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-18 13:00:04 +08:00
|
|
|
#define PFX "powernow-k6: "
|
2005-04-17 06:20:36 +08:00
|
|
|
static unsigned int busfreq; /* FSB, in 10 kHz */
|
|
|
|
static unsigned int max_multiplier;
|
|
|
|
|
powernow-k6: correctly initialize default parameters
The powernow-k6 driver used to read the initial multiplier from the
powernow register. However, there is a problem with this:
* If there was a frequency transition before, the multiplier read from the
register corresponds to the current multiplier.
* If there was no frequency transition since reset, the field in the
register always reads as zero, regardless of the current multiplier that
is set using switches on the mainboard and that the CPU is running at.
The zero value corresponds to multiplier 4.5, so as a consequence, the
powernow-k6 driver always assumes multiplier 4.5.
For example, if we have 550MHz CPU with bus frequency 100MHz and
multiplier 5.5, the powernow-k6 driver thinks that the multiplier is 4.5
and bus frequency is 122MHz. The powernow-k6 driver then sets the
multiplier to 4.5, underclocking the CPU to 450MHz, but reports the
current frequency as 550MHz.
There is no reliable way how to read the initial multiplier. I modified
the driver so that it contains a table of known frequencies (based on
parameters of existing CPUs and some common overclocking schemes) and sets
the multiplier according to the frequency. If the frequency is unknown
(because of unusual overclocking or underclocking), the user must supply
the bus speed and maximum multiplier as module parameters.
This patch should be backported to all stable kernels. If it doesn't
apply cleanly, change it, or ask me to change it.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-12-12 08:38:53 +08:00
|
|
|
static unsigned int param_busfreq = 0;
|
|
|
|
static unsigned int param_max_multiplier = 0;
|
|
|
|
|
|
|
|
module_param_named(max_multiplier, param_max_multiplier, uint, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(max_multiplier, "Maximum multiplier (allowed values: 20 30 35 40 45 50 55 60)");
|
|
|
|
|
|
|
|
module_param_named(bus_frequency, param_busfreq, uint, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(bus_frequency, "Bus frequency in kHz");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Clock ratio multiplied by 10 - see table 27 in AMD#23446 */
|
|
|
|
static struct cpufreq_frequency_table clock_ratio[] = {
|
2014-03-28 21:41:47 +08:00
|
|
|
{0, 60, /* 110 -> 6.0x */ 0},
|
|
|
|
{0, 55, /* 011 -> 5.5x */ 0},
|
|
|
|
{0, 50, /* 001 -> 5.0x */ 0},
|
|
|
|
{0, 45, /* 000 -> 4.5x */ 0},
|
|
|
|
{0, 40, /* 010 -> 4.0x */ 0},
|
|
|
|
{0, 35, /* 111 -> 3.5x */ 0},
|
|
|
|
{0, 30, /* 101 -> 3.0x */ 0},
|
|
|
|
{0, 20, /* 100 -> 2.0x */ 0},
|
|
|
|
{0, 0, CPUFREQ_TABLE_END}
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2013-12-12 08:39:19 +08:00
|
|
|
static const u8 index_to_register[8] = { 6, 3, 1, 0, 2, 7, 5, 4 };
|
|
|
|
static const u8 register_to_index[8] = { 3, 2, 4, 1, 7, 6, 0, 5 };
|
|
|
|
|
powernow-k6: correctly initialize default parameters
The powernow-k6 driver used to read the initial multiplier from the
powernow register. However, there is a problem with this:
* If there was a frequency transition before, the multiplier read from the
register corresponds to the current multiplier.
* If there was no frequency transition since reset, the field in the
register always reads as zero, regardless of the current multiplier that
is set using switches on the mainboard and that the CPU is running at.
The zero value corresponds to multiplier 4.5, so as a consequence, the
powernow-k6 driver always assumes multiplier 4.5.
For example, if we have 550MHz CPU with bus frequency 100MHz and
multiplier 5.5, the powernow-k6 driver thinks that the multiplier is 4.5
and bus frequency is 122MHz. The powernow-k6 driver then sets the
multiplier to 4.5, underclocking the CPU to 450MHz, but reports the
current frequency as 550MHz.
There is no reliable way how to read the initial multiplier. I modified
the driver so that it contains a table of known frequencies (based on
parameters of existing CPUs and some common overclocking schemes) and sets
the multiplier according to the frequency. If the frequency is unknown
(because of unusual overclocking or underclocking), the user must supply
the bus speed and maximum multiplier as module parameters.
This patch should be backported to all stable kernels. If it doesn't
apply cleanly, change it, or ask me to change it.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-12-12 08:38:53 +08:00
|
|
|
static const struct {
|
|
|
|
unsigned freq;
|
|
|
|
unsigned mult;
|
|
|
|
} usual_frequency_table[] = {
|
|
|
|
{ 400000, 40 }, // 100 * 4
|
|
|
|
{ 450000, 45 }, // 100 * 4.5
|
|
|
|
{ 475000, 50 }, // 95 * 5
|
|
|
|
{ 500000, 50 }, // 100 * 5
|
|
|
|
{ 506250, 45 }, // 112.5 * 4.5
|
|
|
|
{ 533500, 55 }, // 97 * 5.5
|
|
|
|
{ 550000, 55 }, // 100 * 5.5
|
|
|
|
{ 562500, 50 }, // 112.5 * 5
|
|
|
|
{ 570000, 60 }, // 95 * 6
|
|
|
|
{ 600000, 60 }, // 100 * 6
|
|
|
|
{ 618750, 55 }, // 112.5 * 5.5
|
|
|
|
{ 660000, 55 }, // 120 * 5.5
|
|
|
|
{ 675000, 60 }, // 112.5 * 6
|
|
|
|
{ 720000, 60 }, // 120 * 6
|
|
|
|
};
|
|
|
|
|
|
|
|
#define FREQ_RANGE 3000
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* powernow_k6_get_cpu_multiplier - returns the current FSB multiplier
|
|
|
|
*
|
2013-12-12 08:38:32 +08:00
|
|
|
* Returns the current setting of the frequency multiplier. Core clock
|
2005-04-17 06:20:36 +08:00
|
|
|
* speed is frequency of the Front-Side Bus multiplied with this value.
|
|
|
|
*/
|
|
|
|
static int powernow_k6_get_cpu_multiplier(void)
|
|
|
|
{
|
2013-12-12 08:38:32 +08:00
|
|
|
unsigned long invalue = 0;
|
2009-01-18 13:00:04 +08:00
|
|
|
u32 msrval;
|
2006-02-28 13:43:23 +08:00
|
|
|
|
2013-12-12 08:38:32 +08:00
|
|
|
local_irq_disable();
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
msrval = POWERNOW_IOPORT + 0x1;
|
|
|
|
wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
|
2008-07-29 03:08:16 +08:00
|
|
|
invalue = inl(POWERNOW_IOPORT + 0x8);
|
2005-04-17 06:20:36 +08:00
|
|
|
msrval = POWERNOW_IOPORT + 0x0;
|
|
|
|
wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */
|
|
|
|
|
2013-12-12 08:38:32 +08:00
|
|
|
local_irq_enable();
|
|
|
|
|
2013-12-12 08:39:19 +08:00
|
|
|
return clock_ratio[register_to_index[(invalue >> 5)&7]].driver_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-12-12 08:38:32 +08:00
|
|
|
static void powernow_k6_set_cpu_multiplier(unsigned int best_i)
|
|
|
|
{
|
|
|
|
unsigned long outvalue, invalue;
|
|
|
|
unsigned long msrval;
|
|
|
|
unsigned long cr0;
|
|
|
|
|
|
|
|
/* we now need to transform best_i to the BVC format, see AMD#23446 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The processor doesn't respond to inquiry cycles while changing the
|
|
|
|
* frequency, so we must disable cache.
|
|
|
|
*/
|
|
|
|
local_irq_disable();
|
|
|
|
cr0 = read_cr0();
|
|
|
|
write_cr0(cr0 | X86_CR0_CD);
|
|
|
|
wbinvd();
|
|
|
|
|
2013-12-12 08:39:19 +08:00
|
|
|
outvalue = (1<<12) | (1<<10) | (1<<9) | (index_to_register[best_i]<<5);
|
2013-12-12 08:38:32 +08:00
|
|
|
|
|
|
|
msrval = POWERNOW_IOPORT + 0x1;
|
|
|
|
wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
|
|
|
|
invalue = inl(POWERNOW_IOPORT + 0x8);
|
|
|
|
invalue = invalue & 0x1f;
|
|
|
|
outvalue = outvalue | invalue;
|
|
|
|
outl(outvalue, (POWERNOW_IOPORT + 0x8));
|
|
|
|
msrval = POWERNOW_IOPORT + 0x0;
|
|
|
|
wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */
|
|
|
|
|
|
|
|
write_cr0(cr0);
|
|
|
|
local_irq_enable();
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/**
|
2013-10-25 22:15:48 +08:00
|
|
|
* powernow_k6_target - set the PowerNow! multiplier
|
2005-04-17 06:20:36 +08:00
|
|
|
* @best_i: clock_ratio[best_i] is the target multiplier
|
|
|
|
*
|
|
|
|
* Tries to change the PowerNow! multiplier
|
|
|
|
*/
|
2013-10-25 22:15:48 +08:00
|
|
|
static int powernow_k6_target(struct cpufreq_policy *policy,
|
2013-03-24 14:26:43 +08:00
|
|
|
unsigned int best_i)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
|
2013-03-30 18:55:15 +08:00
|
|
|
if (clock_ratio[best_i].driver_data > max_multiplier) {
|
2009-01-18 13:00:04 +08:00
|
|
|
printk(KERN_ERR PFX "invalid target frequency\n");
|
2013-10-25 22:15:48 +08:00
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-12-12 08:38:32 +08:00
|
|
|
powernow_k6_set_cpu_multiplier(best_i);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
|
|
|
|
{
|
2014-04-26 04:15:38 +08:00
|
|
|
struct cpufreq_frequency_table *pos;
|
2009-01-18 13:00:04 +08:00
|
|
|
unsigned int i, f;
|
powernow-k6: correctly initialize default parameters
The powernow-k6 driver used to read the initial multiplier from the
powernow register. However, there is a problem with this:
* If there was a frequency transition before, the multiplier read from the
register corresponds to the current multiplier.
* If there was no frequency transition since reset, the field in the
register always reads as zero, regardless of the current multiplier that
is set using switches on the mainboard and that the CPU is running at.
The zero value corresponds to multiplier 4.5, so as a consequence, the
powernow-k6 driver always assumes multiplier 4.5.
For example, if we have 550MHz CPU with bus frequency 100MHz and
multiplier 5.5, the powernow-k6 driver thinks that the multiplier is 4.5
and bus frequency is 122MHz. The powernow-k6 driver then sets the
multiplier to 4.5, underclocking the CPU to 450MHz, but reports the
current frequency as 550MHz.
There is no reliable way how to read the initial multiplier. I modified
the driver so that it contains a table of known frequencies (based on
parameters of existing CPUs and some common overclocking schemes) and sets
the multiplier according to the frequency. If the frequency is unknown
(because of unusual overclocking or underclocking), the user must supply
the bus speed and maximum multiplier as module parameters.
This patch should be backported to all stable kernels. If it doesn't
apply cleanly, change it, or ask me to change it.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-12-12 08:38:53 +08:00
|
|
|
unsigned khz;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (policy->cpu != 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
powernow-k6: correctly initialize default parameters
The powernow-k6 driver used to read the initial multiplier from the
powernow register. However, there is a problem with this:
* If there was a frequency transition before, the multiplier read from the
register corresponds to the current multiplier.
* If there was no frequency transition since reset, the field in the
register always reads as zero, regardless of the current multiplier that
is set using switches on the mainboard and that the CPU is running at.
The zero value corresponds to multiplier 4.5, so as a consequence, the
powernow-k6 driver always assumes multiplier 4.5.
For example, if we have 550MHz CPU with bus frequency 100MHz and
multiplier 5.5, the powernow-k6 driver thinks that the multiplier is 4.5
and bus frequency is 122MHz. The powernow-k6 driver then sets the
multiplier to 4.5, underclocking the CPU to 450MHz, but reports the
current frequency as 550MHz.
There is no reliable way how to read the initial multiplier. I modified
the driver so that it contains a table of known frequencies (based on
parameters of existing CPUs and some common overclocking schemes) and sets
the multiplier according to the frequency. If the frequency is unknown
(because of unusual overclocking or underclocking), the user must supply
the bus speed and maximum multiplier as module parameters.
This patch should be backported to all stable kernels. If it doesn't
apply cleanly, change it, or ask me to change it.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-12-12 08:38:53 +08:00
|
|
|
max_multiplier = 0;
|
|
|
|
khz = cpu_khz;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(usual_frequency_table); i++) {
|
|
|
|
if (khz >= usual_frequency_table[i].freq - FREQ_RANGE &&
|
|
|
|
khz <= usual_frequency_table[i].freq + FREQ_RANGE) {
|
|
|
|
khz = usual_frequency_table[i].freq;
|
|
|
|
max_multiplier = usual_frequency_table[i].mult;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (param_max_multiplier) {
|
2014-04-26 04:15:38 +08:00
|
|
|
cpufreq_for_each_entry(pos, clock_ratio)
|
|
|
|
if (pos->driver_data == param_max_multiplier) {
|
powernow-k6: correctly initialize default parameters
The powernow-k6 driver used to read the initial multiplier from the
powernow register. However, there is a problem with this:
* If there was a frequency transition before, the multiplier read from the
register corresponds to the current multiplier.
* If there was no frequency transition since reset, the field in the
register always reads as zero, regardless of the current multiplier that
is set using switches on the mainboard and that the CPU is running at.
The zero value corresponds to multiplier 4.5, so as a consequence, the
powernow-k6 driver always assumes multiplier 4.5.
For example, if we have 550MHz CPU with bus frequency 100MHz and
multiplier 5.5, the powernow-k6 driver thinks that the multiplier is 4.5
and bus frequency is 122MHz. The powernow-k6 driver then sets the
multiplier to 4.5, underclocking the CPU to 450MHz, but reports the
current frequency as 550MHz.
There is no reliable way how to read the initial multiplier. I modified
the driver so that it contains a table of known frequencies (based on
parameters of existing CPUs and some common overclocking schemes) and sets
the multiplier according to the frequency. If the frequency is unknown
(because of unusual overclocking or underclocking), the user must supply
the bus speed and maximum multiplier as module parameters.
This patch should be backported to all stable kernels. If it doesn't
apply cleanly, change it, or ask me to change it.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-12-12 08:38:53 +08:00
|
|
|
max_multiplier = param_max_multiplier;
|
|
|
|
goto have_max_multiplier;
|
|
|
|
}
|
|
|
|
printk(KERN_ERR "powernow-k6: invalid max_multiplier parameter, valid parameters 20, 30, 35, 40, 45, 50, 55, 60\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!max_multiplier) {
|
|
|
|
printk(KERN_WARNING "powernow-k6: unknown frequency %u, cannot determine current multiplier\n", khz);
|
|
|
|
printk(KERN_WARNING "powernow-k6: use module parameters max_multiplier and bus_frequency\n");
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
have_max_multiplier:
|
|
|
|
param_max_multiplier = max_multiplier;
|
|
|
|
|
|
|
|
if (param_busfreq) {
|
|
|
|
if (param_busfreq >= 50000 && param_busfreq <= 150000) {
|
|
|
|
busfreq = param_busfreq / 10;
|
|
|
|
goto have_busfreq;
|
|
|
|
}
|
|
|
|
printk(KERN_ERR "powernow-k6: invalid bus_frequency parameter, allowed range 50000 - 150000 kHz\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
busfreq = khz / max_multiplier;
|
|
|
|
have_busfreq:
|
|
|
|
param_busfreq = busfreq * 10;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* table init */
|
2014-04-26 04:15:38 +08:00
|
|
|
cpufreq_for_each_entry(pos, clock_ratio) {
|
|
|
|
f = pos->driver_data;
|
2009-01-18 13:00:04 +08:00
|
|
|
if (f > max_multiplier)
|
2014-04-26 04:15:38 +08:00
|
|
|
pos->frequency = CPUFREQ_ENTRY_INVALID;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2014-04-26 04:15:38 +08:00
|
|
|
pos->frequency = busfreq * f;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cpuinfo and default policy values */
|
2013-12-12 08:38:32 +08:00
|
|
|
policy->cpuinfo.transition_latency = 500000;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-09-16 21:26:27 +08:00
|
|
|
return cpufreq_table_validate_and_show(policy, clock_ratio);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
2014-04-29 02:54:27 +08:00
|
|
|
|
|
|
|
for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
|
2014-04-29 02:54:42 +08:00
|
|
|
if (clock_ratio[i].driver_data == max_multiplier) {
|
|
|
|
struct cpufreq_freqs freqs;
|
|
|
|
|
|
|
|
freqs.old = policy->cur;
|
|
|
|
freqs.new = clock_ratio[i].frequency;
|
|
|
|
freqs.flags = 0;
|
|
|
|
|
|
|
|
cpufreq_freq_transition_begin(policy, &freqs);
|
2013-10-25 22:15:48 +08:00
|
|
|
powernow_k6_target(policy, i);
|
2014-04-29 02:54:42 +08:00
|
|
|
cpufreq_freq_transition_end(policy, &freqs, 0);
|
|
|
|
break;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-02-28 13:43:23 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int powernow_k6_get(unsigned int cpu)
|
|
|
|
{
|
2009-01-18 13:00:04 +08:00
|
|
|
unsigned int ret;
|
|
|
|
ret = (busfreq * powernow_k6_get_cpu_multiplier());
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-27 06:55:48 +08:00
|
|
|
static struct cpufreq_driver powernow_k6_driver = {
|
2013-10-03 22:58:17 +08:00
|
|
|
.verify = cpufreq_generic_frequency_table_verify,
|
2013-10-25 22:15:48 +08:00
|
|
|
.target_index = powernow_k6_target,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init = powernow_k6_cpu_init,
|
|
|
|
.exit = powernow_k6_cpu_exit,
|
|
|
|
.get = powernow_k6_get,
|
|
|
|
.name = "powernow-k6",
|
2013-10-03 22:58:17 +08:00
|
|
|
.attr = cpufreq_generic_attr,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2012-01-26 07:09:12 +08:00
|
|
|
static const struct x86_cpu_id powernow_k6_ids[] = {
|
|
|
|
{ X86_VENDOR_AMD, 5, 12 },
|
|
|
|
{ X86_VENDOR_AMD, 5, 13 },
|
|
|
|
{}
|
|
|
|
};
|
2012-02-12 07:04:12 +08:00
|
|
|
MODULE_DEVICE_TABLE(x86cpu, powernow_k6_ids);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* powernow_k6_init - initializes the k6 PowerNow! CPUFreq driver
|
|
|
|
*
|
|
|
|
* Initializes the K6 PowerNow! support. Returns -ENODEV on unsupported
|
|
|
|
* devices, -EINVAL or -ENOMEM on problems during initiatization, and zero
|
|
|
|
* on success.
|
|
|
|
*/
|
|
|
|
static int __init powernow_k6_init(void)
|
2006-02-28 13:43:23 +08:00
|
|
|
{
|
2012-01-26 07:09:12 +08:00
|
|
|
if (!x86_match_cpu(powernow_k6_ids))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (!request_region(POWERNOW_IOPORT, 16, "PowerNow!")) {
|
2009-01-18 13:00:04 +08:00
|
|
|
printk(KERN_INFO PFX "PowerNow IOPORT region already used.\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cpufreq_register_driver(&powernow_k6_driver)) {
|
2008-07-29 03:08:16 +08:00
|
|
|
release_region(POWERNOW_IOPORT, 16);
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* powernow_k6_exit - unregisters AMD K6-2+/3+ PowerNow! support
|
|
|
|
*
|
|
|
|
* Unregisters AMD K6-2+ / K6-3+ PowerNow! support.
|
|
|
|
*/
|
|
|
|
static void __exit powernow_k6_exit(void)
|
|
|
|
{
|
|
|
|
cpufreq_unregister_driver(&powernow_k6_driver);
|
2008-07-29 03:08:16 +08:00
|
|
|
release_region(POWERNOW_IOPORT, 16);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-18 13:00:04 +08:00
|
|
|
MODULE_AUTHOR("Arjan van de Ven, Dave Jones <davej@redhat.com>, "
|
|
|
|
"Dominik Brodowski <linux@brodo.de>");
|
2008-07-29 03:08:16 +08:00
|
|
|
MODULE_DESCRIPTION("PowerNow! driver for AMD K6-2+ / K6-3+ processors.");
|
|
|
|
MODULE_LICENSE("GPL");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
module_init(powernow_k6_init);
|
|
|
|
module_exit(powernow_k6_exit);
|