Rev 769 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
582 | mauro | 1 | /* |
770 | mauro | 2 | * (c) 2003, 2004 Advanced Micro Devices, Inc. |
582 | mauro | 3 | * Your use of this code is subject to the terms and conditions of the |
4 | * GNU general public license version 2. See "../../../COPYING" or |
||
5 | * http://www.gnu.org/licenses/gpl.html |
||
6 | */ |
||
7 | |||
8 | /* processor's cpuid instruction support */ |
||
769 | mauro | 9 | #define CPUID_PROCESSOR_SIGNATURE 1 /* function 1 */ |
10 | #define CPUID_XFAM 0x0ff00000 /* extended family */ |
||
11 | #define CPUID_XFAM_K8 0 |
||
12 | #define CPUID_XMOD 0x000f0000 /* extended model */ |
||
13 | #define CPUID_XMOD_REV_E 0x00020000 |
||
14 | #define CPUID_USE_XFAM_XMOD 0x00000f00 |
||
582 | mauro | 15 | #define CPUID_GET_MAX_CAPABILITIES 0x80000000 |
16 | #define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007 |
||
17 | #define P_STATE_TRANSITION_CAPABLE 6 |
||
18 | |||
19 | /* Model Specific Registers for p-state transitions. MSRs are 64-bit. For */ |
||
20 | /* writes (wrmsr - opcode 0f 30), the register number is placed in ecx, and */ |
||
21 | /* the value to write is placed in edx:eax. For reads (rdmsr - opcode 0f 32), */ |
||
22 | /* the register number is placed in ecx, and the data is returned in edx:eax. */ |
||
23 | #define MSR_FIDVID_CTL 0xc0010041 |
||
24 | #define MSR_FIDVID_STATUS 0xc0010042 |
||
25 | |||
26 | /* Field definitions within the FID VID Low Control MSR : */ |
||
27 | #define MSR_C_LO_INIT_FID_VID 0x00010000 |
||
28 | #define MSR_C_LO_NEW_VID 0x00001f00 |
||
29 | #define MSR_C_LO_NEW_FID 0x0000002f |
||
30 | #define MSR_C_LO_VID_SHIFT 8 |
||
31 | |||
32 | /* Field definitions within the FID VID High Control MSR : */ |
||
33 | #define MSR_C_HI_STP_GNT_TO 0x000fffff |
||
34 | |||
35 | /* Field definitions within the FID VID Low Status MSR : */ |
||
36 | #define MSR_S_LO_CHANGE_PENDING 0x80000000 /* cleared when completed */ |
||
37 | #define MSR_S_LO_MAX_RAMP_VID 0x1f000000 |
||
38 | #define MSR_S_LO_MAX_FID 0x003f0000 |
||
39 | #define MSR_S_LO_START_FID 0x00003f00 |
||
40 | #define MSR_S_LO_CURRENT_FID 0x0000003f |
||
41 | |||
42 | /* Field definitions within the FID VID High Status MSR : */ |
||
43 | #define MSR_S_HI_MAX_WORKING_VID 0x001f0000 |
||
44 | #define MSR_S_HI_START_VID 0x00001f00 |
||
45 | #define MSR_S_HI_CURRENT_VID 0x0000001f |
||
46 | |||
47 | /* fids (frequency identifiers) are arranged in 2 tables - lo and hi */ |
||
770 | mauro | 48 | #define LO_FID_TABLE_TOP 6 /* fid values marking the boundary */ |
49 | #define HI_FID_TABLE_BOTTOM 8 /* between the low and high tables */ |
||
582 | mauro | 50 | #define LO_VCOFREQ_TABLE_TOP 1400 /* corresponding vco frequency values */ |
51 | #define HI_VCOFREQ_TABLE_BOTTOM 1600 |
||
52 | |||
53 | #define MIN_FREQ_RESOLUTION 200 /* fids jump by 2 matching freq jumps by 200 */ |
||
54 | |||
55 | #define MAX_FID 0x2a /* Spec only gives FID values as far as 5 GHz */ |
||
56 | #define LEAST_VID 0x1e /* Lowest (numerically highest) useful vid value */ |
||
57 | #define MIN_FREQ 800 /* Min and max freqs, per spec */ |
||
58 | #define MAX_FREQ 5000 |
||
59 | |||
770 | mauro | 60 | #define INVALID_FID_MASK 0xffffffc1 /* not a valid fid if these bits are set */ |
61 | #define INVALID_VID_MASK 0xffffffe0 /* not a valid vid if these bits are set */ |
||
582 | mauro | 62 | |
63 | #define STOP_GRANT_5NS 1 /* min poss memory access latency for voltage change */ |
||
64 | #define PLL_LOCK_CONVERSION (1000/5) /* ms to ns, then divide by clock period */ |
||
65 | #define MAXIMUM_VID_STEPS 1 /* Current cpus only allow a single step of 25mV */ |
||
66 | #define VST_UNITS_20US 20 /* Voltage Stabalization Time is in units of 20us */ |
||
67 | |||
68 | /* |
||
770 | mauro | 69 | * Version 1.4 of the PSB table. This table is constructed by BIOS and is |
70 | * to tell the OS's power management driver which VIDs and FIDs are |
||
71 | * supported by this particular processor. |
||
72 | * If the data in the PSB / PST is wrong, then this driver will program the |
||
73 | * wrong values into hardware, which is very likely to lead to a crash. |
||
74 | */ |
||
582 | mauro | 75 | |
76 | #define PSB_ID_STRING "AMDK7PNOW!" |
||
77 | #define PSB_ID_STRING_LEN 10 |
||
78 | |||
79 | #define PSB_VERSION_1_4 0x14 |
||
80 | |||
81 | struct psb_s { |
||
82 | u8 signature[10]; |
||
83 | u8 tableversion; |
||
84 | u8 flags1; |
||
85 | u16 voltagestabilizationtime; |
||
86 | u8 flags2; |
||
87 | u8 numpst; |
||
88 | u32 cpuid; |
||
89 | u8 plllocktime; |
||
90 | u8 maxfid; |
||
91 | u8 maxvid; |
||
92 | u8 numpstates; |
||
93 | }; |
||
94 | |||
95 | /* Pairs of fid/vid values are appended to the version 1.4 PSB table. */ |
||
96 | struct pst_s { |
||
97 | u8 fid; |
||
98 | u8 vid; |
||
99 | }; |
||
100 | |||
101 | static inline int core_voltage_pre_transition(u32 reqvid); |
||
102 | static inline int core_voltage_post_transition(u32 reqvid); |
||
103 | static inline int core_frequency_transition(u32 reqfid); |