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