Skip to contentSkip to conversation

power: supply: add support for Pegatron Chagall battery

PATCH Applied Svyatoslav Ryhel 3 participants 9 messages Apr 29, 2025 – Jul 11, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover power: supply: add support for Pegatron Chagall battery

The Pegatron Chagall is an Android tablet utilizing a customized Cypress CG7153AM microcontroller (MCU) as its battery fuel gauge. It supports a single-cell battery and features a dual-color charging LED.

---
Changes in v3:
- status update handled via default-trigger
- chagall_battery_prop_offs sorted by chagall_battery_properties
- separated status logic into chagall_battery_get_status helper
- removed controversial POWER_SUPPLY_STATUS_NOT_CHARGING use
- code formatting improvemets

Changes in v2:
- removed CG7153AM mentions in code, documentation and commit messages
- moved schema to power/supply
- left only pegatron,chagall compatible, other is dropped
---

Svyatoslav Ryhel (4):
dt-bindings: vendor-prefixes: add prefix for Pegatron Corporation
dt-bindings: power: supply: Document Pegatron Chagall fuel gauge
power: supply: Add driver for Pegatron Chagall battery
ARM: tegra: chagall: Add embedded controller node

 .../power/supply/pegatron,chagall-ec.yaml     |  49 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 .../dts/nvidia/tegra30-pegatron-chagall.dts   |  16 +
 drivers/power/supply/Kconfig                  |  12 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/chagall-battery.c        | 291 ++++++++++++++++++
 6 files changed, 371 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/pegatron,chagall-ec.yaml
 create mode 100644 drivers/power/supply/chagall-battery.c
Signature · 1 line
2.48.1
#1 lore raw

PATCH v3 1/4 dt-bindings: vendor-prefixes: add prefix for Pegatron Corporation

PEGATRON Corporation is a Taiwanese electronics manufacturing company that mainly develops computing, communications and consumer electronics for branded vendors. Link https://www.pegatroncorp.com/

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index da01616802c7..d36389aa4d7b 100644
@@ -1146,6 +1146,8 @@ patternProperties:
     description: Parallax Inc.
   "^pda,.*":
     description: Precision Design Associates, Inc.
+  "^pegatron,.*":
+    description: Pegatron Corporation
   "^pericom,.*":
     description: Pericom Technology Inc.
   "^pervasive,.*":
Signature · 1 line
2.48.1
#2 lore raw

PATCH v3 2/4 dt-bindings: power: supply: Document Pegatron Chagall fuel gauge

In reply to Svyatoslav Ryhel

Add binding for Pegatron Chagall tablets battery monitor.

---
 .../power/supply/pegatron,chagall-ec.yaml     | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/pegatron,chagall-ec.yaml
Documentation/devicetree/bindings/power/supply/pegatron,chagall-ec.yaml new file +49 -0
new file mode 100644
index 000000000000..defb0861e268
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/pegatron,chagall-ec.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Pegatron Chagall EC
+
+maintainers:
+  - Svyatoslav Ryhel <[email protected]>
+
+description:
+  Pegatron Chagall EC is based on an 8-bit programmable microcontroller from
+  Infineon/Cypress Semiconductor, it communicates over I2C and is used in the
+  Pegatron Chagall tablet for fuel gauge and battery control functions.
+
+$ref: /schemas/power/supply/power-supply.yaml
+
+properties:
+  compatible:
+    const: pegatron,chagall-ec
+
+  reg:
+    maxItems: 1
+
+  monitored-battery: true
+  power-supplies: true
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        embedded-controller@10 {
+            compatible = "pegatron,chagall-ec";
+            reg = <0x10>;
+
+            monitored-battery = <&battery>;
+            power-supplies = <&mains>;
+        };
+    };
+...
Signature · 1 line
2.48.1
#3 lore raw

PATCH v3 3/4 power: supply: Add driver for Pegatron Chagall battery

In reply to Svyatoslav Ryhel

The Pegatron Chagall is an Android tablet utilizing a customized Cypress CG7153AM microcontroller (MCU) as its battery fuel gauge. It supports a single-cell battery and features a dual-color charging LED.

---
 drivers/power/supply/Kconfig           |  12 +
 drivers/power/supply/Makefile          |   1 +
 drivers/power/supply/chagall-battery.c | 291 +++++++++++++++++++++++++
 3 files changed, 304 insertions(+)
 create mode 100644 drivers/power/supply/chagall-battery.c
drivers/power/supply/Kconfig +12 -0
index 9f2eef6787f7..d0fc9db524bd 100644
@@ -107,6 +107,18 @@ config BATTERY_ACT8945A
 	  Say Y here to enable support for power supply provided by
 	  Active-semi ActivePath ACT8945A charger.
 
+config BATTERY_CHAGALL
+	tristate "Pegatron Chagall battery driver"
+	depends on I2C
+	depends on LEDS_CLASS
+	help
+	  Say Y to include support for Cypress CG7153AM IC based battery
+	  fuel gauge with custom firmware found in Pegatron Chagall based
+	  tablet line.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called chagall-battery.
+
 config BATTERY_CPCAP
 	tristate "Motorola CPCAP PMIC battery driver"
 	depends on MFD_CPCAP && IIO
drivers/power/supply/Makefile +1 -0
index 59c4a9f40d28..4ecf48a33fdd 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_CHARGER_ADP5061)	+= adp5061.o
 obj-$(CONFIG_BATTERY_ACT8945A)	+= act8945a_charger.o
 obj-$(CONFIG_BATTERY_AXP20X)	+= axp20x_battery.o
 obj-$(CONFIG_CHARGER_AXP20X)	+= axp20x_ac_power.o
+obj-$(CONFIG_BATTERY_CHAGALL)	+= chagall-battery.o
 obj-$(CONFIG_BATTERY_CPCAP)	+= cpcap-battery.o
 obj-$(CONFIG_BATTERY_CW2015)	+= cw2015_battery.o
 obj-$(CONFIG_BATTERY_DS2760)	+= ds2760_battery.o
drivers/power/supply/chagall-battery.c new file +291 -0

291 lines not on this page · raw message

Signature · 1 line
2.48.1
#4 lore raw

Re: [PATCH v3 3/4] power: supply: Add driver for Pegatron Chagall battery

Hi,

Quoted 9 lines · Svyatoslav Ryhel

The Pegatron Chagall is an Android tablet utilizing a customized Cypress CG7153AM microcontroller (MCU) as its battery fuel gauge. It supports a single-cell battery and features a dual-color charging LED.

---

[...]

drivers/power/supply/chagall-battery.c line 232

Quoted 5 lines
drivers/power/supply/chagall-battery.c new file +5 -0
+	cg->white_led.name = "power::white";
+	cg->white_led.max_brightness = 1;
+	cg->white_led.flags = LED_CORE_SUSPENDRESUME;
+	cg->white_led.brightness_set = chagall_led_set_brightness_white;
+	cg->amber_led.default_trigger = "chagall-battery-full";

^^^ I fixed up the typo while applying.

Quoted 1 line

[...]

Greetings,

-- Sebastian

#5 lore raw

Re: [PATCH v3 3/4] power: supply: Add driver for Pegatron Chagall battery

ср, 30 квіт. 2025 р. о 01:06 Sebastian Reichel
<[email protected]> пише:

Quoted 13 lines

Hi,

Quoted 9 lines · Svyatoslav Ryhel

The Pegatron Chagall is an Android tablet utilizing a customized Cypress CG7153AM microcontroller (MCU) as its battery fuel gauge. It supports a single-cell battery and features a dual-color charging LED.

---

[...]

Quoted 8 lines

drivers/power/supply/chagall-battery.c line 232

Quoted 5 lines
drivers/power/supply/chagall-battery.c new file +5 -0
+     cg->white_led.name = "power::white";
+     cg->white_led.max_brightness = 1;
+     cg->white_led.flags = LED_CORE_SUSPENDRESUME;
+     cg->white_led.brightness_set = chagall_led_set_brightness_white;
+     cg->amber_led.default_trigger = "chagall-battery-full";

^^^ I fixed up the typo while applying.

Thank you!

Quoted 5 lines
Quoted 1 line

[...]

Greetings,

-- Sebastian

#6 lore raw

PATCH v3 4/4 ARM: tegra: chagall: Add embedded controller node

In reply to Svyatoslav Ryhel

Add embedded controller node to Pegatron Chagall device-tree.

---
 .../boot/dts/nvidia/tegra30-pegatron-chagall.dts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm/boot/dts/nvidia/tegra30-pegatron-chagall.dts +16 -0
index 4012f9c799a8..b7d0ebb766a6 100644
@@ -1155,6 +1155,14 @@ lcd_ddc: i2c@7000c000 {
 		status = "okay";
 		clock-frequency = <400000>;
 
+		embedded-controller@10 {
+			compatible = "pegatron,chagall-ec";
+			reg = <0x10>;
+
+			monitored-battery = <&battery>;
+			power-supplies = <&mains>;
+		};
+
 		/* Wolfson Microelectronics WM8903 audio codec */
 		wm8903: audio-codec@1a {
 			compatible = "wlf,wm8903";
@@ -2596,6 +2604,14 @@ backlight: backlight {
 		default-brightness-level = <15>;
 	};
 
+	battery: battery-cell {
+		compatible = "simple-battery";
+		device-chemistry = "lithium-ion-polymer";
+		charge-full-design-microamp-hours = <3050000>;
+		energy-full-design-microwatt-hours = <23000000>;
+		operating-range-celsius = <0 45>;
+	};
+
 	/* PMIC has a built-in 32KHz oscillator which is used by PMC */
 	clk32k_in: clock-32k {
 		compatible = "fixed-clock";
Signature · 1 line
2.48.1
#7 lore raw

Re: (subset) [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery

In reply to Svyatoslav Ryhel
Quoted 4 lines · Svyatoslav Ryhel

The Pegatron Chagall is an Android tablet utilizing a customized Cypress CG7153AM microcontroller (MCU) as its battery fuel gauge. It supports a single-cell battery and features a dual-color charging LED.

Applied, thanks!

[1/4] dt-bindings: vendor-prefixes: add prefix for Pegatron Corporation

      commit: b5cd5c42a9182cf6602b2a68201d39bd60a2a65e
[2/4] dt-bindings: power: supply: Document Pegatron Chagall fuel gauge
      commit: 615a8d9d897de77268ee81a78a5bf65fad53bcc8
[3/4] power: supply: Add driver for Pegatron Chagall battery
      commit: fbc1d056d3f3d417bc9df521cb45a0f51758b64a

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>
#8 lore raw

Re: (subset) [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery

In reply to Svyatoslav Ryhel

From: Thierry Reding <[email protected]>

Quoted 4 lines · Svyatoslav Ryhel

The Pegatron Chagall is an Android tablet utilizing a customized Cypress CG7153AM microcontroller (MCU) as its battery fuel gauge. It supports a single-cell battery and features a dual-color charging LED.

Applied, thanks!

[4/4] ARM: tegra: chagall: Add embedded controller node

      commit: 3c2c00572fc3e0b128f75c7ce9c3f70ca457cc3b

Best regards,

Signature · 1 line
Thierry Reding <[email protected]>