2 * Fuel gauge driver for Maxim 17042 / 8966 / 8997
3 * Note that Maxim 8966 and 8997 are mfd and this is its subdevice.
5 * Copyright (C) 2011 Samsung Electronics
6 * MyungJoo Ham <myungjoo.ham@samsung.com>
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.
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.
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
23 #ifndef __MAX17042_BATTERY_H_
24 #define __MAX17042_BATTERY_H_
26 #define MAX17042_STATUS_BattAbsent (1 << 3)
27 #define MAX17042_BATTERY_FULL (95) /* Recommend. FullSOCThr value */
28 #define MAX17042_DEFAULT_SNS_RESISTOR (10000)
29 #define MAX17042_DEFAULT_VMIN (3000)
30 #define MAX17042_DEFAULT_VMAX (4500) /* LiHV cell max */
31 #define MAX17042_DEFAULT_TEMP_MIN (0) /* For sys without temp sensor */
32 #define MAX17042_DEFAULT_TEMP_MAX (700) /* 70 degrees Celcius */
34 /* Consider RepCap which is less then 10 units below FullCAP full */
35 #define MAX17042_FULL_THRESHOLD 10
37 #define MAX17042_CHARACTERIZATION_DATA_SIZE 48
39 enum max17042_register
{
40 MAX17042_STATUS
= 0x00,
41 MAX17042_VALRT_Th
= 0x01,
42 MAX17042_TALRT_Th
= 0x02,
43 MAX17042_SALRT_Th
= 0x03,
44 MAX17042_AtRate
= 0x04,
45 MAX17042_RepCap
= 0x05,
46 MAX17042_RepSOC
= 0x06,
49 MAX17042_VCELL
= 0x09,
50 MAX17042_Current
= 0x0A,
51 MAX17042_AvgCurrent
= 0x0B,
54 MAX17042_AvSOC
= 0x0E,
55 MAX17042_RemCap
= 0x0F,
56 MAX17042_FullCAP
= 0x10,
58 MAX17042_V_empty
= 0x12,
60 MAX17042_RSLOW
= 0x14,
62 MAX17042_AvgTA
= 0x16,
63 MAX17042_Cycles
= 0x17,
64 MAX17042_DesignCap
= 0x18,
65 MAX17042_AvgVCELL
= 0x19,
66 MAX17042_MinMaxTemp
= 0x1A,
67 MAX17042_MinMaxVolt
= 0x1B,
68 MAX17042_MinMaxCurr
= 0x1C,
69 MAX17042_CONFIG
= 0x1D,
70 MAX17042_ICHGTerm
= 0x1E,
71 MAX17042_AvCap
= 0x1F,
72 MAX17042_ManName
= 0x20,
73 MAX17042_DevName
= 0x21,
75 MAX17042_FullCAPNom
= 0x23,
76 MAX17042_TempNom
= 0x24,
77 MAX17042_TempLim
= 0x25,
78 MAX17042_TempHot
= 0x26,
80 MAX17042_LearnCFG
= 0x28,
81 MAX17042_FilterCFG
= 0x29,
82 MAX17042_RelaxCFG
= 0x2A,
83 MAX17042_MiscCFG
= 0x2B,
84 MAX17042_TGAIN
= 0x2C,
86 MAX17042_CGAIN
= 0x2E,
89 MAX17042_MaskSOC
= 0x32,
90 MAX17042_SOC_empty
= 0x33,
91 MAX17042_T_empty
= 0x34,
93 MAX17042_FullCAP0
= 0x35,
94 MAX17042_LAvg_empty
= 0x36,
96 MAX17042_RCOMP0
= 0x38,
97 MAX17042_TempCo
= 0x39,
98 MAX17042_EmptyTempCo
= 0x3A,
99 MAX17042_K_empty0
= 0x3B,
100 MAX17042_TaskPeriod
= 0x3C,
101 MAX17042_FSTAT
= 0x3D,
103 MAX17042_SHDNTIMER
= 0x3F,
105 MAX17042_dQacc
= 0x45,
106 MAX17042_dPacc
= 0x46,
108 MAX17042_VFSOC0
= 0x48,
113 MAX17042_VFSOC0Enable
= 0x60,
114 MAX17042_MLOCKReg1
= 0x62,
115 MAX17042_MLOCKReg2
= 0x63,
117 MAX17042_MODELChrTbl
= 0x80,
121 MAX17042_OCVInternal
= 0xFB,
123 MAX17042_VFSOC
= 0xFF,
126 /* Registers specific to max17047/50 */
127 enum max17047_register
{
128 MAX17047_QRTbl00
= 0x12,
129 MAX17047_FullSOCThr
= 0x13,
130 MAX17047_QRTbl10
= 0x22,
131 MAX17047_QRTbl20
= 0x32,
132 MAX17047_V_empty
= 0x3A,
133 MAX17047_QRTbl30
= 0x42,
136 enum max170xx_chip_type
{
137 MAXIM_DEVICE_TYPE_UNKNOWN
= 0,
138 MAXIM_DEVICE_TYPE_MAX17042
,
139 MAXIM_DEVICE_TYPE_MAX17047
,
140 MAXIM_DEVICE_TYPE_MAX17050
,
142 MAXIM_DEVICE_TYPE_NUM
146 * used for setting a register to a desired value
147 * addr : address for a register
148 * data : setting value for the register
150 struct max17042_reg_data
{
155 struct max17042_config_data
{
156 /* External current sense resistor value in milli-ohms */
159 /* A/D measurement */
160 u16 tgain
; /* 0x2C */
162 u16 cgain
; /* 0x2E */
166 u16 valrt_thresh
; /* 0x01 */
167 u16 talrt_thresh
; /* 0x02 */
168 u16 soc_alrt_thresh
; /* 0x03 */
169 u16 config
; /* 0x01D */
170 u16 shdntimer
; /* 0x03F */
173 u16 full_soc_thresh
; /* 0x13 */
174 u16 design_cap
; /* 0x18 */
175 u16 ichgt_term
; /* 0x1E */
178 u16 at_rate
; /* 0x04 */
179 u16 learn_cfg
; /* 0x28 */
180 u16 filter_cfg
; /* 0x29 */
181 u16 relax_cfg
; /* 0x2A */
182 u16 misc_cfg
; /* 0x2B */
183 u16 masksoc
; /* 0x32 */
185 /* MG3 save and restore */
186 u16 fullcap
; /* 0x10 */
187 u16 fullcapnom
; /* 0x23 */
188 u16 socempty
; /* 0x33 */
189 u16 lavg_empty
; /* 0x36 */
190 u16 dqacc
; /* 0x45 */
191 u16 dpacc
; /* 0x46 */
192 u16 qrtbl00
; /* 0x12 */
193 u16 qrtbl10
; /* 0x22 */
194 u16 qrtbl20
; /* 0x32 */
195 u16 qrtbl30
; /* 0x42 */
197 /* Cell technology from power_supply.h */
201 u16 vempty
; /* 0x12 */
202 u16 temp_nom
; /* 0x24 */
203 u16 temp_lim
; /* 0x25 */
205 u16 rcomp0
; /* 0x38 */
206 u16 tcompc0
; /* 0x39 */
207 u16 empty_tempco
; /* 0x3A */
208 u16 kempty0
; /* 0x3B */
209 u16 cell_char_tbl
[MAX17042_CHARACTERIZATION_DATA_SIZE
];
212 struct max17042_platform_data
{
213 struct max17042_reg_data
*init_data
;
214 struct max17042_config_data
*config_data
;
215 int num_init_data
; /* Number of enties in init_data array */
216 bool enable_current_sense
;
217 bool enable_por_init
; /* Use POR init from Maxim appnote */
220 * R_sns in micro-ohms.
221 * default 10000 (if r_sns = 0) as it is the recommended value by
222 * the datasheet although it can be changed by board designers.
225 int vmin
; /* in millivolts */
226 int vmax
; /* in millivolts */
227 int temp_min
; /* in tenths of degree Celsius */
228 int temp_max
; /* in tenths of degree Celsius */
231 #endif /* __MAX17042_BATTERY_H_ */