diff --git a/board/fruitpie/board.h b/board/fruitpie/board.h index 021e95a1df..8ab7345c56 100644 --- a/board/fruitpie/board.h +++ b/board/fruitpie/board.h @@ -42,6 +42,7 @@ #define CONFIG_CHARGER_SENSE_RESISTOR 5 /* milliOhms */ #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 /* milliOhms */ #define CONFIG_CHARGER_INPUT_CURRENT 512 /* mA */ +#define CONFIG_CHARGER_ILIM_PIN_DISABLED /* external ILIM pin disabled */ /* * Allow dangerous commands all the time, since we don't have a write protect diff --git a/driver/charger/bq24773.c b/driver/charger/bq24773.c index 854bb6dfb0..7443f5d0f3 100644 --- a/driver/charger/bq24773.c +++ b/driver/charger/bq24773.c @@ -170,9 +170,28 @@ int charger_set_voltage(int voltage) int charger_post_init(void) { int rv; +#ifdef CONFIG_CHARGER_ILIM_PIN_DISABLED + int option2; +#endif /* Set charger input current limit */ rv = charger_set_input_current(CONFIG_CHARGER_INPUT_CURRENT); + +#ifdef CONFIG_CHARGER_ILIM_PIN_DISABLED + if (rv) + return rv; + + /* Disable the external ILIM pin. */ + rv = i2c_read16(I2C_PORT_CHARGER, BQ24773_ADDR, + BQ24773_CHARGE_OPTION2, &option2); + if (rv) + return rv; + + option2 &= ~OPTION2_EN_EXTILIM; + rv = i2c_write16(I2C_PORT_CHARGER, BQ24773_ADDR, + BQ24773_CHARGE_OPTION2, option2); +#endif + return rv; } diff --git a/driver/charger/bq24773.h b/driver/charger/bq24773.h index cce3e7e902..4b36fc7c74 100644 --- a/driver/charger/bq24773.h +++ b/driver/charger/bq24773.h @@ -28,4 +28,6 @@ #define OPTION0_CHARGE_INHIBIT (1 << 0) #define OPTION0_LEARN_ENABLE (1 << 5) +#define OPTION2_EN_EXTILIM (1 << 7) + #endif /* __CROS_EC_CHARGER_BQ24773_H */ diff --git a/include/config.h b/include/config.h index ae51b24c26..a31e8bd5d4 100644 --- a/include/config.h +++ b/include/config.h @@ -204,6 +204,13 @@ */ #undef CONFIG_CHARGER_DISCHARGE_ON_AC +/* + * Board specific flag used to disable external ILIM pin used to determine input + * current limit. When defined, the input current limit is decided only by + * the software register value. + */ +#undef CONFIG_CHARGER_ILIM_PIN_DISABLED + /* * Maximum amount of input current the charger can receive, in mA. *