1151564Snjl/*- 2151564Snjl * Copyright (c) 2005 Hans Petter Selasky 3151564Snjl * All rights reserved. 4151564Snjl * 5151564Snjl * Redistribution and use in source and binary forms, with or without 6151564Snjl * modification, are permitted provided that the following conditions 7151564Snjl * are met: 8151564Snjl * 1. Redistributions of source code must retain the above copyright 9151564Snjl * notice, this list of conditions and the following disclaimer. 10151564Snjl * 2. Redistributions in binary form must reproduce the above copyright 11151564Snjl * notice, this list of conditions and the following disclaimer in the 12151564Snjl * documentation and/or other materials provided with the distribution. 13151564Snjl * 14151564Snjl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15151564Snjl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16151564Snjl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17151564Snjl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18151564Snjl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19151564Snjl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20151564Snjl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21151564Snjl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22151564Snjl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23151564Snjl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24151564Snjl * SUCH DAMAGE. 25151564Snjl * 26151564Snjl * $FreeBSD: releng/10.3/sys/dev/acpica/acpi_smbus.h 151564 2005-10-23 00:20:13Z njl $ 27151564Snjl */ 28151564Snjl 29151564Snjl#ifndef _ACPI_SMBUS_H_ 30151564Snjl#define _ACPI_SMBUS_H_ 31151564Snjl 32151564Snjl/* 33151564Snjl * System Management Bus register offsets 34151564Snjl */ 35151564Snjl#define SMBUS_PRTCL 0 36151564Snjl#define SMBUS_STS 1 37151564Snjl#define SMBUS_STS_MASK 0x1f 38151564Snjl#define SMBUS_ADDR 2 39151564Snjl#define SMBUS_CMD 3 40151564Snjl#define SMBUS_DATA 4 /* 32 bytes */ 41151564Snjl#define SMBUS_BCNT 36 42151564Snjl#define SMBUS_ALRM_ADDR 37 43151564Snjl#define SMBUS_ALRM_DATA 38 /* 2 bytes */ 44151564Snjl 45151564Snjl/* 46151564Snjl * Smart-Battery commands and definitions 47151564Snjl */ 48151564Snjl 49151564Snjl/* Base address */ 50151564Snjl#define SMBATT_ADDRESS 0x16 51151564Snjl 52151564Snjl 53151564Snjl/* access: READ WRITE WORD */ 54151564Snjl#define SMBATT_CMD_MANUFACTURER_ACCESS 0 55151564Snjl 56151564Snjl/* 57151564Snjl * access: READ WRITE WORD 58151564Snjl * unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1) 59151564Snjl * range : 0 .. 65535 inclusively 60151564Snjl */ 61151564Snjl#define SMBATT_CMD_REMAINING_CAPACITY_ALARM 0x1 62151564Snjl 63151564Snjl/* 64151564Snjl * access: READ WRITE WORD 65151564Snjl * unit : minutes 66151564Snjl * range : 0 .. 65535 inclusively 67151564Snjl */ 68151564Snjl#define SMBATT_CMD_REMAINING_TIME_ALARM 0x2 69151564Snjl 70151564Snjl/* access: READ WRITE WORD */ 71151564Snjl#define SMBATT_CMD_BATTERY_MODE 0x3 72151564Snjl 73151564Snjl#define SMBATT_BM_INTERNAL_CHARGE_CONTROLLER (1 << 0) /* READ */ 74151564Snjl#define SMBATT_BM_PRIMARY_BATTERY_SUPPORT (1 << 1) /* READ */ 75151564Snjl#define SMBATT_BM_CONDITION_FLAG (1 << 7) /* READ */ 76151564Snjl#define SMBATT_BM_CHARGE_CONTROLLER_ENABLED (1 << 8) /* READ WRITE */ 77151564Snjl#define SMBATT_BM_PRIMARY_BATTERY (1 << 9) /* READ WRITE */ 78151564Snjl#define SMBATT_BM_ALARM_MODE (1 << 13) /* READ WRITE */ 79151564Snjl#define SMBATT_BM_CHARGER_MODE (1 << 14) /* READ WRITE */ 80151564Snjl#define SMBATT_BM_CAPACITY_MODE (1 << 15) /* READ WRITE */ 81151564Snjl 82151564Snjl/* 83151564Snjl * access: READ WRITE WORD 84151564Snjl * unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1) 85151564Snjl * range : signed WORD 86151564Snjl */ 87151564Snjl#define SMBATT_CMD_AT_RATE 0x4 88151564Snjl 89151564Snjl/* 90151564Snjl * access: READ WORD 91151564Snjl * unit : minutes 92151564Snjl * range : 0 .. 65534, 65535 has special meaning 93151564Snjl */ 94151564Snjl#define SMBATT_CMD_AT_RATE_TIME_TO_FULL 0x5 95151564Snjl 96151564Snjl/* 97151564Snjl * access: READ WORD 98151564Snjl * unit : minutes 99151564Snjl * range : 0 .. 65534, 65535 has special meaning 100151564Snjl */ 101151564Snjl#define SMBATT_CMD_AT_RATE_TIME_TO_EMPTY 0x6 102151564Snjl 103151564Snjl/* 104151564Snjl * access: READ WORD */ 105151564Snjl#define SMBATT_CMD_AT_RATE_OK 0x7 106151564Snjl 107151564Snjl/* 108151564Snjl * access: READ WORD 109151564Snjl * unit : 0.1 degrees Kelvin 110151564Snjl * range : 0 .. 6553.5 Kelvin 111151564Snjl */ 112151564Snjl#define SMBATT_CMD_TEMPERATURE 0x8 113151564Snjl 114151564Snjl/* 115151564Snjl * access: READ WORD 116151564Snjl * unit : mV 117151564Snjl * range : 0 .. 65535 inclusively 118151564Snjl */ 119151564Snjl#define SMBATT_CMD_VOLTAGE 0x9 120151564Snjl 121151564Snjl/* 122151564Snjl * access: READ WORD 123151564Snjl * unit : mA 124151564Snjl * range : signed WORD 125151564Snjl */ 126151564Snjl#define SMBATT_CMD_CURRENT 0xa 127151564Snjl 128151564Snjl/* 129151564Snjl * access: READ WORD 130151564Snjl * unit : mA 131151564Snjl * range : signed WORD 132151564Snjl */ 133151564Snjl#define SMBATT_CMD_AVERAGE_CURRENT 0xb 134151564Snjl 135151564Snjl/* 136151564Snjl * access: READ WORD 137151564Snjl * unit : percent 138151564Snjl * range : 0..100 inclusively 139151564Snjl */ 140151564Snjl#define SMBATT_CMD_MAX_ERROR 0xc 141151564Snjl 142151564Snjl/* 143151564Snjl * access: READ WORD 144151564Snjl * unit : percent 145151564Snjl * range : 0..100 inclusively 146151564Snjl */ 147151564Snjl#define SMBATT_CMD_RELATIVE_STATE_OF_CHARGE 0xd 148151564Snjl 149151564Snjl/* 150151564Snjl * access: READ WORD 151151564Snjl * unit : percent 152151564Snjl * range : 0..100 inclusively 153151564Snjl */ 154151564Snjl#define SMBATT_CMD_ABSOLUTE_STATE_OF_CHARGE 0xe 155151564Snjl 156151564Snjl/* 157151564Snjl * access: READ WORD 158151564Snjl * unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1) 159151564Snjl * range : 0..65535 inclusively 160151564Snjl */ 161151564Snjl#define SMBATT_CMD_REMAINING_CAPACITY 0xf 162151564Snjl 163151564Snjl/* 164151564Snjl * access: READ WORD 165151564Snjl * unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1) 166151564Snjl * range : 0..65535 inclusively 167151564Snjl */ 168151564Snjl#define SMBATT_CMD_FULL_CHARGE_CAPACITY 0x10 169151564Snjl 170151564Snjl/* 171151564Snjl * access: READ WORD 172151564Snjl * unit : minutes 173151564Snjl * range : 0..65534, 65535 is reserved 174151564Snjl */ 175151564Snjl#define SMBATT_CMD_RUN_TIME_TO_EMPTY 0x11 176151564Snjl 177151564Snjl/* 178151564Snjl * access: READ WORD 179151564Snjl * unit : minutes 180151564Snjl * range : 0..65534, 65535 is reserved 181151564Snjl */ 182151564Snjl#define SMBATT_CMD_AVERAGE_TIME_TO_EMPTY 0x12 183151564Snjl 184151564Snjl/* 185151564Snjl * access: READ WORD 186151564Snjl * unit : minutes 187151564Snjl * range : 0..65534, 65535 is reserved 188151564Snjl */ 189151564Snjl#define SMBATT_CMD_AVERAGE_TIME_TO_FULL 0x13 190151564Snjl 191151564Snjl/* 192151564Snjl * access: READ WORD 193151564Snjl * unit : mA 194151564Snjl */ 195151564Snjl#define SMBATT_CMD_CHARGING_CURRENT 0x14 196151564Snjl 197151564Snjl/* 198151564Snjl * access: READ WORD 199151564Snjl * unit : mV 200151564Snjl * range : 0 .. 65534, 65535 reserved 201151564Snjl */ 202151564Snjl#define SMBATT_CMD_CHARGING_VOLTAGE 0x15 203151564Snjl 204151564Snjl/* access: READ WORD */ 205151564Snjl#define SMBATT_CMD_BATTERY_STATUS 0x16 206151564Snjl 207151564Snjl/* alarm bits */ 208151564Snjl#define SMBATT_BS_OVER_CHARGED_ALARM (1 << 15) 209151564Snjl#define SMBATT_BS_TERMINATE_CHARGE_ALARM (1 << 14) 210151564Snjl#define SMBATT_BS_RESERVED_2 (1 << 13) 211151564Snjl#define SMBATT_BS_OVER_TEMP_ALARM (1 << 12) 212151564Snjl#define SMBATT_BS_TERMINATE_DISCHARGE_ALARM (1 << 11) 213151564Snjl#define SMBATT_BS_RESERVED_1 (1 << 10) 214151564Snjl#define SMBATT_BS_REMAINING_CAPACITY_ALARM (1 << 9) 215151564Snjl#define SMBATT_BS_REMAINING_TIME_ALARM (1 << 8) 216151564Snjl 217151564Snjl/* status bits */ 218151564Snjl#define SMBATT_BS_INITIALIZED (1 << 7) 219151564Snjl#define SMBATT_BS_DISCHARGING (1 << 6) 220151564Snjl#define SMBATT_BS_FULLY_CHARGED (1 << 5) 221151564Snjl#define SMBATT_BS_FULLY_DISCHARGED (1 << 4) 222151564Snjl 223151564Snjl/* error bits */ 224151564Snjl#define SMBATT_BS_GET_ERROR(x) ((x) & 0xf) 225151564Snjl#define SMBATT_BS_ERROR_OK 0 226151564Snjl#define SMBATT_BS_ERROR_BUSY 1 227151564Snjl#define SMBATT_BS_ERROR_RESERVED_COMMAND 2 228151564Snjl#define SMBATT_BS_ERROR_UNSUPPORTED_COMMAND 3 229151564Snjl#define SMBATT_BS_ERROR_ACCESS_DENIED 4 230151564Snjl#define SMBATT_BS_ERROR_OVER_UNDER_FLOW 5 231151564Snjl#define SMBATT_BS_ERROR_BADSIZE 6 232151564Snjl#define SMBATT_BS_ERROR_UNKNOWN 7 233151564Snjl 234151564Snjl/* 235151564Snjl * access: READ WORD 236151564Snjl * unit : cycle(s) 237151564Snjl * range : 0 .. 65534, 65535 reserved 238151564Snjl */ 239151564Snjl#define SMBATT_CMD_CYCLE_COUNT 0x17 240151564Snjl 241151564Snjl/* 242151564Snjl * access: READ WORD 243151564Snjl * unit : mAh (CAPACITY_MODE=0) or 10 mWh (CAPACITY_MODE=1) 244151564Snjl * range : 0..65535 inclusively 245151564Snjl */ 246151564Snjl#define SMBATT_CMD_DESIGN_CAPACITY 0x18 247151564Snjl 248151564Snjl/* 249151564Snjl * access: READ WORD 250151564Snjl * unit : mV 251151564Snjl * range : 0..65535 mV 252151564Snjl */ 253151564Snjl#define SMBATT_CMD_DESIGN_VOLTAGE 0x19 254151564Snjl 255151564Snjl/* access: READ WORD */ 256151564Snjl#define SMBATT_CMD_SPECIFICATION_INFO 0x1a 257151564Snjl 258151564Snjl#define SMBATT_SI_GET_REVISION(x) (((x) >> 0) & 0xf) 259151564Snjl#define SMBATT_SI_GET_VERSION(x) (((x) >> 4) & 0xf) 260151564Snjl#define SMBATT_SI_GET_VSCALE(x) (((x) >> 8) & 0xf) 261151564Snjl#define SMBATT_SI_GET_IPSCALE(x) (((x) >> 12) & 0xf) 262151564Snjl 263151564Snjl/* access: READ WORD */ 264151564Snjl#define SMBATT_CMD_MANUFACTURE_DATE 0x1b 265151564Snjl 266151564Snjl#define SMBATT_MD_GET_DAY(x) (((x) >> 0) & 0x1f) 267151564Snjl#define SMBATT_MD_GET_MONTH(x) (((x) >> 5) & 0xf) 268151564Snjl#define SMBATT_MD_GET_YEAR(x) ((((x) >> 9) & 0x7f) + 1980) 269151564Snjl 270151564Snjl/* access: READ WORD */ 271151564Snjl#define SMBATT_CMD_SERIAL_NUMBER 0x1c 272151564Snjl 273151564Snjl/* access: READ BLOCK */ 274151564Snjl#define SMBATT_CMD_MANUFACTURER_NAME 0x20 275151564Snjl 276151564Snjl/* access: READ BLOCK */ 277151564Snjl#define SMBATT_CMD_DEVICE_NAME 0x21 278151564Snjl 279151564Snjl/* access: READ BLOCK */ 280151564Snjl#define SMBATT_CMD_DEVICE_CHEMISTRY 0x22 281151564Snjl 282151564Snjl/* access: READ BLOCK */ 283151564Snjl#define SMBATT_CMD_MANUFACTURER_DATA 0x23 284151564Snjl 285151564Snjl#endif /* !_ACPI_SMBUS_H_ */ 286