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
|
/*-
* Copyright (c) 2005 Hans Petter Selasky
* 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$
*/
#ifndef _ACPI_SMBUS_H_
#define _ACPI_SMBUS_H_
enum {
SMBUS_WRITE_QUICK = 2,
SMBUS_READ_QUICK = 3,
SMBUS_SEND_BYTE = 4,
SMBUS_RECEIVE_BYTE = 5,
SMBUS_WRITE_BYTE = 6,
SMBUS_READ_BYTE = 7,
SMBUS_WRITE_WORD = 8,
SMBUS_READ_WORD = 9,
SMBUS_WRITE_BLOCK = 0xa,
SMBUS_READ_BLOCK = 0xb,
SMBUS_PROCESS_CALL = 0xc,
SMBUS_BLOCK_PROCESS_CALL = 0xd,
};
/*
* System Management Bus register offsets
*/
#define SMBUS_PRTCL 0
#define SMBUS_STS 1
#define SMBUS_STS_MASK 0x1f
#define SMBUS_ADDR 2
#define SMBUS_CMD 3
#define SMBUS_DATA 4 /* SMBUS_DATA_SIZE bytes */
#define SMBUS_DATA_SIZE 32
#define SMBUS_BCNT 36
#define SMBUS_ALRM_ADDR 37
#define SMBUS_ALRM_DATA 38 /* 2 bytes */
/*
* Smart-Battery commands and definitions
*/
/* Base address */
#define SMBATT_ADDRESS 0x16
/* access: READ WRITE WORD */
#define SMBATT_CMD_MANUFACTURER_ACCESS 0
/*
* access: READ WRITE WORD
* unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1)
* range : 0 .. 65535 inclusively
*/
#define SMBATT_CMD_REMAINING_CAPACITY_ALARM 0x1
/*
* access: READ WRITE WORD
* unit : minutes
* range : 0 .. 65535 inclusively
*/
#define SMBATT_CMD_REMAINING_TIME_ALARM 0x2
/* access: READ WRITE WORD */
#define SMBATT_CMD_BATTERY_MODE 0x3
#define SMBATT_BM_INTERNAL_CHARGE_CONTROLLER (1 << 0) /* READ */
#define SMBATT_BM_PRIMARY_BATTERY_SUPPORT (1 << 1) /* READ */
#define SMBATT_BM_CONDITION_FLAG (1 << 7) /* READ */
#define SMBATT_BM_CHARGE_CONTROLLER_ENABLED (1 << 8) /* READ WRITE */
#define SMBATT_BM_PRIMARY_BATTERY (1 << 9) /* READ WRITE */
#define SMBATT_BM_ALARM_MODE (1 << 13) /* READ WRITE */
#define SMBATT_BM_CHARGER_MODE (1 << 14) /* READ WRITE */
#define SMBATT_BM_CAPACITY_MODE (1 << 15) /* READ WRITE */
/*
* access: READ WRITE WORD
* unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1)
* range : signed WORD
*/
#define SMBATT_CMD_AT_RATE 0x4
/*
* access: READ WORD
* unit : minutes
* range : 0 .. 65534, 65535 has special meaning
*/
#define SMBATT_CMD_AT_RATE_TIME_TO_FULL 0x5
/*
* access: READ WORD
* unit : minutes
* range : 0 .. 65534, 65535 has special meaning
*/
#define SMBATT_CMD_AT_RATE_TIME_TO_EMPTY 0x6
/*
* access: READ WORD */
#define SMBATT_CMD_AT_RATE_OK 0x7
/*
* access: READ WORD
* unit : 0.1 degrees Kelvin
* range : 0 .. 6553.5 Kelvin
*/
#define SMBATT_CMD_TEMPERATURE 0x8
/*
* access: READ WORD
* unit : mV
* range : 0 .. 65535 inclusively
*/
#define SMBATT_CMD_VOLTAGE 0x9
/*
* access: READ WORD
* unit : mA
* range : signed WORD
*/
#define SMBATT_CMD_CURRENT 0xa
/*
* access: READ WORD
* unit : mA
* range : signed WORD
*/
#define SMBATT_CMD_AVERAGE_CURRENT 0xb
/*
* access: READ WORD
* unit : percent
* range : 0..100 inclusively
*/
#define SMBATT_CMD_MAX_ERROR 0xc
/*
* access: READ WORD
* unit : percent
* range : 0..100 inclusively
*/
#define SMBATT_CMD_RELATIVE_STATE_OF_CHARGE 0xd
/*
* access: READ WORD
* unit : percent
* range : 0..100 inclusively
*/
#define SMBATT_CMD_ABSOLUTE_STATE_OF_CHARGE 0xe
/*
* access: READ WORD
* unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1)
* range : 0..65535 inclusively
*/
#define SMBATT_CMD_REMAINING_CAPACITY 0xf
/*
* access: READ WORD
* unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1)
* range : 0..65535 inclusively
*/
#define SMBATT_CMD_FULL_CHARGE_CAPACITY 0x10
/*
* access: READ WORD
* unit : minutes
* range : 0..65534, 65535 is reserved
*/
#define SMBATT_CMD_RUN_TIME_TO_EMPTY 0x11
/*
* access: READ WORD
* unit : minutes
* range : 0..65534, 65535 is reserved
*/
#define SMBATT_CMD_AVERAGE_TIME_TO_EMPTY 0x12
/*
* access: READ WORD
* unit : minutes
* range : 0..65534, 65535 is reserved
*/
#define SMBATT_CMD_AVERAGE_TIME_TO_FULL 0x13
/*
* access: READ WORD
* unit : mA
*/
#define SMBATT_CMD_CHARGING_CURRENT 0x14
/*
* access: READ WORD
* unit : mV
* range : 0 .. 65534, 65535 reserved
*/
#define SMBATT_CMD_CHARGING_VOLTAGE 0x15
/* access: READ WORD */
#define SMBATT_CMD_BATTERY_STATUS 0x16
/* alarm bits */
#define SMBATT_BS_OVER_CHARGED_ALARM (1 << 15)
#define SMBATT_BS_TERMINATE_CHARGE_ALARM (1 << 14)
#define SMBATT_BS_RESERVED_2 (1 << 13)
#define SMBATT_BS_OVER_TEMP_ALARM (1 << 12)
#define SMBATT_BS_TERMINATE_DISCHARGE_ALARM (1 << 11)
#define SMBATT_BS_RESERVED_1 (1 << 10)
#define SMBATT_BS_REMAINING_CAPACITY_ALARM (1 << 9)
#define SMBATT_BS_REMAINING_TIME_ALARM (1 << 8)
/* status bits */
#define SMBATT_BS_INITIALIZED (1 << 7)
#define SMBATT_BS_DISCHARGING (1 << 6)
#define SMBATT_BS_FULLY_CHARGED (1 << 5)
#define SMBATT_BS_FULLY_DISCHARGED (1 << 4)
/* error bits */
#define SMBATT_BS_GET_ERROR(x) ((x) & 0xf)
#define SMBATT_BS_ERROR_OK 0
#define SMBATT_BS_ERROR_BUSY 1
#define SMBATT_BS_ERROR_RESERVED_COMMAND 2
#define SMBATT_BS_ERROR_UNSUPPORTED_COMMAND 3
#define SMBATT_BS_ERROR_ACCESS_DENIED 4
#define SMBATT_BS_ERROR_OVER_UNDER_FLOW 5
#define SMBATT_BS_ERROR_BADSIZE 6
#define SMBATT_BS_ERROR_UNKNOWN 7
/*
* access: READ WORD
* unit : cycle(s)
* range : 0 .. 65534, 65535 reserved
*/
#define SMBATT_CMD_CYCLE_COUNT 0x17
/*
* access: READ WORD
* unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1)
* range : 0..65535 inclusively
*/
#define SMBATT_CMD_DESIGN_CAPACITY 0x18
/*
* access: READ WORD
* unit : mV
* range : 0..65535 mV
*/
#define SMBATT_CMD_DESIGN_VOLTAGE 0x19
/* access: READ WORD */
#define SMBATT_CMD_SPECIFICATION_INFO 0x1a
#define SMBATT_SI_GET_REVISION(x) (((x) >> 0) & 0xf)
#define SMBATT_SI_GET_VERSION(x) (((x) >> 4) & 0xf)
#define SMBATT_SI_GET_VSCALE(x) (((x) >> 8) & 0xf)
#define SMBATT_SI_GET_IPSCALE(x) (((x) >> 12) & 0xf)
/* access: READ WORD */
#define SMBATT_CMD_MANUFACTURE_DATE 0x1b
#define SMBATT_MD_GET_DAY(x) (((x) >> 0) & 0x1f)
#define SMBATT_MD_GET_MONTH(x) (((x) >> 5) & 0xf)
#define SMBATT_MD_GET_YEAR(x) ((((x) >> 9) & 0x7f) + 1980)
/* access: READ WORD */
#define SMBATT_CMD_SERIAL_NUMBER 0x1c
/* access: READ BLOCK */
#define SMBATT_CMD_MANUFACTURER_NAME 0x20
/* access: READ BLOCK */
#define SMBATT_CMD_DEVICE_NAME 0x21
/* access: READ BLOCK */
#define SMBATT_CMD_DEVICE_CHEMISTRY 0x22
/* access: READ BLOCK */
#define SMBATT_CMD_MANUFACTURER_DATA 0x23
#endif /* !_ACPI_SMBUS_H_ */
|