4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #include <sys/cpuvar.h>
30 #include <sys/acpi/acpi.h>
31 #include <sys/acpi/accommon.h>
32 #include <sys/acpi/acresrc.h>
33 #include <sys/acpica.h>
40 * P-state related macros
42 #define CPU_ACPI_PPC(sp) sp->cs_ppc
43 #define CPU_ACPI_PSD(sp) sp->cs_psd
44 #define CPU_ACPI_PCT(sp) sp->cs_pct
45 #define CPU_ACPI_PCT_CTRL(sp) &sp->cs_pct[0]
46 #define CPU_ACPI_PCT_STATUS(sp) &sp->cs_pct[1]
47 #define CPU_ACPI_PSTATES(sp) sp->cs_pstates.ss_states
48 #define CPU_ACPI_PSTATES_COUNT(sp) sp->cs_pstates.ss_count
50 #define CPU_ACPI_FREQ(pstate) pstate->ps_freq
51 #define CPU_ACPI_PSTATE_TRANSLAT(pstate) pstate->ps_translat
52 #define CPU_ACPI_PSTATE_CTRL(pstate) pstate->ps_ctrl
55 * T-state related macros
57 #define CPU_ACPI_TPC(sp) sp->cs_tpc
58 #define CPU_ACPI_TSD(sp) sp->cs_tsd
59 #define CPU_ACPI_PTC(sp) sp->cs_ptc
60 #define CPU_ACPI_PTC_CTRL(sp) &sp->cs_ptc[0]
61 #define CPU_ACPI_PTC_STATUS(sp) &sp->cs_ptc[1]
62 #define CPU_ACPI_TSTATES(sp) sp->cs_tstates.ss_states
63 #define CPU_ACPI_TSTATES_COUNT(sp) sp->cs_tstates.ss_count
65 #define CPU_ACPI_FREQPER(tstate) tstate->ts_freqper
66 #define CPU_ACPI_TSTATE_TRANSLAT(tstate) tstate->ts_translat
67 #define CPU_ACPI_TSTATE_CTRL(tstate) tstate->ts_ctrl
68 #define CPU_ACPI_TSTATE_STAT(tstate) tstate->ts_state
71 * C-state realted macros
73 #define CPU_ACPI_CSD(sp) sp->cs_csd
74 #define CPU_ACPI_CSTATES(sp) sp->cs_cstates.ss_states
75 #define CPU_ACPI_CSTATES_COUNT(sp) sp->cs_cstates.ss_count
77 #define CPU_ACPI_NONE_CACHED 0x0000
78 #define CPU_ACPI_PCT_CACHED 0x0001
79 #define CPU_ACPI_PSS_CACHED 0x0002
80 #define CPU_ACPI_PSD_CACHED 0x0004
81 #define CPU_ACPI_PPC_CACHED 0x0008
82 #define CPU_ACPI_PTC_CACHED 0x0010
83 #define CPU_ACPI_TSS_CACHED 0x0020
84 #define CPU_ACPI_TSD_CACHED 0x0040
85 #define CPU_ACPI_TPC_CACHED 0x0080
86 #define CPU_ACPI_CST_CACHED 0x0100
87 #define CPU_ACPI_CSD_CACHED 0x0200
89 #define CPU_ACPI_IS_OBJ_CACHED(sp, obj) (sp->cpu_acpi_cached & obj)
90 #define CPU_ACPI_OBJ_IS_CACHED(sp, obj) (sp->cpu_acpi_cached |= obj)
91 #define CPU_ACPI_OBJ_IS_NOT_CACHED(sp, obj) (sp->cpu_acpi_cached &= ~obj)
93 #define CPU_ACPI_PSTATES_SIZE(cnt) (cnt * sizeof (cpu_acpi_pstate_t))
94 #define CPU_ACPI_PSS_CNT (sizeof (cpu_acpi_pstate_t) / sizeof (uint32_t))
95 #define CPU_ACPI_TSTATES_SIZE(cnt) (cnt * sizeof (cpu_acpi_tstate_t))
96 #define CPU_ACPI_TSS_CNT (sizeof (cpu_acpi_tstate_t) / sizeof (uint32_t))
97 #define CPU_ACPI_CSTATES_SIZE(cnt) (cnt * sizeof (cpu_acpi_cstate_t))
98 #define CPU_ACPI_CST_CNT (sizeof (cpu_acpi_cstate_t) / sizeof (uint32_t))
100 * CPU Domain Coordination Types
102 #define CPU_ACPI_SW_ALL 0xfc
103 #define CPU_ACPI_SW_ANY 0xfd
104 #define CPU_ACPI_HW_ALL 0xfe
107 * Container for ACPI processor state dependency information
109 typedef struct cpu_acpi_state_dependency
117 } cpu_acpi_state_dependency_t
;
119 typedef cpu_acpi_state_dependency_t cpu_acpi_psd_t
;
120 typedef cpu_acpi_state_dependency_t cpu_acpi_tsd_t
;
121 typedef cpu_acpi_state_dependency_t cpu_acpi_csd_t
;
124 * Container for ACPI processor control register information
126 typedef struct cpu_acpi_ctrl_regs
128 uint8_t cr_addrspace_id
;
132 ACPI_IO_ADDRESS cr_address
;
133 } cpu_acpi_ctrl_regs_t
;
135 typedef cpu_acpi_ctrl_regs_t cpu_acpi_pct_t
;
136 typedef cpu_acpi_ctrl_regs_t cpu_acpi_ptc_t
;
139 * Container for ACPI _PSS information
141 typedef struct cpu_acpi_pstate
145 uint32_t ps_translat
;
152 * Container for _TSS information
154 typedef struct cpu_acpi_tstate
158 uint32_t ts_translat
;
165 * Container for _CST information
167 typedef struct cpu_acpi_cstate
169 uint32_t cs_addrspace_id
;
177 typedef struct cpu_acpi_supported_states
{
180 } cpu_acpi_supported_states_t
;
182 typedef cpu_acpi_supported_states_t cpu_acpi_pstates_t
;
183 typedef cpu_acpi_supported_states_t cpu_acpi_tstates_t
;
184 typedef cpu_acpi_supported_states_t cpu_acpi_cstates_t
;
186 typedef int cpu_acpi_present_capabilities_t
;
187 typedef int cpu_acpi_ppc_t
;
188 typedef int cpu_acpi_tpc_t
;
191 * Container for cached ACPI data.
193 typedef struct cpu_acpi_state
{
194 ACPI_HANDLE cs_handle
;
196 uint_t cpu_acpi_cached
;
197 cpu_acpi_pstates_t cs_pstates
;
198 cpu_acpi_pct_t cs_pct
[2];
199 cpu_acpi_psd_t cs_psd
;
200 cpu_acpi_ppc_t cs_ppc
;
201 cpu_acpi_tstates_t cs_tstates
;
202 cpu_acpi_ptc_t cs_ptc
[2];
203 cpu_acpi_tsd_t cs_tsd
;
204 cpu_acpi_tpc_t cs_tpc
;
205 cpu_acpi_cstates_t cs_cstates
;
206 cpu_acpi_csd_t cs_csd
;
209 typedef cpu_acpi_state_t
*cpu_acpi_handle_t
;
211 extern void cpu_acpi_cache_ppc(cpu_acpi_handle_t
);
212 extern void cpu_acpi_cache_tpc(cpu_acpi_handle_t
);
213 extern int cpu_acpi_cache_pstate_data(cpu_acpi_handle_t
);
214 extern void cpu_acpi_free_pstate_data(cpu_acpi_handle_t
);
215 extern int cpu_acpi_cache_tstate_data(cpu_acpi_handle_t
);
216 extern void cpu_acpi_free_tstate_data(cpu_acpi_handle_t
);
217 extern int cpu_acpi_cache_cstate_data(cpu_acpi_handle_t
);
218 extern void cpu_acpi_free_cstate_data(cpu_acpi_handle_t
);
219 extern void cpu_acpi_install_notify_handler(cpu_acpi_handle_t
,
220 ACPI_NOTIFY_HANDLER
, void *);
221 extern void cpu_acpi_remove_notify_handler(cpu_acpi_handle_t
,
222 ACPI_NOTIFY_HANDLER
);
223 extern int cpu_acpi_write_pdc(cpu_acpi_handle_t
, uint32_t, uint32_t,
225 extern int cpu_acpi_write_port(ACPI_IO_ADDRESS
, uint32_t, uint32_t);
226 extern int cpu_acpi_read_port(ACPI_IO_ADDRESS
, uint32_t *, uint32_t);
227 extern void cpu_acpi_set_register(uint32_t, uint32_t);
228 extern void cpu_acpi_get_register(uint32_t, uint32_t *);
229 extern uint_t
cpu_acpi_get_speeds(cpu_acpi_handle_t
, int **);
230 extern uint_t
cpu_acpi_get_max_cstates(cpu_acpi_handle_t
);
231 extern void cpu_acpi_free_speeds(int *, uint_t
);
232 extern cpu_acpi_handle_t
cpu_acpi_init(cpu_t
*);
233 extern void cpu_acpi_fini(cpu_acpi_handle_t
);
239 #endif /* _CPU_ACPI_H */