summaryrefslogtreecommitdiff
path: root/driver/charger/isl9241.h
blob: 0e5acd09df650e8bc797311241cbf76bc222b5a7 (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
/* Copyright 2019 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * Renesas (Intersil) ISL-9241 battery charger driver header.
 */

#ifndef __CROS_EC_ISL9241_H
#define __CROS_EC_ISL9241_H

#include "driver/charger/isl9241_public.h"

#define CHARGER_NAME	"ISL9241"
#define CHARGE_V_MAX	18304
#define CHARGE_V_MIN	64
#define CHARGE_V_STEP	8
#define CHARGE_I_MAX	6140
#define CHARGE_I_MIN	4
#define CHARGE_I_STEP	4
#define INPUT_I_MAX	6140
#define INPUT_I_MIN	4
#define	INPUT_I_STEP	4

/* Registers */

/*
 * ChargeCurrentLimit [12:2] 11-bit (0x0000h = disables fast charging,
 * trickle charging is allowed)
 */
#define ISL9241_REG_CHG_CURRENT_LIMIT	0x14

/* MaxSystemVoltage [14:3] 12-bit, (0x0000h = disables switching) */
#define ISL9241_REG_MAX_SYSTEM_VOLTAGE	0x15

#define ISL9241_REG_CONTROL7		0x38

/* Configures various charger options */
#define ISL9241_REG_CONTROL0		0x39
/* 2: Input Voltage Regulation (0 = Enable (default), 1 = Disable) */
#define ISL9241_CONTROL0_INPUT_VTG_REGULATION	BIT(2)


#define ISL9241_REG_INFORMATION1	0x3A
#define ISL9241_REG_ADAPTER_CUR_LIMIT2	0x3B

/* Configures various charger options */
#define ISL9241_REG_CONTROL1		0x3C
#define ISL9241_CONTROL1_PSYS		BIT(3)
#define ISL9241_CONTROL1_LEARN_MODE	BIT(12)
/*
 * 9:7 - Switching Frequency
 */
#define ISL9241_CONTROL1_SWITCHING_FREQ_MASK 0x380
#define ISL9241_CONTROL1_SWITCHING_FREQ_1420KHZ 0
#define ISL9241_CONTROL1_SWITCHING_FREQ_1180KHZ 1
#define ISL9241_CONTROL1_SWITCHING_FREQ_1020KHZ 2
#define ISL9241_CONTROL1_SWITCHING_FREQ_890KHZ  3
#define ISL9241_CONTROL1_SWITCHING_FREQ_808KHZ  4
#define ISL9241_CONTROL1_SWITCHING_FREQ_724KHZ  5
#define ISL9241_CONTROL1_SWITCHING_FREQ_656KHZ  6
#define ISL9241_CONTROL1_SWITCHING_FREQ_600KHZ  7

/* Configures various charger options */
#define ISL9241_REG_CONTROL2		0x3D
/*
 * 15:13 - Trickle Charging Current
 *         <000> 32mA (do not use)
 *         <001> 64mA
 *         <010> 96mA
 *         <011> 128mA (default)
 *         <100> 160mA
 *         <101> 192mA
 *         <110> 224mA
 *         <111> 256mA
 */
#define ISL9241_CONTROL2_TRICKLE_CHG_CURR(curr)	((((curr) >> 5) - 1) << 13)
/* 12 - Two-Level Adapter Current Limit */
#define ISL9241_CONTROL2_TWO_LEVEL_ADP_CURR	BIT(12)
/* 10:9 PROCHOT# debounce time in uS */
#define ISL9241_CONTROL2_PROCHOT_DEBOUNCE_MASK  GENMASK(10, 9)
#define ISL9241_CONTROL2_PROCHOT_DEBOUNCE_500	(2 << 9)
#define ISL9241_CONTROL2_PROCHOT_DEBOUNCE_1000	(3 << 9)

/* MinSystemVoltage [13:6] 8-bit (0x0000h = disables all battery charging) */
#define ISL9241_REG_MIN_SYSTEM_VOLTAGE	0x3E

#define ISL9241_REG_ADAPTER_CUR_LIMIT1	0x3F
#define ISL9241_REG_ACOK_REFERENCE	0x40
#define ISL9241_REG_CONTROL6		0x43
#define ISL9241_REG_AC_PROCHOT		0x47
#define ISL9241_REG_DC_PROCHOT		0x48
#define ISL9241_REG_OTG_VOLTAGE		0x49
#define ISL9241_REG_OTG_CURRENT		0x4A

/* VIN Voltage (ADP Min Voltage) (default 4.096V) */
#define ISL9241_REG_VIN_VOLTAGE		0x4B

/* Configures various charger options */
#define ISL9241_REG_CONTROL3		0x4C
/* 14: ACLIM Reload (0 - reload, 1 - Do not reload */
#define ISL9241_CONTROL3_ACLIM_RELOAD	BIT(14)
/* 2: Digital Reset (0 - Idle, 1 - Reset */
#define ISL9241_CONTROL3_DIGITAL_RESET	BIT(2)
/* 0: Enable ADC (0 - Active when charging, 1 - Active always) */
#define ISL9241_CONTROL3_ENABLE_ADC	BIT(0)

/* Indicates various charger status */
#define ISL9241_REG_INFORMATION2	0x4D
/* 12: BATGONE pin status (0 = Battery is present, 1 = No battery) */
#define ISL9241_INFORMATION2_BATGONE_PIN	BIT(12)
/* 14: ACOK pin status (0 = No adapter, 1 = Adapter is present) */
#define ISL9241_INFORMATION2_ACOK_PIN		BIT(14)

#define ISL9241_REG_CONTROL4		0x4E
/* 11: Rsense (Rs1:Rs2) ratio for PSYS (0 - 2:1, 1 - 1:1) */
#define ISL9241_CONTROL4_PSYS_RSENSE_RATIO  BIT(11)
/* 13: Enable VSYS slew rate control (0 - disable, 1 - enable) */
#define ISL9241_CONTROL4_SLEW_RATE_CTRL     BIT(13)

#define ISL9241_REG_CONTROL5		0x4F
#define ISL9241_REG_NTC_ADC_RESULTS	0x80
#define ISL9241_REG_VBAT_ADC_RESULTS	0x81
#define ISL9241_REG_TJ_ADC_RESULTS	0x82

/* ADC result for adapter current measurements, LSB = 22.2mA */
#define ISL9241_REG_IADP_ADC_RESULTS	0x83

#define ISL9241_REG_DC_ADC_RESULTS	0x84
#define ISL9241_REG_CC_ADC_RESULTS	0x85
#define ISL9241_REG_VSYS_ADC_RESULTS	0x86
#define ISL9241_REG_VIN_ADC_RESULTS	0x87
#define ISL9241_REG_INFORMATION3	0x90
#define ISL9241_REG_INFORMATION4	0x91
#define ISL9241_REG_MANUFACTURER_ID	0xFE
#define ISL9241_REG_DEVICE_ID		0xFF

#define ISL9241_VIN_ADC_BIT_OFFSET	6
#define ISL9241_VIN_ADC_STEP_MV		96

#endif /* __CROS_EC_ISL9241_H */