Skip to contentSkip to conversation

power: supply: twl6030/32 charger

PATCH Applied Andreas Kemnade 3 participants 6 messages Oct 16, 2024 – Oct 29, 2024

Subsystems (3)
lore
Share & tools
lore

Andreas Kemnade

author maintainer
#0 lore raw

v5 cover power: supply: twl6030/32 charger

Add basic support for the charger in the TWL6030/32. Supported is the USB path. AC path is not handled yet, also there is no entry yet in /sys/class/power_supply with type battery yet.

Without this series, devices will happily drain battery when running on mainline.

Changes in v5:
- set fwnode
- drop mfd patch as it is already applied

Changes in v4:
- require compatible in charger node

Changes in v3:
- define charger in toplevel
- s/bci/charger for twl4030

Changes in v2:
- s/bci/charger in mfd schema
- additionalProperties for charger node
- extended example in mfd schema
- no quotes for compatibles in charger schema
- no example in charger schema
- interrupt description in charger schema
- replace device_is_compatible by driver data
- clang compile fix
- removed alias
- style fixes

Andreas Kemnade (3):
dt-bindings: power: supply: Add TI TWL603X charger
power: supply: initial support for TWL6030/32
ARM: dts: ti/omap: use standard node name for twl4030 charger

 .../power/supply/ti,twl6030-charger.yaml      |  48 ++
 arch/arm/boot/dts/ti/omap/twl4030.dtsi        |   2 +-
 drivers/power/supply/Kconfig                  |  10 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/twl6030_charger.c        | 581 ++++++++++++++++++
 5 files changed, 641 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/power/supply/ti,twl6030-charger.yaml
 create mode 100644 drivers/power/supply/twl6030_charger.c
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH v5 1/3 dt-bindings: power: supply: Add TI TWL603X charger

Use a fallback compatible since for especially for generic defensive setup of parameters, both 6030 and 6032 are the same and U-Boot actually uses a generic 6030/32 function to enable the charger.

---
 .../power/supply/ti,twl6030-charger.yaml      | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/ti,twl6030-charger.yaml
Documentation/devicetree/bindings/power/supply/ti,twl6030-charger.yaml new file +48 -0
new file mode 100644
index 0000000000000..fc604d8a469df
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/ti,twl6030-charger.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TWL6030/32 BCI (Battery Charger Interface)
+
+description:
+  The battery charger needs to be configured to do any charging besides of
+  precharging. The GPADC in the PMIC has to be used to get the related
+  voltages.
+
+maintainers:
+  - Andreas Kemnade <[email protected]>
+
+allOf:
+  - $ref: power-supply.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - const: ti,twl6030-charger
+      - items:
+          - const: ti,twl6032-charger
+          - const: ti,twl6030-charger
+
+  interrupts:
+    items:
+      - description: Charger Control Interrupt
+      - description: Charger Fault Interrupt
+
+  io-channels:
+    items:
+      - description: VBUS Voltage Channel
+
+  io-channel-names:
+    items:
+      - const: vusb
+
+  monitored-battery: true
+
+required:
+  - compatible
+  - interrupts
+  - monitored-battery
+
+additionalProperties: false
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH v5 2/3 power: supply: initial support for TWL6030/32

In reply to Andreas Kemnade

Add a driver for the charger in the TWL6030/32. For now it does not report much in sysfs but parameters are set up for USB, charging is enabled with the specified parameters. It stops charging when full and also restarts charging.
This prevents ending up in a system setup where you run out of battery although a charger is plugged in after precharge completed.

Battery voltage behavior was checked via the GPADC.

---
 drivers/power/supply/Kconfig           |  10 +
 drivers/power/supply/Makefile          |   1 +
 drivers/power/supply/twl6030_charger.c | 581 +++++++++++++++++++++++++
 3 files changed, 592 insertions(+)
 create mode 100644 drivers/power/supply/twl6030_charger.c
drivers/power/supply/Kconfig +10 -0
index bcfa63fb9f1e2..9f2eef6787f7a 100644
@@ -493,6 +493,16 @@ config CHARGER_TWL4030
 	help
 	  Say Y here to enable support for TWL4030 Battery Charge Interface.
 
+config CHARGER_TWL6030
+	tristate "OMAP TWL6030 BCI charger driver"
+	depends on IIO && TWL4030_CORE
+	help
+	  Say Y here to enable support for TWL6030/6032 Battery Charge
+	  Interface.
+
+	  This driver can be build as a module. If so, the module will be
+	  called twl6030_charger.
+
 config CHARGER_LP8727
 	tristate "TI/National Semiconductor LP8727 charger driver"
 	depends on I2C
drivers/power/supply/Makefile +1 -0
index 8dcb415453171..59c4a9f40d28a 100644
@@ -69,6 +69,7 @@ obj-$(CONFIG_CHARGER_CPCAP)	+= cpcap-charger.o
 obj-$(CONFIG_CHARGER_ISP1704)	+= isp1704_charger.o
 obj-$(CONFIG_CHARGER_MAX8903)	+= max8903_charger.o
 obj-$(CONFIG_CHARGER_TWL4030)	+= twl4030_charger.o
+obj-$(CONFIG_CHARGER_TWL6030)	+= twl6030_charger.o
 obj-$(CONFIG_CHARGER_LP8727)	+= lp8727_charger.o
 obj-$(CONFIG_CHARGER_LP8788)	+= lp8788-charger.o
 obj-$(CONFIG_CHARGER_GPIO)	+= gpio-charger.o
drivers/power/supply/twl6030_charger.c new file +581 -0

581 lines not on this page · raw message

Signature · 1 line
2.39.2
author maintainer
#3 lore raw

PATCH v5 3/3 ARM: dts: ti/omap: use standard node name for twl4030 charger

In reply to Andreas Kemnade

Use the established node name for the charger.

---
 arch/arm/boot/dts/ti/omap/twl4030.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/ti/omap/twl4030.dtsi +1 -1
index a5d9c5738317a..07b9ca942e78d 100644
@@ -16,7 +16,7 @@ rtc {
 		interrupts = <11>;
 	};
 
-	charger: bci {
+	charger: charger {
 		compatible = "ti,twl4030-bci";
 		interrupts = <9>, <2>;
 		bci3v1-supply = <&vusb3v1>;
Signature · 1 line
2.39.2
maintainer Applied
#4 lore raw

Re: [PATCH v5 3/3] ARM: dts: ti/omap: use standard node name for twl4030 charger

Quoted 3 lines · Andreas Kemnade

Use the established node name for the charger.

Applied, thanks!

[3/3] ARM: dts: ti/omap: use standard node name for twl4030 charger

      commit: 55f96ea329ee8248215a08ae0b88330084304748

Best regards,

Signature · 1 line
Kevin Hilman <[email protected]>
#5 lore raw

Re: (subset) [PATCH v5 0/3] power: supply: twl6030/32 charger

In reply to Andreas Kemnade
Quoted 8 lines · Andreas Kemnade

Add basic support for the charger in the TWL6030/32. Supported is the USB path. AC path is not handled yet, also there is no entry yet in /sys/class/power_supply with type battery yet.

Without this series, devices will happily drain battery when running on mainline.

[...]

Applied, thanks!

[1/3] dt-bindings: power: supply: Add TI TWL603X charger

      commit: 421aadd19a622852172ccc15ad4049201fd1f80b
[2/3] power: supply: initial support for TWL6030/32
      commit: b45cdceba64d79a2538aeb36926fd9a065f0f753

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>