1 // SPDX-License-Identifier: GPL-2.0+
3 * Texas Instruments System Control Interface (TI SCI) system reset driver
5 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
6 * Andreas Dannenberg <dannenberg@ti.com>
13 #include <dm/device_compat.h>
14 #include <linux/err.h>
15 #include <linux/soc/ti/ti_sci_protocol.h>
18 * struct ti_sci_sysreset_data - sysreset controller information structure
19 * @sci: TI SCI handle used for communication with system controller
21 struct ti_sci_sysreset_data {
22 const struct ti_sci_handle *sci;
25 static int ti_sci_sysreset_probe(struct udevice *dev)
27 struct ti_sci_sysreset_data *data = dev_get_priv(dev);
29 debug("%s(dev=%p)\n", __func__, dev);
34 /* Store handle for communication with the system controller */
35 data->sci = ti_sci_get_handle(dev);
36 if (IS_ERR(data->sci))
37 return PTR_ERR(data->sci);
42 static int ti_sci_sysreset_request(struct udevice *dev, enum sysreset_t type)
44 struct ti_sci_sysreset_data *data = dev_get_priv(dev);
45 const struct ti_sci_handle *sci = data->sci;
46 const struct ti_sci_core_ops *cops = &sci->ops.core_ops;
49 debug("%s(dev=%p, type=%d)\n", __func__, dev, type);
51 ret = cops->reboot_device(sci);
53 dev_err(rst->dev, "%s: reboot_device failed (%d)\n",
59 static struct sysreset_ops ti_sci_sysreset_ops = {
60 .request = ti_sci_sysreset_request,
63 static const struct udevice_id ti_sci_sysreset_of_match[] = {
64 { .compatible = "ti,sci-sysreset", },
68 U_BOOT_DRIVER(ti_sci_sysreset) = {
69 .name = "ti-sci-sysreset",
70 .id = UCLASS_SYSRESET,
71 .of_match = ti_sci_sysreset_of_match,
72 .probe = ti_sci_sysreset_probe,
73 .priv_auto_alloc_size = sizeof(struct ti_sci_sysreset_data),
74 .ops = &ti_sci_sysreset_ops,