Skip to content

Commit a29fb97

Browse files
marigold: control CSIN SINK Discharge (#1057)
when plug-out ac should set 0x39 bit15 for fast discharge until charger response acok level to low. This is to solve the icon side effect issue when theAC is removed. Set charger 0x39 bit15 to "1" to speed up the sink input current. Because there is not set it back to "0", the charger continues to discharge in the AC state, increasing power consumption. The solution proposed by the Power team is that the AC is unplugged, bit15 will be set to "1" first, and then set to "0" when the charger response acok level to low is reached, which can avoid this problem. Signed-off-by: LeoCX_Tsai <LeoCX_Tsai@compal.com> Co-authored-by: Daniel Schaefer <dhs@frame.work>
1 parent 5475270 commit a29fb97

3 files changed

Lines changed: 46 additions & 4 deletions

File tree

zephyr/program/framework/include/marigold/charger.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* Control ACOK by active charger port voltage
1111
*
1212
* @param voltage active port voltage
13+
* @param port active port
1314
*/
14-
void acok_control(int voltage);
15+
void acok_control(int voltage, int port);
1516

1617
#endif /* __CHARGER_H__ */

zephyr/program/framework/marigold/src/charger.c

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static void charger_chips_init(void)
126126

127127
if (i2c_write16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
128128
ISL9241_REG_CONTROL0,
129-
ISL9241_CONTROL0_CSIN_SINK_DISCHARGE))
129+
0x0000))
130130
goto init_fail;
131131

132132
val = ISL9241_CONTROL1_PROCHOT_REF_6800;
@@ -313,10 +313,28 @@ __override void board_hibernate(void)
313313
charge_gate_onoff(0);
314314
}
315315

316-
void acok_control(int voltage)
316+
void acok_control(int voltage, int port)
317317
{
318318
static int pre_acok_data;
319319
int acok_data = 0x00;
320+
int control0 = 0x0000;
321+
322+
/* when detect AC but PD not connect, set BIT15 for fast Discharge */
323+
if (extpower_is_present() && port == -1) {
324+
325+
if (i2c_read16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
326+
ISL9241_REG_CONTROL0, &control0)) {
327+
CPRINTS("ISL9241: read control0 fail");
328+
}
329+
330+
CPRINTS("CSIN SINK Discharge Enable");
331+
control0 |= ISL9241_CONTROL0_CSIN_SINK_DISCHARGE;
332+
333+
if (i2c_write16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
334+
ISL9241_REG_CONTROL0, control0)) {
335+
CPRINTS("ISL9241: Enable CSIN SINK control0 fail");
336+
}
337+
}
320338

321339
if (!charger_psys_enable_flag)
322340
return;
@@ -334,3 +352,26 @@ void acok_control(int voltage)
334352
pre_acok_data = acok_data;
335353
}
336354
}
355+
356+
/* only disable the fast discharge when the acok deasserts */
357+
void disable_fast_discharge(void)
358+
{
359+
int control0 = 0x0000;
360+
361+
if (extpower_is_present())
362+
return;
363+
364+
if (i2c_read16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
365+
ISL9241_REG_CONTROL0, &control0)) {
366+
CPRINTS("ISL9241: read control0 fail");
367+
}
368+
369+
CPRINTS("CSIN SINK Discharge Disable");
370+
control0 &= ~ISL9241_CONTROL0_CSIN_SINK_DISCHARGE;
371+
372+
if (i2c_write16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
373+
ISL9241_REG_CONTROL0, control0)) {
374+
CPRINTS("ISL9241: Disable CSIN SINK control0 fail");
375+
}
376+
}
377+
DECLARE_HOOK(HOOK_AC_CHANGE, disable_fast_discharge, HOOK_PRIO_DEFAULT);

zephyr/program/framework/src/cypd_ccg6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ int board_set_active_charge_port(int charge_port)
300300
hook_call_deferred(&update_power_state_deferred_data, 100 * MSEC);
301301

302302
#ifdef CONFIG_BOARD_MARIGOLD
303-
acok_control(pd_port_states[charge_port].voltage);
303+
acok_control(pd_port_states[charge_port].voltage, charge_port);
304304
#endif /*CONFIG_BOARD_MARIGOLD*/
305305

306306
return EC_SUCCESS;

0 commit comments

Comments
 (0)