Skip to contentSkip to conversation

Add Richtek RT9467 5A Battery Charger support

PATCH RESEND In review ChiaEn Wu 3 participants 6 messages Jan 3, 2023 – Feb 7, 2023

Subsystems (2)
lore
Share & tools
lore

ChiaEn Wu

author
#0 lore raw

v3 cover Add Richtek RT9467 5A Battery Charger support

From: ChiaEn Wu <[email protected]>

This patch set is to add Richtek RT9467 5A Battery Charger support.

RT9467 is a switch-mode single cell Li-Ion/Li-Polymer battery charger for portable applications.

It integrates a synchronous PWM controller, power MOSFETs, input current sensing and regulation, high-accuracy voltage regulation, and charge termination. The charge current is regulated through integrated sensing resistors.

The RT9467 also features USB On-The-Go (OTG) support. It also integrates D+/D- pin for USB host/charging port detection.

Thank you,
ChiaEn Wu
---
Change in v3:
- In Patch 1/3 (dt-bindings: RT9467 Charger DTS)
- Add 'Reviewed-By' tag

Change in v2:
- In Patch 1/3 (dt-bindings: RT9467 Charger DTS)
- Revise the definition of 'enable-gpios'
- Revise the node name to generic name in the example ('rt9467@5b' --> 'charger@5b')
- Revise the example usage of 'charge-enable-gpios' with GPIO flags

- In Patch 2/3 (power: supply: RT9467 Charger Driver)
- Add missing header file <linux/bitfied.h>
- Add new header files <linux/sysfs.h> and <linux/kstrtox.h> for adding 'sysoff' sysfs feature
- Add assign 'rt9467_sysfs_groups' to '.attr_grp' of psy config
- Remove unused varible 'rt9467_port_stat_names[]'

- In Patch 3/3 (ABI Documentation for RT9467 sysfs attribute)
- New file since v2 patch

ChiaEn Wu (3):
dt-bindings: power: supply: Add Richtek RT9467 battery charger
power: supply: rt9467: Add Richtek RT9467 charger driver
Documentation: power: rt9467: Document exported sysfs entries

 .../ABI/testing/sysfs-class-power-rt9467      |   19 +
 .../power/supply/richtek,rt9467-charger.yaml  |   82 ++
 drivers/power/supply/Kconfig                  |   19 +
 drivers/power/supply/Makefile                 |    1 +
 drivers/power/supply/rt9467-charger.c         | 1282 +++++++++++++++++
 5 files changed, 1403 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9467
 create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9467-charger.yaml
 create mode 100644 drivers/power/supply/rt9467-charger.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH RESEND v3 1/3 dt-bindings: power: supply: Add Richtek RT9467 battery charger

From: ChiaEn Wu <[email protected]>

Add bindings for the Richtek RT9467 battery charger.

---
 .../power/supply/richtek,rt9467-charger.yaml  | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9467-charger.yaml
Documentation/devicetree/bindings/power/supply/richtek,rt9467-charger.yaml new file +82 -0
new file mode 100644
index 000000000000..92c570643d2c
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/richtek,rt9467-charger.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT9467 Switching Battery Charger with Power Path Management
+
+maintainers:
+  - ChiYuan Huang <[email protected]>
+  - ChiaEn Wu <[email protected]>
+
+description: |
+  RT9467 is a switch-mode single cell Li-Ion/Li-Polymer battery charger for
+  portable applications. It integrates a synchronous PWM controller, power
+  MOSFETs, input current sensing and regulation, high-accuracy voltage
+  regulation, and charge termination. The charge current is regulated through
+  integrated sensing resistors.
+
+  The RT9467 also features USB On-The-Go (OTG) support. It also integrates
+  D+/D- pin for USB host/charging port detection.
+
+  Datasheet is available at
+  https://www.richtek.com/assets/product_file/RT9467/DS9467-01.pdf
+
+properties:
+  compatible:
+    const: richtek,rt9467-charger
+
+  reg:
+    maxItems: 1
+
+  wakeup-source: true
+
+  interrupts:
+    maxItems: 1
+
+  charge-enable-gpios:
+    description: GPIO is used to turn on and off charging.
+    maxItems: 1
+
+  usb-otg-vbus-regulator:
+    type: object
+    description: OTG boost regulator.
+    unevaluatedProperties: false
+    $ref: /schemas/regulator/regulator.yaml#
+
+    properties:
+      enable-gpios: true
+
+required:
+  - compatible
+  - reg
+  - wakeup-source
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      charger@5b {
+        compatible = "richtek,rt9467-charger";
+        reg = <0x5b>;
+        wakeup-source;
+        interrupts-extended = <&gpio_intc 32 IRQ_TYPE_LEVEL_LOW>;
+        charge-enable-gpios = <&gpio26 1 GPIO_ACTIVE_LOW>;
+
+        rt9467_otg_vbus: usb-otg-vbus-regulator {
+          regulator-name = "rt9467-usb-otg-vbus";
+          regulator-min-microvolt = <4425000>;
+          regulator-max-microvolt = <5825000>;
+          regulator-min-microamp = <500000>;
+          regulator-max-microamp = <3000000>;
+        };
+      };
+    };
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH RESEND v3 2/3 power: supply: rt9467: Add Richtek RT9467 charger driver

In reply to ChiaEn Wu

From: ChiaEn Wu <[email protected]>

RT9467 is a switch-mode single cell Li-Ion/Li-Polymer battery charger for portable applications.

It integrates a synchronous PWM controller, power MOSFETs, input current sensing and regulation, high-accuracy voltage regulation, and charge termination. The charge current is regulated through integrated sensing resistors.

The RT9467 also features USB On-The-Go (OTG) support. It also integrates D+/D- pin for USB host/charging port detection.

---
 drivers/power/supply/Kconfig          |   19 +
 drivers/power/supply/Makefile         |    1 +
 drivers/power/supply/rt9467-charger.c | 1282 +++++++++++++++++++++++++
 3 files changed, 1302 insertions(+)
 create mode 100644 drivers/power/supply/rt9467-charger.c
drivers/power/supply/Kconfig +19 -0
index 0bbfe6a7ce4d..2208ab61eac5 100644
@@ -793,6 +793,25 @@ config CHARGER_RT9455
 	help
 	  Say Y to enable support for Richtek RT9455 battery charger.
 
+config CHARGER_RT9467
+	tristate "Richtek RT9467 Battery Charger Driver"
+	depends on I2C && GPIOLIB && REGULATOR
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	select LINEAR_RANGES
+	help
+	  Say Y here to enable RT9467 Battery Charger.
+	  RT9467 is a switch-mode single cell Li-Ion/Li-Polymer battery charger
+	  for portable applications. It integrates a synchronous PWM controller,
+	  power MOSFETs, input current sensing and regulation, high-accuracy
+	  voltage regulation, and charge termination. The charge current is
+	  regulated through integrated sensing resistors. It also features
+	  USB On-The-Go (OTG) support and integrates D+/D- pin for USB
+	  host/charging port detection.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called "rt9467-charger".
+
 config CHARGER_CROS_USBPD
 	tristate "ChromeOS EC based USBPD charger"
 	depends on CROS_USBPD_NOTIFY
drivers/power/supply/Makefile +1 -0
index 0ee8653e882e..9e9a603f2a4f 100644
@@ -57,6 +57,7 @@ obj-$(CONFIG_BATTERY_MAX1721X)	+= max1721x_battery.o
 obj-$(CONFIG_BATTERY_Z2)	+= z2_battery.o
 obj-$(CONFIG_BATTERY_RT5033)	+= rt5033_battery.o
 obj-$(CONFIG_CHARGER_RT9455)	+= rt9455_charger.o
+obj-$(CONFIG_CHARGER_RT9467)	+= rt9467-charger.o
 obj-$(CONFIG_BATTERY_S3C_ADC)	+= s3c_adc_battery.o
 obj-$(CONFIG_BATTERY_TWL4030_MADC)	+= twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X)	+= 88pm860x_charger.o
drivers/power/supply/rt9467-charger.c new file +1282 -0

1,282 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH v3 RESEND 2/3] power: supply: rt9467: Add Richtek RT9467 charger driver

Quoted 23 lines · ChiaEn Wu

From: ChiaEn Wu <[email protected]>

RT9467 is a switch-mode single cell Li-Ion/Li-Polymer battery charger for portable applications.

It integrates a synchronous PWM controller, power MOSFETs, input current sensing and regulation, high-accuracy voltage regulation, and charge termination. The charge current is regulated through integrated sensing resistors.

The RT9467 also features USB On-The-Go (OTG) support. It also integrates D+/D- pin for USB host/charging port detection.

---
 drivers/power/supply/Kconfig          |   19 +
 drivers/power/supply/Makefile         |    1 +
 drivers/power/supply/rt9467-charger.c | 1282 +++++++++++++++++++++++++
 3 files changed, 1302 insertions(+)
 create mode 100644 drivers/power/supply/rt9467-charger.c

[...]

drivers/power/supply/rt9467-charger.c line 1265

Quoted 2 lines
drivers/power/supply/rt9467-charger.c new file +2 -0
+static const struct of_device_id rt9467_charger_of_match_table[] = {
+       { .compatible = "richtek,rt9467", },

This does not match the binding. Probably the binding should be fixed if this is only a charger. In that case, '-charger' is redundant.

FYI, 'make dt_compatible_check' will detect this.

Rob

author
#4 lore raw

PATCH RESEND v3 3/3 Documentation: power: rt9467: Document exported sysfs entries

In reply to ChiaEn Wu

From: ChiaEn Wu <[email protected]>

Document the settings exported by rt9467 charger driver through sysfs entries:
- sysoff_enable

---
 .../ABI/testing/sysfs-class-power-rt9467      | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9467
Documentation/ABI/testing/sysfs-class-power-rt9467 new file +19 -0
new file mode 100644
index 000000000000..dd0b962f6fd4
@@ -0,0 +1,19 @@
+What:		/sys/class/power_supply/rt9467-*/sysoff_enable
+Date:		Oct 2022
+KernelVersion:	6.0
+Contact:	ChiaEn Wu <[email protected]>
+Description:
+		This entry allows enabling the sysoff mode of rt9467 charger
+		devices.
+		If enabled and the input is removed, the internal battery FET
+		is turned off to reduce the leakage from the BAT pin. See
+		device datasheet for details. It's commonly used when the
+		product enter shipping stage. After entering shipping mode,
+		only 'VBUS' or 'Power key" pressed can make it leave this mode.
+		'Disable' also can help to leave it, but it's more like to
+		abort the action before the device really enter shipping mode.
+
+		Access: Read, Write
+		Valid values:
+		- 1: enabled
+		- 0: disabled
Signature · 1 line
2.25.1
#5 lore raw
In reply to ChiaEn Wu

Hi,

Quoted 12 lines · ChiaEn Wu

From: ChiaEn Wu <[email protected]>

This patch set is to add Richtek RT9467 5A Battery Charger support.

RT9467 is a switch-mode single cell Li-Ion/Li-Polymer battery charger for portable applications.

It integrates a synchronous PWM controller, power MOSFETs, input current sensing and regulation, high-accuracy voltage regulation, and charge termination. The charge current is regulated through integrated sensing resistors.

Quoted 6 lines

The RT9467 also features USB On-The-Go (OTG) support. It also integrates D+/D- pin for USB host/charging port detection.

Thank you,
ChiaEn Wu
---

Thanks, queued.

-- Sebastian