xref: /titanic_44/usr/src/uts/i86pc/sys/cpu_acpi.h (revision 551bc2a66868b5cb5be6b70ab9f55515e77a39a9)
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 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/acpi/acpi.h>
32 #include <sys/acpi/acresrc.h>
33 #include <sys/acpi/acglobal.h>
34 #include <sys/acpica.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #define	CPU_ACPI_PPC(sp)		sp->cs_ppc
41 #define	CPU_ACPI_PSD(sp)		sp->cs_psd
42 #define	CPU_ACPI_PCT(sp)		sp->cs_pct
43 #define	CPU_ACPI_PCT_CTRL(sp)		&sp->cs_pct[0]
44 #define	CPU_ACPI_PCT_STATUS(sp)		&sp->cs_pct[1]
45 #define	CPU_ACPI_PSTATES(sp)		sp->cs_pstates->pss_pstates
46 #define	CPU_ACPI_PSTATES_COUNT(sp)	sp->cs_pstates->pss_count
47 
48 #define	CPU_ACPI_PSTATE(sp, i)		&sp->cs_pstates->pss_pstates[i]
49 #define	CPU_ACPI_FREQ(pstate)		pstate->ps_freq
50 #define	CPU_ACPI_TRANSLAT(pstate)	pstate->ps_translat
51 #define	CPU_ACPI_CTRL(pstate)		pstate->ps_ctrl
52 #define	CPU_ACPI_STAT(pstate)		pstate->ps_state
53 
54 #define	CPU_ACPI_NONE_CACHED		0x00
55 #define	CPU_ACPI_PCT_CACHED		0x01
56 #define	CPU_ACPI_PSS_CACHED		0x02
57 #define	CPU_ACPI_PSD_CACHED		0x04
58 #define	CPU_ACPI_PPC_CACHED		0x08
59 
60 #define	CPU_ACPI_IS_OBJ_CACHED(sp, obj)	(sp->cpu_acpi_cached & obj)
61 #define	CPU_ACPI_OBJ_IS_CACHED(sp, obj)	(sp->cpu_acpi_cached |= obj)
62 #define	CPU_ACPI_OBJ_IS_NOT_CACHED(sp, obj) (sp->cpu_acpi_cached &= ~obj)
63 
64 /*
65  * Container for _PSD information
66  */
67 typedef struct cpu_acpi_psd
68 {
69 	uint8_t pd_entries;
70 	uint8_t pd_revision;
71 	uint32_t pd_domain;
72 	uint32_t pd_type;
73 	uint32_t pd_num;
74 } cpu_acpi_psd_t;
75 
76 /*
77  * Container for _PCT information
78  */
79 typedef struct cpu_acpi_pct
80 {
81 	uint8_t pc_addrspace_id;
82 	uint8_t pc_width;
83 	uint8_t pc_offset;
84 	uint8_t pc_asize;
85 	ACPI_IO_ADDRESS pc_address;
86 } cpu_acpi_pct_t;
87 
88 /*
89  * Containers for _PSS information
90  */
91 typedef struct cpu_acpi_pstate
92 {
93 	uint32_t ps_freq;
94 	uint32_t ps_disp;
95 	uint32_t ps_translat;
96 	uint32_t ps_buslat;
97 	uint32_t ps_ctrl;
98 	uint32_t ps_state;
99 } cpu_acpi_pstate_t;
100 
101 typedef struct cpu_acpi_pstates {
102 	cpu_acpi_pstate_t *pss_pstates;
103 	uint32_t pss_count;
104 } cpu_acpi_pstates_t;
105 
106 typedef int cpu_acpi_ppc_t;
107 
108 /*
109  * Container for cached ACPI data.
110  */
111 typedef struct cpu_acpi_state {
112 	ACPI_HANDLE cs_handle;
113 	dev_info_t *cs_dip;
114 	uint_t cpu_acpi_cached;
115 	cpu_acpi_pstates_t *cs_pstates;
116 	cpu_acpi_pct_t cs_pct[2];
117 	cpu_acpi_psd_t cs_psd;
118 	cpu_acpi_ppc_t cs_ppc;
119 } cpu_acpi_state_t;
120 
121 typedef cpu_acpi_state_t *cpu_acpi_handle_t;
122 
123 extern cpu_acpi_handle_t cpu_acpi_init(dev_info_t *);
124 extern void cpu_acpi_fini(cpu_acpi_handle_t);
125 extern int cpu_acpi_cache_pstates(cpu_acpi_handle_t);
126 extern int cpu_acpi_cache_pct(cpu_acpi_handle_t);
127 extern int cpu_acpi_cache_psd(cpu_acpi_handle_t);
128 extern void cpu_acpi_cache_ppc(cpu_acpi_handle_t);
129 extern int cpu_acpi_cache_data(cpu_acpi_handle_t);
130 extern void cpu_acpi_install_ppc_handler(cpu_acpi_handle_t,
131     ACPI_NOTIFY_HANDLER, dev_info_t *);
132 extern int cpu_acpi_write_pdc(cpu_acpi_handle_t, uint32_t, uint32_t,
133     uint32_t *);
134 extern int cpu_acpi_write_port(ACPI_IO_ADDRESS, uint32_t, uint32_t);
135 extern int cpu_acpi_read_port(ACPI_IO_ADDRESS, uint32_t *, uint32_t);
136 extern uint_t cpu_acpi_get_speeds(cpu_acpi_handle_t, int **);
137 extern void cpu_acpi_free_speeds(int *, uint_t);
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif	/* _CPU_ACPI_H */
144