xref: /illumos-gate/usr/src/uts/i86pc/sys/cpu_acpi.h (revision 968633ad8faee931821fd6b656eb0d96d4b186c0)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_CPU_ACPI_H
27 #define	_CPU_ACPI_H
28 
29 #include <sys/acpi/acpi.h>
30 #include <sys/acpi/acresrc.h>
31 #include <sys/acpi/acglobal.h>
32 #include <sys/acpica.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * P-state related macros
40  */
41 #define	CPU_ACPI_PPC(sp)		sp->cs_ppc
42 #define	CPU_ACPI_PSD(sp)		sp->cs_psd
43 #define	CPU_ACPI_PCT(sp)		sp->cs_pct
44 #define	CPU_ACPI_PCT_CTRL(sp)		&sp->cs_pct[0]
45 #define	CPU_ACPI_PCT_STATUS(sp)		&sp->cs_pct[1]
46 #define	CPU_ACPI_PSTATES(sp)		sp->cs_pstates.ss_states
47 #define	CPU_ACPI_PSTATES_COUNT(sp)	sp->cs_pstates.ss_count
48 
49 #define	CPU_ACPI_FREQ(pstate)		pstate->ps_freq
50 #define	CPU_ACPI_PSTATE_TRANSLAT(pstate) pstate->ps_translat
51 #define	CPU_ACPI_PSTATE_CTRL(pstate)	pstate->ps_ctrl
52 
53 /*
54  * T-state related macros
55  */
56 #define	CPU_ACPI_TPC(sp)		sp->cs_tpc
57 #define	CPU_ACPI_TSD(sp)		sp->cs_tsd
58 #define	CPU_ACPI_PTC(sp)		sp->cs_ptc
59 #define	CPU_ACPI_PTC_CTRL(sp)		&sp->cs_ptc[0]
60 #define	CPU_ACPI_PTC_STATUS(sp)		&sp->cs_ptc[1]
61 #define	CPU_ACPI_TSTATES(sp)		sp->cs_tstates.ss_states
62 #define	CPU_ACPI_TSTATES_COUNT(sp)	sp->cs_tstates.ss_count
63 
64 #define	CPU_ACPI_FREQPER(tstate)	tstate->ts_freqper
65 #define	CPU_ACPI_TSTATE_TRANSLAT(tstate) tstate->ts_translat
66 #define	CPU_ACPI_TSTATE_CTRL(tstate)	tstate->ts_ctrl
67 #define	CPU_ACPI_TSTATE_STAT(tstate)	tstate->ts_state
68 
69 #define	CPU_ACPI_NONE_CACHED		0x00
70 #define	CPU_ACPI_PCT_CACHED		0x01
71 #define	CPU_ACPI_PSS_CACHED		0x02
72 #define	CPU_ACPI_PSD_CACHED		0x04
73 #define	CPU_ACPI_PPC_CACHED		0x08
74 #define	CPU_ACPI_PTC_CACHED		0x10
75 #define	CPU_ACPI_TSS_CACHED		0x20
76 #define	CPU_ACPI_TSD_CACHED		0x40
77 #define	CPU_ACPI_TPC_CACHED		0x80
78 
79 #define	CPU_ACPI_IS_OBJ_CACHED(sp, obj)	(sp->cpu_acpi_cached & obj)
80 #define	CPU_ACPI_OBJ_IS_CACHED(sp, obj)	(sp->cpu_acpi_cached |= obj)
81 #define	CPU_ACPI_OBJ_IS_NOT_CACHED(sp, obj) (sp->cpu_acpi_cached &= ~obj)
82 
83 #define	CPU_ACPI_PSTATES_SIZE(cnt) (cnt * sizeof (cpu_acpi_pstate_t))
84 #define	CPU_ACPI_PSS_CNT (sizeof (cpu_acpi_pstate_t) / sizeof (uint32_t))
85 #define	CPU_ACPI_TSTATES_SIZE(cnt) (cnt * sizeof (cpu_acpi_tstate_t))
86 #define	CPU_ACPI_TSS_CNT (sizeof (cpu_acpi_tstate_t) / sizeof (uint32_t))
87 
88 /*
89  * CPU Domain Coordination Types
90  */
91 #define	CPU_ACPI_SW_ALL	0xfc
92 #define	CPU_ACPI_SW_ANY	0xfd
93 #define	CPU_ACPI_HW_ALL	0xfe
94 
95 /*
96  * Container for ACPI processor state dependency information
97  */
98 typedef struct cpu_acpi_state_dependency
99 {
100 	uint8_t sd_entries;
101 	uint8_t sd_revision;
102 	uint32_t sd_domain;
103 	uint32_t sd_type;
104 	uint32_t sd_num;
105 } cpu_acpi_state_dependency_t;
106 
107 typedef cpu_acpi_state_dependency_t cpu_acpi_psd_t;
108 typedef cpu_acpi_state_dependency_t cpu_acpi_tsd_t;
109 
110 /*
111  * Container for ACPI processor control register information
112  */
113 typedef struct cpu_acpi_ctrl_regs
114 {
115 	uint8_t cr_addrspace_id;
116 	uint8_t cr_width;
117 	uint8_t cr_offset;
118 	uint8_t cr_asize;
119 	ACPI_IO_ADDRESS cr_address;
120 } cpu_acpi_ctrl_regs_t;
121 
122 typedef cpu_acpi_ctrl_regs_t cpu_acpi_pct_t;
123 typedef cpu_acpi_ctrl_regs_t cpu_acpi_ptc_t;
124 
125 /*
126  * Container for ACPI _PSS information
127  */
128 typedef struct cpu_acpi_pstate
129 {
130 	uint32_t ps_freq;
131 	uint32_t ps_disp;
132 	uint32_t ps_translat;
133 	uint32_t ps_buslat;
134 	uint32_t ps_ctrl;
135 	uint32_t ps_state;
136 } cpu_acpi_pstate_t;
137 
138 /*
139  * Container for _TSS information
140  */
141 typedef struct cpu_acpi_tstate
142 {
143 	uint32_t ts_freqper;
144 	uint32_t ts_disp;
145 	uint32_t ts_translat;
146 	uint32_t ts_ctrl;
147 	uint32_t ts_state;
148 
149 } cpu_acpi_tstate_t;
150 
151 typedef struct cpu_acpi_supported_states {
152 	void *ss_states;
153 	uint32_t ss_count;
154 } cpu_acpi_supported_states_t;
155 
156 typedef cpu_acpi_supported_states_t cpu_acpi_pstates_t;
157 typedef cpu_acpi_supported_states_t cpu_acpi_tstates_t;
158 
159 typedef int cpu_acpi_present_capabilities_t;
160 typedef int cpu_acpi_ppc_t;
161 typedef int cpu_acpi_tpc_t;
162 
163 /*
164  * Container for cached ACPI data.
165  */
166 typedef struct cpu_acpi_state {
167 	ACPI_HANDLE cs_handle;
168 	dev_info_t *cs_dip;
169 	uint_t cpu_acpi_cached;
170 	cpu_acpi_pstates_t cs_pstates;
171 	cpu_acpi_pct_t cs_pct[2];
172 	cpu_acpi_psd_t cs_psd;
173 	cpu_acpi_ppc_t cs_ppc;
174 	cpu_acpi_tstates_t cs_tstates;
175 	cpu_acpi_ptc_t cs_ptc[2];
176 	cpu_acpi_tsd_t cs_tsd;
177 	cpu_acpi_tpc_t cs_tpc;
178 } cpu_acpi_state_t;
179 
180 typedef cpu_acpi_state_t *cpu_acpi_handle_t;
181 
182 extern void cpu_acpi_cache_ppc(cpu_acpi_handle_t);
183 extern void cpu_acpi_cache_tpc(cpu_acpi_handle_t);
184 extern int cpu_acpi_cache_pstate_data(cpu_acpi_handle_t);
185 extern void cpu_acpi_free_pstate_data(cpu_acpi_handle_t);
186 extern int cpu_acpi_cache_tstate_data(cpu_acpi_handle_t);
187 extern void cpu_acpi_free_tstate_data(cpu_acpi_handle_t);
188 extern void cpu_acpi_install_notify_handler(cpu_acpi_handle_t,
189     ACPI_NOTIFY_HANDLER, dev_info_t *);
190 extern int cpu_acpi_write_pdc(cpu_acpi_handle_t, uint32_t, uint32_t,
191     uint32_t *);
192 extern int cpu_acpi_write_port(ACPI_IO_ADDRESS, uint32_t, uint32_t);
193 extern int cpu_acpi_read_port(ACPI_IO_ADDRESS, uint32_t *, uint32_t);
194 extern uint_t cpu_acpi_get_speeds(cpu_acpi_handle_t, int **);
195 extern void cpu_acpi_free_speeds(int *, uint_t);
196 extern cpu_acpi_handle_t cpu_acpi_init(dev_info_t *);
197 extern void cpu_acpi_fini(cpu_acpi_handle_t);
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif	/* _CPU_ACPI_H */
204