Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to export the pin used by the gpio-poweroff driver #2552

Merged
merged 3 commits into from
May 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ 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.
- export : Export the GPIO line to the sysfs system

Examples:

Expand Down
3 changes: 3 additions & 0 deletions arch/arm/boot/dts/overlays/README
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ Params: gpiopin GPIO for signalling (default 26)
custom dt-blob.bin to prevent a power-down
during the boot process, and that a reboot
will also cause the pin to go low.
input Set if the gpio pin should be configured as
an input.
export Set to export the configured pin to sysfs


Name: gpio-shutdown
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/boot/dts/overlays/gpio-poweroff-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@
gpiopin = <&power_ctrl>,"gpios:4",
<&power_ctrl_pins>,"brcm,pins:0";
active_low = <&power_ctrl>,"gpios:8";
input = <&power_ctrl>,"input?";
export = <&power_ctrl>,"export?";
};
};
9 changes: 9 additions & 0 deletions drivers/power/reset/gpio-poweroff.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
bool input = false;
enum gpiod_flags flags;
bool force = false;
bool export = false;

/* If a pm_power_off function has already been added, leave it alone */
force = of_property_read_bool(pdev->dev.of_node, "force");
Expand All @@ -70,6 +71,12 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
if (IS_ERR(reset_gpio))
return PTR_ERR(reset_gpio);

export = of_property_read_bool(pdev->dev.of_node, "export");
if (export) {
gpiod_export(reset_gpio, false);
gpiod_export_link(&pdev->dev, "poweroff-gpio", reset_gpio);
}

pm_power_off = &gpio_poweroff_do_poweroff;
return 0;
}
Expand All @@ -79,6 +86,8 @@ static int gpio_poweroff_remove(struct platform_device *pdev)
if (pm_power_off == &gpio_poweroff_do_poweroff)
pm_power_off = NULL;

gpiod_unexport(reset_gpio);

return 0;
}

Expand Down