Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 132654
b: refs/heads/master
c: 14a6650
h: refs/heads/master
v: v3
  • Loading branch information
Dave Jones committed Feb 25, 2009
1 parent 70b2d52 commit 052afcb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 48ee923a666d4cc54e48d55fc573c57492501122
refs/heads/master: 14a6650f13b958aabc30ddd575b0902384b22457
44 changes: 26 additions & 18 deletions trunk/arch/x86/kernel/cpu/cpufreq/powernow-k6.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* This file was based upon code in Powertweak Linux (http://powertweak.sf.net)
* (C) 2000-2003 Dave Jones, Arjan van de Ven, Janne Pänkälä, Dominik Brodowski.
* (C) 2000-2003 Dave Jones, Arjan van de Ven, Janne Pänkälä,
* Dominik Brodowski.
*
* Licensed under the terms of the GNU GPL License version 2.
*
Expand All @@ -13,14 +14,15 @@
#include <linux/cpufreq.h>
#include <linux/ioport.h>
#include <linux/slab.h>

#include <asm/msr.h>
#include <linux/timex.h>
#include <linux/io.h>

#include <asm/msr.h>

#define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long
as it is unused */

#define PFX "powernow-k6: "
static unsigned int busfreq; /* FSB, in 10 kHz */
static unsigned int max_multiplier;

Expand All @@ -47,8 +49,8 @@ static struct cpufreq_frequency_table clock_ratio[] = {
*/
static int powernow_k6_get_cpu_multiplier(void)
{
u64 invalue = 0;
u32 msrval;
u64 invalue = 0;
u32 msrval;

msrval = POWERNOW_IOPORT + 0x1;
wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
Expand All @@ -68,12 +70,12 @@ static int powernow_k6_get_cpu_multiplier(void)
*/
static void powernow_k6_set_state(unsigned int best_i)
{
unsigned long outvalue = 0, invalue = 0;
unsigned long msrval;
struct cpufreq_freqs freqs;
unsigned long outvalue = 0, invalue = 0;
unsigned long msrval;
struct cpufreq_freqs freqs;

if (clock_ratio[best_i].index > max_multiplier) {
printk(KERN_ERR "cpufreq: invalid target frequency\n");
printk(KERN_ERR PFX "invalid target frequency\n");
return;
}

Expand Down Expand Up @@ -119,17 +121,19 @@ static int powernow_k6_verify(struct cpufreq_policy *policy)
* powernow_k6_setpolicy - sets a new CPUFreq policy
* @policy: new policy
* @target_freq: the target frequency
* @relation: how that frequency relates to achieved frequency (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
* @relation: how that frequency relates to achieved frequency
* (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
*
* sets a new CPUFreq policy
*/
static int powernow_k6_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation)
{
unsigned int newstate = 0;
unsigned int newstate = 0;

if (cpufreq_frequency_table_target(policy, &clock_ratio[0], target_freq, relation, &newstate))
if (cpufreq_frequency_table_target(policy, &clock_ratio[0],
target_freq, relation, &newstate))
return -EINVAL;

powernow_k6_set_state(newstate);
Expand All @@ -140,7 +144,7 @@ static int powernow_k6_target(struct cpufreq_policy *policy,

static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
{
unsigned int i;
unsigned int i, f;
int result;

if (policy->cpu != 0)
Expand All @@ -152,10 +156,11 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)

/* table init */
for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
if (clock_ratio[i].index > max_multiplier)
f = clock_ratio[i].index;
if (f > max_multiplier)
clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID;
else
clock_ratio[i].frequency = busfreq * clock_ratio[i].index;
clock_ratio[i].frequency = busfreq * f;
}

/* cpuinfo and default policy values */
Expand Down Expand Up @@ -185,7 +190,9 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)

static unsigned int powernow_k6_get(unsigned int cpu)
{
return busfreq * powernow_k6_get_cpu_multiplier();
unsigned int ret;
ret = (busfreq * powernow_k6_get_cpu_multiplier());
return ret;
}

static struct freq_attr *powernow_k6_attr[] = {
Expand Down Expand Up @@ -221,7 +228,7 @@ static int __init powernow_k6_init(void)
return -ENODEV;

if (!request_region(POWERNOW_IOPORT, 16, "PowerNow!")) {
printk("cpufreq: PowerNow IOPORT region already used.\n");
printk(KERN_INFO PFX "PowerNow IOPORT region already used.\n");
return -EIO;
}

Expand All @@ -246,7 +253,8 @@ static void __exit powernow_k6_exit(void)
}


MODULE_AUTHOR("Arjan van de Ven, Dave Jones <davej@redhat.com>, Dominik Brodowski <linux@brodo.de>");
MODULE_AUTHOR("Arjan van de Ven, Dave Jones <davej@redhat.com>, "
"Dominik Brodowski <linux@brodo.de>");
MODULE_DESCRIPTION("PowerNow! driver for AMD K6-2+ / K6-3+ processors.");
MODULE_LICENSE("GPL");

Expand Down

0 comments on commit 052afcb

Please sign in to comment.