Skip to contentSkip to conversation

regulator: Add X-Powers AXP313a PMIC support

PATCH Applied Andre Przywara 6 participants 25 messages Apr 1, 2023 – Apr 24, 2023

Subsystems (5)

v10 of 11 Applied Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v10 cover regulator: Add X-Powers AXP313a PMIC support

This patch series adds support for the X-Powers AXP313a PMIC, which is often bundled with Allwinner H616 or H313 SoCs.
It's my turn again for this revision of the series, after Martin did v7 and v8.
After some more significant changes in v9, this is fixing some nits, and builds on Krzysztof's patch to simplify the DT binding document (patch ID at the end of this email). For a complete changelog see below.

Up to v5 this was speaking of the AXP1530, which seems to be some internal name. The chips we have seen in the wild are all labeled AXP313a, so we go with this name here, from now on. This is supported by the fact that there is an AXP313a datasheet, but none for the AXP1530.

Patch 1 is the binding documentation (just the new compatible string), patch 2 adds the MFD bits (mostly describing the extent of the regmap), while patch 3 describes the actual AXP313a register definitions. Since this ties neatly into the existing AXP and generic regulator framework, the patches are indeed only structure definitions, there is little new code.

For now we papered over this "fixed customizable" RTC-LDO regulator in the same way this was done before for other PMICs (AXP803, for instance), We think we can fix this properly with a follow-up patch, for all instances.

Please have a look!

Cheers,
Andre

Changelog:

v9 .. v10:
- use MFD_CELL_RES macro
- mark dcdc-freq property as "false" for AXP313a
- add Lee's ACK

v8 .. v9:
- use MFD_CELL_NAME macro
- fix LDO regulator names to match the datasheet
- only mark changing registers as volatile
- use correct register for shutdown operation
- add power key resources
- disallow x-powers,dcdc-freq in the DT binding
- drop unused OUTPUT_MONITOR register name, add SHUTDOWN_CTRL
- require dcdcfreq being 0 (non-present DT property default)

v7 .. v8:
- Add check for dcdcfreq being zero

v6 .. v7:
- Use alphabetical ordering

v5 .. v6:
- change name from AXP1530 to AXP313a
- extend commit messages
- drop AXP*_FREQUENCY register (not used anyway)
- better vertically align struct definitions
- rename IRQs to match names used for other PMICs
- add RTC_LDO regulator
- use decimal numbers for selector ranges
- use macro definitions to name some values
- force DC/DC switching frequency to be fixed at 3 MHz
- change LDO source supply to VIN1 (as per datasheet)

v4 .. v5:
- Use alphabetical ordering in mfd
- Correct { placement line
- Replace spaces with tabs in 1 struct

v3 .. v4:
- Fix indentation

v2 .. v3:
- Move AXP1530 dt-binding to alphabetical order

v1 .. v2:
- Remove RSB support.
- Drop .id = 0
- Add dt-binding for the AXP1530

Martin Botka (3):
dt-bindings: mfd: x-powers,axp152: Document the AXP313a variant
mfd: axp20x: Add support for AXP313a PMIC
regulator: axp20x: Add support for AXP313a variant

 .../bindings/mfd/x-powers,axp152.yaml         | 11 +++
 drivers/mfd/axp20x-i2c.c                      |  2 +
 drivers/mfd/axp20x.c                          | 78 ++++++++++++++++++-
 drivers/regulator/axp20x-regulator.c          | 60 ++++++++++++++
 include/linux/mfd/axp20x.h                    | 32 ++++++++
 5 files changed, 182 insertions(+), 1 deletion(-)

base-commit: a0264d198aad19429df0ca2e320caf8b1f98ec64
prerequisite-patch-id: b1636dbb381288f5c2c117615a9c1a005d5dcd94

Signature · 1 line
2.35.7
#1 lore raw

PATCH v10 1/3 dt-bindings: mfd: x-powers,axp152: Document the AXP313a variant

From: Martin Botka <[email protected]>

The X-Powers AXP313a is a PMIC used on some devices with the Allwinner H616 or H313 SoC.
According to the datasheet, the DC/DC converter PWM frequency is fixed (to 3 MHz), so disallow the property that lets us set this frequency for the other PMICs.

---
 .../devicetree/bindings/mfd/x-powers,axp152.yaml      | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml +11 -0
index 2691ac08f5362..ed76b1c58cdf4 100644
@@ -73,6 +73,16 @@ allOf:
       required:
         - interrupts
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: x-powers,axp313a
+
+    then:
+      properties:
+        x-powers,dcdc-freq: false
+
 properties:
   compatible:
     oneOf:
@@ -82,6 +92,7 @@ properties:
           - x-powers,axp209
           - x-powers,axp221
           - x-powers,axp223
+          - x-powers,axp313a
           - x-powers,axp803
           - x-powers,axp806
           - x-powers,axp809
Signature · 1 line
2.35.7
Reviewed-by on v10 1/3
#2 lore raw

Re: [PATCH v10 1/3] dt-bindings: mfd: x-powers,axp152: Document the AXP313a variant

Quoted 9 lines · Andre Przywara

From: Martin Botka <[email protected]>

The X-Powers AXP313a is a PMIC used on some devices with the Allwinner H616 or H313 SoC.
According to the datasheet, the DC/DC converter PWM frequency is fixed (to 3 MHz), so disallow the property that lets us set this frequency for the other PMICs.

Best regards,
Krzysztof

Acked-by on v10 1/3
#3 lore raw

Re: [PATCH v10 1/3] dt-bindings: mfd: x-powers,axp152: Document the AXP313a variant

In reply to Andre Przywara
Quoted 11 lines · Andre Przywara

From: Martin Botka <[email protected]>

The X-Powers AXP313a is a PMIC used on some devices with the Allwinner H616 or H313 SoC.
According to the datasheet, the DC/DC converter PWM frequency is fixed (to 3 MHz), so disallow the property that lets us set this frequency for the other PMICs.

maintainer Applied
#4 lore raw

Re: [PATCH v10 1/3] dt-bindings: mfd: x-powers,axp152: Document the AXP313a variant

In reply to Andre Przywara
Quoted 8 lines · Andre Przywara

From: Martin Botka <[email protected]>

The X-Powers AXP313a is a PMIC used on some devices with the Allwinner H616 or H313 SoC.
According to the datasheet, the DC/DC converter PWM frequency is fixed (to 3 MHz), so disallow the property that lets us set this frequency for the other PMICs.

Quoted 5 lines
---
 .../devicetree/bindings/mfd/x-powers,axp152.yaml      | 11 +++++++++++
 1 file changed, 11 insertions(+)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
#5 lore raw

PATCH v10 2/3 mfd: axp20x: Add support for AXP313a PMIC

In reply to Andre Przywara

From: Martin Botka <[email protected]>

The AXP313a is a PMIC chip produced by X-Powers, it can be connected via an I2C bus.
The name AXP1530 seems to appear as well, and this is what is used in the BSP driver. From all we know it's the same chip, just a different name. However we have only seen AXP313a chips in the wild, so go with this name.

Compared to the other AXP PMICs it's a rather simple affair: just three DCDC converters, three LDOs, and no battery charging support.

Describe the regmap and the MFD bits, along with the registers exposed via I2C. Aside from the various regulators, also describe the power key interrupts, and adjust the shutdown handler routine to use a different register than the other PMICs.
Eventually advertise the device using the new compatible string.

---
 drivers/mfd/axp20x-i2c.c   |  2 +
 drivers/mfd/axp20x.c       | 78 +++++++++++++++++++++++++++++++++++++-
 include/linux/mfd/axp20x.h | 32 ++++++++++++++++
 3 files changed, 111 insertions(+), 1 deletion(-)
drivers/mfd/axp20x-i2c.c +2 -0
index f49fbd3079589..03fb0840a4c0e 100644
@@ -63,6 +63,7 @@ static const struct of_device_id axp20x_i2c_of_match[] = {
 	{ .compatible = "x-powers,axp209", .data = (void *)AXP209_ID },
 	{ .compatible = "x-powers,axp221", .data = (void *)AXP221_ID },
 	{ .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
+	{ .compatible = "x-powers,axp313a", .data = (void *)AXP313A_ID },
 	{ .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
 	{ .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
 	{ },
@@ -76,6 +77,7 @@ static const struct i2c_device_id axp20x_i2c_id[] = {
 	{ "axp209", 0 },
 	{ "axp221", 0 },
 	{ "axp223", 0 },
+	{ "axp313a", 0 },
 	{ "axp803", 0 },
 	{ "axp806", 0 },
 	{ },
drivers/mfd/axp20x.c +77 -1

133 lines not on this page · raw message

include/linux/mfd/axp20x.h +32 -0
index 2058194807bd2..edd7fdcc33f91 100644
@@ -17,6 +17,7 @@ enum axp20x_variants {
 	AXP221_ID,
 	AXP223_ID,
 	AXP288_ID,
+	AXP313A_ID,
 	AXP803_ID,
 	AXP806_ID,
 	AXP809_ID,
@@ -91,6 +92,17 @@ enum axp20x_variants {
 #define AXP22X_ALDO3_V_OUT		0x2a
 #define AXP22X_CHRG_CTRL3		0x35
 
+#define AXP313A_ON_INDICATE		0x00
+#define AXP313A_OUTPUT_CONTROL		0x10
+#define AXP313A_DCDC1_CONRTOL		0x13
+#define AXP313A_DCDC2_CONRTOL		0x14
+#define AXP313A_DCDC3_CONRTOL		0x15
+#define AXP313A_ALDO1_CONRTOL		0x16
+#define AXP313A_DLDO1_CONRTOL		0x17
+#define AXP313A_SHUTDOWN_CTRL		0x1a
+#define AXP313A_IRQ_EN			0x20
+#define AXP313A_IRQ_STATE		0x21
+
 #define AXP806_STARTUP_SRC		0x00
 #define AXP806_CHIP_ID			0x03
 #define AXP806_PWR_OUT_CTRL1		0x10
@@ -322,6 +334,16 @@ enum {
 	AXP22X_REG_ID_MAX,
 };
 
+enum {
+	AXP313A_DCDC1 = 0,
+	AXP313A_DCDC2,
+	AXP313A_DCDC3,
+	AXP313A_ALDO1,
+	AXP313A_DLDO1,
+	AXP313A_RTC_LDO,
+	AXP313A_REG_ID_MAX,
+};
+
 enum {
 	AXP806_DCDCA = 0,
 	AXP806_DCDCB,
@@ -548,6 +570,16 @@ enum axp288_irqs {
 	AXP288_IRQ_BC_USB_CHNG,
 };
 
+enum axp313a_irqs {
+	AXP313A_IRQ_DIE_TEMP_HIGH,
+	AXP313A_IRQ_DCDC2_V_LOW = 2,
+	AXP313A_IRQ_DCDC3_V_LOW,
+	AXP313A_IRQ_PEK_LONG,
+	AXP313A_IRQ_PEK_SHORT,
+	AXP313A_IRQ_PEK_FAL_EDGE,
+	AXP313A_IRQ_PEK_RIS_EDGE,
+};
+
 enum axp803_irqs {
 	AXP803_IRQ_ACIN_OVER_V = 1,
 	AXP803_IRQ_ACIN_PLUGIN,
Signature · 1 line
2.35.7
Reviewed-by on v10 2/3
#6 lore raw

Re: [PATCH v10 2/3] mfd: axp20x: Add support for AXP313a PMIC

Quoted 19 lines · Andre Przywara

From: Martin Botka <[email protected]>

The AXP313a is a PMIC chip produced by X-Powers, it can be connected via an I2C bus.
The name AXP1530 seems to appear as well, and this is what is used in the BSP driver. From all we know it's the same chip, just a different name. However we have only seen AXP313a chips in the wild, so go with this name.

Compared to the other AXP PMICs it's a rather simple affair: just three DCDC converters, three LDOs, and no battery charging support.

Describe the regmap and the MFD bits, along with the registers exposed via I2C. Aside from the various regulators, also describe the power key interrupts, and adjust the shutdown handler routine to use a different register than the other PMICs.
Eventually advertise the device using the new compatible string.

Quoted 3 lines
maintainer Applied
#7 lore raw

Re: [PATCH v10 2/3] mfd: axp20x: Add support for AXP313a PMIC

In reply to Andre Przywara
Quoted 18 lines · Andre Przywara

From: Martin Botka <[email protected]>

The AXP313a is a PMIC chip produced by X-Powers, it can be connected via an I2C bus.
The name AXP1530 seems to appear as well, and this is what is used in the BSP driver. From all we know it's the same chip, just a different name. However we have only seen AXP313a chips in the wild, so go with this name.

Compared to the other AXP PMICs it's a rather simple affair: just three DCDC converters, three LDOs, and no battery charging support.

Describe the regmap and the MFD bits, along with the registers exposed via I2C. Aside from the various regulators, also describe the power key interrupts, and adjust the shutdown handler routine to use a different register than the other PMICs.
Eventually advertise the device using the new compatible string.

Quoted 8 lines
---
 drivers/mfd/axp20x-i2c.c   |  2 +
 drivers/mfd/axp20x.c       | 78 +++++++++++++++++++++++++++++++++++++-
 include/linux/mfd/axp20x.h | 32 ++++++++++++++++
 3 files changed, 111 insertions(+), 1 deletion(-)

Applied, thanks.

Signature · 1 line
Lee Jones [李琼斯]
#8 lore raw

Re: [PATCH v10 2/3] mfd: axp20x: Add support for AXP313a PMIC

Hello Lee,

Where is your branch? I'm gonna rebase my AXP15060 series on it.

Best regards,

Shengyu

Quoted 30 lines · Lee Jones
Quoted 18 lines · Andre Przywara

From: Martin Botka <[email protected]>

The AXP313a is a PMIC chip produced by X-Powers, it can be connected via an I2C bus.
The name AXP1530 seems to appear as well, and this is what is used in the BSP driver. From all we know it's the same chip, just a different name. However we have only seen AXP313a chips in the wild, so go with this name.

Compared to the other AXP PMICs it's a rather simple affair: just three DCDC converters, three LDOs, and no battery charging support.

Describe the regmap and the MFD bits, along with the registers exposed via I2C. Aside from the various regulators, also describe the power key interrupts, and adjust the shutdown handler routine to use a different register than the other PMICs.
Eventually advertise the device using the new compatible string.

Quoted 8 lines
---
  drivers/mfd/axp20x-i2c.c   |  2 +
  drivers/mfd/axp20x.c       | 78 +++++++++++++++++++++++++++++++++++++-
  include/linux/mfd/axp20x.h | 32 ++++++++++++++++
  3 files changed, 111 insertions(+), 1 deletion(-)

Applied, thanks.

maintainer
#9 lore raw

Re: [PATCH v10 2/3] mfd: axp20x: Add support for AXP313a PMIC

Quoted 3 lines · Shengyu Qu

Hello Lee,

Where is your branch? I'm gonna rebase my AXP15060 series on it.

You can use -next.

Quoted 31 lines · Lee Jones
Quoted 30 lines · Andre Przywara
Quoted 19 lines

From: Martin Botka <[email protected]>

The AXP313a is a PMIC chip produced by X-Powers, it can be connected via an I2C bus.
The name AXP1530 seems to appear as well, and this is what is used in the BSP driver. From all we know it's the same chip, just a different name. However we have only seen AXP313a chips in the wild, so go with this name.

Compared to the other AXP PMICs it's a rather simple affair: just three DCDC converters, three LDOs, and no battery charging support.

Describe the regmap and the MFD bits, along with the registers exposed via I2C. Aside from the various regulators, also describe the power key interrupts, and adjust the shutdown handler routine to use a different register than the other PMICs.
Eventually advertise the device using the new compatible string.

Quoted 8 lines
---
  drivers/mfd/axp20x-i2c.c   |  2 +
  drivers/mfd/axp20x.c       | 78 +++++++++++++++++++++++++++++++++++++-
  include/linux/mfd/axp20x.h | 32 ++++++++++++++++
  3 files changed, 111 insertions(+), 1 deletion(-)

Applied, thanks.

Signature · 1 line
Lee Jones [李琼斯]
#10 lore raw

PATCH v10 3/3 regulator: axp20x: Add support for AXP313a variant

In reply to Andre Przywara

From: Martin Botka <[email protected]>

The AXP313a is your typical I2C controlled PMIC, although in a lighter fashion compared to the other X-Powers PMICs: it has only three DCDC rails, three LDOs, and no battery charging support.

The AXP313a datasheet does not describe a register to change the DCDC switching frequency, and talks of it being fixed at 3 MHz. Check that the property allowing to change that frequency is absent from the DT, and bail out otherwise.

The third LDO, RTCLDO, is fixed, and cannot even be turned on or off, programmatically. On top of that, its voltage is customisable (either 1.8V or 3.3V), which we cannot describe easily using the existing regulator wrapper functions. This should be fixed properly, using regulator-{min,max}-microvolt in the DT, but this requires more changes to the code. As some other PMICs (AXP2xx, AXP803) seem to paper over the same problem as well, we follow suit here and pretend it's a fixed 1.8V regulator. A proper fix can follow later. The BSP code seems to ignore this regulator altogether.

Describe the AXP313A's voltage settings and switch registers, how the voltages are encoded, and connect this to the MFD device via its regulator ID.

---
 drivers/regulator/axp20x-regulator.c | 60 ++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
drivers/regulator/axp20x-regulator.c +60 -0
index d260c442b788d..81f339009df9b 100644
@@ -134,6 +134,11 @@
 #define AXP22X_PWR_OUT_DLDO4_MASK	BIT_MASK(6)
 #define AXP22X_PWR_OUT_ALDO3_MASK	BIT_MASK(7)
 
+#define AXP313A_DCDC1_NUM_VOLTAGES	107
+#define AXP313A_DCDC23_NUM_VOLTAGES	88
+#define AXP313A_DCDC_V_OUT_MASK		GENMASK(6, 0)
+#define AXP313A_LDO_V_OUT_MASK		GENMASK(4, 0)
+
 #define AXP803_PWR_OUT_DCDC1_MASK	BIT_MASK(0)
 #define AXP803_PWR_OUT_DCDC2_MASK	BIT_MASK(1)
 #define AXP803_PWR_OUT_DCDC3_MASK	BIT_MASK(2)
@@ -638,6 +643,48 @@ static const struct regulator_desc axp22x_drivevbus_regulator = {
 	.ops		= &axp20x_ops_sw,
 };
 
+static const struct linear_range axp313a_dcdc1_ranges[] = {
+	REGULATOR_LINEAR_RANGE(500000,   0,  70,  10000),
+	REGULATOR_LINEAR_RANGE(1220000, 71,  87,  20000),
+	REGULATOR_LINEAR_RANGE(1600000, 88, 106, 100000),
+};
+
+static const struct linear_range axp313a_dcdc2_ranges[] = {
+	REGULATOR_LINEAR_RANGE(500000,   0, 70, 10000),
+	REGULATOR_LINEAR_RANGE(1220000, 71, 87, 20000),
+};
+
+/*
+ * This is deviating from the datasheet. The values here are taken from the
+ * BSP driver and have been confirmed by measurements.
+ */
+static const struct linear_range axp313a_dcdc3_ranges[] = {
+	REGULATOR_LINEAR_RANGE(500000,   0,  70, 10000),
+	REGULATOR_LINEAR_RANGE(1220000, 71, 102, 20000),
+};
+
+static const struct regulator_desc axp313a_regulators[] = {
+	AXP_DESC_RANGES(AXP313A, DCDC1, "dcdc1", "vin1",
+			axp313a_dcdc1_ranges, AXP313A_DCDC1_NUM_VOLTAGES,
+			AXP313A_DCDC1_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
+			AXP313A_OUTPUT_CONTROL, BIT(0)),
+	AXP_DESC_RANGES(AXP313A, DCDC2, "dcdc2", "vin2",
+			axp313a_dcdc2_ranges, AXP313A_DCDC23_NUM_VOLTAGES,
+			AXP313A_DCDC2_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
+			AXP313A_OUTPUT_CONTROL, BIT(1)),
+	AXP_DESC_RANGES(AXP313A, DCDC3, "dcdc3", "vin3",
+			axp313a_dcdc3_ranges, AXP313A_DCDC23_NUM_VOLTAGES,
+			AXP313A_DCDC3_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
+			AXP313A_OUTPUT_CONTROL, BIT(2)),
+	AXP_DESC(AXP313A, ALDO1, "aldo1", "vin1", 500, 3500, 100,
+		 AXP313A_ALDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK,
+		 AXP313A_OUTPUT_CONTROL, BIT(3)),
+	AXP_DESC(AXP313A, DLDO1, "dldo1", "vin1", 500, 3500, 100,
+		 AXP313A_DLDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK,
+		 AXP313A_OUTPUT_CONTROL, BIT(4)),
+	AXP_DESC_FIXED(AXP313A, RTC_LDO, "rtc-ldo", "vin1", 1800),
+};
+
 /* DCDC ranges shared with AXP813 */
 static const struct linear_range axp803_dcdc234_ranges[] = {
 	REGULATOR_LINEAR_RANGE(500000,
@@ -1040,6 +1087,15 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 		def = 3000;
 		step = 150;
 		break;
+	case AXP313A_ID:
+		/* The DCDC PWM frequency seems to be fixed to 3 MHz. */
+		if (dcdcfreq != 0) {
+			dev_err(&pdev->dev,
+				"DCDC frequency on AXP313a is fixed to 3 MHz.\n");
+			return -EINVAL;
+		}
+
+		return 0;
 	default:
 		dev_err(&pdev->dev,
 			"Setting DCDC frequency for unsupported AXP variant\n");
@@ -1232,6 +1288,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 		drivevbus = of_property_read_bool(pdev->dev.parent->of_node,
 						  "x-powers,drive-vbus-en");
 		break;
+	case AXP313A_ID:
+		regulators = axp313a_regulators;
+		nregulators = AXP313A_REG_ID_MAX;
+		break;
 	case AXP803_ID:
 		regulators = axp803_regulators;
 		nregulators = AXP803_REG_ID_MAX;
Signature · 1 line
2.35.7
Reviewed-by on v10 3/3
#11 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

Quoted 22 lines · Andre Przywara

From: Martin Botka <[email protected]>

The AXP313a is your typical I2C controlled PMIC, although in a lighter fashion compared to the other X-Powers PMICs: it has only three DCDC rails, three LDOs, and no battery charging support.

The AXP313a datasheet does not describe a register to change the DCDC switching frequency, and talks of it being fixed at 3 MHz. Check that the property allowing to change that frequency is absent from the DT, and bail out otherwise.

The third LDO, RTCLDO, is fixed, and cannot even be turned on or off, programmatically. On top of that, its voltage is customisable (either 1.8V or 3.3V), which we cannot describe easily using the existing regulator wrapper functions. This should be fixed properly, using regulator-{min,max}-microvolt in the DT, but this requires more changes to the code. As some other PMICs (AXP2xx, AXP803) seem to paper over the same problem as well, we follow suit here and pretend it's a fixed 1.8V regulator. A proper fix can follow later. The BSP code seems to ignore this regulator altogether.

Quoted 6 lines

Describe the AXP313A's voltage settings and switch registers, how the voltages are encoded, and connect this to the MFD device via its regulator ID.

maintainer
#12 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

In reply to Andre Przywara

Mark,

Quoted 25 lines · Andre Przywara

From: Martin Botka <[email protected]>

The AXP313a is your typical I2C controlled PMIC, although in a lighter fashion compared to the other X-Powers PMICs: it has only three DCDC rails, three LDOs, and no battery charging support.

The AXP313a datasheet does not describe a register to change the DCDC switching frequency, and talks of it being fixed at 3 MHz. Check that the property allowing to change that frequency is absent from the DT, and bail out otherwise.

The third LDO, RTCLDO, is fixed, and cannot even be turned on or off, programmatically. On top of that, its voltage is customisable (either 1.8V or 3.3V), which we cannot describe easily using the existing regulator wrapper functions. This should be fixed properly, using regulator-{min,max}-microvolt in the DT, but this requires more changes to the code. As some other PMICs (AXP2xx, AXP803) seem to paper over the same problem as well, we follow suit here and pretend it's a fixed 1.8V regulator. A proper fix can follow later. The BSP code seems to ignore this regulator altogether.

Describe the AXP313A's voltage settings and switch registers, how the voltages are encoded, and connect this to the MFD device via its regulator ID.

Quoted 5 lines
---
 drivers/regulator/axp20x-regulator.c | 60 ++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

Is this on your radar?

Can I take the other two patches without causing issues?

Quoted 93 lines
drivers/regulator/axp20x-regulator.c +60 -1
index d260c442b788d..81f339009df9b 100644
@@ -134,6 +134,11 @@
 #define AXP22X_PWR_OUT_DLDO4_MASK	BIT_MASK(6)
 #define AXP22X_PWR_OUT_ALDO3_MASK	BIT_MASK(7)
 
+#define AXP313A_DCDC1_NUM_VOLTAGES	107
+#define AXP313A_DCDC23_NUM_VOLTAGES	88
+#define AXP313A_DCDC_V_OUT_MASK		GENMASK(6, 0)
+#define AXP313A_LDO_V_OUT_MASK		GENMASK(4, 0)
+
 #define AXP803_PWR_OUT_DCDC1_MASK	BIT_MASK(0)
 #define AXP803_PWR_OUT_DCDC2_MASK	BIT_MASK(1)
 #define AXP803_PWR_OUT_DCDC3_MASK	BIT_MASK(2)
@@ -638,6 +643,48 @@ static const struct regulator_desc axp22x_drivevbus_regulator = {
 	.ops		= &axp20x_ops_sw,
 };
 
+static const struct linear_range axp313a_dcdc1_ranges[] = {
+	REGULATOR_LINEAR_RANGE(500000,   0,  70,  10000),
+	REGULATOR_LINEAR_RANGE(1220000, 71,  87,  20000),
+	REGULATOR_LINEAR_RANGE(1600000, 88, 106, 100000),
+};
+
+static const struct linear_range axp313a_dcdc2_ranges[] = {
+	REGULATOR_LINEAR_RANGE(500000,   0, 70, 10000),
+	REGULATOR_LINEAR_RANGE(1220000, 71, 87, 20000),
+};
+
+/*
+ * This is deviating from the datasheet. The values here are taken from the
+ * BSP driver and have been confirmed by measurements.
+ */
+static const struct linear_range axp313a_dcdc3_ranges[] = {
+	REGULATOR_LINEAR_RANGE(500000,   0,  70, 10000),
+	REGULATOR_LINEAR_RANGE(1220000, 71, 102, 20000),
+};
+
+static const struct regulator_desc axp313a_regulators[] = {
+	AXP_DESC_RANGES(AXP313A, DCDC1, "dcdc1", "vin1",
+			axp313a_dcdc1_ranges, AXP313A_DCDC1_NUM_VOLTAGES,
+			AXP313A_DCDC1_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
+			AXP313A_OUTPUT_CONTROL, BIT(0)),
+	AXP_DESC_RANGES(AXP313A, DCDC2, "dcdc2", "vin2",
+			axp313a_dcdc2_ranges, AXP313A_DCDC23_NUM_VOLTAGES,
+			AXP313A_DCDC2_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
+			AXP313A_OUTPUT_CONTROL, BIT(1)),
+	AXP_DESC_RANGES(AXP313A, DCDC3, "dcdc3", "vin3",
+			axp313a_dcdc3_ranges, AXP313A_DCDC23_NUM_VOLTAGES,
+			AXP313A_DCDC3_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
+			AXP313A_OUTPUT_CONTROL, BIT(2)),
+	AXP_DESC(AXP313A, ALDO1, "aldo1", "vin1", 500, 3500, 100,
+		 AXP313A_ALDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK,
+		 AXP313A_OUTPUT_CONTROL, BIT(3)),
+	AXP_DESC(AXP313A, DLDO1, "dldo1", "vin1", 500, 3500, 100,
+		 AXP313A_DLDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK,
+		 AXP313A_OUTPUT_CONTROL, BIT(4)),
+	AXP_DESC_FIXED(AXP313A, RTC_LDO, "rtc-ldo", "vin1", 1800),
+};
+
 /* DCDC ranges shared with AXP813 */
 static const struct linear_range axp803_dcdc234_ranges[] = {
 	REGULATOR_LINEAR_RANGE(500000,
@@ -1040,6 +1087,15 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 		def = 3000;
 		step = 150;
 		break;
+	case AXP313A_ID:
+		/* The DCDC PWM frequency seems to be fixed to 3 MHz. */
+		if (dcdcfreq != 0) {
+			dev_err(&pdev->dev,
+				"DCDC frequency on AXP313a is fixed to 3 MHz.\n");
+			return -EINVAL;
+		}
+
+		return 0;
 	default:
 		dev_err(&pdev->dev,
 			"Setting DCDC frequency for unsupported AXP variant\n");
@@ -1232,6 +1288,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 		drivevbus = of_property_read_bool(pdev->dev.parent->of_node,
 						  "x-powers,drive-vbus-en");
 		break;
+	case AXP313A_ID:
+		regulators = axp313a_regulators;
+		nregulators = AXP313A_REG_ID_MAX;
+		break;
 	case AXP803_ID:
 		regulators = axp803_regulators;
 		nregulators = AXP803_REG_ID_MAX;
--
Quoted 2 lines

2.35.7

--
Lee Jones [李琼斯]

maintainer
#13 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

Quoted 3 lines · Lee Jones

Is this on your radar?

Can I take the other two patches without causing issues?

I'm waiting for the MFD.

maintainer
#14 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

Quoted 7 lines · Mark Brown
Quoted 3 lines · Lee Jones

Is this on your radar?

Can I take the other two patches without causing issues?

I'm waiting for the MFD.

To do what? #deadlock

--
Lee Jones [李琼斯]

maintainer
#15 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

Quoted 5 lines · Lee Jones
Quoted 1 line · Mark Brown

I'm waiting for the MFD.

To do what? #deadlock

Whatever it is you need to do to be happy with and apply the shared bit of the series. We're somehow on v10 here for what seems like it should be a very simple change, I've not followed the ins and outs of how that happened.

maintainer
#16 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

Quoted 11 lines · Mark Brown
Quoted 5 lines · Lee Jones
Quoted 1 line · Mark Brown

I'm waiting for the MFD.

To do what? #deadlock

Whatever it is you need to do to be happy with and apply the shared bit of the series. We're somehow on v10 here for what seems like it should be a very simple change, I've not followed the ins and outs of how that happened.

From an MFD perspective, reviews happened followed by an approval in v9.

I can't do anything without an Ack from you or some indication that you want me to apply the first 2 patches and share an IB.

--
Lee Jones [李琼斯]

maintainer
#17 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

Quoted 11 lines · Lee Jones
Quoted 4 lines · Mark Brown

Whatever it is you need to do to be happy with and apply the shared bit of the series. We're somehow on v10 here for what seems like it should be a very simple change, I've not followed the ins and outs of how that happened.

From an MFD perspective, reviews happened followed by an approval in v9.

I can't do anything without an Ack from you or some indication that you want me to apply the first 2 patches and share an IB.

Yes, please apply and share a branch like you usually do.

maintainer
#18 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

Quoted 8 lines · Mark Brown
Quoted 6 lines · Lee Jones
Quoted 4 lines · Mark Brown

Whatever it is you need to do to be happy with and apply the shared bit of the series. We're somehow on v10 here for what seems like it should be a very simple change, I've not followed the ins and outs of how that happened.

Quoted 6 lines
Quoted 4 lines

From an MFD perspective, reviews happened followed by an approval in v9.

I can't do anything without an Ack from you or some indication that you want me to apply the first 2 patches and share an IB.

Yes, please apply and share a branch like you usually do.

I usually encompass the other subsystem's patches in the IB too.

To enable me to do that, I need an Ack from you.

--
Lee Jones [李琼斯]

maintainer
#19 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

Quoted 11 lines · Lee Jones
Quoted 6 lines · Mark Brown
Quoted 2 lines · Lee Jones

I can't do anything without an Ack from you or some indication that you want me to apply the first 2 patches and share an IB.

Yes, please apply and share a branch like you usually do.

I usually encompass the other subsystem's patches in the IB too.

To enable me to do that, I need an Ack from you.

So not apply the first two patches and share a branch like you said above... TBH these serieses would probably be a bit more legible if the branch were created with just the MFD patches, that'd also mean smaller cross merges.

maintainer Reviewed-by on v10 3/3
#20 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

In reply to Andre Przywara
Quoted 5 lines · Andre Przywara

From: Martin Botka <[email protected]>

The AXP313a is your typical I2C controlled PMIC, although in a lighter fashion compared to the other X-Powers PMICs: it has only three DCDC rails, three LDOs, and no battery charging support.

#21 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

On Thu, 6 Apr 2023 14:49:44 +0100
Mark Brown <[email protected]> wrote:

Hi Mark, Lee,

Quoted 8 lines · Andre Przywara
Quoted 5 lines

From: Martin Botka <[email protected]>

The AXP313a is your typical I2C controlled PMIC, although in a lighter fashion compared to the other X-Powers PMICs: it has only three DCDC rails, three LDOs, and no battery charging support.

so is there anything Martin and I can do to help this move forward? I guess broonie's tag above means that the regulator part is good, so the MFC parts can go ahead now?

Cheers,
Andre

maintainer
#22 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

Quoted 12 lines · Andre Przywara

On Thu, 6 Apr 2023 14:49:44 +0100
Mark Brown <[email protected]> wrote:

Hi Mark, Lee,

Quoted 7 lines · Andre Przywara
Quoted 5 lines

From: Martin Botka <[email protected]>

The AXP313a is your typical I2C controlled PMIC, although in a lighter fashion compared to the other X-Powers PMICs: it has only three DCDC rails, three LDOs, and no battery charging support.

Quoted 5 lines
Quoted 1 line

so is there anything Martin and I can do to help this move forward? I guess broonie's tag above means that the regulator part is good, so the MFC parts can go ahead now?

It's on my list. Busy time. Please bear with.

Signature · 1 line
Lee Jones [李琼斯]
#23 lore raw

Re: [PATCH v10 3/3] regulator: axp20x: Add support for AXP313a variant

On Wed, 19 Apr 2023 16:49:24 +0100
Lee Jones <[email protected]> wrote:

Hi Lee,

Quoted 14 lines · Andre Przywara
Quoted 13 lines

On Thu, 6 Apr 2023 14:49:44 +0100
Mark Brown <[email protected]> wrote:

Hi Mark, Lee,

Quoted 7 lines · Andre Przywara
Quoted 5 lines

From: Martin Botka <[email protected]>

The AXP313a is your typical I2C controlled PMIC, although in a lighter fashion compared to the other X-Powers PMICs: it has only three DCDC rails, three LDOs, and no battery charging support.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

so is there anything Martin and I can do to help this move forward? I guess broonie's tag above means that the regulator part is good, so the MFC parts can go ahead now?

It's on my list. Busy time. Please bear with.

Thanks, and no worries, just wanted to avoid it falling through the cracks!

Cheers,
Andre

maintainer
#24 lore raw
In reply to Andre Przywara
Quoted 20 lines · Andre Przywara

This patch series adds support for the X-Powers AXP313a PMIC, which is often bundled with Allwinner H616 or H313 SoCs.
It's my turn again for this revision of the series, after Martin did v7 and v8.
After some more significant changes in v9, this is fixing some nits, and builds on Krzysztof's patch to simplify the DT binding document (patch ID at the end of this email). For a complete changelog see below.

Up to v5 this was speaking of the AXP1530, which seems to be some internal name. The chips we have seen in the wild are all labeled AXP313a, so we go with this name here, from now on. This is supported by the fact that there is an AXP313a datasheet, but none for the AXP1530.

Patch 1 is the binding documentation (just the new compatible string), patch 2 adds the MFD bits (mostly describing the extent of the regmap), while patch 3 describes the actual AXP313a register definitions. Since this ties neatly into the existing AXP and generic regulator framework, the patches are indeed only structure definitions, there is little new code.

Quoted 3 lines

For now we papered over this "fixed customizable" RTC-LDO regulator in the same way this was done before for other PMICs (AXP803, for instance), We think we can fix this properly with a follow-up patch, for all instances.

MFD patches applied. PR for Mark to follow.

Signature · 1 line
Lee Jones [李琼斯]