blob: 67eeada71073bfef1c53fc495d2f3eed00476bfc [file] [log] [blame]
MyungJoo Ham359ab9f2011-01-14 14:46:11 +09001/*
2 * Fuel gauge driver for Maxim 17042 / 8966 / 8997
3 * Note that Maxim 8966 and 8997 are mfd and this is its subdevice.
4 *
5 * Copyright (C) 2011 Samsung Electronics
6 * MyungJoo Ham <myungjoo.ham@samsung.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef __MAX17042_BATTERY_H_
24#define __MAX17042_BATTERY_H_
25
Donggeun Kim086ef502011-06-30 18:07:41 +090026#define MAX17042_STATUS_BattAbsent (1 << 3)
27#define MAX17042_BATTERY_FULL (100)
28#define MAX17042_DEFAULT_SNS_RESISTOR (10000)
29
30enum max17042_register {
31 MAX17042_STATUS = 0x00,
32 MAX17042_VALRT_Th = 0x01,
33 MAX17042_TALRT_Th = 0x02,
34 MAX17042_SALRT_Th = 0x03,
35 MAX17042_AtRate = 0x04,
36 MAX17042_RepCap = 0x05,
37 MAX17042_RepSOC = 0x06,
38 MAX17042_Age = 0x07,
39 MAX17042_TEMP = 0x08,
40 MAX17042_VCELL = 0x09,
41 MAX17042_Current = 0x0A,
42 MAX17042_AvgCurrent = 0x0B,
Dirk Brandewief42c2b42012-01-24 09:26:04 -080043
Donggeun Kim086ef502011-06-30 18:07:41 +090044 MAX17042_SOC = 0x0D,
45 MAX17042_AvSOC = 0x0E,
46 MAX17042_RemCap = 0x0F,
Dirk Brandewief42c2b42012-01-24 09:26:04 -080047 MAX17042_FullCAP = 0x10,
Donggeun Kim086ef502011-06-30 18:07:41 +090048 MAX17042_TTE = 0x11,
49 MAX17042_V_empty = 0x12,
50
51 MAX17042_RSLOW = 0x14,
52
53 MAX17042_AvgTA = 0x16,
54 MAX17042_Cycles = 0x17,
55 MAX17042_DesignCap = 0x18,
56 MAX17042_AvgVCELL = 0x19,
57 MAX17042_MinMaxTemp = 0x1A,
58 MAX17042_MinMaxVolt = 0x1B,
59 MAX17042_MinMaxCurr = 0x1C,
60 MAX17042_CONFIG = 0x1D,
61 MAX17042_ICHGTerm = 0x1E,
62 MAX17042_AvCap = 0x1F,
63 MAX17042_ManName = 0x20,
64 MAX17042_DevName = 0x21,
Donggeun Kim086ef502011-06-30 18:07:41 +090065
Dirk Brandewief42c2b42012-01-24 09:26:04 -080066 MAX17042_FullCAPNom = 0x23,
Donggeun Kim086ef502011-06-30 18:07:41 +090067 MAX17042_TempNom = 0x24,
Dirk Brandewief42c2b42012-01-24 09:26:04 -080068 MAX17042_TempLim = 0x25,
Donggeun Kim086ef502011-06-30 18:07:41 +090069 MAX17042_TempHot = 0x26,
70 MAX17042_AIN = 0x27,
71 MAX17042_LearnCFG = 0x28,
Dirk Brandewief42c2b42012-01-24 09:26:04 -080072 MAX17042_FilterCFG = 0x29,
Donggeun Kim086ef502011-06-30 18:07:41 +090073 MAX17042_RelaxCFG = 0x2A,
74 MAX17042_MiscCFG = 0x2B,
75 MAX17042_TGAIN = 0x2C,
76 MAx17042_TOFF = 0x2D,
77 MAX17042_CGAIN = 0x2E,
78 MAX17042_COFF = 0x2F,
79
Dirk Brandewief42c2b42012-01-24 09:26:04 -080080 MAX17042_MaskSOC = 0x32,
81 MAX17042_SOC_empty = 0x33,
Donggeun Kim086ef502011-06-30 18:07:41 +090082 MAX17042_T_empty = 0x34,
83
Dirk Brandewief42c2b42012-01-24 09:26:04 -080084 MAX17042_FullCAP0 = 0x35,
85 MAX17042_LAvg_empty = 0x36,
86 MAX17042_FCTC = 0x37,
Donggeun Kim086ef502011-06-30 18:07:41 +090087 MAX17042_RCOMP0 = 0x38,
88 MAX17042_TempCo = 0x39,
Dirk Brandewief42c2b42012-01-24 09:26:04 -080089 MAX17042_EmptyTempCo = 0x3A,
90 MAX17042_K_empty0 = 0x3B,
Donggeun Kim086ef502011-06-30 18:07:41 +090091 MAX17042_TaskPeriod = 0x3C,
92 MAX17042_FSTAT = 0x3D,
93
94 MAX17042_SHDNTIMER = 0x3F,
95
Dirk Brandewief42c2b42012-01-24 09:26:04 -080096 MAX17042_dQacc = 0x45,
97 MAX17042_dPacc = 0x46,
98
99 MAX17042_VFSOC0 = 0x48,
Donggeun Kim086ef502011-06-30 18:07:41 +0900100
101 MAX17042_QH = 0x4D,
102 MAX17042_QL = 0x4E,
Dirk Brandewief42c2b42012-01-24 09:26:04 -0800103
104 MAX17042_VFSOC0Enable = 0x60,
105 MAX17042_MLOCKReg1 = 0x62,
106 MAX17042_MLOCKReg2 = 0x63,
107
108 MAX17042_MODELChrTbl = 0x80,
109
110 MAX17042_OCV = 0xEE,
111
112 MAX17042_OCVInternal = 0xFB,
113
114 MAX17042_VFSOC = 0xFF,
Donggeun Kim086ef502011-06-30 18:07:41 +0900115};
116
117/*
118 * used for setting a register to a desired value
119 * addr : address for a register
120 * data : setting value for the register
121 */
122struct max17042_reg_data {
123 u8 addr;
124 u16 data;
125};
126
MyungJoo Ham359ab9f2011-01-14 14:46:11 +0900127struct max17042_platform_data {
Donggeun Kim086ef502011-06-30 18:07:41 +0900128 struct max17042_reg_data *init_data;
129 int num_init_data; /* Number of enties in init_data array */
MyungJoo Ham359ab9f2011-01-14 14:46:11 +0900130 bool enable_current_sense;
Donggeun Kim086ef502011-06-30 18:07:41 +0900131
132 /*
133 * R_sns in micro-ohms.
134 * default 10000 (if r_sns = 0) as it is the recommended value by
135 * the datasheet although it can be changed by board designers.
136 */
137 unsigned int r_sns;
MyungJoo Ham359ab9f2011-01-14 14:46:11 +0900138};
139
140#endif /* __MAX17042_BATTERY_H_ */