Skip to contentSkip to conversation

power: supply: twl6030/32 charger

PATCH Superseded Andreas Kemnade 2 participants 6 messages Sep 30, 2024 – Oct 1, 2024

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 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 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
dt-bindings: mfd: twl: add charger node also for TWL603x
power: supply: initial support for TWL6030/32

 .../devicetree/bindings/mfd/ti,twl.yaml       |  22 +
 .../power/supply/ti,twl6030-charger.yaml      |  48 ++
 drivers/power/supply/Kconfig                  |  10 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/twl6030_charger.c        | 580 ++++++++++++++++++
 5 files changed, 661 insertions(+)
 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
#1 lore raw

PATCH v2 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
Reviewed-by on v2 1/3
#2 lore raw

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

Quoted 10 lines · Andreas Kemnade

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

Best regards,
Krzysztof

#3 lore raw

PATCH v2 2/3 dt-bindings: mfd: twl: add charger node also for TWL603x

In reply to Andreas Kemnade

Also the TWL603X devices have a charger, so allow to specify it here.

---
 .../devicetree/bindings/mfd/ti,twl.yaml       | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
Documentation/devicetree/bindings/mfd/ti,twl.yaml +22 -0
index e94b0fd7af0f8..488d419b211d1 100644
@@ -105,6 +105,12 @@ allOf:
             regulator-initial-mode: false
 
       properties:
+        charger:
+          type: object
+          additionalProperties: true
+          properties:
+            compatible:
+              const: ti,twl6030-charger
         gpadc:
           type: object
           properties:
@@ -136,6 +142,14 @@ allOf:
             regulator-initial-mode: false
 
       properties:
+        charger:
+          type: object
+          additionalProperties: true
+          properties:
+            compatible:
+              items:
+                - const: ti,twl6032-charger
+                - const: ti,twl6030-charger
         gpadc:
           type: object
           properties:
@@ -222,6 +236,14 @@ examples:
         interrupt-controller;
         #interrupt-cells = <1>;
 
+        charger {
+          compatible = "ti,twl6030-charger";
+          interrupts = <2>, <5>;
+          io-channels = <&gpadc 10>;
+          io-channel-names = "vusb";
+          monitored-battery = <&bat>;
+        };
+
         gpadc {
           compatible = "ti,twl6030-gpadc";
           interrupts = <6>;
Signature · 1 line
2.39.2
#4 lore raw

Re: [PATCH v2 2/3] dt-bindings: mfd: twl: add charger node also for TWL603x

Quoted 12 lines · Andreas Kemnade

Also the TWL603X devices have a charger, so allow to specify it here.

---
 .../devicetree/bindings/mfd/ti,twl.yaml       | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
Documentation/devicetree/bindings/mfd/ti,twl.yaml +0 -0
index e94b0fd7af0f8..488d419b211d1 100644

Documentation/devicetree/bindings/mfd/ti,twl.yaml allOf: · line 108

Quoted 4 lines
Documentation/devicetree/bindings/mfd/ti,twl.yaml +1 -0
@@ -105,6 +105,12 @@ allOf:
             regulator-initial-mode: false
 
       properties:
+        charger:

Properties should be defined in top-level, mot in allOf. You can disallow them for certain variants.

Best regards,
Krzysztof

#5 lore raw

PATCH v2 3/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 | 580 +++++++++++++++++++++++++
 3 files changed, 591 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 +580 -0

580 lines not on this page · raw message

Signature · 1 line
2.39.2