]>
Commit | Line | Data |
---|---|---|
3a60a9f5 A |
1 | /* |
2 | * Copyright (c) 2004-2005 Apple Computer, Inc. All rights reserved. | |
3 | * | |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
3a60a9f5 | 5 | * |
8ad349bb A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
3a60a9f5 A |
29 | */ |
30 | ||
31 | #ifdef KERNEL_PRIVATE | |
32 | ||
33 | #ifndef _PPC_PMS_H_ | |
34 | #define _PPC_PMS_H_ | |
8ad349bb A |
35 | |
36 | #define pmsMaxStates 64 | |
37 | #define HalfwayToForever 0x7FFFFFFFFFFFFFFFULL | |
38 | #define century 790560000000000ULL | |
39 | ||
40 | typedef void (*pmsSetFunc_t)(uint32_t, uint32_t, uint32_t); /* Function used to set hardware power state */ | |
41 | typedef uint32_t (*pmsQueryFunc_t)(uint32_t, uint32_t); /* Function used to query hardware power state */ | |
42 | ||
43 | typedef struct pmsStat { | |
44 | uint64_t stTime[2]; /* Total time until switch to next step */ | |
45 | uint32_t stCnt[2]; /* Number of times switched to next step */ | |
46 | } pmsStat; | |
47 | ||
48 | typedef struct pmsDef { | |
49 | uint64_t pmsLimit; /* Max time in this state in microseconds */ | |
50 | uint32_t pmsStepID; /* Unique ID for this step */ | |
51 | uint32_t pmsSetCmd; /* Command to select power state */ | |
52 | #define pmsCngXClk 0x80000000 /* Change external clock */ | |
53 | #define pmsXUnk 0x7F /* External clock unknown */ | |
54 | #define pmsXClk 0x7F000000 /* External clock frequency */ | |
55 | #define pmsCngCPU 0x00800000 /* Change CPU parameters */ | |
56 | #define pmsSync 0x00400000 /* Make changes synchronously, i.e., spin until delay finished */ | |
57 | #define pmsMustCmp 0x00200000 /* Delay must complete before next change */ | |
58 | #define pmsCPU 0x001F0000 /* CPU frequency */ | |
59 | #define pmsCPUUnk 0x1F /* CPU frequency unknown */ | |
60 | #define pmsCngVolt 0x00008000 /* Change voltage */ | |
61 | #define pmsVoltage 0x00007F00 /* Voltage */ | |
62 | #define pmsVoltUnk 0x7F /* Voltage unknown */ | |
63 | #define pmsPowerID 0x000000FF /* Identify power state to HW */ | |
64 | ||
65 | /* Special commands - various things */ | |
66 | #define pmsDelay 0xFFFFFFFD /* Delayed step, no processor or platform changes. Timer expiration causes transition to pmsTDelay */ | |
67 | #define pmsParkIt 0xFFFFFFFF /* Enters the parked state. No processor or platform changes. Timers cancelled */ | |
68 | #define pmsCInit ((pmsXUnk << 24) | (pmsCPUUnk << 16) | (pmsVoltUnk << 8)) /* Initial current set command value */ | |
69 | /* Note: pmsSetFuncInd is an index into a table of function pointers and pmsSetFunc is the address | |
70 | * of a function. Initially, when you create a step table, this field is set as an index into | |
71 | * a table of function addresses that gets passed as a parameter to pmsBuild. When pmsBuild | |
72 | * internalizes the step and function tables, it converts the index to the function address. | |
73 | */ | |
74 | union sf { | |
75 | pmsSetFunc_t pmsSetFunc; /* Function used to set platform power state */ | |
76 | uint32_t pmsSetFuncInd; /* Index to function in function table */ | |
77 | } sf; | |
78 | ||
79 | uint32_t pmsDown; /* Next state if going lower */ | |
80 | uint32_t pmsNext; /* Normal next state */ | |
81 | uint32_t pmsTDelay; /* State if command was pmsDelay and timer expired */ | |
82 | } pmsDef; | |
83 | ||
84 | typedef struct pmsCtl { | |
85 | pmsStat (*pmsStats)[pmsMaxStates]; /* Pointer to statistics information, 0 if not enabled */ | |
86 | pmsDef *pmsDefs[pmsMaxStates]; /* Indexed pointers to steps */ | |
87 | } pmsCtl; | |
88 | ||
89 | /* | |
90 | * Note that this block is in the middle of the per_proc and the size (32 bytes) | |
91 | * can't be changed without moving it. | |
92 | */ | |
93 | ||
94 | typedef struct pmsd { | |
95 | uint32_t pmsState; /* Current power management state */ | |
96 | uint32_t pmsCSetCmd; /* Current select command */ | |
97 | uint64_t pmsPop; /* Time of next step */ | |
98 | uint64_t pmsStamp; /* Time of transition to current state */ | |
99 | uint64_t pmsTime; /* Total time in this state */ | |
100 | } pmsd; | |
101 | ||
102 | /* | |
103 | * Required power management step programs | |
104 | */ | |
105 | ||
106 | enum { | |
107 | pmsIdle = 0, /* Power state in idle loop */ | |
108 | pmsNorm = 1, /* Normal step - usually low power */ | |
109 | pmsNormHigh = 2, /* Highest power in normal step */ | |
110 | pmsBoost = 3, /* Boost/overdrive step */ | |
111 | pmsLow = 4, /* Lowest non-idle power state, no transitions */ | |
112 | pmsHigh = 5, /* Power step for full on, no transitions */ | |
113 | pmsPrepCng = 6, /* Prepare for step table change */ | |
114 | pmsPrepSleep = 7, /* Prepare for sleep */ | |
115 | pmsOverTemp = 8, /* Machine is too hot */ | |
116 | pmsEnterNorm = 9, /* Enter into the normal step program */ | |
117 | pmsFree = 10, /* First available empty step */ | |
118 | pmsStartUp = 0xFFFFFFFE, /* Start stepping */ | |
119 | pmsParked = 0xFFFFFFFF /* Power parked - used when changing stepping table */ | |
120 | }; | |
121 | ||
122 | /* | |
123 | * Power Management Stepper Control requests | |
124 | */ | |
125 | ||
126 | enum { | |
127 | pmsCPark = 0, /* Parks the stepper */ | |
128 | pmsCStart = 1, /* Starts normal steppping */ | |
129 | pmsCFLow = 2, /* Forces low power */ | |
130 | pmsCFHigh = 3, /* Forces high power */ | |
131 | pmsCCnfg = 4, /* Loads new stepper program */ | |
132 | pmsCQuery = 5, /* Query current step and state */ | |
133 | pmsCExperimental = 6, /* Enter experimental mode */ | |
134 | pmsCFree = 7 /* Next control command to be assigned */ | |
135 | }; | |
136 | ||
137 | extern pmsCtl pmsCtls; /* Power Management Stepper control */ | |
138 | extern uint32_t pmsCtlp; | |
139 | extern uint32_t pmsBroadcastWait; /* Number of outstanding broadcasts */ | |
140 | extern pmsDef pmsDefault[]; | |
141 | extern int pmsInstalled; | |
142 | extern int pmsExperimental; | |
143 | ||
144 | #define pmsSetFuncMax 32 | |
145 | extern pmsSetFunc_t pmsFuncTab[pmsSetFuncMax]; | |
146 | extern pmsQueryFunc_t pmsQueryFunc; | |
147 | extern uint32_t pmsPlatformData; | |
148 | ||
149 | extern int pmsCntrl(struct savearea *save); | |
150 | extern void pmsInit(void); | |
151 | extern void pmsStep(int timer); | |
152 | extern void pmsDown(void); | |
153 | extern void pmsSetStep(uint32_t nstep, int dir); | |
154 | extern void pmsRemote(uint32_t nstep); | |
155 | extern void pmsCPUSet(uint32_t sel); | |
156 | extern uint32_t pmsCPUquery(void); | |
157 | extern void pmsCPUConf(void); | |
158 | extern void pmsCPUInit(void); | |
159 | ||
160 | #ifdef __cplusplus | |
161 | extern "C" { | |
162 | #endif | |
163 | ||
164 | extern kern_return_t pmsBuild(pmsDef *pd, uint32_t pdsize, pmsSetFunc_t *functab, uint32_t platformData, pmsQueryFunc_t queryFunc); | |
165 | extern void pmsRun(uint32_t nstep); | |
166 | extern void pmsRunLocal(uint32_t nstep); | |
167 | extern void pmsPark(void); | |
168 | extern void pmsStart(void); | |
169 | ||
170 | #ifdef __cplusplus | |
171 | } | |
172 | #endif | |
173 | ||
3a60a9f5 A |
174 | #endif /* _PPC_PMS_H_ */ |
175 | #endif /* KERNEL_PRIVATE */ |