Subversion Repositories shark

Rev

Rev 582 | Go to most recent revision | Details | Compare with Previous | 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 */
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
 
24
#define MSR_FIDVID_CTL      0xc0010041
25
#define MSR_FIDVID_STATUS   0xc0010042
26
 
27
/* Field definitions within the FID VID Low Control MSR : */
28
#define MSR_C_LO_INIT_FID_VID     0x00010000
29
#define MSR_C_LO_NEW_VID          0x00001f00
30
#define MSR_C_LO_NEW_FID          0x0000002f
31
#define MSR_C_LO_VID_SHIFT        8
32
 
33
/* Field definitions within the FID VID High Control MSR : */
34
#define MSR_C_HI_STP_GNT_TO       0x000fffff
35
 
36
/* Field definitions within the FID VID Low Status MSR : */
37
#define MSR_S_LO_CHANGE_PENDING   0x80000000    /* cleared when completed */
38
#define MSR_S_LO_MAX_RAMP_VID     0x1f000000
39
#define MSR_S_LO_MAX_FID          0x003f0000
40
#define MSR_S_LO_START_FID        0x00003f00
41
#define MSR_S_LO_CURRENT_FID      0x0000003f
42
 
43
/* Field definitions within the FID VID High Status MSR : */
44
#define MSR_S_HI_MAX_WORKING_VID  0x001f0000
45
#define MSR_S_HI_START_VID        0x00001f00
46
#define MSR_S_HI_CURRENT_VID      0x0000001f
47
 
48
/* fids (frequency identifiers) are arranged in 2 tables - lo and hi */
49
#define LO_FID_TABLE_TOP     6
50
#define HI_FID_TABLE_BOTTOM  8
51
 
52
#define LO_VCOFREQ_TABLE_TOP    1400    /* corresponding vco frequency values */
53
#define HI_VCOFREQ_TABLE_BOTTOM 1600
54
 
55
#define MIN_FREQ_RESOLUTION  200 /* fids jump by 2 matching freq jumps by 200 */
56
 
57
#define MAX_FID 0x2a    /* Spec only gives FID values as far as 5 GHz */
58
 
59
#define LEAST_VID 0x1e  /* Lowest (numerically highest) useful vid value */
60
 
61
#define MIN_FREQ 800    /* Min and max freqs, per spec */
62
#define MAX_FREQ 5000
63
 
64
#define INVALID_FID_MASK 0xffffffc1  /* not a valid fid if these bits are set */
65
 
66
#define INVALID_VID_MASK 0xffffffe0  /* not a valid vid if these bits are set */
67
 
68
#define STOP_GRANT_5NS 1 /* min poss memory access latency for voltage change */
69
 
70
#define PLL_LOCK_CONVERSION (1000/5) /* ms to ns, then divide by clock period */
71
 
72
#define MAXIMUM_VID_STEPS 1  /* Current cpus only allow a single step of 25mV */
73
 
74
#define VST_UNITS_20US 20   /* Voltage Stabalization Time is in units of 20us */
75
 
76
/*
77
Version 1.4 of the PSB table. This table is constructed by BIOS and is
78
to tell the OS's power management driver which VIDs and FIDs are
79
supported by this particular processor. This information is obtained from
80
the data sheets for each processor model by the system vendor and
81
incorporated into the BIOS.
82
If the data in the PSB / PST is wrong, then this driver will program the
83
wrong values into hardware, which is very likely to lead to a crash.
84
*/
85
 
86
#define PSB_ID_STRING      "AMDK7PNOW!"
87
#define PSB_ID_STRING_LEN  10
88
 
89
#define PSB_VERSION_1_4  0x14
90
 
91
struct psb_s {
92
        u8 signature[10];
93
        u8 tableversion;
94
        u8 flags1;
95
        u16 voltagestabilizationtime;
96
        u8 flags2;
97
        u8 numpst;
98
        u32 cpuid;
99
        u8 plllocktime;
100
        u8 maxfid;
101
        u8 maxvid;
102
        u8 numpstates;
103
};
104
 
105
/* Pairs of fid/vid values are appended to the version 1.4 PSB table. */
106
struct pst_s {
107
        u8 fid;
108
        u8 vid;
109
};
110
 
111
static inline int core_voltage_pre_transition(u32 reqvid);
112
static inline int core_voltage_post_transition(u32 reqvid);
113
static inline int core_frequency_transition(u32 reqfid);
114
static int powernowk8_verify(struct cpufreq_policy *pol);
115
static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq,
116
                      unsigned relation);
117
static int __init powernowk8_cpu_init(struct cpufreq_policy *pol);