Skip to content

Commit f2c199d

Browse files
Guy Shapirosre
authored andcommitted
power: reset: syscon-poweroff: add a mask property
Make the syscon-poweroff 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. Signed-off-by: Guy Shapiro <guy.shapiro@mobi-wize.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
1 parent f385e6e commit f2c199d

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

Documentation/devicetree/bindings/power/reset/syscon-poweroff.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@ Generic SYSCON mapped register poweroff driver
33
This is a generic poweroff driver using syscon to map the poweroff register.
44
The poweroff is generally performed with a write to the poweroff register
55
defined by the register map pointed by syscon reference plus the offset
6-
with the mask defined in the poweroff node.
6+
with the value and mask defined in the poweroff node.
77

88
Required properties:
99
- compatible: should contain "syscon-poweroff"
1010
- regmap: this is phandle to the register map node
1111
- offset: offset in the register map for the poweroff register (in bytes)
12-
- mask: the poweroff value written to the poweroff register (32 bit access)
12+
- value: the poweroff value written to the poweroff register (32 bit access)
13+
14+
Optional properties:
15+
- mask: update only the register bits defined by the mask (32 bit)
16+
17+
Legacy usage:
18+
If a node doesn't contain a value property but contains a mask property, the
19+
mask property is used as the value.
1320

1421
Default will be little endian mode, 32 bit access only.
1522

drivers/power/reset/syscon-poweroff.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828

2929
static struct regmap *map;
3030
static u32 offset;
31+
static u32 value;
3132
static u32 mask;
3233

3334
static void syscon_poweroff(void)
3435
{
3536
/* Issue the poweroff */
36-
regmap_write(map, offset, mask);
37+
regmap_update_bits(map, offset, mask, value);
3738

3839
mdelay(1000);
3940

@@ -43,6 +44,7 @@ static void syscon_poweroff(void)
4344
static int syscon_poweroff_probe(struct platform_device *pdev)
4445
{
4546
char symname[KSYM_NAME_LEN];
47+
int mask_err, value_err;
4648

4749
map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "regmap");
4850
if (IS_ERR(map)) {
@@ -55,11 +57,22 @@ static int syscon_poweroff_probe(struct platform_device *pdev)
5557
return -EINVAL;
5658
}
5759

58-
if (of_property_read_u32(pdev->dev.of_node, "mask", &mask)) {
59-
dev_err(&pdev->dev, "unable to read 'mask'");
60+
value_err = of_property_read_u32(pdev->dev.of_node, "value", &value);
61+
mask_err = of_property_read_u32(pdev->dev.of_node, "mask", &mask);
62+
if (value_err && mask_err) {
63+
dev_err(&pdev->dev, "unable to read 'value' and 'mask'");
6064
return -EINVAL;
6165
}
6266

67+
if (value_err) {
68+
/* support old binding */
69+
value = mask;
70+
mask = 0xFFFFFFFF;
71+
} else if (mask_err) {
72+
/* support value without mask*/
73+
mask = 0xFFFFFFFF;
74+
}
75+
6376
if (pm_power_off) {
6477
lookup_symbol_name((ulong)pm_power_off, symname);
6578
dev_err(&pdev->dev,

0 commit comments

Comments
 (0)