linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery
@ 2025-04-29  6:17 Svyatoslav Ryhel
  2025-04-29  6:17 ` [PATCH v3 1/4] dt-bindings: vendor-prefixes: add prefix for Pegatron Corporation Svyatoslav Ryhel
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-04-29  6:17 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Thierry Reding, Jonathan Hunter, Neil Armstrong, Jonathan Cameron,
	Rafał Miłecki, Aradhya Bhatia, Svyatoslav Ryhel
  Cc: linux-pm, devicetree, linux-kernel, linux-tegra

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

-- 
2.48.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/4] dt-bindings: vendor-prefixes: add prefix for Pegatron Corporation
  2025-04-29  6:17 [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Svyatoslav Ryhel
@ 2025-04-29  6:17 ` Svyatoslav Ryhel
  2025-04-29  6:18 ` [PATCH v3 2/4] dt-bindings: power: supply: Document Pegatron Chagall fuel gauge Svyatoslav Ryhel
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-04-29  6:17 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Thierry Reding, Jonathan Hunter, Neil Armstrong, Jonathan Cameron,
	Rafał Miłecki, Aradhya Bhatia, Svyatoslav Ryhel
  Cc: linux-pm, devicetree, linux-kernel, linux-tegra

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

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index da01616802c7..d36389aa4d7b 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1146,6 +1146,8 @@ patternProperties:
     description: Parallax Inc.
   "^pda,.*":
     description: Precision Design Associates, Inc.
+  "^pegatron,.*":
+    description: Pegatron Corporation
   "^pericom,.*":
     description: Pericom Technology Inc.
   "^pervasive,.*":
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/4] dt-bindings: power: supply: Document Pegatron Chagall fuel gauge
  2025-04-29  6:17 [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Svyatoslav Ryhel
  2025-04-29  6:17 ` [PATCH v3 1/4] dt-bindings: vendor-prefixes: add prefix for Pegatron Corporation Svyatoslav Ryhel
@ 2025-04-29  6:18 ` Svyatoslav Ryhel
  2025-04-29  6:18 ` [PATCH v3 3/4] power: supply: Add driver for Pegatron Chagall battery Svyatoslav Ryhel
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-04-29  6:18 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Thierry Reding, Jonathan Hunter, Neil Armstrong, Jonathan Cameron,
	Rafał Miłecki, Aradhya Bhatia, Svyatoslav Ryhel
  Cc: linux-pm, devicetree, linux-kernel, linux-tegra

Add binding for Pegatron Chagall tablets battery monitor.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
---
 .../power/supply/pegatron,chagall-ec.yaml     | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/pegatron,chagall-ec.yaml

diff --git a/Documentation/devicetree/bindings/power/supply/pegatron,chagall-ec.yaml b/Documentation/devicetree/bindings/power/supply/pegatron,chagall-ec.yaml
new file mode 100644
index 000000000000..defb0861e268
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/pegatron,chagall-ec.yaml
@@ -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 <clamor95@gmail.com>
+
+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>;
+        };
+    };
+...
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/4] power: supply: Add driver for Pegatron Chagall battery
  2025-04-29  6:17 [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Svyatoslav Ryhel
  2025-04-29  6:17 ` [PATCH v3 1/4] dt-bindings: vendor-prefixes: add prefix for Pegatron Corporation Svyatoslav Ryhel
  2025-04-29  6:18 ` [PATCH v3 2/4] dt-bindings: power: supply: Document Pegatron Chagall fuel gauge Svyatoslav Ryhel
@ 2025-04-29  6:18 ` Svyatoslav Ryhel
  2025-04-29 22:05   ` Sebastian Reichel
  2025-04-29  6:18 ` [PATCH v3 4/4] ARM: tegra: chagall: Add embedded controller node Svyatoslav Ryhel
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-04-29  6:18 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Thierry Reding, Jonathan Hunter, Neil Armstrong, Jonathan Cameron,
	Rafał Miłecki, Aradhya Bhatia, Svyatoslav Ryhel
  Cc: linux-pm, devicetree, linux-kernel, linux-tegra

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.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 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

diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index 9f2eef6787f7..d0fc9db524bd 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -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
diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile
index 59c4a9f40d28..4ecf48a33fdd 100644
--- a/drivers/power/supply/Makefile
+++ b/drivers/power/supply/Makefile
@@ -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
diff --git a/drivers/power/supply/chagall-battery.c b/drivers/power/supply/chagall-battery.c
new file mode 100644
index 000000000000..9d858d93e244
--- /dev/null
+++ b/drivers/power/supply/chagall-battery.c
@@ -0,0 +1,291 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/array_size.h>
+#include <linux/delay.h>
+#include <linux/devm-helpers.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/leds.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/power_supply.h>
+#include <linux/regmap.h>
+
+#define CHAGALL_REG_LED_AMBER				0x60
+#define CHAGALL_REG_LED_WHITE				0x70
+#define CHAGALL_REG_BATTERY_TEMPERATURE			0xa2
+#define CHAGALL_REG_BATTERY_VOLTAGE			0xa4
+#define CHAGALL_REG_BATTERY_CURRENT			0xa6
+#define CHAGALL_REG_BATTERY_CAPACITY			0xa8
+#define CHAGALL_REG_BATTERY_CHARGING_CURRENT		0xaa
+#define CHAGALL_REG_BATTERY_CHARGING_VOLTAGE		0xac
+#define CHAGALL_REG_BATTERY_STATUS			0xae
+#define   BATTERY_DISCHARGING				BIT(6)
+#define   BATTERY_FULL_CHARGED				BIT(5)
+#define   BATTERY_FULL_DISCHARGED			BIT(4)
+#define CHAGALL_REG_BATTERY_REMAIN_CAPACITY		0xb0
+#define CHAGALL_REG_BATTERY_FULL_CAPACITY		0xb2
+#define CHAGALL_REG_MAX_COUNT				0xb4
+
+#define CHAGALL_BATTERY_DATA_REFRESH			5000
+#define TEMP_CELSIUS_OFFSET				2731
+
+static const struct regmap_config chagall_battery_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = CHAGALL_REG_MAX_COUNT,
+	.reg_format_endian = REGMAP_ENDIAN_LITTLE,
+	.val_format_endian = REGMAP_ENDIAN_LITTLE,
+};
+
+struct chagall_battery_data {
+	struct regmap *regmap;
+	struct led_classdev amber_led;
+	struct led_classdev white_led;
+	struct power_supply *battery;
+	struct delayed_work poll_work;
+	u16 last_state;
+};
+
+static void chagall_led_set_brightness_amber(struct led_classdev *led,
+					     enum led_brightness brightness)
+{
+	struct chagall_battery_data *cg =
+		container_of(led, struct chagall_battery_data, amber_led);
+
+	regmap_write(cg->regmap, CHAGALL_REG_LED_AMBER, brightness);
+}
+
+static void chagall_led_set_brightness_white(struct led_classdev *led,
+					     enum led_brightness brightness)
+{
+	struct chagall_battery_data *cg =
+		container_of(led, struct chagall_battery_data, white_led);
+
+	regmap_write(cg->regmap, CHAGALL_REG_LED_WHITE, brightness);
+}
+
+static const enum power_supply_property chagall_battery_properties[] = {
+	POWER_SUPPLY_PROP_STATUS,
+	POWER_SUPPLY_PROP_PRESENT,
+	POWER_SUPPLY_PROP_VOLTAGE_NOW,
+	POWER_SUPPLY_PROP_VOLTAGE_MAX,
+	POWER_SUPPLY_PROP_CURRENT_NOW,
+	POWER_SUPPLY_PROP_CURRENT_MAX,
+	POWER_SUPPLY_PROP_CAPACITY,
+	POWER_SUPPLY_PROP_TEMP,
+	POWER_SUPPLY_PROP_CHARGE_FULL,
+	POWER_SUPPLY_PROP_CHARGE_NOW,
+};
+
+static const unsigned int chagall_battery_prop_offs[] = {
+	[POWER_SUPPLY_PROP_STATUS] = CHAGALL_REG_BATTERY_STATUS,
+	[POWER_SUPPLY_PROP_VOLTAGE_NOW] = CHAGALL_REG_BATTERY_VOLTAGE,
+	[POWER_SUPPLY_PROP_VOLTAGE_MAX] = CHAGALL_REG_BATTERY_CHARGING_VOLTAGE,
+	[POWER_SUPPLY_PROP_CURRENT_NOW] = CHAGALL_REG_BATTERY_CURRENT,
+	[POWER_SUPPLY_PROP_CURRENT_MAX] = CHAGALL_REG_BATTERY_CHARGING_CURRENT,
+	[POWER_SUPPLY_PROP_CAPACITY] = CHAGALL_REG_BATTERY_CAPACITY,
+	[POWER_SUPPLY_PROP_TEMP] = CHAGALL_REG_BATTERY_TEMPERATURE,
+	[POWER_SUPPLY_PROP_CHARGE_FULL] = CHAGALL_REG_BATTERY_FULL_CAPACITY,
+	[POWER_SUPPLY_PROP_CHARGE_NOW] = CHAGALL_REG_BATTERY_REMAIN_CAPACITY,
+};
+
+static int chagall_battery_get_value(struct chagall_battery_data *cg,
+				     enum power_supply_property psp, u32 *val)
+{
+	if (psp >= ARRAY_SIZE(chagall_battery_prop_offs))
+		return -EINVAL;
+	if (!chagall_battery_prop_offs[psp])
+		return -EINVAL;
+
+	/* Battery data is stored in 2 consecutive registers with little-endian */
+	return regmap_bulk_read(cg->regmap, chagall_battery_prop_offs[psp], val, 2);
+}
+
+static int chagall_battery_get_status(u32 status_reg)
+{
+	if (status_reg & BATTERY_FULL_CHARGED)
+		return POWER_SUPPLY_STATUS_FULL;
+	else if (status_reg & BATTERY_DISCHARGING)
+		return POWER_SUPPLY_STATUS_DISCHARGING;
+	else
+		return POWER_SUPPLY_STATUS_CHARGING;
+}
+
+static int chagall_battery_get_property(struct power_supply *psy,
+					enum power_supply_property psp,
+					union power_supply_propval *val)
+{
+	struct chagall_battery_data *cg = power_supply_get_drvdata(psy);
+	int ret;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_PRESENT:
+		val->intval = 1;
+		break;
+
+	default:
+		ret = chagall_battery_get_value(cg, psp, &val->intval);
+		if (ret)
+			return ret;
+
+		switch (psp) {
+		case POWER_SUPPLY_PROP_TEMP:
+			val->intval -= TEMP_CELSIUS_OFFSET;
+			break;
+
+		case POWER_SUPPLY_PROP_VOLTAGE_MAX:
+		case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+		case POWER_SUPPLY_PROP_CURRENT_MAX:
+		case POWER_SUPPLY_PROP_CURRENT_NOW:
+		case POWER_SUPPLY_PROP_CHARGE_FULL:
+		case POWER_SUPPLY_PROP_CHARGE_NOW:
+			val->intval *= 1000;
+			break;
+
+		case POWER_SUPPLY_PROP_STATUS:
+			val->intval = chagall_battery_get_status(val->intval);
+			break;
+
+		default:
+			break;
+		}
+
+		break;
+	}
+
+	return 0;
+}
+
+static void chagall_battery_poll_work(struct work_struct *work)
+{
+	struct chagall_battery_data *cg =
+		container_of(work, struct chagall_battery_data, poll_work.work);
+	u32 state;
+	int ret;
+
+	ret = chagall_battery_get_value(cg, POWER_SUPPLY_PROP_STATUS, &state);
+	if (ret)
+		return;
+
+	state = chagall_battery_get_status(state);
+
+	if (cg->last_state != state) {
+		cg->last_state = state;
+		power_supply_changed(cg->battery);
+	}
+
+	/* continuously send uevent notification */
+	schedule_delayed_work(&cg->poll_work,
+			      msecs_to_jiffies(CHAGALL_BATTERY_DATA_REFRESH));
+}
+
+static const struct power_supply_desc chagall_battery_desc = {
+	.name = "chagall-battery",
+	.type = POWER_SUPPLY_TYPE_BATTERY,
+	.properties = chagall_battery_properties,
+	.num_properties = ARRAY_SIZE(chagall_battery_properties),
+	.get_property = chagall_battery_get_property,
+	.external_power_changed = power_supply_changed,
+};
+
+static int chagall_battery_probe(struct i2c_client *client)
+{
+	struct chagall_battery_data *cg;
+	struct device *dev = &client->dev;
+	struct power_supply_config cfg = { };
+	int ret;
+
+	cg = devm_kzalloc(dev, sizeof(*cg), GFP_KERNEL);
+	if (!cg)
+		return -ENOMEM;
+
+	cfg.drv_data = cg;
+	cfg.fwnode = dev_fwnode(dev);
+
+	i2c_set_clientdata(client, cg);
+
+	cg->regmap = devm_regmap_init_i2c(client, &chagall_battery_regmap_config);
+	if (IS_ERR(cg->regmap))
+		return dev_err_probe(dev, PTR_ERR(cg->regmap), "cannot allocate regmap\n");
+
+	cg->last_state = POWER_SUPPLY_STATUS_UNKNOWN;
+	cg->battery = devm_power_supply_register(dev, &chagall_battery_desc, &cfg);
+	if (IS_ERR(cg->battery))
+		return dev_err_probe(dev, PTR_ERR(cg->battery),
+				     "failed to register power supply\n");
+
+	cg->amber_led.name = "power::amber";
+	cg->amber_led.max_brightness = 1;
+	cg->amber_led.flags = LED_CORE_SUSPENDRESUME;
+	cg->amber_led.brightness_set = chagall_led_set_brightness_amber;
+	cg->amber_led.default_trigger = "chagall-battery-charging";
+
+	ret = devm_led_classdev_register(dev, &cg->amber_led);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to register amber LED\n");
+
+	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";
+
+	ret = devm_led_classdev_register(dev, &cg->white_led);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to register white LED\n");
+
+	led_set_brightness(&cg->amber_led, LED_OFF);
+	led_set_brightness(&cg->white_led, LED_OFF);
+
+	ret = devm_delayed_work_autocancel(dev, &cg->poll_work, chagall_battery_poll_work);
+	if (ret)
+		return ret;
+
+	schedule_delayed_work(&cg->poll_work, msecs_to_jiffies(CHAGALL_BATTERY_DATA_REFRESH));
+
+	return 0;
+}
+
+static int __maybe_unused chagall_battery_suspend(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct chagall_battery_data *cg = i2c_get_clientdata(client);
+
+	cancel_delayed_work_sync(&cg->poll_work);
+
+	return 0;
+}
+
+static int __maybe_unused chagall_battery_resume(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct chagall_battery_data *cg = i2c_get_clientdata(client);
+
+	schedule_delayed_work(&cg->poll_work, msecs_to_jiffies(CHAGALL_BATTERY_DATA_REFRESH));
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(chagall_battery_pm_ops,
+			 chagall_battery_suspend, chagall_battery_resume);
+
+static const struct of_device_id chagall_of_match[] = {
+	{ .compatible = "pegatron,chagall-ec" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, chagall_of_match);
+
+static struct i2c_driver chagall_battery_driver = {
+	.driver = {
+		.name = "chagall-battery",
+		.pm = &chagall_battery_pm_ops,
+		.of_match_table = chagall_of_match,
+	},
+	.probe = chagall_battery_probe,
+};
+module_i2c_driver(chagall_battery_driver);
+
+MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>");
+MODULE_DESCRIPTION("Pegatron Chagall fuel gauge driver");
+MODULE_LICENSE("GPL");
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/4] ARM: tegra: chagall: Add embedded controller node
  2025-04-29  6:17 [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Svyatoslav Ryhel
                   ` (2 preceding siblings ...)
  2025-04-29  6:18 ` [PATCH v3 3/4] power: supply: Add driver for Pegatron Chagall battery Svyatoslav Ryhel
@ 2025-04-29  6:18 ` Svyatoslav Ryhel
  2025-04-29 22:04 ` (subset) [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Sebastian Reichel
  2025-07-11 15:11 ` Thierry Reding
  5 siblings, 0 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-04-29  6:18 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Thierry Reding, Jonathan Hunter, Neil Armstrong, Jonathan Cameron,
	Rafał Miłecki, Aradhya Bhatia, Svyatoslav Ryhel
  Cc: linux-pm, devicetree, linux-kernel, linux-tegra

Add embedded controller node to Pegatron Chagall device-tree.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 .../boot/dts/nvidia/tegra30-pegatron-chagall.dts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/nvidia/tegra30-pegatron-chagall.dts b/arch/arm/boot/dts/nvidia/tegra30-pegatron-chagall.dts
index 4012f9c799a8..b7d0ebb766a6 100644
--- a/arch/arm/boot/dts/nvidia/tegra30-pegatron-chagall.dts
+++ b/arch/arm/boot/dts/nvidia/tegra30-pegatron-chagall.dts
@@ -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";
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: (subset) [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery
  2025-04-29  6:17 [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Svyatoslav Ryhel
                   ` (3 preceding siblings ...)
  2025-04-29  6:18 ` [PATCH v3 4/4] ARM: tegra: chagall: Add embedded controller node Svyatoslav Ryhel
@ 2025-04-29 22:04 ` Sebastian Reichel
  2025-07-11 15:11 ` Thierry Reding
  5 siblings, 0 replies; 9+ messages in thread
From: Sebastian Reichel @ 2025-04-29 22:04 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Thierry Reding, Jonathan Hunter, Neil Armstrong, Jonathan Cameron,
	Rafał Miłecki, Aradhya Bhatia, Svyatoslav Ryhel
  Cc: linux-pm, devicetree, linux-kernel, linux-tegra


On Tue, 29 Apr 2025 09:17:58 +0300, Svyatoslav Ryhel wrote:
> 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,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/4] power: supply: Add driver for Pegatron Chagall battery
  2025-04-29  6:18 ` [PATCH v3 3/4] power: supply: Add driver for Pegatron Chagall battery Svyatoslav Ryhel
@ 2025-04-29 22:05   ` Sebastian Reichel
  2025-04-30  5:38     ` Svyatoslav Ryhel
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Reichel @ 2025-04-29 22:05 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Thierry Reding,
	Jonathan Hunter, Neil Armstrong, Jonathan Cameron,
	Rafał Miłecki, Aradhya Bhatia, linux-pm, devicetree,
	linux-kernel, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 717 bytes --]

Hi,

On Tue, Apr 29, 2025 at 09:18:01AM +0300, Svyatoslav Ryhel wrote:
> 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.
> 
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
>
> [...]
>
> +	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.

> [...]

Greetings,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/4] power: supply: Add driver for Pegatron Chagall battery
  2025-04-29 22:05   ` Sebastian Reichel
@ 2025-04-30  5:38     ` Svyatoslav Ryhel
  0 siblings, 0 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-04-30  5:38 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Thierry Reding,
	Jonathan Hunter, Neil Armstrong, Jonathan Cameron,
	Rafał Miłecki, Aradhya Bhatia, linux-pm, devicetree,
	linux-kernel, linux-tegra

ср, 30 квіт. 2025 р. о 01:06 Sebastian Reichel
<sebastian.reichel@collabora.com> пише:
>
> Hi,
>
> On Tue, Apr 29, 2025 at 09:18:01AM +0300, Svyatoslav Ryhel wrote:
> > 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.
> >
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > ---
> >
> > [...]
> >
> > +     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!

> > [...]
>
> Greetings,
>
> -- Sebastian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: (subset) [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery
  2025-04-29  6:17 [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Svyatoslav Ryhel
                   ` (4 preceding siblings ...)
  2025-04-29 22:04 ` (subset) [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Sebastian Reichel
@ 2025-07-11 15:11 ` Thierry Reding
  5 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2025-07-11 15:11 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Thierry Reding, Jonathan Hunter, Neil Armstrong, Jonathan Cameron,
	Rafał Miłecki, Aradhya Bhatia, Svyatoslav Ryhel
  Cc: linux-pm, devicetree, linux-kernel, linux-tegra

From: Thierry Reding <treding@nvidia.com>


On Tue, 29 Apr 2025 09:17:58 +0300, Svyatoslav Ryhel wrote:
> 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,
-- 
Thierry Reding <treding@nvidia.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-07-11 15:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-29  6:17 [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Svyatoslav Ryhel
2025-04-29  6:17 ` [PATCH v3 1/4] dt-bindings: vendor-prefixes: add prefix for Pegatron Corporation Svyatoslav Ryhel
2025-04-29  6:18 ` [PATCH v3 2/4] dt-bindings: power: supply: Document Pegatron Chagall fuel gauge Svyatoslav Ryhel
2025-04-29  6:18 ` [PATCH v3 3/4] power: supply: Add driver for Pegatron Chagall battery Svyatoslav Ryhel
2025-04-29 22:05   ` Sebastian Reichel
2025-04-30  5:38     ` Svyatoslav Ryhel
2025-04-29  6:18 ` [PATCH v3 4/4] ARM: tegra: chagall: Add embedded controller node Svyatoslav Ryhel
2025-04-29 22:04 ` (subset) [PATCH v3 0/4] power: supply: add support for Pegatron Chagall battery Sebastian Reichel
2025-07-11 15:11 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).