Re: [PATCH v2 2/7] mfd: axp20x: Add support for the AXP2101

From: Chen-Yu Tsai

Date: Thu Dec 03 2026 - 10:57:34 EST


On Mon, Nov 16, 2026 at 2:12 AM Olivier Louvignes <olivier@xxxxxxxxx> wrote:
>
> The AXP2101 is an X-Powers PMIC with five DC-DC converters, several
> LDOs, a charger and a fuel gauge, used on the HiBy R1 among others. Add
> it to the axp20x core with its register map and interrupts, and cells
> for the regulators, the USB power supply and the battery charger. It
> powers off through bit 0 of COMM_CFG (0x10), not AXP20X_OFF_CTRL.
>
> There is no datasheet behind this: the register map comes from the

So I actually found datasheets: https://github.com/eggfly/AXP2101

And there are two variants, a linear charge and a SW charge. So
first you need to say which variant you are targeting. From a high
level it seems the major difference is whether one of the DCDC buck
converters is used for the charger or not.

This is also seen on the AXP717. However we didn't really model it yet.

> 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's state on a running R1.
>
> Signed-off-by: Olivier Louvignes <olivier@xxxxxxxxx>
> ---
> drivers/mfd/axp20x-i2c.c | 2 +
> drivers/mfd/axp20x.c | 107 +++++++++++++++++++++++++++++++++-
> include/linux/mfd/axp20x.h | 114 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 221 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mfd/axp20x-i2c.c b/drivers/mfd/axp20x-i2c.c
> index 5c93136f977e..c1f7bb8e3a14 100644
> --- a/drivers/mfd/axp20x-i2c.c
> +++ b/drivers/mfd/axp20x-i2c.c
> @@ -69,6 +69,7 @@ static const struct of_device_id axp20x_i2c_of_match[] = {
> { .compatible = "x-powers,axp717", .data = (void *)AXP717_ID },
> { .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
> { .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
> + { .compatible = "x-powers,axp2101", .data = (void *)AXP2101_ID },
> { .compatible = "x-powers,axp15060", .data = (void *)AXP15060_ID },
> { },
> };
> @@ -86,6 +87,7 @@ static const struct i2c_device_id axp20x_i2c_id[] = {
> { "axp717" },
> { "axp803" },
> { "axp806" },
> + { "axp2101" },
> { "axp15060" },
> { }
> };
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index 4d770e718716..2d2c5ded02c3 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -48,6 +48,7 @@ static const char * const axp20x_model_names[] = {
> [AXP806_ID] = "AXP806",
> [AXP809_ID] = "AXP809",
> [AXP813_ID] = "AXP813",
> + [AXP2101_ID] = "AXP2101",
> [AXP15060_ID] = "AXP15060",
> };
>
> @@ -218,6 +219,34 @@ static const struct regmap_access_table axp313a_volatile_table = {
> .n_yes_ranges = ARRAY_SIZE(axp313a_volatile_ranges),
> };
>
> +static const struct regmap_range axp2101_writeable_ranges[] = {
> + regmap_reg_range(AXP2101_COMM_CFG, AXP2101_LOW_BATT_WARN),
> + regmap_reg_range(AXP2101_PWROFF_EN, AXP2101_FAST_PWRON_CTRL),
> + regmap_reg_range(AXP2101_ADC_CH_EN, AXP2101_ADC_CH_EN),
> + regmap_reg_range(AXP2101_IRQ0_EN, AXP2101_IRQ2_STATE),

There are holes in this range.

> + regmap_reg_range(AXP2101_TS_PIN_CFG, AXP2101_BTN_CHG_CFG),
> + regmap_reg_range(AXP2101_DCDC_OUTPUT_CONTROL, AXP2101_DLDO2_CONTROL),

And this one. Please split them.

> + regmap_reg_range(AXP2101_GAUGE_CFG, AXP2101_GAUGE_CFG),
> +};
> +
> +static const struct regmap_range axp2101_volatile_ranges[] = {
> + regmap_reg_range(AXP2101_PMU_STATUS_1, AXP2101_PMU_STATUS_2),
> + regmap_reg_range(AXP2101_PWRON_STATUS, AXP2101_PWROFF_STATUS),
> + regmap_reg_range(AXP2101_BATT_V_H, AXP2101_DIE_TEMP_L),
> + regmap_reg_range(AXP2101_IRQ0_STATE, AXP2101_IRQ2_STATE),
> + regmap_reg_range(AXP2101_BATT_PERCENT_DATA, AXP2101_TTF_L),

Missing AXP2101_COMM_CFG, AXP2101_GAUGE_RESET, AXP2101_WDT_CTRL, and
AXP2101_SLEEP_WAKEUP.

[...]

> @@ -1325,6 +1422,12 @@ int axp20x_match_device(struct axp20x_dev *axp20x)
> axp20x->regmap_cfg = &axp717_regmap_config;
> axp20x->regmap_irq_chip = &axp717_regmap_irq_chip;
> break;
> + case AXP2101_ID:
> + axp20x->nr_cells = ARRAY_SIZE(axp2101_cells);
> + axp20x->cells = axp2101_cells;
> + axp20x->regmap_cfg = &axp2101_regmap_config;
> + axp20x->regmap_irq_chip = &axp2101_regmap_irq_chip;
> + break;

Please stick with one ordering for all the objects you add.

Either it's between AXP8xx and AXP15060, or just before AXP717.
Pick one. If there's a reason to have different orders for different
types of objects, explain it in the commit message.

> case AXP803_ID:
> axp20x->nr_cells = ARRAY_SIZE(axp803_cells);
> axp20x->cells = axp803_cells;
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index b352661d99a1..21db12a4156d 100644
> --- a/include/linux/mfd/axp20x.h
> +++ b/include/linux/mfd/axp20x.h

[...]

> +#define AXP2101_DCDC_MODE_CTRL 0x87

> +#define AXP2101_TTE_H 0xa6
> +#define AXP2101_TTF_L 0xa9

Datasheet does not have these registers.


ChenYu