* [PATCH 0/7] Add support for the X-Powers AXP2101 PMIC
@ 2026-10-23 10:03 Olivier Louvignes
2026-10-23 10:03 ` [PATCH 1/7] dt-bindings: mfd: x-powers,axp152: Add the AXP2101 Olivier Louvignes
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Olivier Louvignes @ 2026-10-23 10:03 UTC (permalink / raw)
To: Lee Jones, Chen-Yu Tsai
Cc: Olivier Louvignes, Conor Dooley, Krzysztof Kozlowski,
Liam Girdwood, Mark Brown, Rob Herring, Sebastian Reichel,
devicetree, linux-kernel, linux-pm, mfd
This adds the AXP2101 to the axp20x drivers: the MFD core with its
registers and interrupts, the regulators, the USB power supply and the
battery charger. The PMIC is on the HiBy R1, a music player built on an
Ingenic X1600. It follows how the AXP717 was added: the existing
drivers are extended, and the two power supplies get their own
compatibles because their registers differ.
Not handled yet: the PMIC's own fuel gauge (the R1 uses a CW2015, and the
AXP2101's reads 0% without a battery model), the power key, the ADC
channels, the TS pin, and writing the input current limit.
Sources: there is no datasheet behind this. The register map comes from
the GPL-2.0 AXP2101 driver of the hiby-custom-kernel project
(github.com/Jepl4r/hiby-custom-kernel), an open replacement for HiBy's
closed module, and was checked against the chip on a running R1.
Tested on the R1, on v7.3 with out-of-tree board patches:
- The rails the stock firmware turns on (DCDC1-4 at 3.3, 1.1, 1.8 and
1.2 V, ALDO2 3.3 V, ALDO3 1.1 V, ALDO4 3.3 V, BLDO1 and BLDO2 2.8 V)
read back at their stock voltages, and the regulator registers
0x80-0x9a stay byte for byte as the stock firmware left them. No
voltage was changed from Linux. BLDO1 and BLDO2 (2.8 V, the LCD
supplies) are switched on and off from Linux by the panel driver, which
claims them: bits 4 and 5 of register 0x90 clear and set again with
the screen blanking and unblanking, about 20 cycles over 8 boots, with
the selectors (0x96 and 0x97) staying at 0x17. That does not change a
voltage, since the registers already held 2.8 V. DCDC5, ALDO1, DLDO1-2
and CPUSLDO are off on the R1 and only come from the register map.
- "poweroff -f" turns the R1 off, through COMM_CFG.
- Unplugging and replugging USB gives one VBUS_REMOVAL and one
VBUS_PLUGIN interrupt, and the USB supply goes online 1, 0, 1.
- The charger registers read back as the stock firmware's values after
boot, and the battery status is Full on USB, Discharging unplugged and
Charging after a replug.
Every patch builds on 734bef548a96 (v7.3-7363) with W=1, passes
checkpatch --strict, and the three bindings pass dt_binding_check.
Open questions: whether extending the axp20x drivers is what you want
here (the alternative is a driver of its own), and whether programming
the charger from the monitored battery at probe, read-only afterwards,
is acceptable for the battery supply.
Olivier Louvignes (7):
dt-bindings: mfd: x-powers,axp152: Add the AXP2101
mfd: axp20x: Add support for the AXP2101
regulator: axp20x: Add support for the AXP2101
dt-bindings: power: supply: axp20x-usb-power: Add the AXP2101
power: supply: axp20x_usb_power: Add support for the AXP2101
dt-bindings: power: supply: axp20x-battery: Add the AXP2101
power: supply: axp20x_battery: Add support for the AXP2101
.../bindings/mfd/x-powers,axp152.yaml | 3 +
.../x-powers,axp20x-battery-power-supply.yaml | 1 +
.../x-powers,axp20x-usb-power-supply.yaml | 1 +
drivers/mfd/axp20x-i2c.c | 2 +
drivers/mfd/axp20x.c | 107 ++++++++-
drivers/power/supply/axp20x_battery.c | 221 ++++++++++++++++++
drivers/power/supply/axp20x_usb_power.c | 86 +++++++
drivers/regulator/axp20x-regulator.c | 88 +++++++
include/linux/mfd/axp20x.h | 114 +++++++++
9 files changed, 621 insertions(+), 2 deletions(-)
base-commit: 734bef548a96e8774d6eef5dfa2026c6edc4e80b
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/7] dt-bindings: mfd: x-powers,axp152: Add the AXP2101
2026-10-23 10:03 [PATCH 0/7] Add support for the X-Powers AXP2101 PMIC Olivier Louvignes
@ 2026-10-23 10:03 ` Olivier Louvignes
2026-10-26 9:30 ` Krzysztof Kozlowski
2026-10-23 10:03 ` [PATCH 4/7] dt-bindings: power: supply: axp20x-usb-power: " Olivier Louvignes
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Olivier Louvignes @ 2026-10-23 10:03 UTC (permalink / raw)
To: Lee Jones, Chen-Yu Tsai
Cc: Olivier Louvignes, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
mfd, devicetree, linux-kernel
The AXP2101's interrupt line is optional, as for the AXP313A and the
AXP15060: the driver then registers only the regulators. It has no DCDC
frequency setting.
Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
---
Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml
index 45f015d63df1..f5e2c8232581 100644
--- a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml
+++ b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml
@@ -68,6 +68,7 @@ allOf:
compatible:
contains:
enum:
+ - x-powers,axp2101
- x-powers,axp15060
- x-powers,axp305
- x-powers,axp313a
@@ -84,6 +85,7 @@ allOf:
enum:
- x-powers,axp313a
- x-powers,axp323
+ - x-powers,axp2101
- x-powers,axp15060
- x-powers,axp717
@@ -108,6 +110,7 @@ properties:
- x-powers,axp806
- x-powers,axp809
- x-powers,axp813
+ - x-powers,axp2101
- x-powers,axp15060
- items:
- const: x-powers,axp228
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/7] dt-bindings: power: supply: axp20x-usb-power: Add the AXP2101
2026-10-23 10:03 [PATCH 0/7] Add support for the X-Powers AXP2101 PMIC Olivier Louvignes
2026-10-23 10:03 ` [PATCH 1/7] dt-bindings: mfd: x-powers,axp152: Add the AXP2101 Olivier Louvignes
@ 2026-10-23 10:03 ` Olivier Louvignes
2026-10-23 10:11 ` sashiko-bot
2026-10-26 9:32 ` Krzysztof Kozlowski
2026-10-23 10:03 ` [PATCH 5/7] power: supply: axp20x_usb_power: Add support for " Olivier Louvignes
` (2 subsequent siblings)
4 siblings, 2 replies; 11+ messages in thread
From: Olivier Louvignes @ 2026-10-23 10:03 UTC (permalink / raw)
To: Lee Jones, Chen-Yu Tsai
Cc: Olivier Louvignes, Sebastian Reichel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, linux-pm, devicetree,
linux-kernel
The AXP2101's USB power supply reports whether VBUS is present and the
input current limit, like the AXP717's; its registers differ, so it gets
its own compatible.
Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
---
.../bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
index 2ec036405ae4..1c582aa5e1d0 100644
--- a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
+++ b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
@@ -25,6 +25,7 @@ properties:
- x-powers,axp223-usb-power-supply
- x-powers,axp717-usb-power-supply
- x-powers,axp813-usb-power-supply
+ - x-powers,axp2101-usb-power-supply
- items:
- const: x-powers,axp803-usb-power-supply
- const: x-powers,axp813-usb-power-supply
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/7] power: supply: axp20x_usb_power: Add support for the AXP2101
2026-10-23 10:03 [PATCH 0/7] Add support for the X-Powers AXP2101 PMIC Olivier Louvignes
2026-10-23 10:03 ` [PATCH 1/7] dt-bindings: mfd: x-powers,axp152: Add the AXP2101 Olivier Louvignes
2026-10-23 10:03 ` [PATCH 4/7] dt-bindings: power: supply: axp20x-usb-power: " Olivier Louvignes
@ 2026-10-23 10:03 ` Olivier Louvignes
2026-10-23 10:04 ` [PATCH 6/7] dt-bindings: power: supply: axp20x-battery: Add " Olivier Louvignes
2026-10-23 10:04 ` [PATCH 7/7] power: supply: axp20x_battery: Add support for " Olivier Louvignes
4 siblings, 0 replies; 11+ messages in thread
From: Olivier Louvignes @ 2026-10-23 10:03 UTC (permalink / raw)
To: Lee Jones, Chen-Yu Tsai
Cc: Olivier Louvignes, Sebastian Reichel, linux-pm, linux-kernel
Report whether VBUS is present (bit 5 of the first status register) and
the input current limit (100 mA to 2 A, in IIN_LIM), and update on the
VBUS plug-in and removal interrupts. Nothing is written: the AXP2101's
VBUS input needs no set-up for that.
Tested on a HiBy R1: unplugging and replugging the cable gives one
VBUS_REMOVAL and one VBUS_PLUGIN interrupt, and "online" goes 1, 0, 1.
Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
---
drivers/power/supply/axp20x_usb_power.c | 86 +++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c
index e951b2b64b25..594f0492b18a 100644
--- a/drivers/power/supply/axp20x_usb_power.c
+++ b/drivers/power/supply/axp20x_usb_power.c
@@ -31,6 +31,7 @@
#define AXP20X_PWR_STATUS_VBUS_USED BIT(4)
#define AXP717_PWR_STATUS_VBUS_GOOD BIT(5)
+#define AXP2101_PWR_STATUS_VBUS_GOOD BIT(5)
#define AXP20X_USB_STATUS_VBUS_VALID BIT(2)
@@ -172,6 +173,24 @@ static void axp717_usb_power_poll_vbus(struct work_struct *work)
power->old_status = val;
}
+static void axp2101_usb_power_poll_vbus(struct work_struct *work)
+{
+ struct axp20x_usb_power *power =
+ container_of(work, struct axp20x_usb_power, vbus_detect.work);
+ unsigned int val;
+ int ret;
+
+ ret = regmap_read(power->regmap, AXP2101_PMU_STATUS_1, &val);
+ if (ret)
+ return;
+
+ val &= AXP2101_PWR_STATUS_VBUS_GOOD;
+ if (val != power->old_status)
+ power_supply_changed(power->supply);
+
+ power->old_status = val;
+}
+
static int axp20x_get_usb_type(struct axp20x_usb_power *power,
union power_supply_propval *val)
{
@@ -315,6 +334,42 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
return 0;
}
+/* Input current limits of AXP2101_IIN_LIM; 6 and 7 are reserved. */
+static const int axp2101_usb_curr_lim_table[] = {
+ 100000, 500000, 900000, 1000000, 1500000, 2000000,
+};
+
+static int axp2101_usb_power_get_property(struct power_supply *psy,
+ enum power_supply_property psp,
+ union power_supply_propval *val)
+{
+ struct axp20x_usb_power *power = power_supply_get_drvdata(psy);
+ unsigned int v;
+ int ret;
+
+ switch (psp) {
+ case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
+ ret = regmap_field_read(power->curr_lim_fld, &v);
+ if (ret)
+ return ret;
+ if (v >= ARRAY_SIZE(axp2101_usb_curr_lim_table))
+ return -EINVAL;
+ val->intval = axp2101_usb_curr_lim_table[v];
+ break;
+ case POWER_SUPPLY_PROP_ONLINE:
+ case POWER_SUPPLY_PROP_PRESENT:
+ ret = regmap_read(power->regmap, AXP2101_PMU_STATUS_1, &v);
+ if (ret)
+ return ret;
+ val->intval = !!(v & AXP2101_PWR_STATUS_VBUS_GOOD);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int axp717_usb_power_get_property(struct power_supply *psy,
enum power_supply_property psp, union power_supply_propval *val)
{
@@ -643,6 +698,12 @@ static enum power_supply_property axp22x_usb_power_properties[] = {
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
};
+static enum power_supply_property axp2101_usb_power_properties[] = {
+ POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
+ POWER_SUPPLY_PROP_ONLINE,
+ POWER_SUPPLY_PROP_PRESENT,
+};
+
static enum power_supply_property axp717_usb_power_properties[] = {
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
@@ -682,6 +743,14 @@ static const struct power_supply_desc axp22x_usb_power_desc = {
.set_property = axp20x_usb_power_set_property,
};
+static const struct power_supply_desc axp2101_usb_power_desc = {
+ .name = "axp20x-usb",
+ .type = POWER_SUPPLY_TYPE_USB,
+ .properties = axp2101_usb_power_properties,
+ .num_properties = ARRAY_SIZE(axp2101_usb_power_properties),
+ .get_property = axp2101_usb_power_get_property,
+};
+
static const struct power_supply_desc axp717_usb_power_desc = {
.name = "axp20x-usb",
.type = POWER_SUPPLY_TYPE_USB,
@@ -722,6 +791,11 @@ static const char * const axp22x_irq_names[] = {
"VBUS_REMOVAL",
};
+static const char * const axp2101_irq_names[] = {
+ "VBUS_PLUGIN",
+ "VBUS_REMOVAL",
+};
+
static const char * const axp717_irq_names[] = {
"VBUS_PLUGIN",
"VBUS_REMOVAL",
@@ -815,6 +889,15 @@ static const struct axp_data axp223_data = {
.axp20x_cfg_adc_reg = axp20x_configure_adc_registers,
};
+static const struct axp_data axp2101_data = {
+ .power_desc = &axp2101_usb_power_desc,
+ .irq_names = axp2101_irq_names,
+ .num_irq_names = ARRAY_SIZE(axp2101_irq_names),
+ .curr_lim_fld = REG_FIELD(AXP2101_IIN_LIM, 0, 2),
+ .vbus_needs_polling = false,
+ .axp20x_read_vbus = &axp2101_usb_power_poll_vbus,
+};
+
static const struct axp_data axp717_data = {
.power_desc = &axp717_usb_power_desc,
.irq_names = axp717_irq_names,
@@ -1056,6 +1139,9 @@ static const struct of_device_id axp20x_usb_power_match[] = {
}, {
.compatible = "x-powers,axp717-usb-power-supply",
.data = &axp717_data,
+ }, {
+ .compatible = "x-powers,axp2101-usb-power-supply",
+ .data = &axp2101_data,
}, {
.compatible = "x-powers,axp813-usb-power-supply",
.data = &axp813_data,
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/7] dt-bindings: power: supply: axp20x-battery: Add the AXP2101
2026-10-23 10:03 [PATCH 0/7] Add support for the X-Powers AXP2101 PMIC Olivier Louvignes
` (2 preceding siblings ...)
2026-10-23 10:03 ` [PATCH 5/7] power: supply: axp20x_usb_power: Add support for " Olivier Louvignes
@ 2026-10-23 10:04 ` Olivier Louvignes
2026-10-26 9:33 ` Krzysztof Kozlowski
2026-10-23 10:04 ` [PATCH 7/7] power: supply: axp20x_battery: Add support for " Olivier Louvignes
4 siblings, 1 reply; 11+ messages in thread
From: Olivier Louvignes @ 2026-10-23 10:04 UTC (permalink / raw)
To: Lee Jones, Chen-Yu Tsai
Cc: Olivier Louvignes, Sebastian Reichel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, linux-pm, devicetree,
linux-kernel
The AXP2101's charger is programmed from the monitored battery and its
registers differ from the other models', so it gets its own compatible.
Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
---
.../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 a90d558e7f86..6a0a0c3f052b 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
@@ -21,6 +21,7 @@ properties:
- const: x-powers,axp209-battery-power-supply
- const: x-powers,axp221-battery-power-supply
- const: x-powers,axp717-battery-power-supply
+ - const: x-powers,axp2101-battery-power-supply
- items:
- const: x-powers,axp803-battery-power-supply
- const: x-powers,axp813-battery-power-supply
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 7/7] power: supply: axp20x_battery: Add support for the AXP2101
2026-10-23 10:03 [PATCH 0/7] Add support for the X-Powers AXP2101 PMIC Olivier Louvignes
` (3 preceding siblings ...)
2026-10-23 10:04 ` [PATCH 6/7] dt-bindings: power: supply: axp20x-battery: Add " Olivier Louvignes
@ 2026-10-23 10:04 ` Olivier Louvignes
4 siblings, 0 replies; 11+ messages in thread
From: Olivier Louvignes @ 2026-10-23 10:04 UTC (permalink / raw)
To: Lee Jones, Chen-Yu Tsai
Cc: Olivier Louvignes, Sebastian Reichel, linux-pm, linux-kernel
Program the AXP2101's charger from the monitored battery: the end of
charge voltage (CV_CHG_SET, 4.0 to 4.4 V), the constant charge current
(ICC_CHG_SET, 25 mA steps to 200 mA then 100 mA steps to 1 A), and the
termination and precharge currents (25 mA steps). Report whether the
battery is present, the charge state (precharge, constant current or
constant voltage charging, done, or by the current direction) and the
settings.
The supply is read-only and reports no capacity: the AXP2101's own fuel
gauge needs a battery model, and the HiBy R1 uses a CW2015 for that.
Tested on a HiBy R1: the charger registers read back as the stock
firmware's values after boot, and the status is Full on USB,
Discharging unplugged and Charging after a replug.
Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
---
drivers/power/supply/axp20x_battery.c | 221 ++++++++++++++++++++++++++
1 file changed, 221 insertions(+)
diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
index ee8701a6e907..a653ad923144 100644
--- a/drivers/power/supply/axp20x_battery.c
+++ b/drivers/power/supply/axp20x_battery.c
@@ -91,6 +91,26 @@
#define AXP717_TS_PIN_DISABLE BIT(4)
+#define AXP2101_PWR_OP_BATT_PRESENT BIT(3)
+#define AXP2101_PWR_STATUS_MASK GENMASK(6, 5)
+#define AXP2101_PWR_STATUS_BAT_STANDBY 0
+#define AXP2101_PWR_STATUS_BAT_CHRG 1
+#define AXP2101_PWR_STATUS_BAT_DISCHRG 2
+#define AXP2101_CHRG_STATE_MASK GENMASK(2, 0)
+#define AXP2101_CHRG_STATE_TRICKLE 0
+#define AXP2101_CHRG_STATE_PRECHARGE 1
+#define AXP2101_CHRG_STATE_CC 2
+#define AXP2101_CHRG_STATE_CV 3
+#define AXP2101_CHRG_STATE_DONE 4
+/* CV_CHG_SET: end of charge voltage selector, 1 to 5 for 4.0 to 4.4 V. */
+#define AXP2101_CHRG_CV_VOLT_MASK GENMASK(2, 0)
+#define AXP2101_ICC_MASK GENMASK(4, 0)
+#define AXP2101_ICC_MAX_SEL 16 /* 1 A; 17 to 31 are reserved */
+#define AXP2101_ITERM_MASK GENMASK(3, 0)
+#define AXP2101_ITERM_ENABLE BIT(4)
+#define AXP2101_IPRECHG_MASK GENMASK(3, 0)
+#define AXP2101_CURRENT_STEP 25000
+
struct axp20x_batt_ps;
struct axp_data {
@@ -213,6 +233,44 @@ static int axp717_battery_get_max_voltage(struct axp20x_batt_ps *axp20x_batt,
}
}
+/* End of charge voltages of CV_CHG_SET selectors 0 to 7; 0, 6 and 7 are reserved. */
+static const int axp2101_cv_uv[] = {
+ 0, 4000000, 4100000, 4200000, 4350000, 4400000, 0, 0,
+};
+
+static int axp2101_battery_get_max_voltage(struct axp20x_batt_ps *axp20x_batt,
+ int *val)
+{
+ int ret, reg;
+
+ ret = regmap_read(axp20x_batt->regmap, AXP2101_CV_CHG_SET, ®);
+ if (ret)
+ return ret;
+
+ *val = axp2101_cv_uv[reg & AXP2101_CHRG_CV_VOLT_MASK];
+ return *val ? 0 : -EINVAL;
+}
+
+static int axp2101_battery_set_max_voltage(struct axp20x_batt_ps *axp20x_batt,
+ int val)
+{
+ int sel;
+
+ for (sel = 0; sel < ARRAY_SIZE(axp2101_cv_uv); sel++)
+ if (axp2101_cv_uv[sel] && axp2101_cv_uv[sel] == val)
+ return regmap_update_bits(axp20x_batt->regmap,
+ AXP2101_CV_CHG_SET,
+ AXP2101_CHRG_CV_VOLT_MASK, sel);
+
+ return -EINVAL;
+}
+
+/* CONSTANT_CHARGE_CURRENT: 25 mA steps up to 200 mA, then 100 mA steps. */
+static int axp2101_ccc_from_sel(unsigned int sel)
+{
+ return sel <= 8 ? sel * 25000 : 200000 + (sel - 8) * 100000;
+}
+
static int axp813_battery_get_max_voltage(struct axp20x_batt_ps *axp20x_batt,
int *val)
{
@@ -425,6 +483,89 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
return 0;
}
+static int axp2101_battery_get_prop(struct power_supply *psy,
+ enum power_supply_property psp,
+ union power_supply_propval *val)
+{
+ struct axp20x_batt_ps *axp20x_batt = power_supply_get_drvdata(psy);
+ int ret, reg;
+
+ switch (psp) {
+ case POWER_SUPPLY_PROP_PRESENT:
+ case POWER_SUPPLY_PROP_ONLINE:
+ ret = regmap_read(axp20x_batt->regmap, AXP2101_PMU_STATUS_1,
+ ®);
+ if (ret)
+ return ret;
+
+ val->intval = !!(reg & AXP2101_PWR_OP_BATT_PRESENT);
+ return 0;
+
+ case POWER_SUPPLY_PROP_STATUS:
+ ret = regmap_read(axp20x_batt->regmap, AXP2101_PMU_STATUS_2,
+ ®);
+ if (ret)
+ return ret;
+
+ switch (FIELD_GET(AXP2101_CHRG_STATE_MASK, reg)) {
+ case AXP2101_CHRG_STATE_PRECHARGE:
+ case AXP2101_CHRG_STATE_CC:
+ case AXP2101_CHRG_STATE_CV:
+ val->intval = POWER_SUPPLY_STATUS_CHARGING;
+ return 0;
+ case AXP2101_CHRG_STATE_DONE:
+ val->intval = POWER_SUPPLY_STATUS_FULL;
+ return 0;
+ }
+
+ /* Trickle charging or not charging: by the current direction. */
+ switch (FIELD_GET(AXP2101_PWR_STATUS_MASK, reg)) {
+ case AXP2101_PWR_STATUS_BAT_STANDBY:
+ val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
+ return 0;
+ case AXP2101_PWR_STATUS_BAT_CHRG:
+ val->intval = POWER_SUPPLY_STATUS_CHARGING;
+ return 0;
+ case AXP2101_PWR_STATUS_BAT_DISCHRG:
+ val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
+ return 0;
+ default:
+ val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
+ return 0;
+ }
+
+ case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
+ ret = regmap_read(axp20x_batt->regmap, AXP2101_ICC_CHG_SET,
+ ®);
+ if (ret)
+ return ret;
+
+ val->intval = axp2101_ccc_from_sel(FIELD_GET(AXP2101_ICC_MASK,
+ reg));
+ return 0;
+
+ case POWER_SUPPLY_PROP_VOLTAGE_MAX:
+ return axp2101_battery_get_max_voltage(axp20x_batt,
+ &val->intval);
+
+ case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
+ ret = regmap_read(axp20x_batt->regmap, AXP2101_ITERM_CHG_SET,
+ ®);
+ if (ret)
+ return ret;
+
+ if (!(reg & AXP2101_ITERM_ENABLE))
+ val->intval = 0;
+ else
+ val->intval = FIELD_GET(AXP2101_ITERM_MASK, reg) *
+ AXP2101_CURRENT_STEP;
+ return 0;
+
+ default:
+ return -EINVAL;
+ }
+}
+
static int axp717_battery_get_prop(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -852,6 +993,15 @@ static enum power_supply_property axp20x_battery_props[] = {
POWER_SUPPLY_PROP_CAPACITY,
};
+static enum power_supply_property axp2101_battery_props[] = {
+ POWER_SUPPLY_PROP_PRESENT,
+ POWER_SUPPLY_PROP_ONLINE,
+ POWER_SUPPLY_PROP_STATUS,
+ POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
+ POWER_SUPPLY_PROP_VOLTAGE_MAX,
+ POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
+};
+
static enum power_supply_property axp717_battery_props[] = {
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_ONLINE,
@@ -895,6 +1045,15 @@ static const struct power_supply_desc axp209_batt_ps_desc = {
.set_property = axp20x_battery_set_prop,
};
+/* Read-only: the charge settings come from the monitored battery. */
+static const struct power_supply_desc axp2101_batt_ps_desc = {
+ .name = "axp20x-battery",
+ .type = POWER_SUPPLY_TYPE_BATTERY,
+ .properties = axp2101_battery_props,
+ .num_properties = ARRAY_SIZE(axp2101_battery_props),
+ .get_property = axp2101_battery_get_prop,
+};
+
static const struct power_supply_desc axp717_batt_ps_desc = {
.name = "axp20x-battery",
.type = POWER_SUPPLY_TYPE_BATTERY,
@@ -978,6 +1137,57 @@ static void axp209_set_battery_info(struct platform_device *pdev,
}
}
+static int axp2101_bat_cfg_iio_channels(struct platform_device *pdev,
+ struct axp20x_batt_ps *axp_batt)
+{
+ return 0;
+}
+
+/*
+ * Programs the charger from the monitored battery: end of charge voltage,
+ * constant charge current, termination and precharge currents. What the
+ * battery doesn't give is left as it is.
+ */
+static void axp2101_set_battery_info(struct platform_device *pdev,
+ struct axp20x_batt_ps *axp_batt,
+ struct power_supply_battery_info *info)
+{
+ int cv = info->constant_charge_voltage_max_uv;
+ int ccc = info->constant_charge_current_max_ua;
+ int iterm = info->charge_term_current_ua;
+ int iprechg = info->precharge_current_ua;
+ unsigned int sel;
+
+ if (cv > 0 && axp2101_battery_set_max_voltage(axp_batt, cv))
+ dev_err(&pdev->dev, "unsupported charge voltage %d uV\n", cv);
+
+ if (ccc > 0) {
+ if (ccc <= 200000)
+ sel = ccc / AXP2101_CURRENT_STEP;
+ else
+ sel = min((ccc - 200000) / 100000 + 8,
+ AXP2101_ICC_MAX_SEL);
+ axp_batt->max_ccc = axp2101_ccc_from_sel(sel);
+ regmap_update_bits(axp_batt->regmap, AXP2101_ICC_CHG_SET,
+ AXP2101_ICC_MASK, sel);
+ }
+
+ if (iterm > 0) {
+ sel = min(iterm / AXP2101_CURRENT_STEP,
+ (int)FIELD_MAX(AXP2101_ITERM_MASK));
+ regmap_update_bits(axp_batt->regmap, AXP2101_ITERM_CHG_SET,
+ AXP2101_ITERM_MASK | AXP2101_ITERM_ENABLE,
+ sel | AXP2101_ITERM_ENABLE);
+ }
+
+ if (iprechg > 0) {
+ sel = min(iprechg / AXP2101_CURRENT_STEP,
+ (int)FIELD_MAX(AXP2101_IPRECHG_MASK));
+ regmap_update_bits(axp_batt->regmap, AXP2101_IPRECHG_SET,
+ AXP2101_IPRECHG_MASK, sel);
+ }
+}
+
static void axp717_set_battery_info(struct platform_device *pdev,
struct axp20x_batt_ps *axp_batt,
struct power_supply_battery_info *info)
@@ -1047,6 +1257,14 @@ static const struct axp_data axp221_data = {
.set_bat_info = axp209_set_battery_info,
};
+static const struct axp_data axp2101_data = {
+ .bat_ps_desc = &axp2101_batt_ps_desc,
+ .get_max_voltage = axp2101_battery_get_max_voltage,
+ .set_max_voltage = axp2101_battery_set_max_voltage,
+ .cfg_iio_chan = axp2101_bat_cfg_iio_channels,
+ .set_bat_info = axp2101_set_battery_info,
+};
+
static const struct axp_data axp717_data = {
.ccc_scale = 64000,
.ccc_offset = 0,
@@ -1082,6 +1300,9 @@ static const struct of_device_id axp20x_battery_ps_id[] = {
}, {
.compatible = "x-powers,axp717-battery-power-supply",
.data = (void *)&axp717_data,
+ }, {
+ .compatible = "x-powers,axp2101-battery-power-supply",
+ .data = (void *)&axp2101_data,
}, {
.compatible = "x-powers,axp813-battery-power-supply",
.data = (void *)&axp813_data,
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 4/7] dt-bindings: power: supply: axp20x-usb-power: Add the AXP2101
2026-10-23 10:03 ` [PATCH 4/7] dt-bindings: power: supply: axp20x-usb-power: " Olivier Louvignes
@ 2026-10-23 10:11 ` sashiko-bot
2026-10-26 9:32 ` Krzysztof Kozlowski
1 sibling, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-10-23 10:11 UTC (permalink / raw)
To: Olivier Louvignes; +Cc: devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dt-bindings: power: supply: missing allOf constraint for axp2101
--
commit 2c463350d4ace5833f7eb6572cc583175ea48340
Author: Olivier Louvignes <olivier@mgcrea.io>
dt-bindings: power: supply: axp20x-usb-power: Add the AXP2101
This commit adds the x-powers,axp2101-usb-power-supply compatible string to
the AXP20x USB power supply binding schema for the AXP2101 PMIC.
> diff --git a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
> index 2ec036405ae47..1c582aa5e1d0b 100644
> --- a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
> @@ -25,6 +25,7 @@ properties:
> - x-powers,axp223-usb-power-supply
> - x-powers,axp717-usb-power-supply
> - x-powers,axp813-usb-power-supply
> + - x-powers,axp2101-usb-power-supply
[Severity: Medium]
Should x-powers,axp2101-usb-power-supply also have a corresponding if-then
block under allOf to constrain input-current-limit-microamp?
In Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml,
the top-level input-current-limit-microamp property only defines broad generic
bounds (minimum: 100000, maximum: 4000000), while allOf restricts the property
for each existing compatible variant:
allOf:
- $ref: power-supply.yaml#
...
- if:
properties:
compatible:
contains:
enum:
- x-powers,axp717-usb-power-supply
then:
properties:
input-current-limit-microamp:
description: Maximum input current in increments of 50000 uA.
minimum: 100000
maximum: 3250000
Without a conditional block in allOf for x-powers,axp2101-usb-power-supply,
device tree nodes using this compatible string will pass schema validation
with any input-current-limit-microamp value between 100000 and 4000000 uA,
even though the AXP2101 hardware only supports discrete limits of 100000,
500000, 900000, 1000000, 1500000, and 2000000 uA.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261023100401.67592-1-olivier@mgcrea.io?part=4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/7] dt-bindings: mfd: x-powers,axp152: Add the AXP2101
2026-10-23 10:03 ` [PATCH 1/7] dt-bindings: mfd: x-powers,axp152: Add the AXP2101 Olivier Louvignes
@ 2026-10-26 9:30 ` Krzysztof Kozlowski
2026-10-26 9:31 ` Krzysztof Kozlowski
0 siblings, 1 reply; 11+ messages in thread
From: Krzysztof Kozlowski @ 2026-10-26 9:30 UTC (permalink / raw)
To: Olivier Louvignes
Cc: Lee Jones, Chen-Yu Tsai, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, mfd, devicetree, linux-kernel
On Fri, Oct 23, 2026 at 12:03:55PM +0200, Olivier Louvignes wrote:
> The AXP2101's interrupt line is optional, as for the AXP313A and the
> AXP15060: the driver then registers only the regulators. It has no DCDC
> frequency setting.
>
> Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
> ---
> Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml
> index 45f015d63df1..f5e2c8232581 100644
> --- a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml
> +++ b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml
> @@ -68,6 +68,7 @@ allOf:
> compatible:
> contains:
> enum:
> + - x-powers,axp2101
Why breaking the order? Keep natural sorted.
> - x-powers,axp15060
> - x-powers,axp305
> - x-powers,axp313a
> @@ -84,6 +85,7 @@ allOf:
> enum:
> - x-powers,axp313a
> - x-powers,axp323
> + - x-powers,axp2101
Sorting is broken in original code but you placed it completely odd.
Neither keeping sorting of 3xx variants nor, between 15060 and 717.
What's the logic?
> - x-powers,axp15060
> - x-powers,axp717
>
> @@ -108,6 +110,7 @@ properties:
> - x-powers,axp806
> - x-powers,axp809
> - x-powers,axp813
> + - x-powers,axp2101
Placement of these entries makes no sense.
> - x-powers,axp15060
> - items:
> - const: x-powers,axp228
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/7] dt-bindings: mfd: x-powers,axp152: Add the AXP2101
2026-10-26 9:30 ` Krzysztof Kozlowski
@ 2026-10-26 9:31 ` Krzysztof Kozlowski
0 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2026-10-26 9:31 UTC (permalink / raw)
To: Olivier Louvignes
Cc: Lee Jones, Chen-Yu Tsai, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, mfd, devicetree, linux-kernel
On 26/10/2026 10:30, Krzysztof Kozlowski wrote:
> On Fri, Oct 23, 2026 at 12:03:55PM +0200, Olivier Louvignes wrote:
>> The AXP2101's interrupt line is optional, as for the AXP313A and the
>> AXP15060: the driver then registers only the regulators. It has no DCDC
>> frequency setting.
>>
>> Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
>> ---
>> Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml
>> index 45f015d63df1..f5e2c8232581 100644
>> --- a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml
>> +++ b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml
>> @@ -68,6 +68,7 @@ allOf:
>> compatible:
>> contains:
>> enum:
>> + - x-powers,axp2101
>
> Why breaking the order? Keep natural sorted.
>
>> - x-powers,axp15060
>> - x-powers,axp305
>> - x-powers,axp313a
>> @@ -84,6 +85,7 @@ allOf:
>> enum:
>> - x-powers,axp313a
>> - x-powers,axp323
>> + - x-powers,axp2101
>
> Sorting is broken in original code but you placed it completely odd.
> Neither keeping sorting of 3xx variants nor, between 15060 and 717.
> What's the logic?
>
>> - x-powers,axp15060
>> - x-powers,axp717
>>
>> @@ -108,6 +110,7 @@ properties:
>> - x-powers,axp806
>> - x-powers,axp809
>> - x-powers,axp813
>> + - x-powers,axp2101
>
> Placement of these entries makes no sense.
Ah, this one is actually sorted by natural sort.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/7] dt-bindings: power: supply: axp20x-usb-power: Add the AXP2101
2026-10-23 10:03 ` [PATCH 4/7] dt-bindings: power: supply: axp20x-usb-power: " Olivier Louvignes
2026-10-23 10:11 ` sashiko-bot
@ 2026-10-26 9:32 ` Krzysztof Kozlowski
1 sibling, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2026-10-26 9:32 UTC (permalink / raw)
To: Olivier Louvignes
Cc: Lee Jones, Chen-Yu Tsai, Sebastian Reichel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, linux-pm, devicetree,
linux-kernel
On Fri, Oct 23, 2026 at 12:03:58PM +0200, Olivier Louvignes wrote:
> The AXP2101's USB power supply reports whether VBUS is present and the
> input current limit, like the AXP717's; its registers differ, so it gets
> its own compatible.
>
> Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
> ---
> .../bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
> index 2ec036405ae4..1c582aa5e1d0 100644
> --- a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
> @@ -25,6 +25,7 @@ properties:
> - x-powers,axp223-usb-power-supply
> - x-powers,axp717-usb-power-supply
> - x-powers,axp813-usb-power-supply
> + - x-powers,axp2101-usb-power-supply
Missing update for constraint of input limit.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/7] dt-bindings: power: supply: axp20x-battery: Add the AXP2101
2026-10-23 10:04 ` [PATCH 6/7] dt-bindings: power: supply: axp20x-battery: Add " Olivier Louvignes
@ 2026-10-26 9:33 ` Krzysztof Kozlowski
0 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2026-10-26 9:33 UTC (permalink / raw)
To: Olivier Louvignes
Cc: Lee Jones, Chen-Yu Tsai, Sebastian Reichel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, linux-pm, devicetree,
linux-kernel
On Fri, Oct 23, 2026 at 12:04:00PM +0200, Olivier Louvignes wrote:
> The AXP2101's charger is programmed from the monitored battery and its
> registers differ from the other models', so it gets its own compatible.
>
> Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
> ---
> .../power/supply/x-powers,axp20x-battery-power-supply.yaml | 1 +
> 1 file changed, 1 insertion(+)
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-10-26 9:33 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23 10:03 [PATCH 0/7] Add support for the X-Powers AXP2101 PMIC Olivier Louvignes
2026-10-23 10:03 ` [PATCH 1/7] dt-bindings: mfd: x-powers,axp152: Add the AXP2101 Olivier Louvignes
2026-10-26 9:30 ` Krzysztof Kozlowski
2026-10-26 9:31 ` Krzysztof Kozlowski
2026-10-23 10:03 ` [PATCH 4/7] dt-bindings: power: supply: axp20x-usb-power: " Olivier Louvignes
2026-10-23 10:11 ` sashiko-bot
2026-10-26 9:32 ` Krzysztof Kozlowski
2026-10-23 10:03 ` [PATCH 5/7] power: supply: axp20x_usb_power: Add support for " Olivier Louvignes
2026-10-23 10:04 ` [PATCH 6/7] dt-bindings: power: supply: axp20x-battery: Add " Olivier Louvignes
2026-10-26 9:33 ` Krzysztof Kozlowski
2026-10-23 10:04 ` [PATCH 7/7] power: supply: axp20x_battery: Add support for " Olivier Louvignes
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.