diff options
-rw-r--r-- | driver/ln9310.c | 49 | ||||
-rw-r--r-- | driver/ln9310.h | 16 |
2 files changed, 61 insertions, 4 deletions
diff --git a/driver/ln9310.c b/driver/ln9310.c index 93ee7973b4..48992f73b8 100644 --- a/driver/ln9310.c +++ b/driver/ln9310.c @@ -121,8 +121,8 @@ static int ln9310_update_startup_seq(void) /* Startup sequence instruction swap */ field_update8(LN9310_REG_LION_CTRL, - 0xff, - 0xaa); + LN9310_LION_CTRL_MASK, + LN9310_LION_CTRL_UNLOCK); field_update8(LN9310_REG_SWAP_CTRL_0, 0xff, @@ -156,8 +156,8 @@ static int ln9310_update_startup_seq(void) field_update8(LN9310_REG_LION_CTRL, - 0xff, - 0x00); + LN9310_LION_CTRL_MASK, + LN9310_LION_CTRL_LOCK); return EC_SUCCESS; } @@ -233,11 +233,52 @@ static int ln9310_init_2to1(void) return EC_SUCCESS; } +static int ln9310_update_infet(void) +{ + CPRINTS("LN9310 update infet configuration"); + + + field_update8(LN9310_REG_LION_CTRL, + LN9310_LION_CTRL_MASK, + LN9310_LION_CTRL_UNLOCK); + + /* Update Infet register settings */ + field_update8(LN9310_REG_CFG_5, + LN9310_CFG_5_INGATE_PD_EN_MASK, + LN9310_CFG_5_INGATE_PD_EN_OFF); + + field_update8(LN9310_REG_CFG_5, + LN9310_CFG_5_INFET_CP_PD_BIAS_CFG_MASK, + LN9310_CFG_5_INFET_CP_PD_BIAS_CFG_LOWEST); + + /* enable automatic infet control */ + field_update8(LN9310_REG_PWR_CTRL, + LN9310_PWR_INFET_AUTO_MODE_MASK, + LN9310_PWR_INFET_AUTO_MODE_ON); + + /* disable LS_HELPER during IDLE by setting MSK bit high */ + field_update8(LN9310_REG_CFG_0, + LN9310_CFG_0_LS_HELPER_IDLE_MSK_MASK, + LN9310_CFG_0_LS_HELPER_IDLE_MSK_ON); + + field_update8(LN9310_REG_LION_CTRL, + LN9310_LION_CTRL_MASK, + LN9310_LION_CTRL_LOCK); + + return EC_SUCCESS; +} + void ln9310_init(void) { int status, val; enum battery_cell_type batt; + /* Update INFET configuration */ + status = ln9310_update_infet(); + + if (status != EC_SUCCESS) + return; + /* * Set OPERATION_MODE update method * - OP_MODE_MANUAL_UPDATE = 0 diff --git a/driver/ln9310.h b/driver/ln9310.h index 3cf4aaa3ca..8441e30b91 100644 --- a/driver/ln9310.h +++ b/driver/ln9310.h @@ -59,6 +59,9 @@ #define LN9310_PWR_OP_MODE_SWITCH31 0x03 #define LN9310_PWR_OP_MODE_MANUAL_UPDATE_MASK 0x40 #define LN9310_PWR_OP_MODE_MANUAL_UPDATE_OFF 0x00 +#define LN9310_PWR_INFET_AUTO_MODE_MASK 0x08 +#define LN9310_PWR_INFET_AUTO_MODE_ON 0x08 +#define LN9310_PWR_INFET_AUTO_MODE_OFF 0x00 #define LN9310_REG_SYS_CTRL 0x1e @@ -126,6 +129,13 @@ #define LN9310_REG_SC_DITHER_CTRL 0x2f #define LN9310_REG_LION_CTRL 0x30 +#define LN9310_LION_CTRL_MASK 0xFF +#define LN9310_LION_CTRL_UNLOCK 0xAA +#define LN9310_LION_CTRL_LOCK 0x00 + +#define LN9310_REG_CFG_0 0x3C +#define LN9310_CFG_0_LS_HELPER_IDLE_MSK_MASK 0x20 +#define LN9310_CFG_0_LS_HELPER_IDLE_MSK_ON 0x20 #define LN9310_REG_CFG_4 0x40 #define LN9310_CFG_4_SC_OUT_PRECHARGE_EN_TIME_CFG BIT(2) @@ -137,6 +147,12 @@ #define LN9310_CFG_4_SW1_VGS_SHORT_EN_MSK_OFF 0x00 #define LN9310_CFG_4_BSTH_BSTL_HIGH_ROUT_CFG_LOWEST 0x00 +#define LN9310_REG_CFG_5 0x41 +#define LN9310_CFG_5_INGATE_PD_EN_MASK 0xC0 +#define LN9310_CFG_5_INGATE_PD_EN_OFF 0x00 +#define LN9310_CFG_5_INFET_CP_PD_BIAS_CFG_MASK 0x30 +#define LN9310_CFG_5_INFET_CP_PD_BIAS_CFG_LOWEST 0x00 + #define LN9310_REG_SWAP_CTRL_0 0x58 #define LN9310_REG_SWAP_CTRL_1 0x59 #define LN9310_REG_SWAP_CTRL_2 0x5A |