Skip to contentSkip to conversation

BQ25150/155 Charger

PATCH Superseded Dan Murphy 2 participants 6 messages Jan 8, 2020 – Jan 13, 2020

Subsystems (2)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

v3 cover BQ25150/155 Charger

Hello

I am introducing the TI BQ25150/155 Charge driver.
The driver also supports the JEITA spec for Thermal battery management. This support for Hot, Warm and Cool are being added to the power supply class.

Datasheets for these devices can be found at:
http://www.ti.com/lit/ds/symlink/bq25150.pdf
http://www.ti.com/lit/ds/symlink/bq25155.pdf

Dan Murphy (4):
power: supply: core: Update sysfs-class-power ABI document
power_supply: Add additional health properties to the header
dt-bindings: power: Add the bq2515x family dt bindings
power: supply: bq2515x: Introduce the bq2515x family

 Documentation/ABI/testing/sysfs-class-power   |   3 +-
 .../bindings/power/supply/bq2515x.yaml        |  85 ++
 drivers/power/supply/Kconfig                  |   8 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/bq2515x_charger.c        | 739 ++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c     |   2 +-
 include/linux/power_supply.h                  |   3 +
 7 files changed, 839 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml
 create mode 100644 drivers/power/supply/bq2515x_charger.c
Signature · 1 line
2.23.0
author
#1 lore raw

PATCH v3 1/4 power: supply: core: Update sysfs-class-power ABI document

Add the "Over Current" string to /sys/class/power_supply/<supply_name>/health description.

Fixes e3e83cc601e57 ("power: supply: core: Add POWER_SUPPLY_HEALTH_OVERCURRENT constant")
---
 Documentation/ABI/testing/sysfs-class-power | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-class-power +2 -1
index 27edc06e2495..bf3b48f022dc 100644
@@ -189,7 +189,8 @@ Description:
 		Access: Read
 		Valid values: "Unknown", "Good", "Overheat", "Dead",
 			      "Over voltage", "Unspecified failure", "Cold",
-			      "Watchdog timer expire", "Safety timer expire"
+			      "Watchdog timer expire", "Safety timer expire",
+			      "Over current"
 
 What:		/sys/class/power_supply/<supply_name>/precharge_current
 Date:		June 2017
Signature · 1 line
2.23.0
author
#3 lore raw

PATCH v3 3/4 dt-bindings: power: Add the bq2515x family dt bindings

In reply to Dan Murphy

Add the bindings for the bq25150 and bq25155 500mA charging ICs from Texas Instruments.

Datasheet:
http://www.ti.com/lit/ds/symlink/bq25150.pdf
http://www.ti.com/lit/ds/symlink/bq25155.pdf

---
v3 - Updated the constant-charge voltage binding to what is declared in battery.txt

 .../bindings/power/supply/bq2515x.yaml        | 85 +++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/bq2515x.yaml
Documentation/devicetree/bindings/power/supply/bq2515x.yaml new file +85 -0
new file mode 100644
index 000000000000..670952021e8d
@@ -0,0 +1,85 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright (C) 2019 Texas Instruments Incorporated
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/power/supply/bq2515x.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: TI bq2515x 500-mA Linear charger family
+
+maintainers:
+  - Dan Murphy <[email protected]>
+
+description: |
+  The BQ2515x family is a highly integrated battery charge management IC that
+  integrates the most common functions for wearable devices, namely a charger,
+  an output voltage rail, ADC for battery and system monitoring, and
+  push-button controller.
+
+  Specifications about the charger can be found at:
+    http://www.ti.com/lit/ds/symlink/bq25150.pdf
+    http://www.ti.com/lit/ds/symlink/bq25155.pdf
+
+properties:
+  compatible:
+    enum:
+      - ti,bq25150
+      - ti,bq25155
+
+  reg:
+    maxItems: 1
+
+  pg-gpios:
+    description: |
+       GPIO used for connecting the bq2515x device PG (Power Good)
+       pin.  This pin should be used if possible as this is the
+       recommended way to obtain the charger's input PG state.
+       If this pin is not specified a software-based approach for PG
+       detection is used.
+
+  reset-gpios:
+    description: |
+       GPIO used for hardware reset.
+
+  low-power-gpios:
+    description: |
+       GPIO used for low power mode of IC.
+
+  charge-enable-gpios:
+    description: |
+       GPIO used to turn on and off charging.
+
+  constant-charge-current-max-microamp:
+    description: |
+       Maximum charging current in micro Amps.
+    minimum: 50000
+    maximum: 600000
+
+  constant-charge-voltage-max-microvolt:
+    description: |
+       Maximum charging voltage in micro volts.
+    minimum: 3600000
+    maximum: 4600000
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c0 {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      charger@6b {
+          compatible = "ti,bq25150";
+          reg = <0x6b>;
+
+          pg-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+          reset-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
+          low-power-gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
+          charge-enable-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
+          constant-charge-current-max-microamp = <300000>;
+          voltage-max-design-microvolt = <4200000>;
+      };
+    };
Signature · 1 line
2.23.0
author
#4 lore raw

PATCH v3 4/4 power: supply: bq2515x: Introduce the bq2515x family

In reply to Dan Murphy

Introduce the bq25150 and bq25155 supply chargers.

---
 drivers/power/supply/Kconfig           |   8 +
 drivers/power/supply/Makefile          |   1 +
 drivers/power/supply/bq2515x_charger.c | 739 +++++++++++++++++++++++++
 3 files changed, 748 insertions(+)
 create mode 100644 drivers/power/supply/bq2515x_charger.c
drivers/power/supply/Kconfig +8 -0
index 27164a1d3c7c..ee9f4b29e0b7 100644
@@ -589,6 +589,14 @@ config CHARGER_BQ24735
 	help
 	  Say Y to enable support for the TI BQ24735 battery charger.
 
+config CHARGER_BQ2515X
+	tristate "TI BQ2515X battery charger family"
+	depends on I2C
+	depends on GPIOLIB || COMPILE_TEST
+	select REGMAP_I2C
+	help
+	  Say Y to enable support for the TI BQ2515X battery charger.
+
 config CHARGER_BQ25890
 	tristate "TI BQ25890 battery charger driver"
 	depends on I2C
drivers/power/supply/Makefile +1 -0
index 6c7da920ea83..8fcc175a7e22 100644
@@ -80,6 +80,7 @@ obj-$(CONFIG_CHARGER_BQ2415X)	+= bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)	+= bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24257)	+= bq24257_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)	+= bq24735-charger.o
+obj-$(CONFIG_CHARGER_BQ2515X)	+= bq2515x_charger.o
 obj-$(CONFIG_CHARGER_BQ25890)	+= bq25890_charger.o
 obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090)	+= tps65090-charger.o
drivers/power/supply/bq2515x_charger.c new file +739 -0

739 lines not on this page · raw message

Signature · 1 line
2.23.0
author
#2 lore raw

PATCH v3 2/4 power_supply: Add additional health properties to the header

In reply to Dan Murphy

Add HEALTH_WARM, HEALTH_COOL and HEALTH_HOT to the health enum.

---

v3 - updated the ABI documentation and the power supply health text array.

 Documentation/ABI/testing/sysfs-class-power | 2 +-
 drivers/power/supply/power_supply_sysfs.c   | 2 +-
 include/linux/power_supply.h                | 3 +++
 3 files changed, 5 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-class-power +1 -1
index bf3b48f022dc..9f3fd01a9373 100644
@@ -190,7 +190,7 @@ Description:
 		Valid values: "Unknown", "Good", "Overheat", "Dead",
 			      "Over voltage", "Unspecified failure", "Cold",
 			      "Watchdog timer expire", "Safety timer expire",
-			      "Over current"
+			      "Over current", "Warm", "Cool", "Hot"
 
 What:		/sys/class/power_supply/<supply_name>/precharge_current
 Date:		June 2017
drivers/power/supply/power_supply_sysfs.c +1 -1
index f37ad4eae60b..d0d549611794 100644
@@ -61,7 +61,7 @@ static const char * const power_supply_charge_type_text[] = {
 static const char * const power_supply_health_text[] = {
 	"Unknown", "Good", "Overheat", "Dead", "Over voltage",
 	"Unspecified failure", "Cold", "Watchdog timer expire",
-	"Safety timer expire", "Over current"
+	"Safety timer expire", "Over current", "Warm", "Cool", "Hot"
 };
 
 static const char * const power_supply_technology_text[] = {
include/linux/power_supply.h +3 -0
index 28413f737e7d..bd0d3225f245 100644
@@ -61,6 +61,9 @@ enum {
 	POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE,
 	POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE,
 	POWER_SUPPLY_HEALTH_OVERCURRENT,
+	POWER_SUPPLY_HEALTH_WARM,
+	POWER_SUPPLY_HEALTH_COOL,
+	POWER_SUPPLY_HEALTH_HOT,
 };
 
 enum {
Signature · 1 line
2.23.0
#5 lore raw

Re: [PATCH v3 4/4] power: supply: bq2515x: Introduce the bq2515x family

In reply to Dan Murphy

Hi Dan,

url:    https://github.com/0day-ci/linux/commits/Dan-Murphy/BQ25150-155-Charger/20200110-055201
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next

If you fix the issue, kindly add following tag

New smatch warnings:
drivers/power/supply/bq2515x_charger.c:316 bq2515x_set_ilim_lvl() error: buffer overflow 'bq2515x_ilim_lvl_values' 8 <= 8

Old smatch warnings:
drivers/power/supply/bq2515x_charger.c:320 bq2515x_set_ilim_lvl() error: buffer overflow 'bq2515x_ilim_lvl_values' 8 <= 8 drivers/power/supply/bq2515x_charger.c:322 bq2515x_set_ilim_lvl() error: buffer overflow 'bq2515x_ilim_lvl_values' 8 <= 8

# https://github.com/0day-ci/linux/commit/f5918978695e4e465d54f5c34f356af86874b051
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout f5918978695e4e465d54f5c34f356af86874b051
vim +/bq2515x_ilim_lvl_values +316 drivers/power/supply/bq2515x_charger.c

f5918978695e4e Dan Murphy 2020-01-08  311  static int bq2515x_set_ilim_lvl(struct bq2515x_device *bq2515x, int val)
f5918978695e4e Dan Murphy 2020-01-08  312  {
f5918978695e4e Dan Murphy 2020-01-08  313  	int i;
f5918978695e4e Dan Murphy 2020-01-08  314  
f5918978695e4e Dan Murphy 2020-01-08  315  	for (i = 0; i <= ARRAY_SIZE(bq2515x_ilim_lvl_values); i++) {
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Typo. This should be < ARRAY_SIZE().

f5918978695e4e Dan Murphy 2020-01-08 @316 if (val == bq2515x_ilim_lvl_values[i])

f5918978695e4e Dan Murphy 2020-01-08  317  			break;
f5918978695e4e Dan Murphy 2020-01-08  318  
f5918978695e4e Dan Murphy 2020-01-08  319  		if (val > bq2515x_ilim_lvl_values[i - 1] &&
f5918978695e4e Dan Murphy 2020-01-08  320  		    val < bq2515x_ilim_lvl_values[i]) {
f5918978695e4e Dan Murphy 2020-01-08  321  			if (val - bq2515x_ilim_lvl_values[i - 1] <
f5918978695e4e Dan Murphy 2020-01-08  322  			    bq2515x_ilim_lvl_values[i] - val) {
f5918978695e4e Dan Murphy 2020-01-08  323  				i = i - 1;
f5918978695e4e Dan Murphy 2020-01-08  324  				break;
f5918978695e4e Dan Murphy 2020-01-08  325  			}
f5918978695e4e Dan Murphy 2020-01-08  326  		}
f5918978695e4e Dan Murphy 2020-01-08  327  	}
f5918978695e4e Dan Murphy 2020-01-08  328  
f5918978695e4e Dan Murphy 2020-01-08  329  	return regmap_write(bq2515x->regmap, BQ2515X_ILIMCTRL, i);
f5918978695e4e Dan Murphy 2020-01-08  330  }

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation