acpiio.h revision 101560
178344Sobrien/*-
278344Sobrien * Copyright (c) 1999 Takanori Watanabe <takawata@shidahara1.planet.sci.kobe-u.ac.jp>
398184Sgordon * Copyright (c) 1999 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
478344Sobrien * All rights reserved.
578344Sobrien *
678344Sobrien * Redistribution and use in source and binary forms, with or without
7240336Sobrien * modification, are permitted provided that the following conditions
8180564Sdougb * are met:
978344Sobrien * 1. Redistributions of source code must retain the above copyright
1078344Sobrien *    notice, this list of conditions and the following disclaimer.
1178344Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1278344Sobrien *    notice, this list of conditions and the following disclaimer in the
13230099Sdougb *    documentation and/or other materials provided with the distribution.
14151586Syar *
1598184Sgordon * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1698184Sgordon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17255766Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18255766Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19240109Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2078344Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21240109Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2278344Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23255766Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24255766Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25255766Sdes * SUCH DAMAGE.
26255766Sdes *
27262566Sdes *	$FreeBSD: head/sys/dev/acpica/acpiio.h 101560 2002-08-09 07:08:53Z iwasaki $
28133110Smarkm */
29255766Sdes
30133110Smarkm/*
31255766Sdes * Core ACPI subsystem ioctls
32255766Sdes */
33255766Sdes#define ACPIIO_ENABLE		_IO('P', 1)
34255766Sdes#define ACPIIO_DISABLE		_IO('P', 2)
35255766Sdes#define ACPIIO_SETSLPSTATE	_IOW('P', 3, int)
36255766Sdes
37133110Smarkmstruct acpi_battdesc {
38133110Smarkm	int	 type;				/* battery type: e.g. CMBAT */
39255766Sdes	int	 phys_unit;			/* physical unit of devclass */
40255766Sdes};
41255766Sdes
42255766Sdes#define ACPI_BATT_TYPE_CMBAT		0x0000
43262566Sdes#define ACPI_BATT_TYPE_SMBAT		0x0001
44255766Sdes
45255766Sdesstruct acpi_battinfo {
46255766Sdes	int	 cap;				/* percent */
47255766Sdes	int	 min;				/* remianing time */
48255766Sdes	int	 state;				/* battery state */
49255766Sdes};
5098184Sgordon
51255766Sdes#define ACPI_CMBAT_MAXSTRLEN 32
52161530Sflzstruct acpi_bif {
5398184Sgordon	u_int32_t unit;				/* 0 for mWh, 1 for mAh */
5478344Sobrien	u_int32_t dcap;				/* Design Capacity */
5578344Sobrien	u_int32_t lfcap;			/* Last Full capacity */
56255766Sdes	u_int32_t btech;			/* Battery Technorogy */
57256126Sdelphij	u_int32_t dvol;				/* Design voltage (mV) */
5878344Sobrien	u_int32_t wcap;				/* WARN capacity */
59255766Sdes	u_int32_t lcap;				/* Low capacity */
60255766Sdes	u_int32_t gra1;				/* Granulity 1(Warn to Low) */
61255766Sdes	u_int32_t gra2;				/* Granulity 2(Full to Warn) */
6278344Sobrien	char model[ACPI_CMBAT_MAXSTRLEN];	/* model identifier */
63255766Sdes	char serial[ACPI_CMBAT_MAXSTRLEN];	/* Serial number */
6498184Sgordon	char type[ACPI_CMBAT_MAXSTRLEN];	/* Type */
65255766Sdes	char oeminfo[ACPI_CMBAT_MAXSTRLEN];	/* OEM infomation */
66255766Sdes};
67255766Sdes
68255766Sdesstruct acpi_bst {
69255766Sdes	u_int32_t state;			/* Battery State */
70255766Sdes	u_int32_t rate;				/* Present Rate */
71262566Sdes	u_int32_t cap;				/* Remaining Capacity */
7278344Sobrien	u_int32_t volt;				/* Present Voltage */
7378344Sobrien};
74240109Sdes
75240109Sdes#define ACPI_BATT_STAT_DISCHARG		0x0001
76240109Sdes#define ACPI_BATT_STAT_CHARGING		0x0002
77240109Sdes#define ACPI_BATT_STAT_CRITICAL		0x0004
78240109Sdes#define ACPI_BATT_STAT_NOT_PRESENT	0x0007
79240109Sdes#define ACPI_BATT_STAT_MAX		0x0007
8078344Sobrien
8178344Sobrienunion acpi_battery_ioctl_arg {
82255766Sdes	int	 unit;		/* argument: logical unit (-1 = overall) */
83255766Sdes
8478344Sobrien	struct acpi_battdesc	battdesc;
8578344Sobrien	struct acpi_battinfo	battinfo;
86161530Sflz
8778344Sobrien	struct acpi_bif	bif;	/* for acpi_cmbat */
88	struct acpi_bst	bst;	/* for acpi_cmbat */
89};
90
91/* Common battery ioctl */
92#define ACPIIO_BATT_GET_UNITS	_IOR('B', 0x01, int)
93#define ACPIIO_BATT_GET_TYPE	_IOR('B', 0x02, union acpi_battery_ioctl_arg)
94#define ACPIIO_BATT_GET_BATTINFO _IOWR('B', 0x03, union acpi_battery_ioctl_arg)
95#define ACPIIO_BATT_GET_BATTDESC _IOWR('B', 0x04, union acpi_battery_ioctl_arg)
96
97/* Cotrol Method battery ioctl */
98#define ACPIIO_CMBAT_GET_BIF	_IOWR('B', 0x10, union acpi_battery_ioctl_arg)
99#define ACPIIO_CMBAT_GET_BST	_IOWR('B', 0x11, union acpi_battery_ioctl_arg)
100
101#define ACPIIO_ACAD_GET_STATUS	_IOR('A', 1, int)
102
103#ifdef _KERNEL
104extern int	acpi_register_ioctl(u_long cmd, int (* fn)(u_long cmd, caddr_t addr, void *arg), void *arg);
105extern void	acpi_deregister_ioctl(u_long cmd, int (* fn)(u_long cmd, caddr_t addr, void *arg));
106#endif
107