summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeepti Deshatty <deepti.deshatty@intel.corp-partner.google.com>2021-10-09 02:31:40 +0530
committerCommit Bot <commit-bot@chromium.org>2021-10-28 17:58:06 +0000
commit6696cc47cd93e55db0989263da56dcb4316aeca1 (patch)
tree0cbf2f9d91c62b9816347ea633bc8aa6d0bfd560
parentfe70589e38a1f8abd36746bfb95c7a6196ca593f (diff)
downloadchrome-ec-6696cc47cd93e55db0989263da56dcb4316aeca1.tar.gz
cleanup: charger: Add BQ25710 sense resistor configs
Defined different sense register configs for BQ25710. All the charger chip driver implementation uses common sense register configs i.e CONFIG_CHARGER_SENSE_RESISTOR and CONFIG_CHARGER_SENSE_RESISTOR_AC. When we enable a charger driver for a platform, it is expected that the platform define these sense register configs. But ADLRVP requires two different charger drivers i.e ISL9241 and BQ25720 to be enabled to support all the variant builds. Hence BQ25710 driver is changed to use different sense register configs so that the configs defined for ISL9241 are not affected. BRANCH=none TEST=make -j buildall has no issues Signed-off-by: Deepti Deshatty <deepti.deshatty@intel.corp-partner.google.com> Change-Id: If1e1422246e2e3a5cb628d9a37c23790502b5ca4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3211773 Reviewed-by: Poornima Tom <poornima.tom@intel.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--baseboard/brya/prochot.c2
-rw-r--r--baseboard/hatch/baseboard.h4
-rw-r--r--baseboard/octopus/baseboard.h3
-rw-r--r--board/anahera/board.h4
-rw-r--r--board/brya/board.h4
-rw-r--r--board/gimble/board.h4
-rw-r--r--board/primus/board.h4
-rw-r--r--board/redrix/board.h4
-rw-r--r--board/taeko/board.h4
-rw-r--r--driver/charger/bq25710.c12
-rw-r--r--include/config.h6
-rw-r--r--util/config_allowed.txt1
-rw-r--r--zephyr/Kconfig.battery18
-rw-r--r--zephyr/shim/include/config_chip.h12
14 files changed, 56 insertions, 26 deletions
diff --git a/baseboard/brya/prochot.c b/baseboard/brya/prochot.c
index 2995bdaddf..b9cec7bba0 100644
--- a/baseboard/brya/prochot.c
+++ b/baseboard/brya/prochot.c
@@ -42,7 +42,7 @@ static int cal_sys_watt(void)
/* the ratio selectable through IADPT_GAIN bit. */
V_iadpt = Vacpacn * 1000 / 40;
- IDPM = V_iadpt / CONFIG_CHARGER_SENSE_RESISTOR_AC;
+ IDPM = V_iadpt / CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC;
adapter_voltage_v = charge_manager_get_charger_voltage() / 1000;
diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h
index bf9140b33f..dc39fcf8ac 100644
--- a/baseboard/hatch/baseboard.h
+++ b/baseboard/hatch/baseboard.h
@@ -100,8 +100,8 @@
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGE_RAMP_HW
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
/*
* Don't allow the system to boot to S0 when the battery is low and unable to
* communicate on locked systems (which haven't PD negotiated)
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h
index 8b05c30f4c..f0ecab4d87 100644
--- a/baseboard/octopus/baseboard.h
+++ b/baseboard/octopus/baseboard.h
@@ -129,7 +129,8 @@
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_BQ25710
#define CONFIG_CHARGER_SENSE_RESISTOR_AC_ISL9238 20
- #define CONFIG_CHARGER_SENSE_RESISTOR_AC_BQ25710 10
+ #define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
+ #define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 200
diff --git a/board/anahera/board.h b/board/anahera/board.h
index 52666ff8e2..f9809906c8 100644
--- a/board/anahera/board.h
+++ b/board/anahera/board.h
@@ -138,8 +138,8 @@
#define CONFIG_CHARGER_BQ25720
#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
#define CONFIG_CHARGE_RAMP_HW
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
/* Keyboard features */
#define CONFIG_KEYBOARD_FACTORY_TEST
diff --git a/board/brya/board.h b/board/brya/board.h
index 77f0ab8490..a4aa9e1dde 100644
--- a/board/brya/board.h
+++ b/board/brya/board.h
@@ -205,8 +205,8 @@
#define CONFIG_CHARGER_BQ25720
#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
#define CONFIG_CHARGE_RAMP_SW
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
/*
* Older boards have a different ADC assignment.
diff --git a/board/gimble/board.h b/board/gimble/board.h
index b7a31631f7..2e79eabcb2 100644
--- a/board/gimble/board.h
+++ b/board/gimble/board.h
@@ -181,8 +181,8 @@
#define CONFIG_CHARGER_BQ25720
#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
#define CONFIG_CHARGE_RAMP_SW
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
/* PROCHOT defines */
#define BATT_MAX_CONTINUE_DISCHARGE_WATT 45
diff --git a/board/primus/board.h b/board/primus/board.h
index c28f409fff..46e1520fb1 100644
--- a/board/primus/board.h
+++ b/board/primus/board.h
@@ -136,8 +136,8 @@
#define CONFIG_CHARGER_BQ25720
#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
#define CONFIG_CHARGE_RAMP_SW
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
/* PROCHOT defines */
#define BATT_MAX_CONTINUE_DISCHARGE_WATT 66
diff --git a/board/redrix/board.h b/board/redrix/board.h
index d17550e545..cb548384b6 100644
--- a/board/redrix/board.h
+++ b/board/redrix/board.h
@@ -189,8 +189,8 @@
#define CONFIG_CHARGER_BQ25710_IDCHG_LIMIT_MA 8192
#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
#define CONFIG_CHARGE_RAMP_HW
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
/* Keyboard features */
#define CONFIG_KEYBOARD_FACTORY_TEST
diff --git a/board/taeko/board.h b/board/taeko/board.h
index 2dacccb6d6..b84099d13d 100644
--- a/board/taeko/board.h
+++ b/board/taeko/board.h
@@ -172,8 +172,8 @@
#define CONFIG_CHARGER_BQ25720
#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
#define CONFIG_CHARGE_RAMP_SW
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
#ifndef __ASSEMBLER__
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c
index dbc7049b91..13da37ab65 100644
--- a/driver/charger/bq25710.c
+++ b/driver/charger/bq25710.c
@@ -35,18 +35,12 @@
/* Sense resistor configurations and macros */
#define DEFAULT_SENSE_RESISTOR 10
-#ifdef CONFIG_CHARGER_SENSE_RESISTOR_AC_BQ25710
- #undef CONFIG_CHARGER_SENSE_RESISTOR_AC
- #define CONFIG_CHARGER_SENSE_RESISTOR_AC \
- CONFIG_CHARGER_SENSE_RESISTOR_AC_BQ25710
-#endif
-
-
#define INPUT_RESISTOR_RATIO \
- ((CONFIG_CHARGER_SENSE_RESISTOR_AC) / DEFAULT_SENSE_RESISTOR)
+ ((CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC) / DEFAULT_SENSE_RESISTOR)
#define CHARGING_RESISTOR_RATIO \
- ((CONFIG_CHARGER_SENSE_RESISTOR) / DEFAULT_SENSE_RESISTOR)
+ ((CONFIG_CHARGER_BQ25710_SENSE_RESISTOR) / DEFAULT_SENSE_RESISTOR)
+
#define REG_TO_CHARGING_CURRENT(REG) ((REG) / CHARGING_RESISTOR_RATIO)
#define CHARGING_CURRENT_TO_REG(CUR) ((CUR) * CHARGING_RESISTOR_RATIO)
#ifdef CONFIG_CHARGER_BQ25720
diff --git a/include/config.h b/include/config.h
index ae78505c4f..1f618ded95 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1047,6 +1047,12 @@
*/
#undef CONFIG_CHARGER_BQ25720_VSYS_TH2_DV
+/* Value of the bq25710 charge sense resistor, in mOhms */
+#undef CONFIG_CHARGER_BQ25710_SENSE_RESISTOR
+
+/* Value of the bq25710 input current sense resistor, in mOhms */
+#undef CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC
+
/*
* Board specific maximum input current limit, in mA.
*/
diff --git a/util/config_allowed.txt b/util/config_allowed.txt
index 64a49d36cd..ba0d54fd5a 100644
--- a/util/config_allowed.txt
+++ b/util/config_allowed.txt
@@ -179,7 +179,6 @@ CONFIG_CHARGER_RAA489000
CONFIG_CHARGER_RT9466
CONFIG_CHARGER_RT9467
CONFIG_CHARGER_RUNTIME_CONFIG
-CONFIG_CHARGER_SENSE_RESISTOR_AC_BQ25710
CONFIG_CHARGER_SENSE_RESISTOR_AC_ISL9238
CONFIG_CHARGER_SINGLE_CHIP
CONFIG_CHARGER_SM5803
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery
index ca5273caff..d7e5e459da 100644
--- a/zephyr/Kconfig.battery
+++ b/zephyr/Kconfig.battery
@@ -250,6 +250,24 @@ endchoice # "Discharge control method"
endif # PLATFORM_EC_CHARGER_DISCHARGE_ON_AC
+config PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR
+ int "Value of the charge sense-resistor, in mOhms"
+ default 10
+ depends on PLATFORM_EC_CHARGER_BQ25710 || PLATFORM_EC_CHARGER_BQ25720
+ help
+ The charge sense-resistor is used to detect the charge current to the
+ battery. Its value must be known for the calculation to be correct.
+ The value is typically around 10 mOhms.
+
+config PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR_AC
+ int "Value of the input sense-resistor, in mOhms"
+ default 10
+ depends on PLATFORM_EC_CHARGER_BQ25710 || PLATFORM_EC_CHARGER_BQ25720
+ help
+ The input sense-resistor is used to detect the input current from the
+ external AC power supply. Its value must be known for the calculation
+ to be correct. The value is typically around 10 mOhms.
+
config PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM
bool "VSYS_TH2 override"
depends on PLATFORM_EC_CHARGER_BQ25720
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 16dbd36eca..511b64ddb1 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1699,6 +1699,18 @@
CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY
#endif
+#undef CONFIG_CHARGER_BQ25710_SENSE_RESISTOR
+#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR \
+ CONFIG_PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR
+#endif
+
+#undef CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC
+#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR_AC
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC \
+ CONFIG_PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR_AC
+#endif
+
#undef CONFIG_CHARGER_DISCHARGE_ON_AC
#ifdef CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_DISCHARGE_ON_AC