diff options
-rw-r--r-- | board/nami/board.c | 6 | ||||
-rw-r--r-- | driver/charger/isl923x.c | 13 | ||||
-rw-r--r-- | driver/charger/isl923x.h | 17 |
3 files changed, 17 insertions, 19 deletions
diff --git a/board/nami/board.c b/board/nami/board.c index 16d4dcbff5..104f892566 100644 --- a/board/nami/board.c +++ b/board/nami/board.c @@ -1034,11 +1034,7 @@ static void board_init(void) swap(scancode_set2[0][4], scancode_set2[7][2]); #endif - isl923x_set_ac_prochot( - /* set ac prochot currentto 3328mA 0xD00, default 3072mA*/ - ISL923X_PROCHOT_CURRENT_256 | - ISL923X_PROCHOT_CURRENT_1024 | - ISL923X_PROCHOT_CURRENT_2048); + isl923x_set_ac_prochot(3328 /* mA */); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index f2bd51b927..18b31b0952 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -302,11 +302,18 @@ int charger_post_init(void) return EC_SUCCESS; } -int isl923x_set_ac_prochot(uint16_t ac_prochot) +int isl923x_set_ac_prochot(uint16_t ma) { - int rv = raw_write16(ISL923X_REG_PROCHOT_AC, ac_prochot); + int rv; + + if (ma > ISL923X_AC_PROCHOT_CURRENT_MAX) { + CPRINTF("%s: invalid current (%d mA)\n", __func__, ma); + return EC_ERROR_INVAL; + } + + rv = raw_write16(ISL923X_REG_PROCHOT_AC, ma); if (rv) - CPRINTF("%s failed\n", __func__); + CPRINTF("%s failed (%d)\n", __func__, rv); return rv; } diff --git a/driver/charger/isl923x.h b/driver/charger/isl923x.h index 6f76106157..89595a60fa 100644 --- a/driver/charger/isl923x.h +++ b/driver/charger/isl923x.h @@ -61,14 +61,6 @@ #define ISL9238_SYS_VOLTAGE_REG_MAX 18304 #define ISL923X_SYS_VOLTAGE_REG_MIN 2048 -/* PROCHOT# adapter prochot current setting in mA */ -#define ISL923X_PROCHOT_CURRENT_128 BIT(7) -#define ISL923X_PROCHOT_CURRENT_256 BIT(8) -#define ISL923X_PROCHOT_CURRENT_512 BIT(9) -#define ISL923X_PROCHOT_CURRENT_1024 BIT(10) -#define ISL923X_PROCHOT_CURRENT_2048 BIT(11) -#define ISL923X_PROCHOT_CURRENT_4096 BIT(12) - /* PROCHOT# debounce time and duration time in micro seconds */ #define ISL923X_PROCHOT_DURATION_10000 (0 << 6) #define ISL923X_PROCHOT_DURATION_20000 BIT(6) @@ -308,9 +300,12 @@ enum isl9237_fsm_state { #endif /* __CROS_EC_ISL923X_H */ /** - * Initialize ac prochot to reach better performance + * Initialize AC prochot threshold * - * @param ac_prochot: ISL923X_PROCHOT_CURRENT_* + * @param Porchot threshold current in mA: multiple of 128 up to 6400 mA + * Bits below 128mA are truncated (ignored). * @return enum ec_error_list */ -int isl923x_set_ac_prochot(uint16_t ac_prochot); +int isl923x_set_ac_prochot(uint16_t ma); + +#define ISL923X_AC_PROCHOT_CURRENT_MAX 6400 /* mA */ |