xref: /openbmc/u-boot/include/power/max17042_fg.h (revision 1a68faac)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  *  Copyright (C) 2012 Samsung Electronics
4  *  Lukasz Majewski <l.majewski@samsung.com>
5  */
6 
7 #ifndef __MAX17042_FG_H_
8 #define __MAX17042_FG_H_
9 
10 /* MAX 17042 registers */
11 enum {
12 	MAX17042_STATUS         = 0x00,
13 	MAX17042_SOCREP         = 0x06,
14 	MAX17042_VCELL          = 0x09,
15 	MAX17042_CURRENT        = 0x0A,
16 	MAX17042_AVG_CURRENT	= 0x0B,
17 	MAX17042_SOCMIX	= 0x0D,
18 	MAX17042_SOCAV		= 0x0E,
19 	MAX17042_DESIGN_CAP	= 0x18,
20 	MAX17042_AVG_VCELL	= 0x19,
21 	MAX17042_CONFIG	= 0x1D,
22 	MAX17042_VERSION	= 0x21,
23 	MAX17042_LEARNCFG       = 0x28,
24 	MAX17042_FILTERCFG	= 0x29,
25 	MAX17042_RELAXCFG	= 0x2A,
26 	MAX17042_MISCCFG	= 0x2B,
27 	MAX17042_CGAIN		= 0x2E,
28 	MAX17042_COFF		= 0x2F,
29 	MAX17042_RCOMP0	= 0x38,
30 	MAX17042_TEMPCO	= 0x39,
31 	MAX17042_FSTAT		= 0x3D,
32 	MAX17042_MLOCKReg1	= 0x62,
33 	MAX17042_MLOCKReg2	= 0x63,
34 	MAX17042_MODEL1         = 0x80,
35 	MAX17042_MODEL2         = 0x90,
36 	MAX17042_MODEL3         = 0xA0,
37 	MAX17042_VFOCV		= 0xFB,
38 	MAX17042_VFSOC		= 0xFF,
39 
40 	FG_NUM_OF_REGS = 0x100,
41 };
42 
43 #define RCOMP0			0x0060
44 #define TempCo			0x1015
45 
46 
47 #define MAX17042_POR (1 << 1)
48 
49 #define MODEL_UNLOCK1		0x0059
50 #define MODEL_UNLOCK2		0x00c4
51 #define MODEL_LOCK1		0x0000
52 #define MODEL_LOCK2		0x0000
53 
54 #define MAX17042_I2C_ADDR	(0x6C >> 1)
55 
56 int power_fg_init(unsigned char bus);
57 #endif /* __MAX17042_FG_H_ */
58