2 * Copyright (C) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
4 * Derived from linux/drivers/power/reset/syscon-reboot.c:
5 * Copyright (C) 2013, Applied Micro Circuits Corporation
6 * Author: Feng Kan <fkan@apm.com>
8 * SPDX-License-Identifier: GPL-2.0+
18 DECLARE_GLOBAL_DATA_PTR;
20 struct syscon_reboot_priv {
21 struct regmap *regmap;
26 static int syscon_reboot_request(struct udevice *dev, enum sysreset_t type)
28 struct syscon_reboot_priv *priv = dev_get_priv(dev);
30 regmap_write(priv->regmap, priv->offset, priv->mask);
35 static struct sysreset_ops syscon_reboot_ops = {
36 .request = syscon_reboot_request,
39 int syscon_reboot_probe(struct udevice *dev)
41 struct udevice *syscon;
42 struct syscon_reboot_priv *priv = dev_get_priv(dev);
45 err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
48 error("unable to find syscon device\n");
52 priv->regmap = syscon_get_regmap(syscon);
54 error("unable to find regmap\n");
58 priv->offset = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
60 priv->mask = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
66 static const struct udevice_id syscon_reboot_ids[] = {
67 { .compatible = "syscon-reboot" },
71 U_BOOT_DRIVER(syscon_reboot) = {
72 .name = "syscon_reboot",
73 .id = UCLASS_SYSRESET,
74 .of_match = syscon_reboot_ids,
75 .probe = syscon_reboot_probe,
76 .priv_auto_alloc_size = sizeof(struct syscon_reboot_priv),
77 .ops = &syscon_reboot_ops,