Rev 769 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
582 | mauro | 1 | /* |
2 | * (c) 2003 Advanced Micro Devices, Inc. |
||
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 */ |
||
9 | #define CPUID_PROCESSOR_SIGNATURE 1 /* function 1 */ |
||
10 | #define CPUID_F1_FAM 0x00000f00 /* family mask */ |
||
11 | #define CPUID_F1_XFAM 0x0ff00000 /* extended family mask */ |
||
12 | #define CPUID_F1_MOD 0x000000f0 /* model mask */ |
||
13 | #define CPUID_F1_STEP 0x0000000f /* stepping level mask */ |
||
14 | #define CPUID_XFAM_MOD 0x0ff00ff0 /* xtended fam, fam + model */ |
||
15 | #define ATHLON64_XFAM_MOD 0x00000f40 /* xtended fam, fam + model */ |
||
16 | #define OPTERON_XFAM_MOD 0x00000f50 /* xtended fam, fam + model */ |
||
17 | #define ATHLON64_REV_C0 8 |
||
18 | #define CPUID_GET_MAX_CAPABILITIES 0x80000000 |
||
19 | #define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007 |
||
20 | #define P_STATE_TRANSITION_CAPABLE 6 |
||
21 | |||
22 | /* Model Specific Registers for p-state transitions. MSRs are 64-bit. For */ |
||
23 | /* writes (wrmsr - opcode 0f 30), the register number is placed in ecx, and */ |
||
24 | /* the value to write is placed in edx:eax. For reads (rdmsr - opcode 0f 32), */ |
||
25 | /* the register number is placed in ecx, and the data is returned in edx:eax. */ |
||
26 | |||
27 | #define MSR_FIDVID_CTL 0xc0010041 |
||
28 | #define MSR_FIDVID_STATUS 0xc0010042 |
||
29 | |||
30 | /* Field definitions within the FID VID Low Control MSR : */ |
||
31 | #define MSR_C_LO_INIT_FID_VID 0x00010000 |
||
32 | #define MSR_C_LO_NEW_VID 0x00001f00 |
||
33 | #define MSR_C_LO_NEW_FID 0x0000002f |
||
34 | #define MSR_C_LO_VID_SHIFT 8 |
||
35 | |||
36 | /* Field definitions within the FID VID High Control MSR : */ |
||
37 | #define MSR_C_HI_STP_GNT_TO 0x000fffff |
||
38 | |||
39 | /* Field definitions within the FID VID Low Status MSR : */ |
||
40 | #define MSR_S_LO_CHANGE_PENDING 0x80000000 /* cleared when completed */ |
||
41 | #define MSR_S_LO_MAX_RAMP_VID 0x1f000000 |
||
42 | #define MSR_S_LO_MAX_FID 0x003f0000 |
||
43 | #define MSR_S_LO_START_FID 0x00003f00 |
||
44 | #define MSR_S_LO_CURRENT_FID 0x0000003f |
||
45 | |||
46 | /* Field definitions within the FID VID High Status MSR : */ |
||
47 | #define MSR_S_HI_MAX_WORKING_VID 0x001f0000 |
||
48 | #define MSR_S_HI_START_VID 0x00001f00 |
||
49 | #define MSR_S_HI_CURRENT_VID 0x0000001f |
||
50 | |||
51 | /* fids (frequency identifiers) are arranged in 2 tables - lo and hi */ |
||
52 | #define LO_FID_TABLE_TOP 6 |
||
53 | #define HI_FID_TABLE_BOTTOM 8 |
||
54 | |||
55 | #define LO_VCOFREQ_TABLE_TOP 1400 /* corresponding vco frequency values */ |
||
56 | #define HI_VCOFREQ_TABLE_BOTTOM 1600 |
||
57 | |||
58 | #define MIN_FREQ_RESOLUTION 200 /* fids jump by 2 matching freq jumps by 200 */ |
||
59 | |||
60 | #define MAX_FID 0x2a /* Spec only gives FID values as far as 5 GHz */ |
||
61 | |||
62 | #define LEAST_VID 0x1e /* Lowest (numerically highest) useful vid value */ |
||
63 | |||
64 | #define MIN_FREQ 800 /* Min and max freqs, per spec */ |
||
65 | #define MAX_FREQ 5000 |
||
66 | |||
67 | #define INVALID_FID_MASK 0xffffffc1 /* not a valid fid if these bits are set */ |
||
68 | |||
69 | #define INVALID_VID_MASK 0xffffffe0 /* not a valid vid if these bits are set */ |
||
70 | |||
71 | #define STOP_GRANT_5NS 1 /* min poss memory access latency for voltage change */ |
||
72 | |||
73 | #define PLL_LOCK_CONVERSION (1000/5) /* ms to ns, then divide by clock period */ |
||
74 | |||
75 | #define MAXIMUM_VID_STEPS 1 /* Current cpus only allow a single step of 25mV */ |
||
76 | |||
77 | #define VST_UNITS_20US 20 /* Voltage Stabalization Time is in units of 20us */ |
||
78 | |||
79 | /* |
||
80 | Version 1.4 of the PSB table. This table is constructed by BIOS and is |
||
81 | to tell the OS's power management driver which VIDs and FIDs are |
||
82 | supported by this particular processor. This information is obtained from |
||
83 | the data sheets for each processor model by the system vendor and |
||
84 | incorporated into the BIOS. |
||
85 | If the data in the PSB / PST is wrong, then this driver will program the |
||
86 | wrong values into hardware, which is very likely to lead to a crash. |
||
87 | */ |
||
88 | |||
89 | #define PSB_ID_STRING "AMDK7PNOW!" |
||
90 | #define PSB_ID_STRING_LEN 10 |
||
91 | |||
92 | #define PSB_VERSION_1_4 0x14 |
||
93 | |||
94 | struct psb_s { |
||
95 | u8 signature[10]; |
||
96 | u8 tableversion; |
||
97 | u8 flags1; |
||
98 | u16 voltagestabilizationtime; |
||
99 | u8 flags2; |
||
100 | u8 numpst; |
||
101 | u32 cpuid; |
||
102 | u8 plllocktime; |
||
103 | u8 maxfid; |
||
104 | u8 maxvid; |
||
105 | u8 numpstates; |
||
106 | }; |
||
107 | |||
108 | /* Pairs of fid/vid values are appended to the version 1.4 PSB table. */ |
||
109 | struct pst_s { |
||
110 | u8 fid; |
||
111 | u8 vid; |
||
112 | }; |
||
113 | |||
114 | #ifdef DEBUG |
||
115 | #define dprintk(msg...) printk(msg) |
||
116 | #else |
||
117 | #define dprintk(msg...) do { } while(0) |
||
118 | #endif |
||
119 | |||
120 | static inline int core_voltage_pre_transition(u32 reqvid); |
||
121 | static inline int core_voltage_post_transition(u32 reqvid); |
||
122 | static inline int core_frequency_transition(u32 reqfid); |
||
123 | static int powernowk8_verify(struct cpufreq_policy *pol); |
||
124 | static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, |
||
125 | unsigned relation); |
||
126 | static int __init powernowk8_cpu_init(struct cpufreq_policy *pol); |