Skip to content

Commit 5bd3e6f

Browse files
LeoCX-Tsaiquinchou77
authored andcommitted
fwk: isl9241: save bypass mode status
split from PR941 ensure we can use correct charger mode if the mode change(Bypass <-> NVDC switch) BRANCH=fwk-tulip-29169 BUG=None TEST=None Signed-off-by: LeoCX_Tsai <LeoCX_Tsai@compal.com>
1 parent 21dd6f6 commit 5bd3e6f

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

driver/charger/isl9241.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,13 @@ static enum ec_error_list isl9241_rtb_chrg_to_rtb(int chgnum)
11151115
}
11161116
#endif
11171117

1118+
static bool isl9241_in_bypass_mode;
1119+
1120+
bool isl9241_is_in_bypass_mode(int chgnum)
1121+
{
1122+
return isl9241_in_bypass_mode;
1123+
}
1124+
11181125
static enum ec_error_list isl9241_enable_bypass_mode(int chgnum, bool enable)
11191126
{
11201127
enum ec_error_list rv = EC_ERROR_UNKNOWN;
@@ -1170,6 +1177,9 @@ static enum ec_error_list isl9241_enable_bypass_mode(int chgnum, bool enable)
11701177
CPRINTS("bypass -> RTB failed(%d)", rv);
11711178
}
11721179
#endif
1180+
if (rv == EC_SUCCESS) {
1181+
isl9241_in_bypass_mode = true;
1182+
}
11731183
return rv;
11741184
}
11751185

@@ -1180,7 +1190,7 @@ static enum ec_error_list isl9241_enable_bypass_mode(int chgnum, bool enable)
11801190

11811191
rv = isl9241_read(chgnum, ISL9241_REG_CONTROL0, &reg);
11821192
if ((reg & ISL9241_CONTROL0_EN_BYPASS_GATE) != ISL9241_CONTROL0_EN_BYPASS_GATE) {
1183-
CPRINTS("Does not in bypass mode, ignore change");
1193+
CPRINTS("Not in bypass mode, ignore change");
11841194
return rv;
11851195
}
11861196

@@ -1202,6 +1212,10 @@ static enum ec_error_list isl9241_enable_bypass_mode(int chgnum, bool enable)
12021212
rv = isl9241_bypass_to_nvdc(chgnum);
12031213
if (rv)
12041214
CPRINTS("bypass -> nvdc failed(%d)", rv);
1215+
1216+
if (rv == EC_SUCCESS) {
1217+
isl9241_in_bypass_mode = false;
1218+
}
12051219
return rv;
12061220
} else {
12071221
/* AC removal */
@@ -1216,11 +1230,23 @@ static enum ec_error_list isl9241_enable_bypass_mode(int chgnum, bool enable)
12161230
if (rv)
12171231
CPRINTS("bypass -> bat failed(%d)", rv);
12181232
}
1233+
1234+
if (rv == EC_SUCCESS) {
1235+
isl9241_in_bypass_mode = false;
1236+
}
1237+
12191238
return rv;
12201239
}
12211240

12221241
return rv;
12231242
}
1243+
#else
1244+
1245+
bool isl9241_is_in_bypass_mode(int chgnum)
1246+
{
1247+
return false;
1248+
}
1249+
12241250
#endif /* CONFIG_CHARGER_BYPASS_MODE */
12251251

12261252
/*****************************************************************************/

include/driver/charger/isl9241_public.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ int isl9241_set_ac_prochot(int chgnum, int ma);
3333
*/
3434
int isl9241_set_dc_prochot(int chgnum, int ma);
3535

36+
/**
37+
* Check if charger is currently in bypass mode
38+
*
39+
* @return true/false
40+
*/
41+
bool isl9241_is_in_bypass_mode(int chgnum);
42+
3643
#ifdef CONFIG_CHARGER_RAA489110
3744
#define ISL9241_AC_PROCHOT_CURRENT_MIN 32 /* mA */
3845
#else /* CONFIG_CHARGER_ISL9241 */

0 commit comments

Comments
 (0)