blob: 9956cddf0194c1c56a4b1c91b475b8545819662e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
/*
* SM5701_charger.h
* SiliconMitus SM5701 Charger Header
*
* Copyright (C) 2014 SiliconMitus
*
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef __SM5701_CHARGER_H
#define __SM5701_CHARGER_H __FILE__
#include <linux/mfd/core.h>
#include <linux/mfd/sm5701_core.h>
/* SM5701 Registers. */
#define SM5701_INT1 0x00
#define SM5701_INT2 0x01
#define SM5701_INT3 0x02
#define SM5701_INTMASK1 0x03
#define SM5701_INTMASK2 0x04
#define SM5701_INTMASK3 0x05
#define SM5701_STATUS1 0x06
#define SM5701_STATUS2 0x07
#define SM5701_STATUS3 0x08
#define SM5701_CNTL 0x09
#define SM5701_VBUSCNTL 0x0A
#define SM5701_CHGCNTL1 0x0B
#define SM5701_CHGCNTL2 0x0C
#define SM5701_CHGCNTL3 0x0D
#define SM5701_CHGCNTL4 0x0E
#define SM5701_FLEDCNTL1 0x0F
#define SM5701_FLEDCNTL2 0x10
#define SM5701_FLEDCNTL3 0x11
#define SM5701_FLEDCNTL4 0x12
#define SM5701_FLEDCNTL5 0x13
#define SM5701_FLEDCNTL6 0x14
#define SM5701_DEVICE_ID 0x15
#define BATREG_MASK 0x00
//INT1
#define SM5701_INT1_AICL 0x01
#define SM5701_INT1_BATOVP 0x02
#define SM5701_INT1_VBUSOK 0x04
#define SM5701_INT1_VBUSUVLO 0x08
#define SM5701_INT1_VBUSOVP 0x10
#define SM5701_INT1_VBUSLIMIT 0x20
#define SM5701_INT1_CHGRSTF 0x40
#define SM5701_INT1_NOBAT 0x80
//INT2
#define SM5701_INT2_TOPOFF 0x01
#define SM5701_INT2_DONE 0x02
#define SM5701_INT2_FASTTMROFF 0x04
#define SM5701_INT2_CHGON 0x08
//INT3
#define SM5701_INT3_THEMSHDN 0x01
#define SM5701_INT3_THEMREG 0x02
#define SM5701_INT3_FLEDSHORT 0x04
#define SM5701_INT3_FLEDOPEN 0x08
#define SM5701_INT3_BOOSTPOK_NG 0x10
#define SM5701_INT3_BOOSTPOK 0x20
#define SM5701_INT3_AMSTMROFF 0x40
#define SM5701_INT3_LOWBATT 0x80
//INTMSK1
#define SM5701_INTMSK1_AICLM 0x01
#define SM5701_INTMSK1_BATOVPM 0x02
#define SM5701_INTMSK1_VBUSOKM 0x04
#define SM5701_INTMSK1_VBUSUVLOM 0x08
#define SM5701_INTMSK1_VBUSOVPM 0x10
#define SM5701_INTMSK1_VBUSLIMITM 0x20
#define SM5701_INTMSK1_CHGRSTFM 0x40
#define SM5701_INTMSK1_NOBATM 0x80
//INTMSK2
#define SM5701_INTMSK2_TOPOFFM 0x01
#define SM5701_INTMSK2_DONEM 0x02
#define SM5701_INTMSK2_FASTTMROFFM 0x04
#define SM5701_INTMSK2_CHGONM 0x08
//INTMSK3
#define SM5701_INTMSK3_THEMSHDNM 0x01
#define SM5701_INTMSK3_THEMREGM 0x02
#define SM5701_INTMSK3_FLEDSHORTM 0x04
#define SM5701_INTMSK3_FLEDOPENM 0x08
#define SM5701_INTMSK3_BOOSTPOK_NGM 0x10
#define SM5701_INTMSK3_BOOSTPOKM 0x20
#define SM5701_INTMSK3_AMSTMROFFM 0x40
#define SM5701_INTMSK3_LOWBATTM 0x80
//STATUS1
#define SM5701_STATUS1_AICL 0x01
#define SM5701_STATUS1_BATOVP 0x02
#define SM5701_STATUS1_VBUSOK 0x04
#define SM5701_STATUS1_VBUSUVLO 0x08
#define SM5701_STATUS1_VBUSOVP 0x10
#define SM5701_STATUS1_VBUSLIMIT 0x20
#define SM5701_STATUS1_CHGRSTF 0x40
#define SM5701_STATUS1_NOBAT 0x80
//STATUS2
#define SM5701_STATUS2_TOPOFF 0x01
#define SM5701_STATUS2_DONE 0x02
#define SM5701_STATUS2_FASTTMROFF 0x04
#define SM5701_STATUS2_CHGON 0x08
//STATUS3
#define SM5701_STATUS3_THEMSHDN 0x01
#define SM5701_STATUS3_THEMREG 0x02
#define SM5701_STATUS3_FLEDSHORT 0x04
#define SM5701_STATUS3_FLEDOPEN 0x08
#define SM5701_STATUS3_BOOSTPOK_NG 0x10
#define SM5701_STATUS3_BOOSTPOK 0x20
#define SM5701_STATUS3_ABSTMROFF 0x40
#define SM5701_STATUS3_LOWBATT 0x80
//CNTL
#define SM5701_CNTL_OPERATIONMODE 0x07
#define SM5701_CNTL_RESET 0x08
#define SM5701_CNTL_OVPSEL 0x30
#define SM5701_CNTL_FREQSEL 0xc0
#define SM5701_RESET 0x1
//VBUSCNTL
#define SM5701_VBUSCNTL_VBUSLIMIT 0x07
#define SM5701_VBUSCNTL_AICLTH 0x38
#define SM5701_VBUSCNTL_AICLEN 0x40
//CHGCNTL1
#define SM5701_CHGCNTL1_TOPOFF 0x0F
#define SM5701_CHGCNTL1_AUTOSTOP 0x10
#define SM5701_CHGCNTL1_HSSLPCTRL 0x60
//CHGCNTL2
#define SM5701_CHGCNTL2_FASTCHG 0x3F
//CHGCNTL3
#define SM5701_CHGCNTL3_BATREG 0x1F
//CHGCNTL4
#define SM5701_CHGCNTL4_TOPOFFTIMER 0x03
#define SM5701_CHGCNTL4_FASTTIMER 0x0B
#define SM5701_STATUS1_NOBAT_SHIFT 7
/* Enable charger Operation Mode */
#define OP_MODE_CHG_ON 0x02
/* Disable charger Operation Mode */
#define OP_MODE_CHG_OFF 0x01
#define FREQ_15 (0x00 << 6)
#define FREQ_12 (0x01 << 6)
#define FREQ_18 (0x02 << 6)
#define FREQ_24 (0x03 << 6)
enum {
POWER_SUPPLY_VBUS_UNKNOWN = 0,
POWER_SUPPLY_VBUS_UVLO,
POWER_SUPPLY_VBUS_WEAK,
POWER_SUPPLY_VBUS_OVLO,
POWER_SUPPLY_VBUS_GOOD,
};
#endif /* __SM5701_CHARGER_H */
|