linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Davis <afd@ti.com>
To: Nishanth Menon <nm@ti.com>, Tero Kristo <kristo@kernel.org>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Sebastian Reichel <sre@kernel.org>,
	Vignesh Raghavendra <vigneshr@ti.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-pm@vger.kernel.org>, Andrew Davis <afd@ti.com>
Subject: [PATCH 03/12] power: reset: Add TI-SCI reboot driver
Date: Wed, 31 Jan 2024 16:19:48 -0600	[thread overview]
Message-ID: <20240131221957.213717-4-afd@ti.com> (raw)
In-Reply-To: <20240131221957.213717-1-afd@ti.com>

This reboot driver calls into firmware using TI-SCI to reboot the system.
We register the handler with low priority as we want PSCI to remain the
main way these devices are rebooted. This driver acts as a fallback if
PSCI is not able to reboot the system.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 MAINTAINERS                         |  1 +
 drivers/power/reset/Kconfig         |  7 ++++
 drivers/power/reset/Makefile        |  1 +
 drivers/power/reset/ti-sci-reboot.c | 63 +++++++++++++++++++++++++++++
 4 files changed, 72 insertions(+)
 create mode 100644 drivers/power/reset/ti-sci-reboot.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 45983bb174fe4..ee67ea497fc56 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -21758,6 +21758,7 @@ F:	drivers/clk/keystone/sci-clk.c
 F:	drivers/firmware/ti_sci*
 F:	drivers/irqchip/irq-ti-sci-inta.c
 F:	drivers/irqchip/irq-ti-sci-intr.c
+F:	drivers/power/reset/ti-sci-reboot.c
 F:	drivers/reset/reset-ti-sci.c
 F:	drivers/soc/ti/ti_sci_inta_msi.c
 F:	drivers/pmdomain/ti/ti_sci_pm_domains.c
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index fece990af4a75..d3e91e54cae24 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -205,6 +205,13 @@ config POWER_RESET_ST
 	help
 	  Reset support for STMicroelectronics boards.
 
+config POWER_RESET_TI_SCI
+	tristate "TI System Control Interface (TI-SCI) reboot driver"
+	depends on TI_SCI_PROTOCOL
+	help
+	  This enables the reboot driver support over TI System Control
+	  Interface available on some TI's SoCs.
+
 config POWER_RESET_TPS65086
 	bool "TPS65086 restart driver"
 	depends on MFD_TPS65086
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index a95d1bd275d18..881ca58a43b9c 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
 obj-$(CONFIG_POWER_RESET_REGULATOR) += regulator-poweroff.o
 obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
 obj-$(CONFIG_POWER_RESET_ST) += st-poweroff.o
+obj-$(CONFIG_POWER_RESET_TI_SCI) += ti-sci-reboot.o
 obj-$(CONFIG_POWER_RESET_TPS65086) += tps65086-restart.o
 obj-$(CONFIG_POWER_RESET_VERSATILE) += arm-versatile-reboot.o
 obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
diff --git a/drivers/power/reset/ti-sci-reboot.c b/drivers/power/reset/ti-sci-reboot.c
new file mode 100644
index 0000000000000..400bd5d740f8b
--- /dev/null
+++ b/drivers/power/reset/ti-sci-reboot.c
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Texas Instrument's System Control Interface (TI-SCI) reboot driver
+ *
+ * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+ *	Andrew Davis <afd@ti.com>
+ */
+
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/reboot.h>
+
+#include <linux/soc/ti/ti_sci_protocol.h>
+
+static int ti_sci_reboot_handler(struct sys_off_data *data)
+{
+	const struct ti_sci_handle *sci = data->cb_data;
+	const struct ti_sci_core_ops *core_ops = &sci->ops.core_ops;
+
+	core_ops->reboot_device(sci);
+
+	return NOTIFY_DONE;
+}
+
+static int ti_sci_reboot_probe(struct platform_device *pdev)
+{
+	const struct ti_sci_handle *sci;
+	int err;
+
+	sci = devm_ti_sci_get_handle(&pdev->dev);
+	if (IS_ERR(sci))
+		return PTR_ERR(sci);
+
+	err = devm_register_sys_off_handler(&pdev->dev,
+					    SYS_OFF_MODE_RESTART,
+					    SYS_OFF_PRIO_LOW,
+					    ti_sci_reboot_handler,
+					    (void *)sci);
+	if (err)
+		return dev_err_probe(&pdev->dev, err, "Cannot register restart handler\n");
+
+	return 0;
+}
+
+static const struct of_device_id ti_sci_reboot_of_match[] = {
+	{ .compatible = "ti,sci-reboot", },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, ti_sci_reboot_of_match);
+
+static struct platform_driver ti_sci_reboot_driver = {
+	.probe = ti_sci_reboot_probe,
+	.driver = {
+		.name = "ti-sci-reboot",
+		.of_match_table = ti_sci_reboot_of_match,
+	},
+};
+module_platform_driver(ti_sci_reboot_driver);
+
+MODULE_AUTHOR("Andrew Davis <afd@ti.com>");
+MODULE_DESCRIPTION("TI System Control Interface (TI SCI) Reboot driver");
+MODULE_LICENSE("GPL");
-- 
2.39.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2024-01-31 22:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31 22:19 [PATCH 00/12] Add TI-SCI reboot driver Andrew Davis
2024-01-31 22:19 ` [PATCH 01/12] dt-bindings: power: reset: Document ti,sci-reboot compatible Andrew Davis
2024-02-01 18:53   ` Conor Dooley
2024-01-31 22:19 ` [PATCH 02/12] dt-bindings: arm: keystone: ti-sci: Add reboot-controller child node Andrew Davis
2024-02-01 18:42   ` Conor Dooley
2024-02-01 23:03   ` Rob Herring
2024-02-01 23:50     ` Andrew Davis
2024-01-31 22:19 ` Andrew Davis [this message]
2024-02-01 21:15   ` [PATCH 03/12] power: reset: Add TI-SCI reboot driver Nishanth Menon
2024-02-02 17:04     ` Sebastian Reichel
2024-01-31 22:19 ` [PATCH 04/12] arm64: dts: ti: k3-am64: Add reboot-controller node Andrew Davis
2024-01-31 22:19 ` [PATCH 05/12] arm64: dts: ti: k3-am62: " Andrew Davis
2024-01-31 22:19 ` [PATCH 06/12] arm64: dts: ti: k3-am62a: " Andrew Davis
2024-01-31 22:19 ` [PATCH 07/12] arm64: dts: ti: k3-am62p: " Andrew Davis
2024-01-31 22:19 ` [PATCH 08/12] arm64: dts: ti: k3-am65: " Andrew Davis
2024-01-31 22:19 ` [PATCH 09/12] arm64: dts: ti: k3-j7200: " Andrew Davis
2024-01-31 22:19 ` [PATCH 10/12] arm64: dts: ti: k3-j721e: " Andrew Davis
2024-01-31 22:19 ` [PATCH 11/12] arm64: dts: ti: k3-j721s2: " Andrew Davis
2024-01-31 22:19 ` [PATCH 12/12] arm64: dts: ti: k3-j784s4: " Andrew Davis
2024-02-01 21:14 ` [PATCH 00/12] Add TI-SCI reboot driver Nishanth Menon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240131221957.213717-4-afd@ti.com \
    --to=afd@ti.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kristo@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --cc=ssantosh@kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).