1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2018 Xilinx, Inc. - Michal Simek
13 struct gpio_reboot_priv {
14 struct gpio_desc gpio;
17 static int gpio_reboot_request(struct udevice *dev, enum sysreset_t type)
19 struct gpio_reboot_priv *priv = dev_get_priv(dev);
22 * When debug log is enabled please make sure that chars won't end up
23 * in output fifo. Or you can append udelay(); to get enough time
24 * to HW to emit output fifo.
26 debug("GPIO reset\n");
28 /* Writing 1 respects polarity (active high/low) based on gpio->flags */
29 return dm_gpio_set_value(&priv->gpio, 1);
32 static struct sysreset_ops gpio_reboot_ops = {
33 .request = gpio_reboot_request,
36 int gpio_reboot_probe(struct udevice *dev)
38 struct gpio_reboot_priv *priv = dev_get_priv(dev);
41 * Linux kernel DT binding contain others optional properties
42 * which are not supported now
45 return gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
48 static const struct udevice_id led_gpio_ids[] = {
49 { .compatible = "gpio-restart" },
53 U_BOOT_DRIVER(gpio_reboot) = {
54 .id = UCLASS_SYSRESET,
55 .name = "gpio_restart",
56 .of_match = led_gpio_ids,
57 .ops = &gpio_reboot_ops,
58 .priv_auto_alloc_size = sizeof(struct gpio_reboot_priv),
59 .probe = gpio_reboot_probe,