Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d85b4f7b authored by Moritz Fischer's avatar Moritz Fischer Committed by Sebastian Reichel
Browse files

power: reset: gpio-poweroff: Support for timeout from device property



Add support for reading a timeout value from device property.
Fall back to previous default of 3s if nothing is specified.

Signed-off-by: default avatarMoritz Fischer <mdf@kernel.org>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 88f59872
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -19,11 +19,13 @@
#include <linux/of_platform.h>
#include <linux/of_platform.h>
#include <linux/module.h>
#include <linux/module.h>


#define DEFAULT_TIMEOUT_MS 3000
/*
/*
 * Hold configuration here, cannot be more than one instance of the driver
 * Hold configuration here, cannot be more than one instance of the driver
 * since pm_power_off itself is global.
 * since pm_power_off itself is global.
 */
 */
static struct gpio_desc *reset_gpio;
static struct gpio_desc *reset_gpio;
static u32 timeout = DEFAULT_TIMEOUT_MS;


static void gpio_poweroff_do_poweroff(void)
static void gpio_poweroff_do_poweroff(void)
{
{
@@ -40,7 +42,7 @@ static void gpio_poweroff_do_poweroff(void)
	gpiod_set_value(reset_gpio, 1);
	gpiod_set_value(reset_gpio, 1);


	/* give it some time */
	/* give it some time */
	mdelay(3000);
	mdelay(timeout);


	WARN_ON(1);
	WARN_ON(1);
}
}
@@ -58,12 +60,14 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
		return -EBUSY;
		return -EBUSY;
	}
	}


	input = of_property_read_bool(pdev->dev.of_node, "input");
	input = device_property_read_bool(&pdev->dev, "input");
	if (input)
	if (input)
		flags = GPIOD_IN;
		flags = GPIOD_IN;
	else
	else
		flags = GPIOD_OUT_LOW;
		flags = GPIOD_OUT_LOW;


	device_property_read_u32(&pdev->dev, "timeout-ms", &timeout);

	reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags);
	reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags);
	if (IS_ERR(reset_gpio))
	if (IS_ERR(reset_gpio))
		return PTR_ERR(reset_gpio);
		return PTR_ERR(reset_gpio);