acpidev.h revision 1.19
1/* $OpenBSD: acpidev.h,v 1.19 2007/01/26 19:54:49 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_BATTERY (1L << 4) 204 205/* 206 * _PSS (Performance Supported States) 207 * Arguments: none 208 * Results : package _PSS (Performance Supported States) 209 * Package { 210 * CoreFreq //DWORD 211 * Power //DWORD 212 * TransitionLatency //DWORD 213 * BusMasterLatency //DWORD 214 * Control //DWORD 215 * Status //DWORD 216 * } 217 */ 218struct acpicpu_pss { 219 u_int32_t pss_core_freq; 220 u_int32_t pss_power; 221 u_int32_t pss_trans_latency; 222 u_int32_t pss_bus_latency; 223 u_int32_t pss_ctrl; 224 u_int32_t pss_status; 225}; 226 227/* 228 * XXX this is returned in a buffer and is not a "natural" type. 229 * 230 * GRD (Generic Register Descriptor ) 231 * 232 */ 233struct acpi_grd { 234 u_int8_t grd_descriptor; 235 u_int16_t grd_length; 236 struct acpi_gas grd_gas; 237} __packed; 238 239/* 240 * _PCT (Performance Control ) 241 * Arguments: none 242 * Results : package _PCT (Performance Control) 243 * Package { 244 * Perf_Ctrl_register //Register 245 * Perf_Status_register //Register 246 * } 247 */ 248struct acpicpu_pct { 249 struct acpi_grd pct_ctrl; 250 struct acpi_grd pct_status; 251}; 252 253/* softc for fake apm devices */ 254struct acpiac_softc { 255 struct device sc_dev; 256 257 bus_space_tag_t sc_iot; 258 bus_space_handle_t sc_ioh; 259 260 struct acpi_softc *sc_acpi; 261 struct aml_node *sc_devnode; 262 263 int sc_ac_stat; 264 265 struct sensor sc_sens[1]; 266 struct sensordev sc_sensdev; 267}; 268 269struct acpibat_softc { 270 struct device sc_dev; 271 272 bus_space_tag_t sc_iot; 273 bus_space_handle_t sc_ioh; 274 275 struct acpi_softc *sc_acpi; 276 struct aml_node *sc_devnode; 277 278 struct acpibat_bif sc_bif; 279 struct acpibat_bst sc_bst; 280 volatile int sc_bat_present; 281 282 struct sensor sc_sens[8]; 283 struct sensordev sc_sensdev; 284}; 285 286struct acpidock_softc { 287 struct device sc_dev; 288 289 bus_space_tag_t sc_iot; 290 bus_space_handle_t sc_ioh; 291 292 struct acpi_softc *sc_acpi; 293 struct aml_node *sc_devnode; 294 295 struct sensor sc_sens[1]; 296 struct sensordev sc_sensdev; 297 298 int sc_docked; 299 int sc_sta; 300 301#define ACPIDOCK_STATUS_UNKNOWN -1 302#define ACPIDOCK_STATUS_UNDOCKED 0 303#define ACPIDOCK_STATUS_DOCKED 1 304}; 305 306#define ACPIDOCK_EVENT_INSERT 0 307#define ACPIDOCK_EVENT_EJECT 3 308 309 310#endif /* __DEV_ACPI_ACPIDEV_H__ */ 311