aboutsummaryrefslogtreecommitdiff
path: root/share/man/man4/acpi_battery.4
blob: 2b44ecbce2b7882d41e03acdf670001e0f7e0900 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
.\"
.\" Copyright (c) 2019 Takanori Watanabe
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd February 16, 2020
.Dt ACPI_BATTERY 4
.Os
.Sh NAME
.Nm acpi_battery
.Nd ACPI battery management subsystem
.Sh SYNOPSIS
.Cd "device acpi"
.Sh DESCRIPTION
The
.Nm
is a driver for battery management features of the ACPI module.
.Pp
An ACPI-compatible battery device supports either a Control
Method Battery interface or a Smart Battery subsystem interface.
The former is accessed by the AML
.Pq ACPI Machine Language
code control methods,
and the latter is controlled directly through the ACPI EC
.Pq Embedded Controller
typically via an SMBus interface.
.Pp
This driver supports the
.Xr sysctl 8
and
.Xr ioctl 2
interfaces as well as the
.Xr devd 8
event notification interface.
.Sh IOCTLS
Every ioctl for the
.Nm
driver takes a single integer value for the battery unit
number as an argument,
and returns a specific structure for each request.
A special unit number
.Dv ACPI_BATTERY_ALL_UNITS
specifies all of the attached units
and reports accumulated information.
.Bl -tag -width indent
.It Dv ACPIIO_BATT_GET_UNITS Vt int
Returns the number of battery units in the system.
The unit number argument will be ignored.
.It Dv ACPIIO_BATT_GET_BATTINFO Vt struct acpi_battinfo
Returns the following:
.Bl -tag -width indent
.It Va cap
Battery capacity in percent,
.It Va min
Remaining battery life in minutes,
.It Va state
Current status of the battery encoded in the following:
.Bl -tag -width indent
.It Dv ACPI_BATT_STAT_DISCHARG Pq 0x0001
Battery is discharging,
.It Dv ACPI_BATT_STAT_CHARGING Pq 0x0002
Battery is being charged, or
.It Dv ACPI_BATT_STAT_CRITICAL Pq 0x0004
Remaining battery life is critically low.
.El
.Pp
Note that the status bits of each battery will be
consolidated when
.Dv ACPI_BATTERY_ALL_UNITS
is specified.
.It Va rate
Current battery discharging rate in mW.
.Li -1
means not discharging right now.
.El
.It Dv ACPIIO_BATT_GET_BIX Vt struct acpi_bix
Returns battery information given by the ACPI
.Li _BIX Pq Battery Information
object,
which is the static portion of the Control Method
Battery information.
In the case of a Smart Battery attached to
SMBus or a Control Method Battery with a
.Li _BIF
object,
this ioctl will build a
.Vt struct acpi_bix
structure based on the obtained information
and return it.
.Bl -tag -width indent
.It Va rev
Revision number of the object.
There are the following well-known values:
.Bl -tag -width indent
.It Dv ACPI_BIX_REV_0 Pq 0x0000
A
.Li _BIX
object in ACPI 4.0.
.It Dv ACPI_BIX_REV_1 Pq 0x0001
A
.Li _BIX
object in ACPI 6.0.
.It Dv ACPI_BIX_REV_BIF Pq 0xffff
A
.Li _BIX
object built from the
.Li _BIF
object found on the system.
.El
.Pp
Note that this field should be checked by using
.Fn ACPI_BIX_REV_MIN_CHECK var rev
macro when checking the minimum revision number.
.It Va units
Indicates the units used by the battery to report its
capacity and charge rate encoded in the following:
.Bl -tag -width indent
.It ACPI_BIX_UNITS_MW Pq 0x00000000
in mW
.Pq power
.It ACPI_BIX_UNITS_MA Pq 0x00000001
in mA
.Pq current
.El
.Pp
Note that capacity is expressed in mWh or mAh,
and rate is expressed in mW or mA,
respectively.
.It Va dcap
The Battery's design capacity,
which is the nominal capacity of a new battery.
This is expressed as power or current depending on
the value of
.Va units .
.It Va lfcap
Predicted battery capacity when fully charged.
Typically this will decrease every charging cycle.
.It btech
Battery technology:
.Bl -tag -width indent
.It 0x00000000 Primary cell Pq non-rechargable
.It 0x00000001 Secondary cell Pq rechargable
.El
.It Va dvol
Design voltage in mV,
which is the nominal voltage of a new battery.
.It Va wcap
Design capacity of warning.
When a discharging battery device reaches this capacity,
notification is sent to the system.
.It Va lcap
Design capacity of low.
.It Va cycles
.Pq rev 0 or newer
The number of cycles the battery has experienced.
A cycle means an amount of discharge occurred which was
approximately equal to the value of Design Capacity.
.It Va accuracy
.Pq rev 0 or newer
The accuracy of the battery capacity measurement,
in thousandth of a percent.
.It Va stmax
.Pq rev 0 or newer
The Maximum Sampling Time of the battery in
milliseconds.
This is the maximum duration between two consecutive
measurements of the battery's capacities specified in
.Li _BST .
If two succeeding readings of
.Li _BST
beyond this duration occur,
two different results can be returned.
.It Va stmin
.Pq rev 0 or newer
The Minimum Sampling Time of the battery in
milliseconds.
.It Va aimax
.Pq rev 0 or newer
The Maximum Average Interval of the battery in
milliseconds.
This is the length of time within which the battery
averages the capacity measurements specified in
.Li _BST .
The Sampling Time specifies the frequency of measurements,
and the Average Interval specifies the width of the time
window of every measurement.
.It Va aimin
.Pq rev 0 or newer
The Minimum Average Interval of the battery in
milliseconds.
.It Va gra1
Battery capacity granularity between
.Va low
and
.Va warning .
This is expressed as power or current depending on
the value of
.Va units .
.It Va gra2
Battery capacity granularity between
.Va warning
and
.Va full .
This is expressed as power or current depending on
the value of
.Va units .
.It Va model
Model number of the battery as a string.
.It Va serial
Serial number of the battery as a string.
.It Va type
Type identifier of the battery as a string.
.It Va oeminfo
OEM-specific information of the battery as a string.
.It Va scap
.Pq rev 1 or newer
Battery swapping capability encoded in the following:
.Bl -tag -width indent
.It ACPI_BIX_SCAP_NO Pq 0x00000000
Non-swappable
.It ACPI_BIX_SCAP_COLD Pq 0x00000001
Cold-swappable
.It ACPI_BIX_SCAP_HOT Pq 0x00000010
Hot-swappable
.El
.El
.It Dv ACPIIO_BATT_GET_BIF Vt struct acpi_bif
.Pq deprecated
Returns battery information given by the ACPI
.Li _BIF Pq Battery Information
object,
which was deprecated in ACPI 4.0 specification.
The data structure is a subset of
.Vt struct acpi_bix .
.Pp
Note that this ioctl will built a
.Vt struct acpi_bif
structure based on the obtained information
even if this object is not available and a
.Li _BIX
object is found.
.It ACPIIO_BATT_GET_BST Vt struct acpi_bst
Returns battery information given by the ACPI
.Li _BST Pq Battery Status
object,
which is the present battery status.
In the case of a Smart Battery attached to SMBus,
this ioctl will build a
.Vt struct acpi_bst
structure based on the obtained information
and return it.
.Bl -tag -width indent
.It Va state
Battery state.
The value is encoded in the same way as
.Va state
of
.Vt struct acpi_battinfo .
.It Va rate
Battery present rate of charging or discharging.
The unit of the value depends on
.Va unit
of
.Vt struct acpi_bif .
.It Va cap
Battery remaining capacity.
The unit of this value depends on
.Va unit
of
.Vt struct acpi_bif .
.It Va volt
Battery present voltage.
.El
.El
.Sh SYSCTL VARIABLES
The following
.Xr sysctl 8
variables export battery status.
Note that they are accumulated status of all of the
connected batteries:
.Bl -tag -width indent
.It Va hw.acpi.battery.info_expire
Information cache expiration time in seconds.
The battery information obtained by
.Li _BIX
or
.Li _BIF
object will be stored and reused for successive
read access to this MIB within the specified period.
.It Va hw.acpi.battery.units
Number of battery units in the system.
.It Va hw.acpi.battery.state
Current battery charging status.
This is same as
.Va state
of
.Vt struct acpi_battinfo .
.It Va hw.acpi.battery.rate
Current battery discharging rate in mW.
.It Va hw.acpi.battery.time
Remaining battery life in minutes.
If the battery is not discharging,
the value shows
.Li -1 .
.It Va hw.acpi.battery.life
Battery capacity in percent.
.El
.Sh EVENT NOTIFICATIONS
Battery-related event notifications are sent
to the userland via the
.Xr devd 8
interface.
See
.Pa /etc/devd.conf
and
.Xr devd.conf 5
for more details.
Note that notifications are supported only by
the Control Method Battery.
.Pp
The
.Nm
driver sends events with the following attributes:
.Pp
.Bl -tag -width "subsystem" -compact
.It system
.Li ACPI
.It subsystem
.Li CMBAT
.It type
The fully qualified battery object path as in the ASL.
.It notify
An integer designating the event:
.Pp
.Bl -tag -width indent -compact
.It Li 0x80
Battery status was changed.
.It Li 0x81
Battery information was changed.
.El
.El
.Sh SEE ALSO
.Xr acpi 4 ,
.Xr acpiconf 8
.Sh AUTHORS
.An -nosplit
.An Nate Lawson Aq Mt njl@FreeBSD.org ,
.An Munehiro Matsuda ,
.An Takanori Watanabe Aq Mt takawata@FreeBSD.org ,
.An Mitsuru IWASAKI Aq Mt iwasaki@FreeBSD.org ,
.An Hans Petter Selasky Aq Mt hselasky@FreeBSD.org ,
and
.An Hiroki Sato Aq Mt hrs@FreeBSD.org .
.Pp
This manual page was written by
.An Takanori Watanabe Aq Mt takawata@FreeBSD.org
and
.An Hiroki Sato Aq Mt hrs@FreeBSD.org .