blob: dcbb62b533145c45b7bf14570bc627d9e9c2310f [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Header file for Quanta I2C Battery Driver
2 *
3 * Copyright (C) 2009 Quanta Computer Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16 /*
17 *
18 * The Driver with I/O communications via the I2C Interface for ON2 of AP BU.
19 * And it is only working on the nuvoTon WPCE775x Embedded Controller.
20 *
21 */
22
23#ifndef __QCI_BATTERY_H__
24#define __QCI_BATTERY_H__
25
26#define BAT_I2C_ADDRESS 0x1A
27#define BATTERY_ID_NAME "qci-i2cbat"
28#define EC_FLAG_ADAPTER_IN 0x01
29#define EC_FLAG_POWER_ON 0x02
30#define EC_FLAG_ENTER_S3 0x04
31#define EC_FLAG_ENTER_S4 0x08
32#define EC_FLAG_IN_STANDBY 0x10
33#define EC_FLAG_SYSTEM_ON 0x20
34#define EC_FLAG_WAIT_HWPG 0x40
35#define EC_FLAG_S5_POWER_ON 0x80
36
37#define MAIN_BATTERY_STATUS_BAT_DISCHRG 0x01
38#define MAIN_BATTERY_STATUS_BAT_CHARGING 0x02
39#define MAIN_BATTERY_STATUS_BAT_ABNORMAL 0x04
40#define MAIN_BATTERY_STATUS_BAT_IN 0x08
41#define MAIN_BATTERY_STATUS_BAT_FULL 0x10
42#define MAIN_BATTERY_STATUS_BAT_LOW 0x20
43#define MAIN_BATTERY_STATUS_BAT_SMB_VALID 0x80
44
45#define CHG_STATUS_BAT_CHARGE 0x01
46#define CHG_STATUS_BAT_PRECHG 0x02
47#define CHG_STATUS_BAT_OVERTEMP 0x04
48#define CHG_STATUS_BAT_TYPE 0x08
49#define CHG_STATUS_BAT_GWROK 0x10
50#define CHG_STATUS_BAT_INCHARGE 0x20
51#define CHG_STATUS_BAT_WAKECHRG 0x40
52#define CHG_STATUS_BAT_CHGTIMEOUT 0x80
53
54#define EC_ADAPTER_PRESENT 0x1
55#define EC_BAT_PRESENT 0x1
56#define EC_ADAPTER_NOT_PRESENT 0x0
57#define EC_BAT_NOT_PRESENT 0x0
58
59#define ECRAM_POWER_SOURCE 0x40
60#define ECRAM_CHARGER_ALARM 0x42
61#define ECRAM_BATTERY_STATUS 0x82
62#define ECRAM_BATTERY_CURRENT_LSB 0x83
63#define ECRAM_BATTERY_CURRENT_MSB 0x84
64#define ECRAM_BATTERY_VOLTAGE_LSB 0x87
65#define ECRAM_BATTERY_VOLTAGE_MSB 0x88
66#define ECRAM_BATTERY_CAPACITY 0x89
67#define ECRAM_BATTERY_TEMP_LSB 0x8C
68#define ECRAM_BATTERY_TEMP_MSB 0x8D
69#define ECRAM_BATTERY_EVENTS 0x99
70
71#define EC_EVENT_BATTERY 0x01
72#define EC_EVENT_CHARGER 0x02
73#define EC_EVENT_AC 0x10
74#define EC_EVENT_TIMER 0x40
75
76/* smbus access */
77#define SMBUS_READ_BYTE_PRTCL 0x07
78#define SMBUS_READ_WORD_PRTCL 0x09
79#define SMBUS_READ_BLOCK_PRTCL 0x0B
80
81/* smbus status code */
82#define SMBUS_OK 0x00
83#define SMBUS_DONE 0x80
84#define SMBUS_ALARM 0x40
85#define SMBUS_UNKNOW_FAILURE 0x07
86#define SMBUS_DEVICE_NOACK 0x10
87#define SMBUS_DEVICE_ERROR 0x11
88#define SMBUS_UNKNOW_ERROR 0x13
89#define SMBUS_TIME_OUT 0x18
90#define SMBUS_BUSY 0x1A
91
92/* ec ram mapping */
93#define ECRAM_SMB_PRTCL 0
94#define ECRAM_SMB_STS 1
95#define ECRAM_SMB_ADDR 2
96#define ECRAM_SMB_CMD 3
97#define ECRAM_SMB_DATA_START 4
98#define ECRAM_SMB_DATA0 4
99#define ECRAM_SMB_DATA1 5
100#define ECRAM_SMB_BCNT 36
101#define ECRAM_SMB_ALARM_ADDR 37
102#define ECRAM_SMB_ALARM_DATA0 38
103#define ECRAM_SMB_ALARM_DATA1 39
104
105/* smart battery commands */
106#define BATTERY_SLAVE_ADDRESS 0x16
107#define BATTERY_FULL_CAPACITY 0x10
108#define BATTERY_AVERAGE_TIME_TO_EMPTY 0x12
109#define BATTERY_AVERAGE_TIME_TO_FULL 0x13
110#define BATTERY_CYCLE_COUNT 0x17
111#define BATTERY_DESIGN_CAPACITY 0x18
112#define BATTERY_DESIGN_VOLTAGE 0x19
113#define BATTERY_SERIAL_NUMBER 0x1C
114#define BATTERY_MANUFACTURE_NAME 0x20
115#define BATTERY_DEVICE_NAME 0x21
116
117/* alarm bit */
118#define ALARM_REMAIN_CAPACITY 0x02
119#define ALARM_OVER_TEMP 0x10
120#define ALARM_OVER_CHARGE 0x80
121#endif