From ac78a35cf198e69cec291d1d645b89997da10ea5 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Thu, 8 May 2014 15:04:26 -0700 Subject: fruitpie: disable battery charging chip ILIM pin Typically bq24xxx charging chip limits input current to minimum of register value and ILIM pin. For fruitpie, the current limit will be decided solely in software, and the hardware pin will be ignored. BUG=chrome-os-partner:28611,chrome-os-partner:28311 BRANCH=none TEST=Tested on fruitpie. Verified that current limit can be set above the ILIM pin value of 500mA. Change-Id: Ia687446f95f9d18fde9d2b4ebb0e1c093aebf885 Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/198940 Reviewed-by: Vincent Palatin --- board/fruitpie/board.h | 1 + driver/charger/bq24773.c | 19 +++++++++++++++++++ driver/charger/bq24773.h | 2 ++ include/config.h | 7 +++++++ 4 files changed, 29 insertions(+) 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. * -- cgit v1.2.1