* [PATCH v2 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout_ms' property
@ 2018-02-19 22:59 Moritz Fischer
2018-02-19 22:59 ` [PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT Moritz Fischer
2018-02-20 14:18 ` [PATCH v2 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout_ms' property Rob Herring
0 siblings, 2 replies; 5+ messages in thread
From: Moritz Fischer @ 2018-02-19 22:59 UTC (permalink / raw)
To: linux-kernel; +Cc: devicetree, linux-pm, sre, Moritz Fischer
Add 'timeout_ms' property to support boards where the 3s timeout that the
current driver defaults to is too short.
Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
Changes from v1:
- Addressed Rob's feedback (timeout -> timeout_ms)
- Added to old example rather than creating separate one
---
Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
index e62d53d844cc..3f557b344dc4 100644
--- a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
+++ b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
@@ -27,10 +27,13 @@ Optional properties:
it to an output when the power-off handler is called. If this optional
property is not specified, the GPIO is initialized as an output in its
inactive state.
+- timeout_ms: Time to wait before asserting a WARN_ON(1). If nothing is
+ specified, 3000 ms is used.
Examples:
gpio-poweroff {
compatible = "gpio-poweroff";
gpios = <&gpio 4 0>;
+ timeout_ms = <3000>;
};
--
2.16.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT
2018-02-19 22:59 [PATCH v2 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout_ms' property Moritz Fischer
@ 2018-02-19 22:59 ` Moritz Fischer
2018-02-20 14:12 ` Andy Shevchenko
2018-02-20 14:18 ` [PATCH v2 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout_ms' property Rob Herring
1 sibling, 1 reply; 5+ messages in thread
From: Moritz Fischer @ 2018-02-19 22:59 UTC (permalink / raw)
To: linux-kernel; +Cc: devicetree, linux-pm, sre, Moritz Fischer
Add support for reading a timeout value from devicetree.
Fall back to previous default of 3s if nothing is specified.
Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
Changes from v1:
- of_property_read_u32() overwrites the output only if it succeeds,
simplify error handling
---
drivers/power/reset/gpio-poweroff.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
index be3d81ff51cc..265cc37646a9 100644
--- a/drivers/power/reset/gpio-poweroff.c
+++ b/drivers/power/reset/gpio-poweroff.c
@@ -19,11 +19,13 @@
#include <linux/of_platform.h>
#include <linux/module.h>
+#define DEFAULT_TIMEOUT_MS 3000
/*
* Hold configuration here, cannot be more than one instance of the driver
* since pm_power_off itself is global.
*/
static struct gpio_desc *reset_gpio;
+static u32 timeout = DEFAULT_TIMEOUT_MS;
static void gpio_poweroff_do_poweroff(void)
{
@@ -40,7 +42,7 @@ static void gpio_poweroff_do_poweroff(void)
gpiod_set_value(reset_gpio, 1);
/* give it some time */
- mdelay(3000);
+ mdelay(timeout);
WARN_ON(1);
}
@@ -64,6 +66,8 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
else
flags = GPIOD_OUT_LOW;
+ of_property_read_u32(pdev->dev.of_node, "timeout_ms", &timeout);
+
reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags);
if (IS_ERR(reset_gpio))
return PTR_ERR(reset_gpio);
--
2.16.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT
2018-02-19 22:59 ` [PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT Moritz Fischer
@ 2018-02-20 14:12 ` Andy Shevchenko
2018-02-20 16:41 ` Moritz Fischer
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2018-02-20 14:12 UTC (permalink / raw)
To: Moritz Fischer
Cc: Linux Kernel Mailing List, devicetree, Linux PM, Sebastian Reichel
On Tue, Feb 20, 2018 at 12:59 AM, Moritz Fischer <mdf@kernel.org> wrote:
> Add support for reading a timeout value from devicetree.
> Fall back to previous default of 3s if nothing is specified.
> + of_property_read_u32(pdev->dev.of_node, "timeout_ms", &timeout);
Perhaps stop being OF-centric by using device_property_read_u32() instead?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout_ms' property
2018-02-19 22:59 [PATCH v2 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout_ms' property Moritz Fischer
2018-02-19 22:59 ` [PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT Moritz Fischer
@ 2018-02-20 14:18 ` Rob Herring
1 sibling, 0 replies; 5+ messages in thread
From: Rob Herring @ 2018-02-20 14:18 UTC (permalink / raw)
To: Moritz Fischer; +Cc: linux-kernel, devicetree, linux-pm, Sebastian Reichel
On Mon, Feb 19, 2018 at 4:59 PM, Moritz Fischer <mdf@kernel.org> wrote:
> Add 'timeout_ms' property to support boards where the 3s timeout that the
> current driver defaults to is too short.
>
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>
> Changes from v1:
> - Addressed Rob's feedback (timeout -> timeout_ms)
> - Added to old example rather than creating separate one
>
> ---
> Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
> index e62d53d844cc..3f557b344dc4 100644
> --- a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
> +++ b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
> @@ -27,10 +27,13 @@ Optional properties:
> it to an output when the power-off handler is called. If this optional
> property is not specified, the GPIO is initialized as an output in its
> inactive state.
> +- timeout_ms: Time to wait before asserting a WARN_ON(1). If nothing is
> + specified, 3000 ms is used.
timeout-ms
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT
2018-02-20 14:12 ` Andy Shevchenko
@ 2018-02-20 16:41 ` Moritz Fischer
0 siblings, 0 replies; 5+ messages in thread
From: Moritz Fischer @ 2018-02-20 16:41 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Moritz Fischer, Linux Kernel Mailing List, devicetree, Linux PM,
Sebastian Reichel
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
On Tue, Feb 20, 2018 at 04:12:59PM +0200, Andy Shevchenko wrote:
> On Tue, Feb 20, 2018 at 12:59 AM, Moritz Fischer <mdf@kernel.org> wrote:
> > Add support for reading a timeout value from devicetree.
> > Fall back to previous default of 3s if nothing is specified.
>
>
> > + of_property_read_u32(pdev->dev.of_node, "timeout_ms", &timeout);
>
> Perhaps stop being OF-centric by using device_property_read_u32() instead?
Good catch, will do. Should probably change commit message accordingly,
too.
Thanks,
Moritz
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-20 16:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 22:59 [PATCH v2 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout_ms' property Moritz Fischer
2018-02-19 22:59 ` [PATCH v2 2/2] power: reset: gpio-poweroff: Add support for timeout from DT Moritz Fischer
2018-02-20 14:12 ` Andy Shevchenko
2018-02-20 16:41 ` Moritz Fischer
2018-02-20 14:18 ` [PATCH v2 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout_ms' property Rob Herring
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.