Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v7 0/9] Add the remaining AXP192 PMIC support
@ 2026-12-06  3:08 Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 1/9] dt-bindings: iio: adc: axp209: Add AXP192 compatible Molnár Máté via B4 Relay
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:08 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Molnár Máté,
	Andy Shevchenko, Chen-Yu Tsai

This picks up Aidan MacDonald's AXP192 series [1]. The MFD core, ADC and
USB power supply parts were merged back then, but the regulator, battery
and two binding patches were not, and Aidan has said he no longer works
on it [2]. I'm resending them, rebased on next-20261201, and adding
a capacity estimate and power key support on top.

Tested on next-20261201 on a Denver TAQ-10162 tablet (RK3126 + AXP192):
all regulators come up at their DT voltages, the battery, USB power
supply and power key work, and with a simple-battery OCV table in the
board DT the capacity tracks the battery voltage, so UPower no longer
shuts the tablet down at what it took for 0%.

I used an AI coding assistant (Claude) to rebase the series, draft the
new patches and commit messages, and run the hardware tests; I have
reviewed and tested every patch myself.

Changes since v6:
- dt-bindings and regulator patches: rebased only, tags kept.
- axp20x_battery patches: the driver has gained per-variant descriptors
  and callbacks (AXP717 support) since v6, so these were reworked to
  fit; review tags dropped for that reason.
- New: capacity estimate from the monitored battery's OCV table, since
  the AXP192 has no fuel gauge.
- New: axp20x-pek and mfd patches for the AXP192 power key, which only
  has short/long press interrupts and no edge interrupts.

[1] https://lore.kernel.org/all/20221016234335.904212-1-aidanmacdonald.0x0@gmail.com/
[2] https://lkml.iu.edu/hypermail/linux/kernel/2501.0/00419.html

---
Aidan MacDonald (6):
      dt-bindings: iio: adc: axp209: Add AXP192 compatible
      dt-bindings: power: axp20x-battery: Add AXP192 compatible
      regulator: axp20x: Add support for AXP192
      power: axp20x_battery: Add constant charge current table
      power: axp20x_battery: Support battery status without fuel gauge
      power: axp20x_battery: Add support for AXP192

Molnár Máté (3):
      power: axp20x_battery: Estimate AXP192 capacity from the OCV table
      Input: axp20x-pek: Add AXP192 support
      mfd: axp20x: Add the AXP192 power key cell

 .../bindings/iio/adc/x-powers,axp209-adc.yaml      |  18 ++
 .../x-powers,axp20x-battery-power-supply.yaml      |   1 +
 drivers/input/misc/axp20x-pek.c                    |  29 ++-
 drivers/mfd/axp20x.c                               |  10 ++
 drivers/power/supply/axp20x_battery.c              | 195 +++++++++++++++++++--
 drivers/regulator/axp20x-regulator.c               | 100 ++++++++++-
 6 files changed, 328 insertions(+), 25 deletions(-)
---
base-commit: d138596e9f822033490b2e577ec2ea64f2aa246c
change-id: 20261206-axp192-d66298edf3e9

Best regards,
--  
Molnár Máté <matemolnar88@gmail.com>



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

* [PATCH v7 1/9] dt-bindings: iio: adc: axp209: Add AXP192 compatible
  2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
@ 2026-12-06  3:08 ` Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 2/9] dt-bindings: power: axp20x-battery: " Molnár Máté via B4 Relay
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:08 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Molnár Máté,
	Chen-Yu Tsai

From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>

The AXP192 is identical to the AXP20x, except for two additional
GPIO ADC channels.

Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Signed-off-by: Molnár Máté <matemolnar88@gmail.com>
---
 .../bindings/iio/adc/x-powers,axp209-adc.yaml          | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml b/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml
index de91cb03f..b3ab1a9e1 100644
--- a/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml
@@ -14,6 +14,23 @@ description: |
   Device is a child of an axp209 multifunction device
   ADC channels and their indexes per variant:
 
+  AXP192
+  ------
+   0 | acin_v
+   1 | acin_i
+   2 | vbus_v
+   3 | vbus_i
+   4 | pmic_temp
+   5 | gpio0_v
+   6 | gpio1_v
+   7 | gpio2_v
+   8 | gpio3_v
+   9 | ipsout_v
+  10 | batt_v
+  11 | batt_chrg_i
+  12 | batt_dischrg_i
+  13 | ts_v
+
   AXP209
   ------
    0 | acin_v
@@ -60,6 +77,7 @@ description: |
 properties:
   compatible:
     oneOf:
+      - const: x-powers,axp192-adc
       - const: x-powers,axp209-adc
       - const: x-powers,axp221-adc
       - const: x-powers,axp717-adc

-- 
2.43.0



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

* [PATCH v7 2/9] dt-bindings: power: axp20x-battery: Add AXP192 compatible
  2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 1/9] dt-bindings: iio: adc: axp209: Add AXP192 compatible Molnár Máté via B4 Relay
@ 2026-12-06  3:08 ` Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 3/9] regulator: axp20x: Add support for AXP192 Molnár Máté via B4 Relay
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:08 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Molnár Máté

From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>

The AXP192's battery charger is similar to the others supported by
the axp20x_battery driver.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Signed-off-by: Molnár Máté <matemolnar88@gmail.com>
---
 .../bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml      | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml
index a90d558e7..f7f6cd3f7 100644
--- a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml
+++ b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml
@@ -17,6 +17,7 @@ maintainers:
 properties:
   compatible:
     oneOf:
+      - const: x-powers,axp192-battery-power-supply
       - const: x-powers,axp202-battery-power-supply
       - const: x-powers,axp209-battery-power-supply
       - const: x-powers,axp221-battery-power-supply

-- 
2.43.0



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

* [PATCH v7 3/9] regulator: axp20x: Add support for AXP192
  2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 1/9] dt-bindings: iio: adc: axp209: Add AXP192 compatible Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 2/9] dt-bindings: power: axp20x-battery: " Molnár Máté via B4 Relay
@ 2026-12-06  3:08 ` Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 4/9] power: axp20x_battery: Add constant charge current table Molnár Máté via B4 Relay
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:08 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Andy Shevchenko,
	Molnár Máté

From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>

Add support for the AXP192 PMIC.

Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Signed-off-by: Molnár Máté <matemolnar88@gmail.com>
---
 drivers/regulator/axp20x-regulator.c | 100 +++++++++++++++++++++++++++++++----
 1 file changed, 91 insertions(+), 9 deletions(-)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 53b1e0499..efd4a3bc3 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -26,6 +26,29 @@
 #include <linux/regulator/machine.h>
 #include <linux/regulator/of_regulator.h>
 
+#define AXP192_GPIO0_FUNC_MASK		GENMASK(2, 0)
+
+#define AXP192_IO_ENABLED		0x02
+#define AXP192_IO_DISABLED		0x06
+
+#define AXP192_WORKMODE_DCDC1_MASK	BIT_MASK(3)
+#define AXP192_WORKMODE_DCDC2_MASK	BIT_MASK(2)
+#define AXP192_WORKMODE_DCDC3_MASK	BIT_MASK(1)
+
+#define AXP192_DCDC1_V_OUT_MASK		GENMASK(6, 0)
+#define AXP192_DCDC2_V_OUT_MASK		GENMASK(5, 0)
+#define AXP192_DCDC3_V_OUT_MASK		GENMASK(6, 0)
+#define AXP192_LDO2_V_OUT_MASK		GENMASK(7, 4)
+#define AXP192_LDO3_V_OUT_MASK		GENMASK(3, 0)
+#define AXP192_LDO_IO0_V_OUT_MASK	GENMASK(7, 4)
+
+#define AXP192_PWR_OUT_EXTEN_MASK	BIT_MASK(6)
+#define AXP192_PWR_OUT_DCDC2_MASK	BIT_MASK(4)
+#define AXP192_PWR_OUT_LDO3_MASK	BIT_MASK(3)
+#define AXP192_PWR_OUT_LDO2_MASK	BIT_MASK(2)
+#define AXP192_PWR_OUT_DCDC3_MASK	BIT_MASK(1)
+#define AXP192_PWR_OUT_DCDC1_MASK	BIT_MASK(0)
+
 #define AXP20X_GPIO0_FUNC_MASK		GENMASK(3, 0)
 #define AXP20X_GPIO1_FUNC_MASK		GENMASK(3, 0)
 
@@ -460,25 +483,32 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
 
 	switch (axp20x->variant) {
 	case AXP209_ID:
-		if (id == AXP20X_DCDC2) {
+		if (id == AXP20X_LDO3) {
 			slew_rates = axp209_dcdc2_ldo3_slew_rates;
 			rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
 			reg = AXP20X_DCDC2_LDO3_V_RAMP;
-			mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK |
-			       AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK;
+			mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK |
+			       AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK;
 			enable = (ramp > 0) ?
-				 AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN : 0;
+				 AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN : 0;
 			break;
 		}
 
-		if (id == AXP20X_LDO3) {
+		fallthrough;
+
+	case AXP192_ID:
+		/*
+		 * AXP192 and AXP209 share the same DCDC2 ramp configuration
+		 */
+		if ((axp20x->variant == AXP209_ID && id == AXP20X_DCDC2) ||
+		    (axp20x->variant == AXP192_ID && id == AXP192_DCDC2)) {
 			slew_rates = axp209_dcdc2_ldo3_slew_rates;
 			rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
 			reg = AXP20X_DCDC2_LDO3_V_RAMP;
-			mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK |
-			       AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK;
+			mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK |
+			       AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK;
 			enable = (ramp > 0) ?
-				 AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN : 0;
+				 AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN : 0;
 			break;
 		}
 
@@ -500,7 +530,8 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
 			if (ramp > slew_rates[i])
 				break;
 
-			if (id == AXP20X_DCDC2)
+			if ((axp20x->variant == AXP209_ID && id == AXP20X_DCDC2) ||
+			    (axp20x->variant == AXP192_ID && id == AXP192_DCDC2))
 				cfg = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE(i);
 			else
 				cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i);
@@ -596,6 +627,29 @@ static const struct regulator_ops axp20x_ops_sw = {
 	.is_enabled		= regulator_is_enabled_regmap,
 };
 
+static const struct regulator_desc axp192_regulators[] = {
+	AXP_DESC(AXP192, DCDC1, "dcdc1", "vin1", 700, 3500, 25,
+		 AXP192_DCDC1_V_OUT, AXP192_DCDC1_V_OUT_MASK,
+		 AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_DCDC1_MASK),
+	AXP_DESC(AXP192, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
+		 AXP192_DCDC2_V_OUT, AXP192_DCDC2_V_OUT_MASK,
+		 AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_DCDC2_MASK),
+	AXP_DESC(AXP192, DCDC3, "dcdc3", "vin3", 700, 3500, 25,
+		 AXP192_DCDC3_V_OUT, AXP192_DCDC3_V_OUT_MASK,
+		 AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_DCDC3_MASK),
+	AXP_DESC_FIXED(AXP192, LDO1, "ldo1", "acin", 1250),
+	AXP_DESC(AXP192, LDO2, "ldo2", "ldoin", 1800, 3300, 100,
+		 AXP192_LDO2_3_V_OUT, AXP192_LDO2_V_OUT_MASK,
+		 AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_LDO2_MASK),
+	AXP_DESC(AXP192, LDO3, "ldo3", "ldoin", 1800, 3300, 100,
+		 AXP192_LDO2_3_V_OUT, AXP192_LDO3_V_OUT_MASK,
+		 AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_LDO3_MASK),
+	AXP_DESC_IO(AXP192, LDO_IO0, "ldo_io0", "ips", 700, 3300, 100,
+		    AXP192_LDO_IO0_V_OUT, AXP192_LDO_IO0_V_OUT_MASK,
+		    AXP192_GPIO0_CTRL, AXP192_GPIO0_FUNC_MASK,
+		    AXP192_IO_ENABLED, AXP192_IO_DISABLED),
+};
+
 static const struct linear_range axp20x_ldo4_ranges[] = {
 	REGULATOR_LINEAR_RANGE(1250000,
 			       AXP20X_LDO4_V_OUT_1250mV_START,
@@ -1314,6 +1368,12 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 	u32 min, max, def, step;
 
 	switch (axp20x->variant) {
+	case AXP192_ID:
+		min = 900;
+		max = 2025;
+		def = 1500;
+		step = 75;
+		break;
 	case AXP202_ID:
 	case AXP209_ID:
 		min = 750;
@@ -1418,6 +1478,24 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
 	unsigned int mask;
 
 	switch (axp20x->variant) {
+	case AXP192_ID:
+		switch (id) {
+		case AXP192_DCDC1:
+			mask = AXP192_WORKMODE_DCDC1_MASK;
+			break;
+		case AXP192_DCDC2:
+			mask = AXP192_WORKMODE_DCDC2_MASK;
+			break;
+		case AXP192_DCDC3:
+			mask = AXP192_WORKMODE_DCDC3_MASK;
+			break;
+		default:
+			return -EINVAL;
+		}
+
+		workmode <<= ffs(mask) - 1;
+		break;
+
 	case AXP202_ID:
 	case AXP209_ID:
 		if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
@@ -1568,6 +1646,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 	bool drivevbus = false;
 
 	switch (axp20x->variant) {
+	case AXP192_ID:
+		regulators = axp192_regulators;
+		nregulators = AXP192_REG_ID_MAX;
+		break;
 	case AXP202_ID:
 	case AXP209_ID:
 		regulators = axp20x_regulators;

-- 
2.43.0



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

* [PATCH v7 4/9] power: axp20x_battery: Add constant charge current table
  2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
                   ` (2 preceding siblings ...)
  2026-12-06  3:08 ` [PATCH v7 3/9] regulator: axp20x: Add support for AXP192 Molnár Máté via B4 Relay
@ 2026-12-06  3:08 ` Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 5/9] power: axp20x_battery: Support battery status without fuel gauge Molnár Máté via B4 Relay
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:08 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Molnár Máté

From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>

Add a table-based lookup method for constant charge current,
which is necessary when the setting cannot be represented as
a linear range.

This also replaces the hard-coded 300 mA default ccc setting
if the DT-specified value is unsupported; the minimum value
for the device is now set exactly instead of relying on the
value being rounded down to a supported value.

Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
[Molnár Máté: rebased onto the current driver, which now has per-variant
 descriptors and callbacks; dropped the review tags because of the rework]
Signed-off-by: Molnár Máté <matemolnar88@gmail.com>
---
 drivers/power/supply/axp20x_battery.c | 59 ++++++++++++++++++++++++++++-------
 1 file changed, 47 insertions(+), 12 deletions(-)

diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
index 4af1a209c..f31b735ed 100644
--- a/drivers/power/supply/axp20x_battery.c
+++ b/drivers/power/supply/axp20x_battery.c
@@ -98,6 +98,14 @@ struct axp_data {
 	int		ccc_offset;
 	unsigned int	ccc_reg;
 	unsigned int	ccc_mask;
+	/*
+	 * Lookup table for constant charge current, if provided this is used
+	 * instead of ccc_scale/ccc_offset.
+	 *
+	 * The table is indexed by the field AXP20X_CHRG_CTRL1_TGT_CURR so it
+	 * must have AXP20X_CHRG_CTRL1_TGT_CURR+1 elements.
+	 */
+	const int	*ccc_table;
 	bool		has_fg_valid;
 	const struct	power_supply_desc *bat_ps_desc;
 	int	(*get_max_voltage)(struct axp20x_batt_ps *batt, int *val);
@@ -253,7 +261,10 @@ static int axp20x_get_constant_charge_current(struct axp20x_batt_ps *axp,
 
 	*val &= AXP20X_CHRG_CTRL1_TGT_CURR;
 
-	*val = *val * axp->data->ccc_scale + axp->data->ccc_offset;
+	if (axp->data->ccc_table)
+		*val = axp->data->ccc_table[*val];
+	else
+		*val = *val * axp->data->ccc_scale + axp->data->ccc_offset;
 
 	return 0;
 }
@@ -675,16 +686,35 @@ static int axp717_battery_set_max_voltage(struct axp20x_batt_ps *axp20x_batt,
 				  AXP717_CHRG_CV_VOLT_MASK, val);
 }
 
+static int axp20x_get_constant_charge_current_sel(struct axp20x_batt_ps *axp_batt,
+						  int charge_current)
+{
+	int i;
+
+	if (axp_batt->data->ccc_table) {
+		for (i = AXP20X_CHRG_CTRL1_TGT_CURR; i >= 0; i--) {
+			if (axp_batt->data->ccc_table[i] <= charge_current)
+				return i;
+		}
+
+		return -EINVAL;
+	}
+
+	i = (charge_current - axp_batt->data->ccc_offset) / axp_batt->data->ccc_scale;
+	if (i > AXP20X_CHRG_CTRL1_TGT_CURR || i < 0)
+		return -EINVAL;
+
+	return i;
+}
+
 static int axp20x_set_constant_charge_current(struct axp20x_batt_ps *axp_batt,
 					      int charge_current)
 {
 	if (charge_current > axp_batt->max_ccc)
 		return -EINVAL;
 
-	charge_current = (charge_current - axp_batt->data->ccc_offset) /
-		axp_batt->data->ccc_scale;
-
-	if (charge_current > AXP20X_CHRG_CTRL1_TGT_CURR || charge_current < 0)
+	charge_current = axp20x_get_constant_charge_current_sel(axp_batt, charge_current);
+	if (charge_current < 0)
 		return -EINVAL;
 
 	return regmap_update_bits(axp_batt->regmap, AXP20X_CHRG_CTRL1,
@@ -714,14 +744,14 @@ static int axp20x_set_max_constant_charge_current(struct axp20x_batt_ps *axp,
 {
 	bool lower_max = false;
 
-	charge_current = (charge_current - axp->data->ccc_offset) /
-		axp->data->ccc_scale;
-
-	if (charge_current > AXP20X_CHRG_CTRL1_TGT_CURR || charge_current < 0)
+	charge_current = axp20x_get_constant_charge_current_sel(axp, charge_current);
+	if (charge_current < 0)
 		return -EINVAL;
 
-	charge_current = charge_current * axp->data->ccc_scale +
-		axp->data->ccc_offset;
+	if (axp->data->ccc_table)
+		charge_current = axp->data->ccc_table[charge_current];
+	else
+		charge_current = charge_current * axp->data->ccc_scale + axp->data->ccc_offset;
 
 	if (charge_current > axp->max_ccc)
 		dev_warn(axp->dev,
@@ -972,7 +1002,12 @@ static void axp209_set_battery_info(struct platform_device *pdev,
 	if (ccc <= 0 || axp20x_set_constant_charge_current(axp_batt, ccc)) {
 		dev_err(&pdev->dev,
 			"couldn't set ccc from DT: fallback to min value\n");
-		ccc = 300000;
+
+		if (axp_batt->data->ccc_table)
+			ccc = axp_batt->data->ccc_table[0];
+		else
+			ccc = axp_batt->data->ccc_offset;
+
 		axp_batt->max_ccc = ccc;
 		axp20x_set_constant_charge_current(axp_batt, ccc);
 	}

-- 
2.43.0



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

* [PATCH v7 5/9] power: axp20x_battery: Support battery status without fuel gauge
  2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
                   ` (3 preceding siblings ...)
  2026-12-06  3:08 ` [PATCH v7 4/9] power: axp20x_battery: Add constant charge current table Molnár Máté via B4 Relay
@ 2026-12-06  3:08 ` Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 6/9] power: axp20x_battery: Add support for AXP192 Molnár Máté via B4 Relay
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:08 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Molnár Máté

From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>

Add a "has_fg" flag to indicate that the chip has a fuel gauge.
Report battery full status on chips with no fuel gauge using the
battery voltage.

Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
[Molnár Máté: rebased onto the current driver, which now has per-variant
 descriptors and callbacks; dropped the review tags because of the rework]
Signed-off-by: Molnár Máté <matemolnar88@gmail.com>
---
 drivers/power/supply/axp20x_battery.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
index f31b735ed..f7485ac6a 100644
--- a/drivers/power/supply/axp20x_battery.c
+++ b/drivers/power/supply/axp20x_battery.c
@@ -106,6 +106,7 @@ struct axp_data {
 	 * must have AXP20X_CHRG_CTRL1_TGT_CURR+1 elements.
 	 */
 	const int	*ccc_table;
+	bool		has_fg;
 	bool		has_fg_valid;
 	const struct	power_supply_desc *bat_ps_desc;
 	int	(*get_max_voltage)(struct axp20x_batt_ps *batt, int *val);
@@ -289,7 +290,7 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
 				   union power_supply_propval *val)
 {
 	struct axp20x_batt_ps *axp20x_batt = power_supply_get_drvdata(psy);
-	int ret = 0, reg, val1;
+	int ret = 0, reg, val1, val2;
 
 	switch (psp) {
 	case POWER_SUPPLY_PROP_PRESENT:
@@ -323,6 +324,34 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
 			return 0;
 		}
 
+		/*
+		 * If the chip does not have a fuel gauge, we check battery full status
+		 * using voltage instead.
+		 */
+		if (!axp20x_batt->data->has_fg) {
+			ret = axp20x_batt->data->get_max_voltage(axp20x_batt, &val1);
+			if (ret)
+				return ret;
+
+			ret = iio_read_channel_processed(axp20x_batt->batt_v, &val2);
+			if (ret)
+				return ret;
+
+			/* IIO subsystem reports voltage in mV but we need uV */
+			val2 *= 1000;
+
+			/*
+			 * According to the AXP192 datasheet, charging will restart if
+			 * the battery voltage drops below V_rch = V_tgt - 0.1 V, so we
+			 * report the battery is full if its voltage is at least V_rch.
+			 */
+			if (val2 >= val1 - 100000)
+				val->intval = POWER_SUPPLY_STATUS_FULL;
+			else
+				val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
+			break;
+		}
+
 		ret = regmap_read(axp20x_batt->regmap, AXP20X_FG_RES, &val1);
 		if (ret)
 			return ret;
@@ -1062,6 +1091,7 @@ static const struct axp_data axp209_data = {
 	.ccc_offset = 300000,
 	.ccc_reg = AXP20X_CHRG_CTRL1,
 	.ccc_mask = AXP20X_CHRG_CTRL1_TGT_CURR,
+	.has_fg = true,
 	.bat_ps_desc = &axp209_batt_ps_desc,
 	.get_max_voltage = axp20x_battery_get_max_voltage,
 	.set_max_voltage = axp20x_battery_set_max_voltage,
@@ -1075,6 +1105,7 @@ static const struct axp_data axp221_data = {
 	.ccc_reg = AXP20X_CHRG_CTRL1,
 	.ccc_mask = AXP20X_CHRG_CTRL1_TGT_CURR,
 	.has_fg_valid = true,
+	.has_fg = true,
 	.bat_ps_desc = &axp209_batt_ps_desc,
 	.get_max_voltage = axp22x_battery_get_max_voltage,
 	.set_max_voltage = axp22x_battery_set_max_voltage,
@@ -1100,6 +1131,7 @@ static const struct axp_data axp813_data = {
 	.ccc_reg = AXP20X_CHRG_CTRL1,
 	.ccc_mask = AXP20X_CHRG_CTRL1_TGT_CURR,
 	.has_fg_valid = true,
+	.has_fg = true,
 	.bat_ps_desc = &axp209_batt_ps_desc,
 	.get_max_voltage = axp813_battery_get_max_voltage,
 	.set_max_voltage = axp20x_battery_set_max_voltage,

-- 
2.43.0



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

* [PATCH v7 6/9] power: axp20x_battery: Add support for AXP192
  2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
                   ` (4 preceding siblings ...)
  2026-12-06  3:08 ` [PATCH v7 5/9] power: axp20x_battery: Support battery status without fuel gauge Molnár Máté via B4 Relay
@ 2026-12-06  3:08 ` Molnár Máté via B4 Relay
  2026-12-06  3:08 ` [PATCH v7 7/9] power: axp20x_battery: Estimate AXP192 capacity from the OCV table Molnár Máté via B4 Relay
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:08 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Molnár Máté

From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>

The AXP192 has a battery charger similar to other X-Powers PMICs,
but unlike the other supported devices, it does not have a fuel
gauge and can't report battery capacity directly.

Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
[Molnár Máté: rebased onto the current driver, which now has per-variant
 descriptors and callbacks; dropped the review tags because of the rework]
Signed-off-by: Molnár Máté <matemolnar88@gmail.com>
---
 drivers/power/supply/axp20x_battery.c | 44 +++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
index f7485ac6a..b55089a81 100644
--- a/drivers/power/supply/axp20x_battery.c
+++ b/drivers/power/supply/axp20x_battery.c
@@ -944,6 +944,29 @@ static int axp717_battery_prop_writeable(struct power_supply *psy,
 	       psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX;
 }
 
+static enum power_supply_property axp192_battery_props[] = {
+	POWER_SUPPLY_PROP_PRESENT,
+	POWER_SUPPLY_PROP_ONLINE,
+	POWER_SUPPLY_PROP_STATUS,
+	POWER_SUPPLY_PROP_VOLTAGE_NOW,
+	POWER_SUPPLY_PROP_CURRENT_NOW,
+	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
+	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
+	POWER_SUPPLY_PROP_HEALTH,
+	POWER_SUPPLY_PROP_VOLTAGE_MAX,
+	POWER_SUPPLY_PROP_VOLTAGE_MIN,
+};
+
+static const struct power_supply_desc axp192_batt_ps_desc = {
+	.name = "axp192-battery",
+	.type = POWER_SUPPLY_TYPE_BATTERY,
+	.properties = axp192_battery_props,
+	.num_properties = ARRAY_SIZE(axp192_battery_props),
+	.property_is_writeable = axp20x_battery_prop_writeable,
+	.get_property = axp20x_battery_get_prop,
+	.set_property = axp20x_battery_set_prop,
+};
+
 static const struct power_supply_desc axp209_batt_ps_desc = {
 	.name = "axp20x-battery",
 	.type = POWER_SUPPLY_TYPE_BATTERY,
@@ -1086,6 +1109,24 @@ static void axp717_set_battery_info(struct platform_device *pdev,
 	}
 }
 
+static const int axp192_ccc_table[AXP20X_CHRG_CTRL1_TGT_CURR + 1] = {
+	100000,  190000,  280000,  360000,
+	450000,  550000,  630000,  700000,
+	780000,  880000,  960000,  1000000,
+	1080000, 1160000, 1240000, 1320000,
+};
+
+static const struct axp_data axp192_data = {
+	.ccc_reg = AXP20X_CHRG_CTRL1,
+	.ccc_mask = AXP20X_CHRG_CTRL1_TGT_CURR,
+	.ccc_table = axp192_ccc_table,
+	.bat_ps_desc = &axp192_batt_ps_desc,
+	.get_max_voltage = axp20x_battery_get_max_voltage,
+	.set_max_voltage = axp20x_battery_set_max_voltage,
+	.cfg_iio_chan = axp209_bat_cfg_iio_channels,
+	.set_bat_info = axp209_set_battery_info,
+};
+
 static const struct axp_data axp209_data = {
 	.ccc_scale = 100000,
 	.ccc_offset = 300000,
@@ -1141,6 +1182,9 @@ static const struct axp_data axp813_data = {
 
 static const struct of_device_id axp20x_battery_ps_id[] = {
 	{
+		.compatible = "x-powers,axp192-battery-power-supply",
+		.data = (void *)&axp192_data,
+	}, {
 		.compatible = "x-powers,axp209-battery-power-supply",
 		.data = (void *)&axp209_data,
 	}, {

-- 
2.43.0



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

* [PATCH v7 7/9] power: axp20x_battery: Estimate AXP192 capacity from the OCV table
  2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
                   ` (5 preceding siblings ...)
  2026-12-06  3:08 ` [PATCH v7 6/9] power: axp20x_battery: Add support for AXP192 Molnár Máté via B4 Relay
@ 2026-12-06  3:08 ` Molnár Máté via B4 Relay
  2026-12-06  3:09 ` [PATCH v7 8/9] Input: axp20x-pek: Add AXP192 support Molnár Máté via B4 Relay
  2026-12-06  3:09 ` [PATCH v7 9/9] mfd: axp20x: Add the AXP192 power key cell Molnár Máté via B4 Relay
  8 siblings, 0 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:08 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Molnár Máté

From: Molnár Máté <matemolnar88@gmail.com>

The AXP192 has no fuel gauge, so the driver does not report a capacity
at all. Userspace then has no idea how full the battery is: UPower, for
example, reads 0% and powers the device off as soon as the battery
reports discharging.

Use the OCV table of the monitored battery, when one is given, to
estimate the capacity from the battery voltage. The voltage is corrected
for the drop across the battery's internal resistance when the battery
info has it. Keep the battery info around for this on PMICs without a
fuel gauge instead of releasing it after probe.

Signed-off-by: Molnár Máté <matemolnar88@gmail.com>
---
 drivers/power/supply/axp20x_battery.c | 58 ++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
index b55089a81..3c3cf349f 100644
--- a/drivers/power/supply/axp20x_battery.c
+++ b/drivers/power/supply/axp20x_battery.c
@@ -21,6 +21,7 @@
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/math64.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -128,6 +129,8 @@ struct axp20x_batt_ps {
 	/* Maximum constant charge current */
 	unsigned int max_ccc;
 	const struct axp_data	*data;
+	/* Battery info kept for the OCV capacity estimate on PMICs without FG */
+	struct power_supply_battery_info *bat_info;
 	bool ts_disable;
 };
 
@@ -285,6 +288,50 @@ static int axp717_get_constant_charge_current(struct axp20x_batt_ps *axp,
 	return 0;
 }
 
+static int axp20x_battery_get_prop(struct power_supply *psy,
+				   enum power_supply_property psp,
+				   union power_supply_propval *val);
+
+/*
+ * Estimate the capacity from the open circuit voltage for PMICs without a
+ * fuel gauge, using the OCV table of the monitored battery. The OCV is
+ * approximated from the battery voltage and current with the battery's
+ * internal resistance, when it is known.
+ */
+static int axp20x_battery_ocv_capacity(struct axp20x_batt_ps *axp20x_batt,
+				       int *val)
+{
+	struct power_supply_battery_info *info = axp20x_batt->bat_info;
+	union power_supply_propval v, i;
+	int ret;
+
+	if (!info || !info->ocv_table[0])
+		return -ENODATA;
+
+	ret = axp20x_battery_get_prop(axp20x_batt->batt,
+				      POWER_SUPPLY_PROP_VOLTAGE_NOW, &v);
+	if (ret)
+		return ret;
+
+	ret = axp20x_battery_get_prop(axp20x_batt->batt,
+				      POWER_SUPPLY_PROP_CURRENT_NOW, &i);
+	if (ret)
+		return ret;
+
+	if (info->factory_internal_resistance_uohm > 0)
+		v.intval -= div_s64((s64)i.intval *
+				    info->factory_internal_resistance_uohm,
+				    1000000);
+
+	/* ponytail: no temperature sensor wired up, assume 20 C */
+	ret = power_supply_batinfo_ocv2cap(info, v.intval, 20);
+	if (ret < 0)
+		return ret;
+
+	*val = ret;
+	return 0;
+}
+
 static int axp20x_battery_get_prop(struct power_supply *psy,
 				   enum power_supply_property psp,
 				   union power_supply_propval *val)
@@ -423,6 +470,10 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
 			return 0;
 		}
 
+		if (!axp20x_batt->data->has_fg)
+			return axp20x_battery_ocv_capacity(axp20x_batt,
+							   &val->intval);
+
 		ret = regmap_read(axp20x_batt->regmap, AXP20X_FG_RES, &reg);
 		if (ret)
 			return ret;
@@ -955,6 +1006,7 @@ static enum power_supply_property axp192_battery_props[] = {
 	POWER_SUPPLY_PROP_HEALTH,
 	POWER_SUPPLY_PROP_VOLTAGE_MAX,
 	POWER_SUPPLY_PROP_VOLTAGE_MIN,
+	POWER_SUPPLY_PROP_CAPACITY,
 };
 
 static const struct power_supply_desc axp192_batt_ps_desc = {
@@ -1237,7 +1289,11 @@ static int axp20x_power_probe(struct platform_device *pdev)
 
 	if (!power_supply_get_battery_info(axp20x_batt->batt, &info)) {
 		axp20x_batt->data->set_bat_info(pdev, axp20x_batt, info);
-		power_supply_put_battery_info(axp20x_batt->batt, info);
+		/* Without a fuel gauge the OCV table is used for the capacity */
+		if (axp20x_batt->data->has_fg)
+			power_supply_put_battery_info(axp20x_batt->batt, info);
+		else
+			axp20x_batt->bat_info = info;
 	}
 
 	/*

-- 
2.43.0



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

* [PATCH v7 8/9] Input: axp20x-pek: Add AXP192 support
  2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
                   ` (6 preceding siblings ...)
  2026-12-06  3:08 ` [PATCH v7 7/9] power: axp20x_battery: Estimate AXP192 capacity from the OCV table Molnár Máté via B4 Relay
@ 2026-12-06  3:09 ` Molnár Máté via B4 Relay
  2026-12-06  3:09 ` [PATCH v7 9/9] mfd: axp20x: Add the AXP192 power key cell Molnár Máté via B4 Relay
  8 siblings, 0 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:09 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Molnár Máté

From: Molnár Máté <matemolnar88@gmail.com>

The AXP192 has no rising/falling edge interrupts for the power key.
It only raises short-press and long-press events, after the key has
been released. Add an axp192-pek variant that reports each of those as
a complete press, so userspace sees a normal KEY_POWER press/release.

Set the variant info before the input device is registered, as the
interrupt handler now uses it.

Signed-off-by: Molnár Máté <matemolnar88@gmail.com>
---
 drivers/input/misc/axp20x-pek.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index a02cdabcf..739da57ca 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -35,6 +35,11 @@ struct axp20x_info {
 	unsigned int startup_mask;
 	const struct axp20x_time *shutdown_time;
 	unsigned int shutdown_mask;
+	/*
+	 * The PMIC only reports short and long presses after the button is
+	 * released, not the edges, so each event is a complete press.
+	 */
+	bool press_events_only;
 };
 
 struct axp20x_pek {
@@ -78,6 +83,14 @@ static const struct axp20x_info axp20x_info = {
 	.shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK,
 };
 
+static const struct axp20x_info axp192_info = {
+	.startup_time = startup_time,
+	.startup_mask = AXP20X_PEK_STARTUP_MASK,
+	.shutdown_time = shutdown_time,
+	.shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK,
+	.press_events_only = true,
+};
+
 static const struct axp20x_info axp221_info = {
 	.startup_time = axp221_startup_time,
 	.startup_mask = AXP20X_PEK_STARTUP_MASK,
@@ -200,6 +213,15 @@ static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
 	struct input_dev *idev = pwr;
 	struct axp20x_pek *axp20x_pek = input_get_drvdata(idev);
 
+	if (axp20x_pek->info->press_events_only) {
+		input_report_key(idev, KEY_POWER, true);
+		input_sync(idev);
+		input_report_key(idev, KEY_POWER, false);
+		input_sync(idev);
+
+		return IRQ_HANDLED;
+	}
+
 	/*
 	 * The power-button is connected to ground so a falling edge (dbf)
 	 * means it is pressed.
@@ -311,6 +333,7 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
+	axp20x_pek->info = (struct axp20x_info *)match->driver_data;
 
 	if (axp20x_pek_should_register_input(axp20x_pek)) {
 		error = axp20x_pek_probe_input_device(axp20x_pek, pdev);
@@ -318,8 +341,6 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 			return error;
 	}
 
-	axp20x_pek->info = (struct axp20x_info *)match->driver_data;
-
 	platform_set_drvdata(pdev, axp20x_pek);
 
 	return 0;
@@ -393,6 +414,10 @@ static const struct platform_device_id axp_pek_id_match[] = {
 		.name = "axp20x-pek",
 		.driver_data = (kernel_ulong_t)&axp20x_info,
 	},
+	{
+		.name = "axp192-pek",
+		.driver_data = (kernel_ulong_t)&axp192_info,
+	},
 	{
 		.name = "axp221-pek",
 		.driver_data = (kernel_ulong_t)&axp221_info,

-- 
2.43.0



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

* [PATCH v7 9/9] mfd: axp20x: Add the AXP192 power key cell
  2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
                   ` (7 preceding siblings ...)
  2026-12-06  3:09 ` [PATCH v7 8/9] Input: axp20x-pek: Add AXP192 support Molnár Máté via B4 Relay
@ 2026-12-06  3:09 ` Molnár Máté via B4 Relay
  8 siblings, 0 replies; 10+ messages in thread
From: Molnár Máté via B4 Relay @ 2026-12-06  3:09 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
	Sebastian Reichel, Liam Girdwood, Mark Brown, Dmitry Torokhov,
	Lee Jones
  Cc: linux-iio, devicetree, linux-kernel, linux-pm, linux-input, mfd,
	Aidan MacDonald, Alex Bee, Molnár Máté

From: Molnár Máté <matemolnar88@gmail.com>

Register the power key for the AXP192. It only has short and long press
interrupts, which are passed to the axp192-pek variant of the
axp20x-pek driver under the usual PEK_DBF/PEK_DBR names.

Signed-off-by: Molnár Máté <matemolnar88@gmail.com>
---
 drivers/mfd/axp20x.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 4d770e718..f9bf06ddb 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -363,6 +363,12 @@ static const struct resource axp288_fuel_gauge_resources[] = {
 	DEFINE_RES_IRQ(AXP288_IRQ_WL1),
 };
 
+/* The AXP192 has no PEK edge interrupts, only short and long press events */
+static const struct resource axp192_pek_resources[] = {
+	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_PEK_LONG, "PEK_DBR"),
+	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_PEK_SHORT, "PEK_DBF"),
+};
+
 static const struct resource axp313a_pek_resources[] = {
 	DEFINE_RES_IRQ_NAMED(AXP313A_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
 	DEFINE_RES_IRQ_NAMED(AXP313A_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
@@ -956,6 +962,10 @@ static const struct mfd_cell axp192_cells[] = {
 		.of_compatible	= "x-powers,axp192-usb-power-supply",
 		.num_resources	= ARRAY_SIZE(axp192_usb_power_supply_resources),
 		.resources	= axp192_usb_power_supply_resources,
+	}, {
+		.name		= "axp192-pek",
+		.num_resources	= ARRAY_SIZE(axp192_pek_resources),
+		.resources	= axp192_pek_resources,
 	},
 	{	.name		= "axp20x-regulator" },
 };

-- 
2.43.0



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

end of thread, other threads:[~2026-12-06  3:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 1/9] dt-bindings: iio: adc: axp209: Add AXP192 compatible Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 2/9] dt-bindings: power: axp20x-battery: " Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 3/9] regulator: axp20x: Add support for AXP192 Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 4/9] power: axp20x_battery: Add constant charge current table Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 5/9] power: axp20x_battery: Support battery status without fuel gauge Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 6/9] power: axp20x_battery: Add support for AXP192 Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 7/9] power: axp20x_battery: Estimate AXP192 capacity from the OCV table Molnár Máté via B4 Relay
2026-12-06  3:09 ` [PATCH v7 8/9] Input: axp20x-pek: Add AXP192 support Molnár Máté via B4 Relay
2026-12-06  3:09 ` [PATCH v7 9/9] mfd: axp20x: Add the AXP192 power key cell Molnár Máté via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox