* [PATCH] power: reset: syscon-reboot: add a mask property
@ 2019-03-08 7:49 Martin Schiller
2019-03-27 23:53 ` Rob Herring
2019-04-05 15:18 ` Sebastian Reichel
0 siblings, 2 replies; 3+ messages in thread
From: Martin Schiller @ 2019-03-08 7:49 UTC (permalink / raw)
To: sre, robh+dt, mark.rutland, fkan
Cc: linux-pm, devicetree, linux-kernel, Martin Schiller
Make the syscon-reboot driver accept value and mask instead of
just value.
Prior to this patch, the property name for the value was 'mask'. If
only the mask property is defined on a node, maintain compatibility
by using it as the value.
This patch is based on commit
f2c199db477e ("power: reset: syscon-poweroff: add a mask property")
and does the same change for the syscon-reboot driver.
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
.../devicetree/bindings/power/reset/syscon-reboot.txt | 11 +++++++++--
drivers/power/reset/syscon-reboot.c | 19 +++++++++++++++++--
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt b/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt
index 11906316b43d..e23dea8344f8 100644
--- a/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt
+++ b/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt
@@ -3,13 +3,20 @@ Generic SYSCON mapped register reset driver
This is a generic reset driver using syscon to map the reset register.
The reset is generally performed with a write to the reset register
defined by the register map pointed by syscon reference plus the offset
-with the mask defined in the reboot node.
+with the value and mask defined in the reboot node.
Required properties:
- compatible: should contain "syscon-reboot"
- regmap: this is phandle to the register map node
- offset: offset in the register map for the reboot register (in bytes)
-- mask: the reset value written to the reboot register (32 bit access)
+- value: the reset value written to the reboot register (32 bit access)
+
+Optional properties:
+- mask: update only the register bits defined by the mask (32 bit)
+
+Legacy usage:
+If a node doesn't contain a value property but contains a mask property, the
+mask property is used as the value.
Default will be little endian mode, 32 bit access only.
diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c
index 7d0d269a0837..5a6bb638c331 100644
--- a/drivers/power/reset/syscon-reboot.c
+++ b/drivers/power/reset/syscon-reboot.c
@@ -27,6 +27,7 @@
struct syscon_reboot_context {
struct regmap *map;
u32 offset;
+ u32 value;
u32 mask;
struct notifier_block restart_handler;
};
@@ -39,7 +40,7 @@ static int syscon_restart_handle(struct notifier_block *this,
restart_handler);
/* Issue the reboot */
- regmap_write(ctx->map, ctx->offset, ctx->mask);
+ regmap_update_bits(ctx->map, ctx->offset, ctx->mask, ctx->value);
mdelay(1000);
@@ -51,6 +52,7 @@ static int syscon_reboot_probe(struct platform_device *pdev)
{
struct syscon_reboot_context *ctx;
struct device *dev = &pdev->dev;
+ int mask_err, value_err;
int err;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
@@ -64,8 +66,21 @@ static int syscon_reboot_probe(struct platform_device *pdev)
if (of_property_read_u32(pdev->dev.of_node, "offset", &ctx->offset))
return -EINVAL;
- if (of_property_read_u32(pdev->dev.of_node, "mask", &ctx->mask))
+ 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);
+ if (value_err && mask_err) {
+ dev_err(dev, "unable to read 'value' and 'mask'");
return -EINVAL;
+ }
+
+ if (value_err) {
+ /* support old binding */
+ ctx->value = ctx->mask;
+ ctx->mask = 0xFFFFFFFF;
+ } else if (mask_err) {
+ /* support value without mask*/
+ ctx->mask = 0xFFFFFFFF;
+ }
ctx->restart_handler.notifier_call = syscon_restart_handle;
ctx->restart_handler.priority = 192;
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] power: reset: syscon-reboot: add a mask property
2019-03-08 7:49 [PATCH] power: reset: syscon-reboot: add a mask property Martin Schiller
@ 2019-03-27 23:53 ` Rob Herring
2019-04-05 15:18 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2019-03-27 23:53 UTC (permalink / raw)
To: Martin Schiller
Cc: sre, mark.rutland, fkan, linux-pm, devicetree, linux-kernel
On Fri, Mar 08, 2019 at 08:49:30AM +0100, Martin Schiller wrote:
> Make the syscon-reboot driver accept value and mask instead of
> just value.
>
> Prior to this patch, the property name for the value was 'mask'. If
> only the mask property is defined on a node, maintain compatibility
> by using it as the value.
>
> This patch is based on commit
> f2c199db477e ("power: reset: syscon-poweroff: add a mask property")
> and does the same change for the syscon-reboot driver.
>
> Signed-off-by: Martin Schiller <ms@dev.tdt.de>
> ---
> .../devicetree/bindings/power/reset/syscon-reboot.txt | 11 +++++++++--
Acked-by: Rob Herring <robh@kernel.org>
> drivers/power/reset/syscon-reboot.c | 19 +++++++++++++++++--
> 2 files changed, 26 insertions(+), 4 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] power: reset: syscon-reboot: add a mask property
2019-03-08 7:49 [PATCH] power: reset: syscon-reboot: add a mask property Martin Schiller
2019-03-27 23:53 ` Rob Herring
@ 2019-04-05 15:18 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2019-04-05 15:18 UTC (permalink / raw)
To: Martin Schiller
Cc: robh+dt, mark.rutland, fkan, linux-pm, devicetree, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 4073 bytes --]
Hi,
On Fri, Mar 08, 2019 at 08:49:30AM +0100, Martin Schiller wrote:
> Make the syscon-reboot driver accept value and mask instead of
> just value.
>
> Prior to this patch, the property name for the value was 'mask'. If
> only the mask property is defined on a node, maintain compatibility
> by using it as the value.
>
> This patch is based on commit
> f2c199db477e ("power: reset: syscon-poweroff: add a mask property")
> and does the same change for the syscon-reboot driver.
>
> Signed-off-by: Martin Schiller <ms@dev.tdt.de>
> ---
thanks, queued.
-- Sebastian
> .../devicetree/bindings/power/reset/syscon-reboot.txt | 11 +++++++++--
> drivers/power/reset/syscon-reboot.c | 19 +++++++++++++++++--
> 2 files changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt b/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt
> index 11906316b43d..e23dea8344f8 100644
> --- a/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt
> +++ b/Documentation/devicetree/bindings/power/reset/syscon-reboot.txt
> @@ -3,13 +3,20 @@ Generic SYSCON mapped register reset driver
> This is a generic reset driver using syscon to map the reset register.
> The reset is generally performed with a write to the reset register
> defined by the register map pointed by syscon reference plus the offset
> -with the mask defined in the reboot node.
> +with the value and mask defined in the reboot node.
>
> Required properties:
> - compatible: should contain "syscon-reboot"
> - regmap: this is phandle to the register map node
> - offset: offset in the register map for the reboot register (in bytes)
> -- mask: the reset value written to the reboot register (32 bit access)
> +- value: the reset value written to the reboot register (32 bit access)
> +
> +Optional properties:
> +- mask: update only the register bits defined by the mask (32 bit)
> +
> +Legacy usage:
> +If a node doesn't contain a value property but contains a mask property, the
> +mask property is used as the value.
>
> Default will be little endian mode, 32 bit access only.
>
> diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c
> index 7d0d269a0837..5a6bb638c331 100644
> --- a/drivers/power/reset/syscon-reboot.c
> +++ b/drivers/power/reset/syscon-reboot.c
> @@ -27,6 +27,7 @@
> struct syscon_reboot_context {
> struct regmap *map;
> u32 offset;
> + u32 value;
> u32 mask;
> struct notifier_block restart_handler;
> };
> @@ -39,7 +40,7 @@ static int syscon_restart_handle(struct notifier_block *this,
> restart_handler);
>
> /* Issue the reboot */
> - regmap_write(ctx->map, ctx->offset, ctx->mask);
> + regmap_update_bits(ctx->map, ctx->offset, ctx->mask, ctx->value);
>
> mdelay(1000);
>
> @@ -51,6 +52,7 @@ static int syscon_reboot_probe(struct platform_device *pdev)
> {
> struct syscon_reboot_context *ctx;
> struct device *dev = &pdev->dev;
> + int mask_err, value_err;
> int err;
>
> ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
> @@ -64,8 +66,21 @@ static int syscon_reboot_probe(struct platform_device *pdev)
> if (of_property_read_u32(pdev->dev.of_node, "offset", &ctx->offset))
> return -EINVAL;
>
> - if (of_property_read_u32(pdev->dev.of_node, "mask", &ctx->mask))
> + 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);
> + if (value_err && mask_err) {
> + dev_err(dev, "unable to read 'value' and 'mask'");
> return -EINVAL;
> + }
> +
> + if (value_err) {
> + /* support old binding */
> + ctx->value = ctx->mask;
> + ctx->mask = 0xFFFFFFFF;
> + } else if (mask_err) {
> + /* support value without mask*/
> + ctx->mask = 0xFFFFFFFF;
> + }
>
> ctx->restart_handler.notifier_call = syscon_restart_handle;
> ctx->restart_handler.priority = 192;
> --
> 2.11.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-05 15:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-08 7:49 [PATCH] power: reset: syscon-reboot: add a mask property Martin Schiller
2019-03-27 23:53 ` Rob Herring
2019-04-05 15:18 ` Sebastian Reichel
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.