Skip to content

Commit 8109392

Browse files
authored
Merge pull request #413 from FrameworkComputer/s5_power
[modify] control charger psys and acok reference
2 parents 78b8e29 + 05d1a55 commit 8109392

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

board/hx20/board.c

+53-1
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,56 @@ static void check_chassis_open(int init)
496496
}
497497
}
498498

499+
void charge_psys_onoff(uint8_t enable)
500+
{
501+
int control0 = 0x0000;
502+
int control1 = 0x0000;
503+
int control4 = 0x0000;
504+
int data = 0x0000;
505+
506+
if (i2c_read16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
507+
ISL9241_REG_CONTROL1, &control1)) {
508+
CPRINTS("read charger control1 fail");
509+
}
510+
511+
if (enable) {
512+
control0 &= ~ISL9241_CONTROL0_NGATE;
513+
control1 &= ~(ISL9241_CONTROL1_IMON | ISL9241_CONTROL1_BGATE);
514+
control1 |= ISL9241_CONTROL1_PSYS;
515+
control4 &= ~ISL9241_CONTROL4_GP_COMPARATOR;
516+
data = 0x0B00;
517+
CPRINTS("Power saving disable");
518+
} else {
519+
control0 |= ISL9241_CONTROL0_NGATE;
520+
control1 |= (ISL9241_CONTROL1_IMON | ISL9241_CONTROL1_BGATE);
521+
control1 &= ~ISL9241_CONTROL1_PSYS;
522+
control4 |= ISL9241_CONTROL4_GP_COMPARATOR;
523+
data = 0x0000;
524+
CPRINTS("Power saving enable");
525+
}
526+
527+
528+
if (i2c_write16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
529+
ISL9241_REG_ACOK_REFERENCE, data)) {
530+
CPRINTS("Update charger ACOK reference fail");
531+
}
532+
533+
if (i2c_write16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
534+
ISL9241_REG_CONTROL0, control0)) {
535+
CPRINTS("Update charger control0 fail");
536+
}
537+
538+
if (i2c_write16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
539+
ISL9241_REG_CONTROL1, control1)) {
540+
CPRINTS("Update charger control1 fail");
541+
}
542+
543+
if (i2c_write16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
544+
ISL9241_REG_CONTROL4, control4)) {
545+
CPRINTS("Update charger control4 fail");
546+
}
547+
}
548+
499549
/* Initialize board. */
500550
static void board_init(void)
501551
{
@@ -529,6 +579,7 @@ static void board_chipset_startup(void)
529579
if (version > 6)
530580
gpio_set_level(GPIO_EN_INVPWR, 1);
531581

582+
charge_psys_onoff(1);
532583
}
533584
DECLARE_HOOK(HOOK_CHIPSET_STARTUP,
534585
board_chipset_startup,
@@ -547,6 +598,7 @@ static void board_chipset_shutdown(void)
547598
if (version > 6)
548599
gpio_set_level(GPIO_EN_INVPWR, 0);
549600

601+
charge_psys_onoff(0);
550602
}
551603
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN,
552604
board_chipset_shutdown,
@@ -783,7 +835,7 @@ void charger_update(void)
783835
CPRINTS("update charger!!");
784836

785837
val = ISL9241_CONTROL1_PROCHOT_REF_6800 |
786-
ISL9241_CONTROL1_SWITCH_FREQ | ISL9241_CONTROL1_PSYS;
838+
ISL9241_CONTROL1_SWITCH_FREQ;
787839

788840
if (i2c_write16(I2C_PORT_CHARGER, ISL9241_ADDR_FLAGS,
789841
ISL9241_REG_CONTROL1, val)) {

driver/charger/isl9241.h

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#define ISL9241_REG_CONTROL0 0x39
4242
/* 2: Input Voltage Regulation (0 = Enable (default), 1 = Disable) */
4343
#define ISL9241_CONTROL0_INPUT_VTG_REGULATION BIT(2)
44+
#define ISL9241_CONTROL0_NGATE BIT(12)
4445

4546

4647
#define ISL9241_REG_INFORMATION1 0x3A
@@ -52,6 +53,8 @@
5253
#define ISL9241_CONTROL1_PROCHOT_REF_6800 (7 << 0)
5354
#define ISL9241_CONTROL1_SWITCH_FREQ (5 << 7)
5455
#define ISL9241_CONTROL1_PSYS BIT(3)
56+
#define ISL9241_CONTROL1_IMON BIT(5)
57+
#define ISL9241_CONTROL1_BGATE BIT(6)
5558
#define ISL9241_CONTROL1_SUPPLEMENTAL_SUPPORT_MODE BIT(10)
5659

5760
/* Configures various charger options */
@@ -112,6 +115,7 @@
112115
/* 13: Enable VSYS slew rate control (0 - disable, 1 - enable) */
113116
#define ISL9241_CONTROL4_ACOK_PROCHOT BIT(5)
114117
#define ISL9241_CONTROL4_OTG_CURR_PROCHOT BIT(7)
118+
#define ISL9241_CONTROL4_GP_COMPARATOR BIT(12)
115119
#define ISL9241_CONTROL4_SLEW_RATE_CTRL BIT(13)
116120

117121
#define ISL9241_REG_CONTROL5 0x4F

0 commit comments

Comments
 (0)