167761Smsmith/*- 2119097Stakawata * Copyright (c) 1999 Takanori Watanabe <takawata@jp.freebsd.org> 367761Smsmith * Copyright (c) 1999 Mitsuru IWASAKI <iwasaki@FreeBSD.org> 467761Smsmith * All rights reserved. 567761Smsmith * 667761Smsmith * Redistribution and use in source and binary forms, with or without 767761Smsmith * modification, are permitted provided that the following conditions 867761Smsmith * are met: 967761Smsmith * 1. Redistributions of source code must retain the above copyright 1067761Smsmith * notice, this list of conditions and the following disclaimer. 1167761Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1267761Smsmith * notice, this list of conditions and the following disclaimer in the 1367761Smsmith * documentation and/or other materials provided with the distribution. 1467761Smsmith * 1567761Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1667761Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1767761Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1867761Smsmith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1967761Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2067761Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2167761Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2267761Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2367761Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2467761Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2567761Smsmith * SUCH DAMAGE. 2667761Smsmith * 27143002Sobrien * $FreeBSD: releng/10.2/sys/dev/acpica/acpiio.h 216503 2010-12-17 16:21:30Z avg $ 2867761Smsmith */ 2967761Smsmith 30142753Snjl#ifndef _ACPIIO_H_ 31142753Snjl#define _ACPIIO_H_ 32142753Snjl 3369744Smsmith/* 3469744Smsmith * Core ACPI subsystem ioctls 3569744Smsmith */ 36170976Snjl#define ACPIIO_SETSLPSTATE _IOW('P', 3, int) /* DEPRECATED */ 3767761Smsmith 38170976Snjl/* Request S1-5 sleep state. User is notified and then sleep proceeds. */ 39170976Snjl#define ACPIIO_REQSLPSTATE _IOW('P', 4, int) 40170976Snjl 41170976Snjl/* Allow suspend to continue (0) or abort it (errno). */ 42170976Snjl#define ACPIIO_ACKSLPSTATE _IOW('P', 5, int) 43170976Snjl 4478662Siwasakistruct acpi_battinfo { 45119529Snjl int cap; /* percent */ 46143771Snjl int min; /* remaining time (in minutes) */ 47119529Snjl int state; /* battery state */ 48148352Snjl int rate; /* emptying rate */ 4978662Siwasaki}; 5078662Siwasaki 5170271Stakawata#define ACPI_CMBAT_MAXSTRLEN 32 5270271Stakawatastruct acpi_bif { 53151563Snjl uint32_t units; /* Units (mW or mA). */ 54151563Snjl#define ACPI_BIF_UNITS_MW 0 /* Capacity in mWh, rate in mW. */ 55151563Snjl#define ACPI_BIF_UNITS_MA 1 /* Capacity in mAh, rate in mA. */ 56148352Snjl uint32_t dcap; /* Design Capacity */ 57148352Snjl uint32_t lfcap; /* Last Full capacity */ 58148352Snjl uint32_t btech; /* Battery Technology */ 59148352Snjl uint32_t dvol; /* Design voltage (mV) */ 60148352Snjl uint32_t wcap; /* WARN capacity */ 61148352Snjl uint32_t lcap; /* Low capacity */ 62148352Snjl uint32_t gra1; /* Granularity 1 (Warn to Low) */ 63148352Snjl uint32_t gra2; /* Granularity 2 (Full to Warn) */ 64119529Snjl char model[ACPI_CMBAT_MAXSTRLEN]; /* model identifier */ 65119529Snjl char serial[ACPI_CMBAT_MAXSTRLEN]; /* Serial number */ 66119529Snjl char type[ACPI_CMBAT_MAXSTRLEN]; /* Type */ 67119529Snjl char oeminfo[ACPI_CMBAT_MAXSTRLEN]; /* OEM infomation */ 6870271Stakawata}; 6970271Stakawata 7070271Stakawatastruct acpi_bst { 71148352Snjl uint32_t state; /* Battery State */ 72148352Snjl uint32_t rate; /* Present Rate */ 73148352Snjl uint32_t cap; /* Remaining Capacity */ 74148352Snjl uint32_t volt; /* Present Voltage */ 7570271Stakawata}; 7670271Stakawata 77216503Savg/* 78216503Savg * Note that the following definitions represent status bits for internal 79216503Savg * driver state. The first three of them (charging, discharging and critical) 80216503Savg * conveninetly conform to ACPI specification of status returned by _BST 81216503Savg * method. Other definitions (not present, etc) are synthetic. 82216503Savg * Also note that according to the specification the charging and discharging 83216503Savg * status bits must not be set at the same time. 84216503Savg */ 8578662Siwasaki#define ACPI_BATT_STAT_DISCHARG 0x0001 8678662Siwasaki#define ACPI_BATT_STAT_CHARGING 0x0002 8778662Siwasaki#define ACPI_BATT_STAT_CRITICAL 0x0004 88216503Savg#define ACPI_BATT_STAT_INVALID \ 89216503Savg (ACPI_BATT_STAT_DISCHARG | ACPI_BATT_STAT_CHARGING) 90216503Savg#define ACPI_BATT_STAT_BST_MASK \ 91216503Savg (ACPI_BATT_STAT_INVALID | ACPI_BATT_STAT_CRITICAL) 92216503Savg#define ACPI_BATT_STAT_NOT_PRESENT ACPI_BATT_STAT_BST_MASK 9378662Siwasaki 9478662Siwasakiunion acpi_battery_ioctl_arg { 95148352Snjl int unit; /* Device unit or ACPI_BATTERY_ALL_UNITS. */ 9678662Siwasaki 97148352Snjl struct acpi_battinfo battinfo; 9878662Siwasaki 99143771Snjl struct acpi_bif bif; 100143771Snjl struct acpi_bst bst; 10170340Siwasaki}; 10270340Siwasaki 103148352Snjl#define ACPI_BATTERY_ALL_UNITS (-1) 104151563Snjl#define ACPI_BATT_UNKNOWN 0xffffffff /* _BST or _BIF value unknown. */ 105148352Snjl 106143771Snjl/* Common battery ioctls */ 107119529Snjl#define ACPIIO_BATT_GET_UNITS _IOR('B', 0x01, int) 10878662Siwasaki#define ACPIIO_BATT_GET_BATTINFO _IOWR('B', 0x03, union acpi_battery_ioctl_arg) 109143771Snjl#define ACPIIO_BATT_GET_BIF _IOWR('B', 0x10, union acpi_battery_ioctl_arg) 110143771Snjl#define ACPIIO_BATT_GET_BST _IOWR('B', 0x11, union acpi_battery_ioctl_arg) 11170340Siwasaki 112143771Snjl/* Control Method battery ioctls (deprecated) */ 113143771Snjl#define ACPIIO_CMBAT_GET_BIF ACPIIO_BATT_GET_BIF 114143771Snjl#define ACPIIO_CMBAT_GET_BST ACPIIO_BATT_GET_BST 11578662Siwasaki 116142753Snjl/* Get AC adapter status. */ 117119529Snjl#define ACPIIO_ACAD_GET_STATUS _IOR('A', 1, int) 11870340Siwasaki 11969744Smsmith#ifdef _KERNEL 120119529Snjltypedef int (*acpi_ioctl_fn)(u_long cmd, caddr_t addr, void *arg); 121119529Snjlextern int acpi_register_ioctl(u_long cmd, acpi_ioctl_fn fn, void *arg); 122119529Snjlextern void acpi_deregister_ioctl(u_long cmd, acpi_ioctl_fn fn); 12369744Smsmith#endif 124142753Snjl 125142753Snjl#endif /* !_ACPIIO_H_ */ 126