acpidev.h revision 1.24
1/* $OpenBSD: acpidev.h,v 1.24 2007/04/23 17:38:30 mk Exp $ */ 2/* 3 * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> 4 * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19#ifndef __DEV_ACPI_ACPIDEV_H__ 20#define __DEV_ACPI_ACPIDEV_H__ 21 22#include <sys/sensors.h> 23#include <sys/rwlock.h> 24 25#define DEVNAME(s) ((s)->sc_dev.dv_xname) 26 27#define ACPIDEV_NOPOLL 0 28#define ACPIDEV_POLL 1 29 30/* 31 * _BIF (Battery InFormation) 32 * Arguments: none 33 * Results : package _BIF (Battery InFormation) 34 * Package { 35 * // ASCIIZ is ASCII character string terminated with a 0x00. 36 * Power Unit //DWORD 37 * Design Capacity //DWORD 38 * Last Full Charge Capacity //DWORD 39 * Battery Technology //DWORD 40 * Design Voltage //DWORD 41 * Design Capacity of Warning //DWORD 42 * Design Capacity of Low //DWORD 43 * Battery Capacity Granularity 1 //DWORD 44 * Battery Capacity Granularity 2 //DWORD 45 * Model Number //ASCIIZ 46 * Serial Number //ASCIIZ 47 * Battery Type //ASCIIZ 48 * OEM Information //ASCIIZ 49 * } 50 */ 51struct acpibat_bif { 52 u_int32_t bif_power_unit; 53#define BIF_POWER_MW 0x00 54#define BIF_POWER_MA 0x01 55 u_int32_t bif_capacity; 56#define BIF_UNKNOWN 0xffffffff 57 u_int32_t bif_last_capacity; 58 u_int32_t bif_technology; 59#define BIF_TECH_PRIMARY 0x00 60#define BIF_TECH_SECONDARY 0x01 61 u_int32_t bif_voltage; 62 u_int32_t bif_warning; 63 u_int32_t bif_low; 64 u_int32_t bif_cap_granu1; 65 u_int32_t bif_cap_granu2; 66 char bif_model[20]; 67 char bif_serial[20]; 68 char bif_type[20]; 69 char bif_oem[20]; 70}; 71 72/* 73 * _OSC Definition for Control Method Battery 74 * Arguments: none 75 * Results : DWORD flags 76 */ 77#define CMB_OSC_UUID "f18fc78b-0f15-4978-b793-53f833a1d35b" 78#define CMB_OSC_GRANULARITY 0x01 79#define CMB_OSC_WAKE_ON_LOW 0x02 80 81/* 82 * _BST (Battery STatus) 83 * Arguments: none 84 * Results : package _BST (Battery STatus) 85 * Package { 86 * Battery State //DWORD 87 * Battery Present Rate //DWORD 88 * Battery Remaining Capacity //DWORD 89 * Battery Present Voltage //DWORD 90 * } 91 * 92 * Per the spec section 10.2.2.3 93 * Remaining Battery Percentage[%] = (Battery Remaining Capacity [=0 ~ 100] / 94 * Last Full Charged Capacity[=100]) * 100 95 * 96 * Remaining Battery Life [h] = Battery Remaining Capacity [mAh/mWh] / 97 * Battery Present Rate [=0xFFFFFFFF] = unknown 98 */ 99struct acpibat_bst { 100 u_int32_t bst_state; 101#define BST_DISCHARGE 0x01 102#define BST_CHARGE 0x02 103#define BST_CRITICAL 0x04 104 u_int32_t bst_rate; 105#define BST_UNKNOWN 0xffffffff 106 u_int32_t bst_capacity; 107 u_int32_t bst_voltage; 108}; 109 110/* 111 * _BTP (Battery Trip Point) 112 * Arguments: DWORD level 113 * Results : none 114 */ 115#define BTP_CLEAR_TRIP_POINT 0x00 116 117/* 118 * _BTM (Battery TiMe) 119 * Arguments: DWORD rate of discharge 120 * Results : DWORD time in seconds or error/unknown 121 */ 122#define BTM_CURRENT_RATE 0x00 123 124#define BTM_RATE_TOO_LARGE 0x00 125#define BTM_CRITICAL 0x00 126#define BTM_UNKNOWN 0xffffffff 127 128/* 129 * _BMD (Battery Maintenance Data) 130 * Arguments: none 131 * Results : package _BMD (Battery Maintenance Data) 132 * Package { 133 * Status Flags //DWORD 134 * Capability Flags //DWORD 135 * Recalibrate Count //DWORD 136 * Quick Recalibrate Time //DWORD 137 * Slow Recalibrate Time //DWORD 138 * } 139 */ 140struct acpibat_bmd { 141 u_int32_t bmd_status; 142#define BMD_AML_CALIBRATE_CYCLE 0x01 143#define BMD_CHARGING_DISABLED 0x02 144#define BMD_DISCHARGE_WHILE_AC 0x04 145#define BMD_RECALIBRATE_BAT 0x08 146#define BMD_GOTO_STANDBY_SPEED 0x10 147 u_int32_t bmd_capability; 148#define BMD_CB_AML_CALIBRATION 0x01 149#define BMD_CB_DISABLE_CHARGER 0x02 150#define BMD_CB_DISCH_WHILE_AC 0x04 151#define BMD_CB_AFFECT_ALL_BATT 0x08 152#define BMD_CB_FULL_CHRG_FIRST 0x10 153 u_int32_t bmd_recalibrate_count; 154#define BMD_ONLY_CALIB_IF_ST3 0x00 /* only recal when status bit 3 set */ 155 u_int32_t bmd_quick_recalibrate_time; 156#define BMD_UNKNOWN 0xffffffff 157 u_int32_t bmd_slow_recalibrate_time; 158}; 159 160/* 161 * _BMC (Battery Maintenance Control) 162 * Arguments: DWORD flags 163 * Results : none 164 */ 165#define BMC_AML_CALIBRATE 0x01 166#define BMC_DISABLE_CHARGING 0x02 167#define BMC_ALLOW_AC_DISCHARGE 0x04 168 169/* AC device */ 170/* 171 * _PSR (Power Source) 172 * Arguments: none 173 * Results : DWORD status 174 */ 175#define PSR_OFFLINE 0x00 176#define PSR_ONLINE 0x01 177 178/* 179 * _PCL (Power Consumer List) 180 * Arguments: none 181 * Results : LIST of Power Class pointers 182 */ 183 184/* hpet device */ 185#define HPET_REG_SIZE 1024 186 187#define HPET_CAPABILITIES 0x000 188#define HPET_CONFIGURATION 0x010 189#define HPET_INTERRUPT_STATUS 0x020 190#define HPET_MAIN_COUNTER 0x0F0 191#define HPET_TIMER0_CONFIG 0x100 192#define HPET_TIMER0_COMPARE 0x108 193#define HPET_TIMER0_INTERRUPT 0x110 194#define HPET_TIMER1_CONFIG 0x200 195#define HPET_TIMER1_COMPARE 0x208 196#define HPET_TIMER1_INTERRUPT 0x310 197#define HPET_TIMER2_CONFIG 0x400 198#define HPET_TIMER2_COMPARE 0x408 199#define HPET_TIMER2_INTERRUPT 0x510 200 201#define STA_PRESENT (1L << 0) 202#define STA_ENABLED (1L << 1) 203#define STA_SHOW_UI (1L << 2) 204#define STA_DEV_OK (1L << 3) 205#define STA_BATTERY (1L << 4) 206 207/* 208 * _PSS (Performance Supported States) 209 * Arguments: none 210 * Results : package _PSS (Performance Supported States) 211 * Package { 212 * CoreFreq //DWORD 213 * Power //DWORD 214 * TransitionLatency //DWORD 215 * BusMasterLatency //DWORD 216 * Control //DWORD 217 * Status //DWORD 218 * } 219 */ 220struct acpicpu_pss { 221 u_int32_t pss_core_freq; 222 u_int32_t pss_power; 223 u_int32_t pss_trans_latency; 224 u_int32_t pss_bus_latency; 225 u_int32_t pss_ctrl; 226 u_int32_t pss_status; 227}; 228 229/* 230 * XXX this is returned in a buffer and is not a "natural" type. 231 * 232 * GRD (Generic Register Descriptor ) 233 * 234 */ 235struct acpi_grd { 236 u_int8_t grd_descriptor; 237 u_int16_t grd_length; 238 struct acpi_gas grd_gas; 239} __packed; 240 241/* 242 * _PCT (Performance Control ) 243 * Arguments: none 244 * Results : package _PCT (Performance Control) 245 * Package { 246 * Perf_Ctrl_register //Register 247 * Perf_Status_register //Register 248 * } 249 */ 250struct acpicpu_pct { 251 struct acpi_grd pct_ctrl; 252 struct acpi_grd pct_status; 253}; 254 255/* softc for fake apm devices */ 256struct acpiac_softc { 257 struct device sc_dev; 258 259 bus_space_tag_t sc_iot; 260 bus_space_handle_t sc_ioh; 261 262 struct acpi_softc *sc_acpi; 263 struct aml_node *sc_devnode; 264 265 int sc_ac_stat; 266 267 struct ksensor sc_sens[1]; 268 struct ksensordev sc_sensdev; 269}; 270 271struct acpibat_softc { 272 struct device sc_dev; 273 274 bus_space_tag_t sc_iot; 275 bus_space_handle_t sc_ioh; 276 277 struct acpi_softc *sc_acpi; 278 struct aml_node *sc_devnode; 279 280 struct acpibat_bif sc_bif; 281 struct acpibat_bst sc_bst; 282 volatile int sc_bat_present; 283 284 struct ksensor sc_sens[8]; 285 struct ksensordev sc_sensdev; 286}; 287 288struct acpidock_softc { 289 struct device sc_dev; 290 291 bus_space_tag_t sc_iot; 292 bus_space_handle_t sc_ioh; 293 294 struct acpi_softc *sc_acpi; 295 struct aml_node *sc_devnode; 296 297 TAILQ_HEAD(, aml_nodelist) sc_deps_h; 298 struct aml_nodelist *sc_deps; 299 300 struct ksensor sc_sens; 301 struct ksensordev sc_sensdev; 302 303 int sc_docked; 304 int sc_sta; 305 306#define ACPIDOCK_STATUS_UNKNOWN -1 307#define ACPIDOCK_STATUS_UNDOCKED 0 308#define ACPIDOCK_STATUS_DOCKED 1 309}; 310 311#define ACPIDOCK_EVENT_INSERT 0 312#define ACPIDOCK_EVENT_EJECT 3 313 314 315#endif /* __DEV_ACPI_ACPIDEV_H__ */ 316