/*-1* Copyright (c) 1999 Takanori Watanabe <[email protected]>2* Copyright (c) 1999 Mitsuru IWASAKI <[email protected]>3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627#ifndef _ACPIIO_H_28#define _ACPIIO_H_2930/*31* Core ACPI subsystem ioctls32*/33#define ACPIIO_SETSLPSTATE _IOW('P', 3, int) /* DEPRECATED */3435/* Request S1-5 sleep state. User is notified and then sleep proceeds. */36#define ACPIIO_REQSLPSTATE _IOW('P', 4, int)3738/* Allow suspend to continue (0) or abort it (errno). */39#define ACPIIO_ACKSLPSTATE _IOW('P', 5, int)4041struct acpi_battinfo {42int cap; /* percent */43int min; /* remaining time (in minutes) */44int state; /* battery state */45int rate; /* emptying rate */46};4748/*49* Battery Information object. Note that this object is deprecated in50* ACPI 4.051*/52#define ACPI_CMBAT_MAXSTRLEN 3253struct acpi_bif {54uint32_t units; /* Power Unit (mW or mA). */55#define ACPI_BIF_UNITS_MW 0 /* Capacity in mWh, rate in mW. */56#define ACPI_BIF_UNITS_MA 1 /* Capacity in mAh, rate in mA. */57uint32_t dcap; /* Design Capacity */58uint32_t lfcap; /* Last Full capacity */59uint32_t btech; /* Battery Technology */60uint32_t dvol; /* Design voltage (mV) */61uint32_t wcap; /* WARN capacity */62uint32_t lcap; /* Low capacity */63uint32_t gra1; /* Granularity 1 (Warn to Low) */64uint32_t gra2; /* Granularity 2 (Full to Warn) */65char model[ACPI_CMBAT_MAXSTRLEN]; /* model identifier */66char serial[ACPI_CMBAT_MAXSTRLEN]; /* Serial number */67char type[ACPI_CMBAT_MAXSTRLEN]; /* Type */68char oeminfo[ACPI_CMBAT_MAXSTRLEN]; /* OEM information */69};7071/*72* Members in acpi_bix are reordered so that the first part is compatible73* with acpi_bif.74*/75struct acpi_bix {76/* _BIF-compatible */77uint32_t units; /* Power Unit (mW or mA). */78#define ACPI_BIX_UNITS_MW 0 /* Capacity in mWh, rate in mW. */79#define ACPI_BIX_UNITS_MA 1 /* Capacity in mAh, rate in mA. */80uint32_t dcap; /* Design Capacity */81uint32_t lfcap; /* Last Full capacity */82uint32_t btech; /* Battery Technology */83uint32_t dvol; /* Design voltage (mV) */84uint32_t wcap; /* WARN capacity */85uint32_t lcap; /* Low capacity */86uint32_t gra1; /* Granularity 1 (Warn to Low) */87uint32_t gra2; /* Granularity 2 (Full to Warn) */88char model[ACPI_CMBAT_MAXSTRLEN]; /* model identifier */89char serial[ACPI_CMBAT_MAXSTRLEN]; /* Serial number */90char type[ACPI_CMBAT_MAXSTRLEN]; /* Type */91char oeminfo[ACPI_CMBAT_MAXSTRLEN]; /* OEM information */92/* ACPI 4.0 or later */93uint16_t rev; /* Revision */94#define ACPI_BIX_REV_0 0 /* ACPI 4.0 _BIX */95#define ACPI_BIX_REV_1 1 /* ACPI 6.0 _BIX */96#define ACPI_BIX_REV_BIF 0xffff /* _BIF */97#define ACPI_BIX_REV_MIN_CHECK(x, min) \98(((min) == ACPI_BIX_REV_BIF) ? ((x) == ACPI_BIX_REV_BIF) : \99(((x) == ACPI_BIX_REV_BIF) ? 0 : ((x) >= (min))))100uint32_t cycles; /* Cycle Count */101uint32_t accuracy; /* Measurement Accuracy */102uint32_t stmax; /* Max Sampling Time */103uint32_t stmin; /* Min Sampling Time */104uint32_t aimax; /* Max Average Interval */105uint32_t aimin; /* Min Average Interval */106/* ACPI 6.0 or later */107uint32_t scap; /* Battery Swapping Capability */108#define ACPI_BIX_SCAP_NO 0x00000000109#define ACPI_BIX_SCAP_COLD 0x00000001110#define ACPI_BIX_SCAP_HOT 0x00000010111uint8_t bix_reserved[58]; /* padding */112};113114#if 0115/* acpi_bix in the original order just for reference */116struct acpi_bix {117uint16_t rev; /* Revision */118uint32_t units; /* Power Unit (mW or mA). */119uint32_t dcap; /* Design Capacity */120uint32_t lfcap; /* Last Full capacity */121uint32_t btech; /* Battery Technology */122uint32_t dvol; /* Design voltage (mV) */123uint32_t wcap; /* Design Capacity of Warning */124uint32_t lcap; /* Design Capacity of Low */125uint32_t cycles; /* Cycle Count */126uint32_t accuracy; /* Measurement Accuracy */127uint32_t stmax; /* Max Sampling Time */128uint32_t stmin; /* Min Sampling Time */129uint32_t aimax; /* Max Average Interval */130uint32_t aimin; /* Min Average Interval */131uint32_t gra1; /* Granularity 1 (Warn to Low) */132uint32_t gra2; /* Granularity 2 (Full to Warn) */133char model[ACPI_CMBAT_MAXSTRLEN]; /* model identifier */134char serial[ACPI_CMBAT_MAXSTRLEN]; /* Serial number */135char type[ACPI_CMBAT_MAXSTRLEN]; /* Type */136char oeminfo[ACPI_CMBAT_MAXSTRLEN]; /* OEM information */137uint32_t scap; /* Battery Swapping Capability */138};139#endif140141struct acpi_bst {142uint32_t state; /* Battery State */143uint32_t rate; /* Present Rate */144uint32_t cap; /* Remaining Capacity */145uint32_t volt; /* Present Voltage */146};147148/*149* Note that the following definitions represent status bits for internal150* driver state. The first three of them (charging, discharging and critical)151* conveninetly conform to ACPI specification of status returned by _BST152* method. Other definitions (not present, etc) are synthetic.153* Also note that according to the specification the charging and discharging154* status bits must not be set at the same time.155*/156#define ACPI_BATT_STAT_DISCHARG 0x0001157#define ACPI_BATT_STAT_CHARGING 0x0002158#define ACPI_BATT_STAT_CRITICAL 0x0004159#define ACPI_BATT_STAT_INVALID \160(ACPI_BATT_STAT_DISCHARG | ACPI_BATT_STAT_CHARGING)161#define ACPI_BATT_STAT_BST_MASK \162(ACPI_BATT_STAT_INVALID | ACPI_BATT_STAT_CRITICAL)163#define ACPI_BATT_STAT_NOT_PRESENT ACPI_BATT_STAT_BST_MASK164165/* For backward compatibility */166union acpi_battery_ioctl_arg_v1 {167int unit; /* Device unit or ACPI_BATTERY_ALL_UNITS. */168169struct acpi_battinfo battinfo;170171struct acpi_bif bif;172struct acpi_bst bst;173};174union acpi_battery_ioctl_arg {175int unit; /* Device unit or ACPI_BATTERY_ALL_UNITS. */176177struct acpi_battinfo battinfo;178179struct acpi_bix bix;180struct acpi_bif bif;181struct acpi_bst bst;182};183184#define ACPI_BATTERY_ALL_UNITS (-1)185#define ACPI_BATT_UNKNOWN 0xffffffff /* _BST or _BI[FX] value unknown. */186187/* Common battery ioctls */188#define ACPIIO_BATT_GET_UNITS _IOR('B', 0x01, int)189#define ACPIIO_BATT_GET_BATTINFO _IOWR('B', 0x03, union acpi_battery_ioctl_arg)190#define ACPIIO_BATT_GET_BATTINFO_V1 _IOWR('B', 0x03, union acpi_battery_ioctl_arg_v1)191#define ACPIIO_BATT_GET_BIF _IOWR('B', 0x10, union acpi_battery_ioctl_arg_v1)192#define ACPIIO_BATT_GET_BIX _IOWR('B', 0x10, union acpi_battery_ioctl_arg)193#define ACPIIO_BATT_GET_BST _IOWR('B', 0x11, union acpi_battery_ioctl_arg)194#define ACPIIO_BATT_GET_BST_V1 _IOWR('B', 0x11, union acpi_battery_ioctl_arg_v1)195196/* Control Method battery ioctls (deprecated) */197#define ACPIIO_CMBAT_GET_BIF ACPIIO_BATT_GET_BIF198#define ACPIIO_CMBAT_GET_BST ACPIIO_BATT_GET_BST199200/* Get AC adapter status. */201#define ACPIIO_ACAD_GET_STATUS _IOR('A', 1, int)202203#ifdef _KERNEL204typedef int (*acpi_ioctl_fn)(u_long cmd, caddr_t addr, void *arg);205extern int acpi_register_ioctl(u_long cmd, acpi_ioctl_fn fn, void *arg);206extern void acpi_deregister_ioctl(u_long cmd, acpi_ioctl_fn fn);207#endif208209#endif /* !_ACPIIO_H_ */210211212