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_CTRL(pstate) pstate->ps_ctrl 51 #define CPU_ACPI_STAT(pstate) pstate->ps_state 52 53 #define CPU_ACPI_NONE_CACHED 0x00 54 #define CPU_ACPI_PCT_CACHED 0x01 55 #define CPU_ACPI_PSS_CACHED 0x02 56 #define CPU_ACPI_PSD_CACHED 0x04 57 #define CPU_ACPI_PPC_CACHED 0x08 58 59 #define CPU_ACPI_IS_OBJ_CACHED(sp, obj) (sp->cpu_acpi_cached & obj) 60 #define CPU_ACPI_OBJ_IS_CACHED(sp, obj) (sp->cpu_acpi_cached |= obj) 61 #define CPU_ACPI_OBJ_IS_NOT_CACHED(sp, obj) (sp->cpu_acpi_cached &= ~obj) 62 63 /* 64 * Container for _PSD information 65 */ 66 typedef struct cpu_acpi_psd 67 { 68 uint8_t pd_entries; 69 uint8_t pd_revision; 70 uint32_t pd_domain; 71 uint32_t pd_type; 72 uint32_t pd_num; 73 } cpu_acpi_psd_t; 74 75 /* 76 * Container for _PCT information 77 */ 78 typedef struct cpu_acpi_pct 79 { 80 uint8_t pc_addrspace_id; 81 uint8_t pc_width; 82 uint8_t pc_offset; 83 uint8_t pc_asize; 84 ACPI_IO_ADDRESS pc_address; 85 } cpu_acpi_pct_t; 86 87 /* 88 * Containers for _PSS information 89 */ 90 typedef struct cpu_acpi_pstate 91 { 92 uint32_t ps_freq; 93 uint32_t ps_disp; 94 uint32_t ps_translat; 95 uint32_t ps_buslat; 96 uint32_t ps_ctrl; 97 uint32_t ps_state; 98 } cpu_acpi_pstate_t; 99 100 typedef struct cpu_acpi_pstates { 101 cpu_acpi_pstate_t *pss_pstates; 102 uint32_t pss_count; 103 } cpu_acpi_pstates_t; 104 105 typedef int cpu_acpi_ppc_t; 106 107 /* 108 * Container for cached ACPI data. 109 */ 110 typedef struct cpu_acpi_state { 111 ACPI_HANDLE cs_handle; 112 dev_info_t *cs_dip; 113 uint_t cpu_acpi_cached; 114 cpu_acpi_pstates_t *cs_pstates; 115 cpu_acpi_pct_t cs_pct[2]; 116 cpu_acpi_psd_t cs_psd; 117 cpu_acpi_ppc_t cs_ppc; 118 } cpu_acpi_state_t; 119 120 typedef cpu_acpi_state_t *cpu_acpi_handle_t; 121 122 extern cpu_acpi_handle_t cpu_acpi_init(dev_info_t *); 123 extern void cpu_acpi_fini(cpu_acpi_handle_t); 124 extern int cpu_acpi_cache_pstates(cpu_acpi_handle_t); 125 extern int cpu_acpi_cache_pct(cpu_acpi_handle_t); 126 extern int cpu_acpi_cache_psd(cpu_acpi_handle_t); 127 extern void cpu_acpi_cache_ppc(cpu_acpi_handle_t); 128 extern int cpu_acpi_cache_data(cpu_acpi_handle_t); 129 extern void cpu_acpi_install_ppc_handler(cpu_acpi_handle_t, 130 ACPI_NOTIFY_HANDLER, dev_info_t *); 131 extern int cpu_acpi_write_pdc(cpu_acpi_handle_t, uint32_t, uint32_t, 132 uint32_t *); 133 extern int cpu_acpi_write_port(ACPI_IO_ADDRESS, uint32_t, uint32_t); 134 extern int cpu_acpi_read_port(ACPI_IO_ADDRESS, uint32_t *, uint32_t); 135 extern uint_t cpu_acpi_get_speeds(cpu_acpi_handle_t, int **); 136 extern void cpu_acpi_free_speeds(int *, uint_t); 137 138 #ifdef __cplusplus 139 } 140 #endif 141 142 #endif /* _CPU_ACPI_H */ 143