* [PATCH 0/2] support Linux reboot modes in syscon-reboot
@ 2025-02-26 14:08 André Draszik
2025-02-26 14:08 ` [PATCH 1/2] dt-bindings: reset: syscon-reboot: support reset modes André Draszik
2025-02-26 14:08 ` [PATCH 2/2] power: reset: syscon-reboot: support different " André Draszik
0 siblings, 2 replies; 6+ messages in thread
From: André Draszik @ 2025-02-26 14:08 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
linux-pm, devicetree, linux-kernel, André Draszik
This series teaches syscon-reboot some of Linux' different reboot
modes.
Linux supports a couple different reboot modes, but syscon-reboot
doesn't distinguish between them and issues the same syscon register
write irrespective of the reboot mode requested by the kernel.
This is a problem when platforms want to do a cold reboot most of the
time, which could e.g. wipe RAM etc, but also want to support rebooting
while keeping RAM contents in certain cases.
DTs can now specify the existing properties prefixed with one of the
Linux reboot modes. All the changes to support this are optional and
opt-in, platforms that don't, or don't specify a register/value/mask
pair for a specific mode will behave just as before.
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
André Draszik (2):
dt-bindings: reset: syscon-reboot: support reset modes
power: reset: syscon-reboot: support different reset modes
.../bindings/power/reset/syscon-reboot.yaml | 74 ++++++++++++++++++
drivers/power/reset/syscon-reboot.c | 88 +++++++++++++++++++---
2 files changed, 151 insertions(+), 11 deletions(-)
---
base-commit: 0226d0ce98a477937ed295fb7df4cc30b46fc304
change-id: 20250226-syscon-reboot-reset-mode-566588b847e1
Best regards,
--
André Draszik <andre.draszik@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] dt-bindings: reset: syscon-reboot: support reset modes
2025-02-26 14:08 [PATCH 0/2] support Linux reboot modes in syscon-reboot André Draszik
@ 2025-02-26 14:08 ` André Draszik
2025-02-26 15:29 ` Rob Herring (Arm)
2025-02-26 14:08 ` [PATCH 2/2] power: reset: syscon-reboot: support different " André Draszik
1 sibling, 1 reply; 6+ messages in thread
From: André Draszik @ 2025-02-26 14:08 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
linux-pm, devicetree, linux-kernel, André Draszik
Add support for specifying different register/mask/value combinations
for different types of reset.
In particular, update the binding to allow platforms to specify the
following reset modes: soft, warm, cold, hard.
Linux can perform different types of reset using its reboot= kernel
command line argument, and some platforms also wish to reset
differently based on whether or not e.g. contents of RAM should be
retained across the reboot.
The new properties match the existing properties, just prefixed with
one of the reset modes mentioned above.
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
.../bindings/power/reset/syscon-reboot.yaml | 74 ++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml b/Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml
index 19d3093e6cd2f7e39d94c56636dc202a4427ffc3..a34b1c08b7e0f34574a0257e13c02fceac0243ae 100644
--- a/Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml
+++ b/Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml
@@ -18,6 +18,11 @@ description: |+
parental dt-node. So the SYSCON reboot node should be represented as a
sub-node of a "syscon", "simple-mfd" node. Though the regmap property
pointing to the system controller node is also supported.
+ This also supports specification of separate sets of register/mask/value
+ pairs for different types of reset: cold, hard, soft and warm, using
+ the respective properties with the respective reset type prefix. If prefixed
+ properties are not specified for a reset type, the non-prefixed properties
+ will be used for that reset type.
properties:
compatible:
@@ -49,12 +54,41 @@ properties:
priority:
default: 192
+patternProperties:
+ "^(cold|hard|soft|warm)-(mask|offset|value)$":
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description:
+ Optional alternative offset / mask / value combinations for specific
+ reboot modes. The mask is optional.
+
+ "^(cold|hard|soft|warm)-reg$":
+ description:
+ Optional alternative base address and size for the reboot register for
+ specific reboot modes.
+
oneOf:
- required:
- offset
- required:
- reg
+dependencies:
+ cold-mask: [ cold-value ]
+ cold-offset: [ cold-value ]
+ cold-reg: [ cold-value ]
+
+ hard-mask: [ hard-value ]
+ hard-offset: [ hard-value ]
+ hard-reg: [ hard-value ]
+
+ soft-mask: [ soft-value ]
+ soft-offset: [ soft-value ]
+ soft-reg: [ soft-value ]
+
+ warm-mask: [ warm-value ]
+ warm-offset: [ warm-value ]
+ warm-reg: [ warm-value ]
+
required:
- compatible
@@ -70,6 +104,46 @@ allOf:
required:
- value
+ - if:
+ required:
+ - cold-value
+ then:
+ oneOf:
+ - required:
+ - cold-offset
+ - required:
+ - cold-reg
+
+ - if:
+ required:
+ - hard-value
+ then:
+ oneOf:
+ - required:
+ - hard-offset
+ - required:
+ - hard-reg
+
+ - if:
+ required:
+ - soft-value
+ then:
+ oneOf:
+ - required:
+ - soft-offset
+ - required:
+ - soft-reg
+
+ - if:
+ required:
+ - warm-value
+ then:
+ oneOf:
+ - required:
+ - warm-offset
+ - required:
+ - warm-reg
+
examples:
- |
reboot {
--
2.48.1.658.g4767266eb4-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] power: reset: syscon-reboot: support different reset modes
2025-02-26 14:08 [PATCH 0/2] support Linux reboot modes in syscon-reboot André Draszik
2025-02-26 14:08 ` [PATCH 1/2] dt-bindings: reset: syscon-reboot: support reset modes André Draszik
@ 2025-02-26 14:08 ` André Draszik
1 sibling, 0 replies; 6+ messages in thread
From: André Draszik @ 2025-02-26 14:08 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team,
linux-pm, devicetree, linux-kernel, André Draszik
Linux supports a couple different reset modes, but this driver here
doesn't distinguish between them and issues the same syscon register
write irrespective of the reset mode requested by the kernel.
Update this driver to support most of Linux' reset modes: cold, hard,
warm, and soft.
The actions to take for these are taken from DT, and are all new
optional properties. The property names match the existing properties
supported but should be prefixed with the reset mode.
This change is meant to be backwards compatible with existing DTs, and
if Linux requests a reset mode that this driver doesn't support, or
that the DT doesn't specify, the reset is triggered using the fallback
/ default entry.
As an example why this is useful, other than properly supporting the
Linux reboot= kernel command line option or sysfs entry, this change
allows platforms to e.g. default to a more secure cold-reset, but
also to do a warm-reset in case RAM contents needs to be retained
across the reset.
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
drivers/power/reset/syscon-reboot.c | 88 ++++++++++++++++++++++++++++++++-----
1 file changed, 77 insertions(+), 11 deletions(-)
diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c
index d623d77e657e4c233d8ae88bb099bee13c48a9ef..1d3d8a3265ae8005c685b42d3e554bd8bb0047ea 100644
--- a/drivers/power/reset/syscon-reboot.c
+++ b/drivers/power/reset/syscon-reboot.c
@@ -14,11 +14,29 @@
#include <linux/reboot.h>
#include <linux/regmap.h>
-struct syscon_reboot_context {
- struct regmap *map;
+/* REBOOT_GPIO doesn't make sense for syscon-reboot */
+static const struct {
+ enum reboot_mode mode;
+ const char *prefix;
+} prefix_map[] = {
+ { .mode = REBOOT_COLD, .prefix = "cold" },
+ { .mode = REBOOT_WARM, .prefix = "warm" },
+ { .mode = REBOOT_HARD, .prefix = "hard" },
+ { .mode = REBOOT_SOFT, .prefix = "soft" },
+};
+
+struct reboot_mode_bits {
u32 offset;
u32 value;
u32 mask;
+ bool valid;
+};
+
+struct syscon_reboot_context {
+ struct regmap *map;
+
+ struct reboot_mode_bits mode_bits[REBOOT_SOFT + 1];
+ struct reboot_mode_bits catchall;
struct notifier_block restart_handler;
};
@@ -28,9 +46,16 @@ static int syscon_restart_handle(struct notifier_block *this,
struct syscon_reboot_context *ctx =
container_of(this, struct syscon_reboot_context,
restart_handler);
+ const struct reboot_mode_bits *mode_bits;
+
+ if (mode < ARRAY_SIZE(ctx->mode_bits) && ctx->mode_bits[mode].valid)
+ mode_bits = &ctx->mode_bits[mode];
+ else
+ mode_bits = &ctx->catchall;
/* Issue the reboot */
- regmap_update_bits(ctx->map, ctx->offset, ctx->mask, ctx->value);
+ regmap_update_bits(ctx->map, mode_bits->offset, mode_bits->mask,
+ mode_bits->value);
mdelay(1000);
@@ -45,6 +70,7 @@ static int syscon_reboot_probe(struct platform_device *pdev)
int mask_err, value_err;
int priority;
int err;
+ char prop[32];
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
@@ -60,12 +86,52 @@ static int syscon_reboot_probe(struct platform_device *pdev)
if (of_property_read_s32(pdev->dev.of_node, "priority", &priority))
priority = 192;
- if (of_property_read_u32(pdev->dev.of_node, "offset", &ctx->offset))
- if (of_property_read_u32(pdev->dev.of_node, "reg", &ctx->offset))
+ BUILD_BUG_ON(ARRAY_SIZE(prefix_map) != ARRAY_SIZE(ctx->mode_bits));
+ BUILD_BUG_ON(ARRAY_SIZE(ctx->mode_bits) <= REBOOT_COLD);
+ BUILD_BUG_ON(ARRAY_SIZE(ctx->mode_bits) <= REBOOT_WARM);
+ BUILD_BUG_ON(ARRAY_SIZE(ctx->mode_bits) <= REBOOT_HARD);
+ BUILD_BUG_ON(ARRAY_SIZE(ctx->mode_bits) <= REBOOT_SOFT);
+
+ for (int i = 0; i < ARRAY_SIZE(prefix_map); ++i) {
+ const char * const prefix = prefix_map[i].prefix;
+ struct reboot_mode_bits * const mode_bits =
+ &ctx->mode_bits[prefix_map[i].mode];
+
+ snprintf(prop, sizeof(prop), "%s-offset", prefix);
+ if (of_property_read_u32(pdev->dev.of_node, "offset",
+ &mode_bits->offset))
+ continue;
+
+ snprintf(prop, sizeof(prop), "%s-value", prefix);
+ if (of_property_read_u32(pdev->dev.of_node, prop,
+ &mode_bits->value)) {
+ /* don't support old binding here */
+ dev_err(dev, "'%s-value' is mandatory\n", prefix);
+ continue;
+ }
+
+ snprintf(prop, sizeof(prop), "%s-mask", prefix);
+ mask_err = of_property_read_u32(pdev->dev.of_node, prop,
+ &mode_bits->mask);
+
+ if (mask_err)
+ /* support value without mask*/
+ mode_bits->mask = 0xffffffff;
+
+ mode_bits->valid = true;
+ }
+
+ /* catch-all entry */
+ if (of_property_read_u32(pdev->dev.of_node, "offset",
+ &ctx->catchall.offset))
+ if (of_property_read_u32(pdev->dev.of_node, "reg",
+ &ctx->catchall.offset))
return -EINVAL;
- value_err = of_property_read_u32(pdev->dev.of_node, "value", &ctx->value);
- mask_err = of_property_read_u32(pdev->dev.of_node, "mask", &ctx->mask);
+ value_err = of_property_read_u32(pdev->dev.of_node, "value",
+ &ctx->catchall.value);
+ mask_err = of_property_read_u32(pdev->dev.of_node, "mask",
+ &ctx->catchall.mask);
if (value_err && mask_err) {
dev_err(dev, "unable to read 'value' and 'mask'");
return -EINVAL;
@@ -73,11 +139,11 @@ static int syscon_reboot_probe(struct platform_device *pdev)
if (value_err) {
/* support old binding */
- ctx->value = ctx->mask;
- ctx->mask = 0xFFFFFFFF;
+ ctx->catchall.value = ctx->catchall.mask;
+ ctx->catchall.mask = 0xFFFFFFFF;
} else if (mask_err) {
- /* support value without mask*/
- ctx->mask = 0xFFFFFFFF;
+ /* support value without mask */
+ ctx->catchall.mask = 0xFFFFFFFF;
}
ctx->restart_handler.notifier_call = syscon_restart_handle;
--
2.48.1.658.g4767266eb4-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: reset: syscon-reboot: support reset modes
2025-02-26 14:08 ` [PATCH 1/2] dt-bindings: reset: syscon-reboot: support reset modes André Draszik
@ 2025-02-26 15:29 ` Rob Herring (Arm)
2025-02-26 15:42 ` André Draszik
0 siblings, 1 reply; 6+ messages in thread
From: Rob Herring (Arm) @ 2025-02-26 15:29 UTC (permalink / raw)
To: André Draszik
Cc: Tudor Ambarus, devicetree, linux-pm, Peter Griffin, Conor Dooley,
Will McVicker, linux-kernel, kernel-team, Krzysztof Kozlowski,
Sebastian Reichel
On Wed, 26 Feb 2025 14:08:20 +0000, André Draszik wrote:
> Add support for specifying different register/mask/value combinations
> for different types of reset.
>
> In particular, update the binding to allow platforms to specify the
> following reset modes: soft, warm, cold, hard.
>
> Linux can perform different types of reset using its reboot= kernel
> command line argument, and some platforms also wish to reset
> differently based on whether or not e.g. contents of RAM should be
> retained across the reboot.
>
> The new properties match the existing properties, just prefixed with
> one of the reset modes mentioned above.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
> .../bindings/power/reset/syscon-reboot.yaml | 74 ++++++++++++++++++++++
> 1 file changed, 74 insertions(+)
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
./Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml:113:11: [warning] wrong indentation: expected 12 but found 10 (indentation)
./Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml:115:11: [warning] wrong indentation: expected 12 but found 10 (indentation)
./Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml:123:11: [warning] wrong indentation: expected 12 but found 10 (indentation)
./Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml:125:11: [warning] wrong indentation: expected 12 but found 10 (indentation)
./Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml:133:11: [warning] wrong indentation: expected 12 but found 10 (indentation)
./Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml:135:11: [warning] wrong indentation: expected 12 but found 10 (indentation)
./Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml:143:11: [warning] wrong indentation: expected 12 but found 10 (indentation)
./Documentation/devicetree/bindings/power/reset/syscon-reboot.yaml:145:11: [warning] wrong indentation: expected 12 but found 10 (indentation)
dtschema/dtc warnings/errors:
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250226-syscon-reboot-reset-mode-v1-1-91c1b62166ae@linaro.org
The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: reset: syscon-reboot: support reset modes
2025-02-26 15:29 ` Rob Herring (Arm)
@ 2025-02-26 15:42 ` André Draszik
2025-02-26 16:20 ` André Draszik
0 siblings, 1 reply; 6+ messages in thread
From: André Draszik @ 2025-02-26 15:42 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Tudor Ambarus, devicetree, linux-pm, Peter Griffin, Conor Dooley,
Will McVicker, linux-kernel, kernel-team, Krzysztof Kozlowski,
Sebastian Reichel
On Wed, 2025-02-26 at 09:29 -0600, Rob Herring (Arm) wrote:
>
> On Wed, 26 Feb 2025 14:08:20 +0000, André Draszik wrote:
> > Add support for specifying different register/mask/value combinations
> > for different types of reset.
> >
> > In particular, update the binding to allow platforms to specify the
> > following reset modes: soft, warm, cold, hard.
> >
> > Linux can perform different types of reset using its reboot= kernel
> > command line argument, and some platforms also wish to reset
> > differently based on whether or not e.g. contents of RAM should be
> > retained across the reboot.
> >
> > The new properties match the existing properties, just prefixed with
> > one of the reset modes mentioned above.
> >
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> > .../bindings/power/reset/syscon-reboot.yaml | 74 ++++++++++++++++++++++
> > 1 file changed, 74 insertions(+)
> >
>
> My bot found errors running 'make dt_binding_check' on your patch:
oops, sorry - the script we usually run didn't cover this binding,
I've updated things and will send a v2.
Cheers,
Andre'
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: reset: syscon-reboot: support reset modes
2025-02-26 15:42 ` André Draszik
@ 2025-02-26 16:20 ` André Draszik
0 siblings, 0 replies; 6+ messages in thread
From: André Draszik @ 2025-02-26 16:20 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Tudor Ambarus, devicetree, linux-pm, Peter Griffin, Conor Dooley,
Will McVicker, linux-kernel, kernel-team, Krzysztof Kozlowski,
Sebastian Reichel
On Wed, 2025-02-26 at 15:42 +0000, André Draszik wrote:
> On Wed, 2025-02-26 at 09:29 -0600, Rob Herring (Arm) wrote:
> >
> > On Wed, 26 Feb 2025 14:08:20 +0000, André Draszik wrote:
> > > Add support for specifying different register/mask/value combinations
> > > for different types of reset.
> > >
> > > In particular, update the binding to allow platforms to specify the
> > > following reset modes: soft, warm, cold, hard.
> > >
> > > Linux can perform different types of reset using its reboot= kernel
> > > command line argument, and some platforms also wish to reset
> > > differently based on whether or not e.g. contents of RAM should be
> > > retained across the reboot.
> > >
> > > The new properties match the existing properties, just prefixed with
> > > one of the reset modes mentioned above.
> > >
> > > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > > ---
> > > .../bindings/power/reset/syscon-reboot.yaml | 74 ++++++++++++++++++++++
> > > 1 file changed, 74 insertions(+)
> > >
> >
> > My bot found errors running 'make dt_binding_check' on your patch:
>
> oops, sorry - the script we usually run didn't cover this binding,
BTW, we did that, because it's easy to miss warnings due to
the amount of bindings and text scrolling past. Ideally make
would exit with != 0 in case of binding errors.
I can see in commit 3e95dfb315de ("dt-bindings: Don't error
out on yamllint and dt-doc-validate errors"), warnings are
never treated as errors.
Is that still relevant, can that commit be revert? Don't we
want the build to fail loudly on binding errors, so that people
don't even submit erroneous bindings in the first place?
Cheers,
Andre'
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-26 16:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-26 14:08 [PATCH 0/2] support Linux reboot modes in syscon-reboot André Draszik
2025-02-26 14:08 ` [PATCH 1/2] dt-bindings: reset: syscon-reboot: support reset modes André Draszik
2025-02-26 15:29 ` Rob Herring (Arm)
2025-02-26 15:42 ` André Draszik
2025-02-26 16:20 ` André Draszik
2025-02-26 14:08 ` [PATCH 2/2] power: reset: syscon-reboot: support different " André Draszik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®