Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/power/max17050.h
1476 views
1
/*
2
* Fuel gauge driver for Nintendo Switch's Maxim 17050
3
*
4
* Copyright (c) 2011 Samsung Electronics
5
* MyungJoo Ham <[email protected]>
6
* Copyright (c) 2018-2020 CTCaer
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 __MAX17050_H_
24
#define __MAX17050_H_
25
26
#include <utils/types.h>
27
28
/* Board default values */
29
#define MAX17050_BOARD_CGAIN 2 /* Actual: 1.99993 */
30
#define MAX17050_BOARD_SNS_RESISTOR_UOHM 5000 /* 0.005 Ohm */
31
32
#define MAX17050_STATUS_BattAbsent BIT(3)
33
34
/* Consider RepCap which is less then 10 units below FullCAP full */
35
#define MAX17050_FULL_THRESHOLD 10
36
37
#define MAX17050_CHARACTERIZATION_DATA_SIZE 48
38
39
#define MAXIM17050_I2C_ADDR 0x36
40
41
enum MAX17050_reg {
42
MAX17050_STATUS = 0x00,
43
MAX17050_VALRT_Th = 0x01,
44
MAX17050_TALRT_Th = 0x02,
45
MAX17050_SALRT_Th = 0x03,
46
MAX17050_AtRate = 0x04,
47
MAX17050_RepCap = 0x05,
48
MAX17050_RepSOC = 0x06,
49
MAX17050_Age = 0x07,
50
MAX17050_TEMP = 0x08,
51
MAX17050_VCELL = 0x09,
52
MAX17050_Current = 0x0A,
53
MAX17050_AvgCurrent = 0x0B,
54
55
MAX17050_SOC = 0x0D,
56
MAX17050_AvSOC = 0x0E,
57
MAX17050_RemCap = 0x0F,
58
MAX17050_FullCAP = 0x10,
59
MAX17050_TTE = 0x11,
60
MAX17050_QRTbl00 = 0x12,
61
MAX17050_FullSOCThr = 0x13,
62
MAX17050_RSLOW = 0x14,
63
64
MAX17050_AvgTA = 0x16,
65
MAX17050_Cycles = 0x17,
66
MAX17050_DesignCap = 0x18,
67
MAX17050_AvgVCELL = 0x19,
68
MAX17050_MinMaxTemp = 0x1A,
69
MAX17050_MinMaxVolt = 0x1B,
70
MAX17050_MinMaxCurr = 0x1C,
71
MAX17050_CONFIG = 0x1D,
72
MAX17050_ICHGTerm = 0x1E,
73
MAX17050_AvCap = 0x1F,
74
MAX17050_ManName = 0x20,
75
MAX17050_DevName = 0x21,
76
MAX17050_QRTbl10 = 0x22,
77
MAX17050_FullCAPNom = 0x23,
78
MAX17050_TempNom = 0x24,
79
MAX17050_TempLim = 0x25,
80
MAX17050_TempHot = 0x26,
81
MAX17050_AIN = 0x27,
82
MAX17050_LearnCFG = 0x28,
83
MAX17050_FilterCFG = 0x29,
84
MAX17050_RelaxCFG = 0x2A,
85
MAX17050_MiscCFG = 0x2B,
86
MAX17050_TGAIN = 0x2C,
87
MAX17050_TOFF = 0x2D,
88
MAX17050_CGAIN = 0x2E,
89
MAX17050_COFF = 0x2F,
90
91
MAX17050_QRTbl20 = 0x32,
92
MAX17050_SOC_empty = 0x33,
93
MAX17050_T_empty = 0x34,
94
MAX17050_FullCAP0 = 0x35,
95
MAX17050_LAvg_empty = 0x36,
96
MAX17050_FCTC = 0x37,
97
MAX17050_RCOMP0 = 0x38,
98
MAX17050_TempCo = 0x39,
99
MAX17050_V_empty = 0x3A,
100
MAX17050_K_empty0 = 0x3B,
101
MAX17050_TaskPeriod = 0x3C,
102
MAX17050_FSTAT = 0x3D,
103
MAX17050_TIMER = 0x3E,
104
MAX17050_SHDNTIMER = 0x3F,
105
106
MAX17050_QRTbl30 = 0x42,
107
108
MAX17050_dQacc = 0x45,
109
MAX17050_dPacc = 0x46,
110
111
MAX17050_VFSOC0 = 0x48,
112
113
Max17050_QH0 = 0x4C,
114
MAX17050_QH = 0x4D,
115
MAX17050_QL = 0x4E,
116
117
MAX17050_MinVolt = 0x50, // Custom ID. Not to be sent to i2c.
118
MAX17050_MaxVolt = 0x51, // Custom ID. Not to be sent to i2c.
119
120
MAX17050_VFSOC0Enable = 0x60,
121
MAX17050_MODELEnable1 = 0x62,
122
MAX17050_MODELEnable2 = 0x63,
123
124
MAX17050_MODELChrTbl = 0x80,
125
126
MAX17050_OCV = 0xEE,
127
128
MAX17050_OCVInternal = 0xFB,
129
130
MAX17050_VFSOC = 0xFF,
131
};
132
133
int max17050_get_property(enum MAX17050_reg reg, int *value);
134
int max17050_fix_configuration();
135
void max17050_dump_regs(void *buf);
136
u32 max17050_get_cached_batt_volt();
137
138
#endif /* __MAX17050_H_ */
139
140