Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
f07b8ab2
Commit
f07b8ab2
authored
Sep 30, 2003
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Merge
bk://linux-dj.bkbits.net/cpufreq
into home.osdl.org:/home/torvalds/v2.5/linux
parents
8b0eeec2
7cdf272f
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1204 additions
and
25 deletions
+1204
-25
Documentation/cpu-freq/user-guide.txt
Documentation/cpu-freq/user-guide.txt
+2
-0
arch/i386/kernel/cpu/cpufreq/Kconfig
arch/i386/kernel/cpu/cpufreq/Kconfig
+10
-0
arch/i386/kernel/cpu/cpufreq/Makefile
arch/i386/kernel/cpu/cpufreq/Makefile
+1
-0
arch/i386/kernel/cpu/cpufreq/longhaul.c
arch/i386/kernel/cpu/cpufreq/longhaul.c
+45
-25
arch/i386/kernel/cpu/cpufreq/powernow-k8.c
arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+1020
-0
arch/i386/kernel/cpu/cpufreq/powernow-k8.h
arch/i386/kernel/cpu/cpufreq/powernow-k8.h
+126
-0
No files found.
Documentation/cpu-freq/user-guide.txt
View file @
f07b8ab2
...
...
@@ -57,6 +57,8 @@ AMD mobile K6-2+
AMD mobile K6-3+
AMD mobile Duron
AMD mobile Athlon
AMD Opteron
AMD Athlon 64
Cyrix Media GXm
Intel mobile PIII and Intel mobile PIII-M on certain chipsets
Intel Pentium 4, Intel Xeon
...
...
arch/i386/kernel/cpu/cpufreq/Kconfig
View file @
f07b8ab2
...
...
@@ -88,6 +88,16 @@ config X86_POWERNOW_K7
If in doubt, say N.
config X86_POWERNOW_K8
tristate "AMD Opteron/Athlon64 PowerNow!"
depends on CPU_FREQ_TABLE
help
This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors.
For details, take a look at linux/Documentation/cpu-freq.
If in doubt, say N.
config X86_GX_SUSPMOD
tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation"
depends on CPU_FREQ
...
...
arch/i386/kernel/cpu/cpufreq/Makefile
View file @
f07b8ab2
obj-$(CONFIG_X86_POWERNOW_K6)
+=
powernow-k6.o
obj-$(CONFIG_X86_POWERNOW_K7)
+=
powernow-k7.o
obj-$(CONFIG_X86_POWERNOW_K8)
+=
powernow-k8.o
obj-$(CONFIG_X86_LONGHAUL)
+=
longhaul.o
obj-$(CONFIG_X86_P4_CLOCKMOD)
+=
p4-clockmod.o
obj-$(CONFIG_ELAN_CPUFREQ)
+=
elanfreq.o
...
...
arch/i386/kernel/cpu/cpufreq/longhaul.c
View file @
f07b8ab2
...
...
@@ -70,21 +70,6 @@ static unsigned int calc_speed (int mult, int fsb)
}
static
unsigned
int
longhaul_get_cpu_fsb
(
void
)
{
unsigned
long
lo
,
hi
;
unsigned
int
eblcr_fsb_table
[]
=
{
66
,
133
,
100
,
-
1
};
unsigned
int
invalue
=
0
;
if
(
fsb
==
0
)
{
rdmsr
(
MSR_IA32_EBL_CR_POWERON
,
lo
,
hi
);
invalue
=
(
lo
&
(
1
<<
18
|
1
<<
19
))
>>
18
;
fsb
=
eblcr_fsb_table
[
invalue
];
}
return
fsb
;
}
static
int
longhaul_get_cpu_mult
(
void
)
{
unsigned
long
invalue
=
0
,
lo
,
hi
;
...
...
@@ -168,7 +153,7 @@ static void longhaul_setstate (unsigned int clock_ratio_index)
break
;
/*
* Longhaul v3. (Ezra-T [C5M], Nehemia
g
[C5N])
* Longhaul v3. (Ezra-T [C5M], Nehemia
h
[C5N])
* This can also do voltage scaling, but see above.
* Ezra-T was alleged to do FSB scaling too, but it never worked in practice.
*/
...
...
@@ -193,6 +178,39 @@ static void longhaul_setstate (unsigned int clock_ratio_index)
cpufreq_notify_transition
(
&
freqs
,
CPUFREQ_POSTCHANGE
);
}
/*
* Centaur decided to make life a little more tricky.
* Only longhaul v1 is allowed to read EBLCR BSEL[0:1].
* Samuel2 and above have to try and guess what the FSB is.
* We do this by assuming we booted at maximum multiplier, and interpolate
* between that value multiplied by possible FSBs and cpu_mhz which
* was calculated at boot time. Really ugly, but no other way to do this.
*/
static
int
_guess
(
int
guess
,
int
maxmult
)
{
int
target
;
target
=
((
maxmult
/
10
)
*
guess
);
if
(
maxmult
%
10
!=
0
)
target
+=
(
guess
/
2
);
target
&=
~
0xf
;
return
target
;
}
static
int
guess_fsb
(
int
maxmult
)
{
int
speed
=
(
cpu_khz
/
1000
)
&
~
0xf
;
int
i
;
int
speeds
[
3
]
=
{
66
,
100
,
133
};
for
(
i
=
0
;
i
<
3
;
i
++
)
{
if
(
_guess
(
speeds
[
i
],
maxmult
)
==
speed
)
return
speeds
[
i
];
}
return
0
;
}
static
int
__init
longhaul_get_ranges
(
void
)
{
...
...
@@ -203,8 +221,8 @@ static int __init longhaul_get_ranges (void)
-
1
,
110
,
120
,
-
1
,
135
,
115
,
125
,
105
,
130
,
150
,
160
,
140
,
-
1
,
155
,
-
1
,
145
};
unsigned
int
j
,
k
=
0
;
union
msr_longhaul
longhaul
;
fsb
=
longhaul_get_cpu_fsb
()
;
unsigned
long
lo
,
hi
;
unsigned
int
eblcr_fsb_table
[]
=
{
66
,
133
,
100
,
-
1
}
;
switch
(
longhaul_version
)
{
case
1
:
...
...
@@ -212,6 +230,9 @@ static int __init longhaul_get_ranges (void)
Assume min=3.0x & max = whatever we booted at. */
minmult
=
30
;
maxmult
=
longhaul_get_cpu_mult
();
rdmsr
(
MSR_IA32_EBL_CR_POWERON
,
lo
,
hi
);
invalue
=
(
lo
&
(
1
<<
18
|
1
<<
19
))
>>
18
;
fsb
=
eblcr_fsb_table
[
invalue
];
break
;
case
2
...
3
:
...
...
@@ -222,14 +243,13 @@ static int __init longhaul_get_ranges (void)
invalue
+=
16
;
maxmult
=
multipliers
[
invalue
];
#if 0
invalue
=
longhaul
.
bits
.
MinMHzBR
;
if (longhaul.bits.MinMHzBR4);
invalue += 16;
if
(
longhaul
.
bits
.
MinMHzBR4
==
1
)
minmult
=
30
;
else
minmult
=
multipliers
[
invalue
];
#else
minmult
=
30
;
/* as per spec */
#endif
fsb
=
guess_fsb
(
maxmult
);
break
;
}
...
...
arch/i386/kernel/cpu/cpufreq/powernow-k8.c
0 → 100644
View file @
f07b8ab2
This diff is collapsed.
Click to expand it.
arch/i386/kernel/cpu/cpufreq/powernow-k8.h
0 → 100644
View file @
f07b8ab2
/*
* (c) 2003 Advanced Micro Devices, Inc.
* Your use of this code is subject to the terms and conditions of the
* GNU general public license version 2. See "../../../COPYING" or
* http://www.gnu.org/licenses/gpl.html
*/
/* processor's cpuid instruction support */
#define CPUID_PROCESSOR_SIGNATURE 1
/* function 1 */
#define CPUID_F1_FAM 0x00000f00
/* family mask */
#define CPUID_F1_XFAM 0x0ff00000
/* extended family mask */
#define CPUID_F1_MOD 0x000000f0
/* model mask */
#define CPUID_F1_STEP 0x0000000f
/* stepping level mask */
#define CPUID_XFAM_MOD 0x0ff00ff0
/* xtended fam, fam + model */
#define ATHLON64_XFAM_MOD 0x00000f40
/* xtended fam, fam + model */
#define OPTERON_XFAM_MOD 0x00000f50
/* xtended fam, fam + model */
#define ATHLON64_REV_C0 8
#define CPUID_GET_MAX_CAPABILITIES 0x80000000
#define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007
#define P_STATE_TRANSITION_CAPABLE 6
/* Model Specific Registers for p-state transitions. MSRs are 64-bit. For */
/* writes (wrmsr - opcode 0f 30), the register number is placed in ecx, and */
/* the value to write is placed in edx:eax. For reads (rdmsr - opcode 0f 32), */
/* the register number is placed in ecx, and the data is returned in edx:eax. */
#define MSR_FIDVID_CTL 0xc0010041
#define MSR_FIDVID_STATUS 0xc0010042
/* Field definitions within the FID VID Low Control MSR : */
#define MSR_C_LO_INIT_FID_VID 0x00010000
#define MSR_C_LO_NEW_VID 0x00001f00
#define MSR_C_LO_NEW_FID 0x0000002f
#define MSR_C_LO_VID_SHIFT 8
/* Field definitions within the FID VID High Control MSR : */
#define MSR_C_HI_STP_GNT_TO 0x000fffff
/* Field definitions within the FID VID Low Status MSR : */
#define MSR_S_LO_CHANGE_PENDING 0x80000000
/* cleared when completed */
#define MSR_S_LO_MAX_RAMP_VID 0x1f000000
#define MSR_S_LO_MAX_FID 0x003f0000
#define MSR_S_LO_START_FID 0x00003f00
#define MSR_S_LO_CURRENT_FID 0x0000003f
/* Field definitions within the FID VID High Status MSR : */
#define MSR_S_HI_MAX_WORKING_VID 0x001f0000
#define MSR_S_HI_START_VID 0x00001f00
#define MSR_S_HI_CURRENT_VID 0x0000001f
/* fids (frequency identifiers) are arranged in 2 tables - lo and hi */
#define LO_FID_TABLE_TOP 6
#define HI_FID_TABLE_BOTTOM 8
#define LO_VCOFREQ_TABLE_TOP 1400
/* corresponding vco frequency values */
#define HI_VCOFREQ_TABLE_BOTTOM 1600
#define MIN_FREQ_RESOLUTION 200
/* fids jump by 2 matching freq jumps by 200 */
#define MAX_FID 0x2a
/* Spec only gives FID values as far as 5 GHz */
#define LEAST_VID 0x1e
/* Lowest (numerically highest) useful vid value */
#define MIN_FREQ 800
/* Min and max freqs, per spec */
#define MAX_FREQ 5000
#define INVALID_FID_MASK 0xffffffc1
/* not a valid fid if these bits are set */
#define INVALID_VID_MASK 0xffffffe0
/* not a valid vid if these bits are set */
#define STOP_GRANT_5NS 1
/* min poss memory access latency for voltage change */
#define PLL_LOCK_CONVERSION (1000/5)
/* ms to ns, then divide by clock period */
#define MAXIMUM_VID_STEPS 1
/* Current cpus only allow a single step of 25mV */
#define VST_UNITS_20US 20
/* Voltage Stabalization Time is in units of 20us */
/*
Version 1.4 of the PSB table. This table is constructed by BIOS and is
to tell the OS's power management driver which VIDs and FIDs are
supported by this particular processor. This information is obtained from
the data sheets for each processor model by the system vendor and
incorporated into the BIOS.
If the data in the PSB / PST is wrong, then this driver will program the
wrong values into hardware, which is very likely to lead to a crash.
*/
#define PSB_ID_STRING "AMDK7PNOW!"
#define PSB_ID_STRING_LEN 10
#define PSB_VERSION_1_4 0x14
struct
psb_s
{
u8
signature
[
10
];
u8
tableversion
;
u8
flags1
;
u16
voltagestabilizationtime
;
u8
flags2
;
u8
numpst
;
u32
cpuid
;
u8
plllocktime
;
u8
maxfid
;
u8
maxvid
;
u8
numpstates
;
};
/* Pairs of fid/vid values are appended to the version 1.4 PSB table. */
struct
pst_s
{
u8
fid
;
u8
vid
;
};
#ifdef DEBUG
#define dprintk(msg...) printk(msg)
#else
#define dprintk(msg...) do { } while(0)
#endif
static
inline
int
core_voltage_pre_transition
(
u32
reqvid
);
static
inline
int
core_voltage_post_transition
(
u32
reqvid
);
static
inline
int
core_frequency_transition
(
u32
reqfid
);
static
int
drv_verify
(
struct
cpufreq_policy
*
pol
);
static
int
drv_target
(
struct
cpufreq_policy
*
pol
,
unsigned
targfreq
,
unsigned
relation
);
static
int
__init
drv_cpu_init
(
struct
cpufreq_policy
*
pol
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment