Devicetree
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Allow caching of buck registers when no GPIO input control is configured
@ 2026-03-20  7:33 André Svensson
  2026-03-20  7:33 ` [PATCH v2 1/2] regulator: dt-bindings: dlg,da9121: Add dlg,no-gpio-control André Svensson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: André Svensson @ 2026-03-20  7:33 UTC (permalink / raw)
  To: Support Opensource, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Adam Ward
  Cc: linux-kernel, devicetree, kernel, Waqar Hameed,
	André Svensson

This series introduces a boolean DT property, dlg,no-gpio-control, for
the DA91xx regulators. Use this property to indicate that GPIO control
is not configured with the functions DVC/RELOAD/EN, allowing buck
registers to be cached.

The DA9121 driver checks dlg,no-gpio-control and updates regmap_config's
volatile_table if the property is present. Buck registers are removed
from the volatile_table if the property is present, enabling caching of
the registers, which removes I2C reads when performing an I2C write to
the buck registers.

---
Changes in v2:
- Update commit messages to clarify why dlg,no-gpio-control is needed.
- Add error check for mutually exclusive properties.
- Link to v1: https://lore.kernel.org/r/20260309-no-gpio-control-v1-0-06d2365917c6@axis.com

---
André Svensson (2):
      regulator: dt-bindings: dlg,da9121: Add dlg,no-gpio-control
      regulator: da9121: Allow caching BUCK registers

 .../devicetree/bindings/regulator/dlg,da9121.yaml  | 49 ++++++++++++++++++++++
 drivers/regulator/da9121-regulator.c               | 43 +++++++++++++++----
 2 files changed, 85 insertions(+), 7 deletions(-)
---
base-commit: 05f7e89ab9731565d8a62e3b5d1ec206485eeb0b
change-id: 20260309-no-gpio-control-9cc02b1e8994

Best regards,
-- 
André Svensson <andre.svensson@axis.com>


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

* [PATCH v2 1/2] regulator: dt-bindings: dlg,da9121: Add dlg,no-gpio-control
  2026-03-20  7:33 [PATCH v2 0/2] Allow caching of buck registers when no GPIO input control is configured André Svensson
@ 2026-03-20  7:33 ` André Svensson
  2026-03-20 17:57   ` Conor Dooley
  2026-03-20  7:33 ` [PATCH v2 2/2] regulator: da9121: Allow caching BUCK registers André Svensson
  2026-03-24 19:40 ` [PATCH v2 0/2] Allow caching of buck registers when no GPIO input control is configured Mark Brown
  2 siblings, 1 reply; 5+ messages in thread
From: André Svensson @ 2026-03-20  7:33 UTC (permalink / raw)
  To: Support Opensource, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Adam Ward
  Cc: linux-kernel, devicetree, kernel, Waqar Hameed,
	André Svensson

Add the optional boolean property dlg,no-gpio-control. When present, it
indicates that no DA91xx GPIO pins are configured/used with functions
RELOAD/DVC/EN, which can affect the output voltage control, regulator
mode control and enable signal control.

The absence of relevant GPIO DT properties does not imply that the
RELOAD/DVC/EN GPIO functions are unused. These functions are provided by
DA91xx GPIO pins and may be controlled by external hardware without
corresponding GPIO DT properties. The dlg,no-gpio-control property
explicitly indicates that none of these GPIO functions are used.

It is mutually exclusive with enable-gpios, regardless of whether the
referenced GPIO is connected to a GPIO pin or the IC_EN pin, since
enable-gpios allows the regulator to be controlled via an external
hardware signal.

Co-developed-by: Waqar Hameed <waqar.hameed@axis.com>
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Signed-off-by: André Svensson <andre.svensson@axis.com>
---
 .../devicetree/bindings/regulator/dlg,da9121.yaml  | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml b/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
index 13b3f75f8e5e..ce76eb5b85bd 100644
--- a/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
+++ b/Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
@@ -81,6 +81,14 @@ properties:
       Specify the polling period, measured in milliseconds, between interrupt status
       update checks. Range 1000-10000 ms.
 
+  dlg,no-gpio-control:
+    type: boolean
+    description: |
+      Available GPIO input pins of the regulator are strapped to fixed levels, therefore
+      GPIO configurable input functions, DVC/RELOAD/EN, cannot dynamically update BUCK
+      registers. GPIO pins connected as output pins are not required to be strapped to a
+      fixed level. Not allowed together with enable-gpios.
+
   regulators:
     type: object
     additionalProperties: false
@@ -134,6 +142,17 @@ allOf:
           properties:
             buck2: false
 
+  - if:
+      required:
+        - dlg,no-gpio-control
+    then:
+      properties:
+        regulators:
+          patternProperties:
+            "^buck([1-2])$":
+              properties:
+                enable-gpios: false
+
 additionalProperties: false
 
 examples:
@@ -168,6 +187,36 @@ examples:
       };
     };
 
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/regulator/dlg,da9121-regulator.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      pmic@68 {
+        compatible = "dlg,da9121";
+        reg = <0x68>;
+
+        interrupt-parent = <&gpio6>;
+        interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+
+        dlg,irq-polling-delay-passive-ms = <2000>;
+        dlg,no-gpio-control;
+
+        regulators {
+          DA9121_BUCK: buck1 {
+            regulator-name = "BUCK1";
+            regulator-min-microvolt = <300000>;
+            regulator-max-microvolt = <1900000>;
+            regulator-min-microamp = <7000000>;
+            regulator-max-microamp = <20000000>;
+            regulator-boot-on;
+            regulator-initial-mode = <DA9121_BUCK_MODE_AUTO>;
+          };
+        };
+      };
+    };
+
   - |
     #include <dt-bindings/gpio/gpio.h>
     #include <dt-bindings/interrupt-controller/irq.h>

-- 
2.43.0


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

* [PATCH v2 2/2] regulator: da9121: Allow caching BUCK registers
  2026-03-20  7:33 [PATCH v2 0/2] Allow caching of buck registers when no GPIO input control is configured André Svensson
  2026-03-20  7:33 ` [PATCH v2 1/2] regulator: dt-bindings: dlg,da9121: Add dlg,no-gpio-control André Svensson
@ 2026-03-20  7:33 ` André Svensson
  2026-03-24 19:40 ` [PATCH v2 0/2] Allow caching of buck registers when no GPIO input control is configured Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: André Svensson @ 2026-03-20  7:33 UTC (permalink / raw)
  To: Support Opensource, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Adam Ward
  Cc: linux-kernel, devicetree, kernel, Waqar Hameed,
	André Svensson

Some BUCK registers may change without software writes when GPIO pins
are configured for functions DVC/RELOAD/EN. If the board does
not use these pin-controlled features, caching is possible.

Caching BUCK registers removes unnecessary I2C reads when performing
register updates. For example, updating regulator mode can result in
two I2C reads, one from the regulator core regulator_set_mode() and one
from the DA9121 driver, where da9121_buck_set_mode() uses
regmap_update_bits() (read/modify/write).

Check for the optional DT property dlg,no-gpio-control. When present,
select the regmap configuration that does not mark the BUCK1 register
block (DA9121_REG_BUCK_BUCK1_0..DA9121_REG_BUCK_BUCK1_6) as volatile, so
that regmap can cache BUCK1 registers and avoid unnecessary I2C reads.
The property dlg,no-gpio-control is required to ensure that BUCK1
registers can be cached, as the absence of relevant GPIO DT properties
does not imply that the RELOAD/DVC/EN GPIO functions are unused. These
functions are provided by DA91xx GPIO pins and may be controlled by
external hardware without corresponding GPIO DT properties. The
dlg,no-gpio-control property explicitly indicates that none of these
GPIO functions are used.

The dlg,no-gpio-control property is mutually exclusive with
enable-gpios, regardless of whether the referenced GPIO is connected to
a GPIO pin or the IC_EN pin, since pulling IC_EN low powers down the
regulator and registers are reinitialized at startup, leaving cached
values stale.

Co-developed-by: Waqar Hameed <waqar.hameed@axis.com>
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Signed-off-by: André Svensson <andre.svensson@axis.com>
---
 drivers/regulator/da9121-regulator.c | 43 ++++++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 7 deletions(-)

diff --git a/drivers/regulator/da9121-regulator.c b/drivers/regulator/da9121-regulator.c
index ef161eb0ca27..2b150bb4d471 100644
--- a/drivers/regulator/da9121-regulator.c
+++ b/drivers/regulator/da9121-regulator.c
@@ -400,8 +400,14 @@ static int da9121_of_parse_cb(struct device_node *np,
 						GPIOD_OUT_HIGH |
 						GPIOD_FLAGS_BIT_NONEXCLUSIVE,
 						"da9121-enable");
-	if (!IS_ERR(ena_gpiod))
+	if (!IS_ERR(ena_gpiod)) {
+		if (of_property_read_bool(chip->dev->of_node, "dlg,no-gpio-control")) {
+			gpiod_put(ena_gpiod);
+			dev_err(chip->dev, "dlg,no-gpio-control conflicts with enable-gpios\n");
+			return -EINVAL;
+		}
 		config->ena_gpiod = ena_gpiod;
+	}
 
 	if (variant_parameters[chip->variant_id].num_bucks == 2) {
 		uint32_t ripple_cancel;
@@ -864,6 +870,21 @@ static const struct regmap_access_table da9121_volatile_table = {
 	.n_yes_ranges = ARRAY_SIZE(da9121_volatile_ranges),
 };
 
+/*
+ * When GPIO functions DVC/RELOAD/EN are not used, the registers in the range
+ * DA9121_REG_BUCK_BUCK1_0 to DA9121_REG_BUCK_BUCK1_6 need not be volatile
+ * because register writes to these registers can only be performed via I2C.
+ */
+static const struct regmap_range da9121_volatile_ranges_no_gpio_ctrl[] = {
+	regmap_reg_range(DA9121_REG_SYS_STATUS_0, DA9121_REG_SYS_EVENT_2),
+	regmap_reg_range(DA9121_REG_SYS_GPIO0_0, DA9121_REG_SYS_GPIO2_1),
+};
+
+static const struct regmap_access_table da9121_volatile_table_no_gpio_ctrl = {
+	.yes_ranges = da9121_volatile_ranges_no_gpio_ctrl,
+	.n_yes_ranges = ARRAY_SIZE(da9121_volatile_ranges_no_gpio_ctrl),
+};
+
 /* DA9121 regmap config for 1 channel variants */
 static const struct regmap_config da9121_1ch_regmap_config = {
 	.reg_bits = 8,
@@ -994,10 +1015,18 @@ static int da9121_assign_chip_model(struct i2c_client *i2c,
 			struct da9121 *chip)
 {
 	const struct regmap_config *regmap;
+	struct regmap_config regmap_config_1ch = da9121_1ch_regmap_config;
+	struct regmap_config regmap_config_2ch = da9121_2ch_regmap_config;
+
 	int ret = 0;
 
 	chip->dev = &i2c->dev;
 
+	if (of_property_read_bool(i2c->dev.of_node, "dlg,no-gpio-control")) {
+		regmap_config_1ch.volatile_table = &da9121_volatile_table_no_gpio_ctrl;
+		regmap_config_2ch.volatile_table = &da9121_volatile_table_no_gpio_ctrl;
+	}
+
 	/* Use configured subtype to select the regulator descriptor index and
 	 * register map, common to both consumer and automotive grade variants
 	 */
@@ -1005,29 +1034,29 @@ static int da9121_assign_chip_model(struct i2c_client *i2c,
 	case DA9121_SUBTYPE_DA9121:
 	case DA9121_SUBTYPE_DA9130:
 		chip->variant_id = DA9121_TYPE_DA9121_DA9130;
-		regmap = &da9121_1ch_regmap_config;
+		regmap = &regmap_config_1ch;
 		break;
 	case DA9121_SUBTYPE_DA9217:
 		chip->variant_id = DA9121_TYPE_DA9217;
-		regmap = &da9121_1ch_regmap_config;
+		regmap = &regmap_config_1ch;
 		break;
 	case DA9121_SUBTYPE_DA9122:
 	case DA9121_SUBTYPE_DA9131:
 		chip->variant_id = DA9121_TYPE_DA9122_DA9131;
-		regmap = &da9121_2ch_regmap_config;
+		regmap = &regmap_config_2ch;
 		break;
 	case DA9121_SUBTYPE_DA9220:
 	case DA9121_SUBTYPE_DA9132:
 		chip->variant_id = DA9121_TYPE_DA9220_DA9132;
-		regmap = &da9121_2ch_regmap_config;
+		regmap = &regmap_config_2ch;
 		break;
 	case DA9121_SUBTYPE_DA9141:
 		chip->variant_id = DA9121_TYPE_DA9141;
-		regmap = &da9121_1ch_regmap_config;
+		regmap = &regmap_config_1ch;
 		break;
 	case DA9121_SUBTYPE_DA9142:
 		chip->variant_id = DA9121_TYPE_DA9142;
-		regmap = &da9121_2ch_regmap_config;
+		regmap = &regmap_config_2ch;
 		break;
 	default:
 		return -EINVAL;

-- 
2.43.0


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

* Re: [PATCH v2 1/2] regulator: dt-bindings: dlg,da9121: Add dlg,no-gpio-control
  2026-03-20  7:33 ` [PATCH v2 1/2] regulator: dt-bindings: dlg,da9121: Add dlg,no-gpio-control André Svensson
@ 2026-03-20 17:57   ` Conor Dooley
  0 siblings, 0 replies; 5+ messages in thread
From: Conor Dooley @ 2026-03-20 17:57 UTC (permalink / raw)
  To: André Svensson
  Cc: Support Opensource, Liam Girdwood, Mark Brown, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Adam Ward, linux-kernel,
	devicetree, kernel, Waqar Hameed

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

On Fri, Mar 20, 2026 at 08:33:24AM +0100, André Svensson wrote:
> Add the optional boolean property dlg,no-gpio-control. When present, it
> indicates that no DA91xx GPIO pins are configured/used with functions
> RELOAD/DVC/EN, which can affect the output voltage control, regulator
> mode control and enable signal control.
> 
> The absence of relevant GPIO DT properties does not imply that the
> RELOAD/DVC/EN GPIO functions are unused. These functions are provided by
> DA91xx GPIO pins and may be controlled by external hardware without
> corresponding GPIO DT properties. The dlg,no-gpio-control property
> explicitly indicates that none of these GPIO functions are used.
> 
> It is mutually exclusive with enable-gpios, regardless of whether the
> referenced GPIO is connected to a GPIO pin or the IC_EN pin, since
> enable-gpios allows the regulator to be controlled via an external
> hardware signal.
> 
> Co-developed-by: Waqar Hameed <waqar.hameed@axis.com>
> Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
> Signed-off-by: André Svensson <andre.svensson@axis.com>

Acked-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable

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

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

* Re: [PATCH v2 0/2] Allow caching of buck registers when no GPIO input control is configured
  2026-03-20  7:33 [PATCH v2 0/2] Allow caching of buck registers when no GPIO input control is configured André Svensson
  2026-03-20  7:33 ` [PATCH v2 1/2] regulator: dt-bindings: dlg,da9121: Add dlg,no-gpio-control André Svensson
  2026-03-20  7:33 ` [PATCH v2 2/2] regulator: da9121: Allow caching BUCK registers André Svensson
@ 2026-03-24 19:40 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-03-24 19:40 UTC (permalink / raw)
  To: Support Opensource, Liam Girdwood, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Adam Ward, André Svensson
  Cc: linux-kernel, devicetree, kernel, Waqar Hameed

On Fri, 20 Mar 2026 08:33:23 +0100, André Svensson wrote:
> Allow caching of buck registers when no GPIO input control is configured
> 
> This series introduces a boolean DT property, dlg,no-gpio-control, for
> the DA91xx regulators. Use this property to indicate that GPIO control
> is not configured with the functions DVC/RELOAD/EN, allowing buck
> registers to be cached.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-7.1

Thanks!

[1/2] regulator: dt-bindings: dlg,da9121: Add dlg,no-gpio-control
      https://git.kernel.org/broonie/regulator/c/7795014962fa
[2/2] regulator: da9121: Allow caching BUCK registers
      https://git.kernel.org/broonie/regulator/c/6c2505e185b0

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


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

end of thread, other threads:[~2026-03-24 19:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20  7:33 [PATCH v2 0/2] Allow caching of buck registers when no GPIO input control is configured André Svensson
2026-03-20  7:33 ` [PATCH v2 1/2] regulator: dt-bindings: dlg,da9121: Add dlg,no-gpio-control André Svensson
2026-03-20 17:57   ` Conor Dooley
2026-03-20  7:33 ` [PATCH v2 2/2] regulator: da9121: Allow caching BUCK registers André Svensson
2026-03-24 19:40 ` [PATCH v2 0/2] Allow caching of buck registers when no GPIO input control is configured Mark Brown

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