Lines Matching +full:gpio +full:- +full:restart

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Toggles a GPIO pin to restart a device
7 * Based on the gpio-poweroff driver.
14 #include <linux/gpio/consumer.h>
27 struct gpio_restart *gpio_restart = data->cb_data; in gpio_restart_notify()
29 /* drive it active, also inactive->active edge */ in gpio_restart_notify()
30 gpiod_direction_output(gpio_restart->reset_gpio, 1); in gpio_restart_notify()
31 mdelay(gpio_restart->active_delay_ms); in gpio_restart_notify()
33 /* drive inactive, also active->inactive edge */ in gpio_restart_notify()
34 gpiod_set_value(gpio_restart->reset_gpio, 0); in gpio_restart_notify()
35 mdelay(gpio_restart->inactive_delay_ms); in gpio_restart_notify()
37 /* drive it active, also inactive->active edge */ in gpio_restart_notify()
38 gpiod_set_value(gpio_restart->reset_gpio, 1); in gpio_restart_notify()
41 mdelay(gpio_restart->wait_delay_ms); in gpio_restart_notify()
56 gpio_restart = devm_kzalloc(&pdev->dev, sizeof(*gpio_restart), in gpio_restart_probe()
59 return -ENOMEM; in gpio_restart_probe()
61 open_source = of_property_read_bool(pdev->dev.of_node, "open-source"); in gpio_restart_probe()
63 gpio_restart->reset_gpio = devm_gpiod_get(&pdev->dev, NULL, in gpio_restart_probe()
65 ret = PTR_ERR_OR_ZERO(gpio_restart->reset_gpio); in gpio_restart_probe()
67 if (ret != -EPROBE_DEFER) in gpio_restart_probe()
68 dev_err(&pdev->dev, "Could not get reset GPIO\n"); in gpio_restart_probe()
72 gpio_restart->active_delay_ms = 100; in gpio_restart_probe()
73 gpio_restart->inactive_delay_ms = 100; in gpio_restart_probe()
74 gpio_restart->wait_delay_ms = 3000; in gpio_restart_probe()
76 ret = of_property_read_u32(pdev->dev.of_node, "priority", &property); in gpio_restart_probe()
79 dev_err(&pdev->dev, "Invalid priority property: %u\n", in gpio_restart_probe()
85 of_property_read_u32(pdev->dev.of_node, "active-delay", in gpio_restart_probe()
86 &gpio_restart->active_delay_ms); in gpio_restart_probe()
87 of_property_read_u32(pdev->dev.of_node, "inactive-delay", in gpio_restart_probe()
88 &gpio_restart->inactive_delay_ms); in gpio_restart_probe()
89 of_property_read_u32(pdev->dev.of_node, "wait-delay", in gpio_restart_probe()
90 &gpio_restart->wait_delay_ms); in gpio_restart_probe()
92 ret = devm_register_sys_off_handler(&pdev->dev, in gpio_restart_probe()
98 dev_err(&pdev->dev, "%s: cannot register restart handler, %d\n", in gpio_restart_probe()
100 return -ENODEV; in gpio_restart_probe()
107 { .compatible = "gpio-restart", },
114 .name = "restart-gpio",
122 MODULE_DESCRIPTION("GPIO restart driver");