Skip to content

Commit da01080

Browse files
Josh-TsaiLeoCX-Tsai
authored andcommitted
lotus: initial the ina236 after the charger initial complete
Signed-off-by: Josh-Tsai <josh_tsai@compal.com>
1 parent 4bfbfdd commit da01080

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

zephyr/program/lotus/lotus/src/charger.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,33 @@ DECLARE_DEFERRED(charger_chips_init_retry);
3737
static void board_check_current(void);
3838
DECLARE_DEFERRED(board_check_current);
3939

40+
static void board_ina236_init(void)
41+
{
42+
int rv;
43+
44+
/* TODO(crosbug.com/p/29730): assume 1mA/LSB, revisit later */
45+
rv = ina2xx_write(0, INA2XX_REG_CALIB, 0x0831);
46+
47+
if (rv != EC_SUCCESS)
48+
CPRINTS("ina236 write calib fail");
49+
50+
rv = ina2xx_write(0, INA2XX_REG_CONFIG, 0x4007);
51+
52+
if (rv != EC_SUCCESS)
53+
CPRINTS("ina236 write config fail");
54+
55+
rv = ina2xx_write(0, INA2XX_REG_ALERT, 0x5DC0);
56+
57+
if (rv != EC_SUCCESS)
58+
CPRINTS("ina236 write alert fail");
59+
60+
rv = ina2xx_write(0, INA2XX_REG_MASK, 0x800A);
61+
62+
if (rv != EC_SUCCESS)
63+
CPRINTS("ina236 write mask fail");
64+
}
65+
66+
4067
static void charger_chips_init(void)
4168
{
4269
int chip;
@@ -110,6 +137,10 @@ static void charger_chips_init(void)
110137
/* TODO: should we need to talk to PD chip after initial complete ? */
111138
hook_call_deferred(&board_check_current_data, 10*MSEC);
112139
CPRINTS("ISL9241 customized initial complete!");
140+
141+
/* Initial the INA236 */
142+
board_ina236_init();
143+
113144
return;
114145

115146
init_fail:

0 commit comments

Comments
 (0)