developer | 1aa3089 | 2020-04-21 09:28:29 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2020 MediaTek Inc. |
| 4 | * |
| 5 | * Author: Weijie Gao <weijie.gao@mediatek.com> |
| 6 | */ |
| 7 | |
developer | 1aa3089 | 2020-04-21 09:28:29 +0200 | [diff] [blame] | 8 | #include <dm.h> |
| 9 | #include <errno.h> |
| 10 | #include <sysreset.h> |
| 11 | #include <reset.h> |
| 12 | |
| 13 | struct resetctl_reboot_priv { |
| 14 | struct reset_ctl_bulk resets; |
| 15 | }; |
| 16 | |
| 17 | static int resetctl_reboot_request(struct udevice *dev, enum sysreset_t type) |
| 18 | { |
| 19 | struct resetctl_reboot_priv *priv = dev_get_priv(dev); |
| 20 | |
| 21 | return reset_assert_bulk(&priv->resets); |
| 22 | } |
| 23 | |
| 24 | static struct sysreset_ops resetctl_reboot_ops = { |
| 25 | .request = resetctl_reboot_request, |
| 26 | }; |
| 27 | |
Samuel Holland | 83e32fa | 2021-11-03 22:55:12 -0500 | [diff] [blame] | 28 | static int resetctl_reboot_probe(struct udevice *dev) |
developer | 1aa3089 | 2020-04-21 09:28:29 +0200 | [diff] [blame] | 29 | { |
| 30 | struct resetctl_reboot_priv *priv = dev_get_priv(dev); |
| 31 | |
| 32 | return reset_get_bulk(dev, &priv->resets); |
| 33 | } |
| 34 | |
| 35 | static const struct udevice_id resetctl_reboot_ids[] = { |
| 36 | { .compatible = "resetctl-reboot" }, |
| 37 | { } |
| 38 | }; |
| 39 | |
| 40 | U_BOOT_DRIVER(resetctl_reboot) = { |
| 41 | .id = UCLASS_SYSRESET, |
| 42 | .name = "resetctl_reboot", |
| 43 | .of_match = resetctl_reboot_ids, |
| 44 | .ops = &resetctl_reboot_ops, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 45 | .priv_auto = sizeof(struct resetctl_reboot_priv), |
developer | 1aa3089 | 2020-04-21 09:28:29 +0200 | [diff] [blame] | 46 | .probe = resetctl_reboot_probe, |
| 47 | }; |