Skip to contentSkip to conversation

Add TI-SCI reboot driver

PATCH In review Andrew Davis 5 participants 20 messages Jan 31, 2024 – Feb 2, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add TI-SCI reboot driver

Hello all,

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. This driver is registered with low priority as we want PSCI to remain the main way these devices are rebooted.

The important part is the binding/DT changes. Currently in U-Boot (which use the Linux device trees) we may not have PSCI available yet (pre TF-A) and so we need this node to correctly reboot. Adding this node in U-Boot is one of the last remaining deltas between the two project DT files.

Thanks,
Andrew

Andrew Davis (12):
dt-bindings: power: reset: Document ti,sci-reboot compatible
dt-bindings: arm: keystone: ti-sci: Add reboot-controller child node
power: reset: Add TI-SCI reboot driver
arm64: dts: ti: k3-am64: Add reboot-controller node
arm64: dts: ti: k3-am62: Add reboot-controller node
arm64: dts: ti: k3-am62a: Add reboot-controller node
arm64: dts: ti: k3-am62p: Add reboot-controller node
arm64: dts: ti: k3-am65: Add reboot-controller node
arm64: dts: ti: k3-j7200: Add reboot-controller node
arm64: dts: ti: k3-j721e: Add reboot-controller node
arm64: dts: ti: k3-j721s2: Add reboot-controller node
arm64: dts: ti: k3-j784s4: Add reboot-controller node

 .../bindings/arm/keystone/ti,sci.yaml         |  8 +++
 .../bindings/power/reset/ti,sci-reboot.yaml   | 33 ++++++++++
 MAINTAINERS                                   |  2 +
 arch/arm64/boot/dts/ti/k3-am62-main.dtsi      |  5 ++
 arch/arm64/boot/dts/ti/k3-am62a-main.dtsi     |  4 ++
 arch/arm64/boot/dts/ti/k3-am62p-main.dtsi     |  5 ++
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi      |  5 ++
 arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi    |  4 ++
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi      |  4 ++
 .../boot/dts/ti/k3-j721e-mcu-wakeup.dtsi      |  4 ++
 .../boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi     |  4 ++
 .../boot/dts/ti/k3-j784s4-mcu-wakeup.dtsi     |  5 ++
 drivers/power/reset/Kconfig                   |  7 +++
 drivers/power/reset/Makefile                  |  1 +
 drivers/power/reset/ti-sci-reboot.c           | 63 +++++++++++++++++++
 15 files changed, 154 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml
 create mode 100644 drivers/power/reset/ti-sci-reboot.c
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/12 dt-bindings: power: reset: Document ti,sci-reboot compatible

This calls into the system firmware using TI-SCI to reboot the system. Used as a fallback when PSCI is unable or not available to reboot the system.

---
 .../bindings/power/reset/ti,sci-reboot.yaml   | 33 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml
Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml new file +33 -0
new file mode 100644
index 0000000000000..aa628be33d122
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/reset/ti,sci-reboot.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI-SCI reboot controller
+
+maintainers:
+  - Andrew Davis <[email protected]>
+
+description: |
+  Some TI SoCs contain a system controller (like the Power Management Micro
+  Controller (PMMC) on Keystone 66AK2G SoC) that are responsible for controlling
+  the state of the various hardware modules present on the SoC. Communication
+  between the host processor running an OS and the system controller happens
+  through a protocol called TI System Control Interface (TI-SCI protocol).
+
+  This reboot controller node uses the TI SCI protocol to perform a device reboot.
+
+  Must be a child node of the associated TI-SCI system controller node.
+
+properties:
+  compatible:
+    const: ti,sci-reboot
+
+additionalProperties: false
+
+examples:
+  - |
+    k3_reboot: reboot-controller {
+        compatible = "ti,sci-reboot";
+    };
MAINTAINERS +1 -0
index 8999497011a26..45983bb174fe4 100644
@@ -21751,6 +21751,7 @@ F:	Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
 F:	Documentation/devicetree/bindings/clock/ti,sci-clk.yaml
 F:	Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.yaml
 F:	Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.yaml
+F:	Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml
 F:	Documentation/devicetree/bindings/reset/ti,sci-reset.yaml
 F:	Documentation/devicetree/bindings/soc/ti/sci-pm-domain.yaml
 F:	drivers/clk/keystone/sci-clk.c
Signature · 1 line
2.39.2
Acked-by on v1 1/12
#2 lore raw

Re: [PATCH 01/12] dt-bindings: power: reset: Document ti,sci-reboot compatible

Quoted 40 lines · Andrew Davis

This calls into the system firmware using TI-SCI to reboot the system. Used as a fallback when PSCI is unable or not available to reboot the system.

---
 .../bindings/power/reset/ti,sci-reboot.yaml   | 33 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml
Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml new file +23 -0
new file mode 100644
index 0000000000000..aa628be33d122
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/reset/ti,sci-reboot.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI-SCI reboot controller
+
+maintainers:
+  - Andrew Davis <[email protected]>
+
+description: |
+  Some TI SoCs contain a system controller (like the Power Management Micro
+  Controller (PMMC) on Keystone 66AK2G SoC) that are responsible for controlling
+  the state of the various hardware modules present on the SoC. Communication
+  between the host processor running an OS and the system controller happens
+  through a protocol called TI System Control Interface (TI-SCI protocol).
+
+  This reboot controller node uses the TI SCI protocol to perform a device reboot.
+
+  Must be a child node of the associated TI-SCI system controller node.
+
+properties:

Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml line 33

Quoted 10 lines
Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml new file +10 -0
+  compatible:
+    const: ti,sci-reboot
+
+additionalProperties: false
+
+examples:
+  - |
+    k3_reboot: reboot-controller {
+        compatible = "ti,sci-reboot";
+    };

I'd drop the example since this has no use standalone and just rely on the one in the parent. Otherwise I think this is fine.

#3 lore raw

PATCH 2/12 dt-bindings: arm: keystone: ti-sci: Add reboot-controller child node

In reply to Andrew Davis

The TI-SCI firmware supports rebooting the system in addition to the functions already listed here, document child node for the same.

---
 .../devicetree/bindings/arm/keystone/ti,sci.yaml          | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml +8 -0
index c24ad0968f3ef..e392175b33c74 100644
@@ -83,6 +83,10 @@ properties:
     type: object
     $ref: /schemas/reset/ti,sci-reset.yaml#
 
+  reboot-controller:
+    type: object
+    $ref: /schemas/power/reset/ti,sci-reboot.yaml#
+
 required:
   - compatible
   - mbox-names
@@ -126,4 +130,8 @@ examples:
         compatible = "ti,sci-reset";
         #reset-cells = <2>;
       };
+
+      k3_reboot: reboot-controller {
+        compatible = "ti,sci-reboot";
+      };
     };
Signature · 1 line
2.39.2
Acked-by on v1 2/12
#4 lore raw

Re: [PATCH 02/12] dt-bindings: arm: keystone: ti-sci: Add reboot-controller child node

Quoted 4 lines · Andrew Davis

The TI-SCI firmware supports rebooting the system in addition to the functions already listed here, document child node for the same.

Cheers,
Conor.

Quoted 31 lines
---
 .../devicetree/bindings/arm/keystone/ti,sci.yaml          | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml +8 -0
index c24ad0968f3ef..e392175b33c74 100644
@@ -83,6 +83,10 @@ properties:
     type: object
     $ref: /schemas/reset/ti,sci-reset.yaml#
 
+  reboot-controller:
+    type: object
+    $ref: /schemas/power/reset/ti,sci-reboot.yaml#
+
 required:
   - compatible
   - mbox-names
@@ -126,4 +130,8 @@ examples:
         compatible = "ti,sci-reset";
         #reset-cells = <2>;
       };
+
+      k3_reboot: reboot-controller {
+        compatible = "ti,sci-reboot";
+      };
     };
Signature · 1 line
2.39.2
maintainer
#5 lore raw

Re: [PATCH 02/12] dt-bindings: arm: keystone: ti-sci: Add reboot-controller child node

In reply to Andrew Davis
Quoted 13 lines · Andrew Davis

The TI-SCI firmware supports rebooting the system in addition to the functions already listed here, document child node for the same.

---
 .../devicetree/bindings/arm/keystone/ti,sci.yaml          | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml +0 -0
index c24ad0968f3ef..e392175b33c74 100644

Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml properties: · line 88

Quoted 6 lines
Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml +3 -0
@@ -83,6 +83,10 @@ properties:
     type: object
     $ref: /schemas/reset/ti,sci-reset.yaml#
 
+  reboot-controller:
+    type: object
+    $ref: /schemas/power/reset/ti,sci-reboot.yaml#

Don't need a ref just for a single property.

But then why do we need a node here at all? Can't you assume reboot support for TI-SCI firmware (i.e. based on the parent node). Then you don't need a DT update to add the feature.

Rob

#6 lore raw

Re: [PATCH 02/12] dt-bindings: arm: keystone: ti-sci: Add reboot-controller child node

Quoted 23 lines · Rob Herring
Quoted 13 lines · Andrew Davis

The TI-SCI firmware supports rebooting the system in addition to the functions already listed here, document child node for the same.

---
  .../devicetree/bindings/arm/keystone/ti,sci.yaml          | 8 ++++++++
  1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml +0 -0
index c24ad0968f3ef..e392175b33c74 100644

Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml properties: · line 88

Quoted 6 lines
Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml +3 -0
@@ -83,6 +83,10 @@ properties:
      type: object
      $ref: /schemas/reset/ti,sci-reset.yaml#
 
+  reboot-controller:
+    type: object
+    $ref: /schemas/power/reset/ti,sci-reboot.yaml#

Don't need a ref just for a single property.

Quoted 4 lines

But then why do we need a node here at all? Can't you assume reboot support for TI-SCI firmware (i.e. based on the parent node). Then you don't need a DT update to add the feature.

We could yes, but then again we could do the same for all the child nodes of this system-controller parent node. Might even have been better that way, for now I'm trying to be consistent with what is already here (child node per service provided, even though the services are always the same).

Andrew

Quoted 1 line

Rob

#7 lore raw

PATCH 3/12 power: reset: Add TI-SCI reboot driver

In reply to Andrew Davis

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.

---
 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
MAINTAINERS +1 -0
index 45983bb174fe4..ee67ea497fc56 100644
@@ -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
drivers/power/reset/Kconfig +7 -0
index fece990af4a75..d3e91e54cae24 100644
@@ -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
drivers/power/reset/Makefile +1 -0
index a95d1bd275d18..881ca58a43b9c 100644
@@ -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
drivers/power/reset/ti-sci-reboot.c new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 3/12
#8 lore raw

Re: [PATCH 03/12] power: reset: Add TI-SCI reboot driver

Quoted 127 lines · Andrew Davis

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.

---
 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
MAINTAINERS +1 -0
index 45983bb174fe4..ee67ea497fc56 100644
@@ -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
drivers/power/reset/Kconfig +7 -0
index fece990af4a75..d3e91e54cae24 100644
@@ -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
drivers/power/reset/Makefile +1 -0
index a95d1bd275d18..881ca58a43b9c 100644
@@ -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
drivers/power/reset/ti-sci-reboot.c new file +63 -0
new file mode 100644
index 0000000000000..400bd5d740f8b
@@ -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 <[email protected]>
+ */
+
+#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 <[email protected]>");
+MODULE_DESCRIPTION("TI System Control Interface (TI SCI) Reboot driver");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.39.2

Will assume the patch to go via Sebastien. Will be good for the dts to go via SoC tree. So hoping Sebastien will just pick the driver and bindings.

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#9 lore raw

Re: [PATCH 03/12] power: reset: Add TI-SCI reboot driver

Hi,

Quoted 124 lines · Nishanth Menon
Quoted 123 lines · Andrew Davis

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.

---
 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
MAINTAINERS +1 -0
index 45983bb174fe4..ee67ea497fc56 100644
@@ -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
drivers/power/reset/Kconfig +7 -0
index fece990af4a75..d3e91e54cae24 100644
@@ -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
drivers/power/reset/Makefile +1 -0
index a95d1bd275d18..881ca58a43b9c 100644
@@ -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
drivers/power/reset/ti-sci-reboot.c new file +61 -0
new file mode 100644
index 0000000000000..400bd5d740f8b
@@ -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 <[email protected]>
+ */
+
+#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 <[email protected]>");
Quoted 8 lines
Quoted 4 lines
drivers/power/reset/ti-sci-reboot.c new file +2 -0
+MODULE_DESCRIPTION("TI System Control Interface (TI SCI) Reboot driver");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.39.2

Will assume the patch to go via Sebastien. Will be good for the dts to go via SoC tree. So hoping Sebastien will just pick the driver and bindings.

I will wait for the DT binding discussion to have settled. The driver itself LGTM.

-- Sebastian

#10 lore raw

PATCH 4/12 arm64: dts: ti: k3-am64: Add reboot-controller node

In reply to Andrew Davis

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. Add direct reboot TI-SCI node to system-controller.

---
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/ti/k3-am64-main.dtsi +5 -0
index e348114f42e01..f9d2d1b67282d 100644
@@ -228,6 +228,11 @@ k3_reset: reset-controller {
 			compatible = "ti,sci-reset";
 			#reset-cells = <2>;
 		};
+
+		k3_reboot: reboot-controller {
+			bootph-all;
+			compatible = "ti,sci-reboot";
+		};
 	};
 
 	main_pmx0: pinctrl@f4000 {
Signature · 1 line
2.39.2
#11 lore raw

PATCH 5/12 arm64: dts: ti: k3-am62: Add reboot-controller node

In reply to Andrew Davis

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. Add direct reboot TI-SCI node to system-controller.

---
 arch/arm64/boot/dts/ti/k3-am62-main.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/ti/k3-am62-main.dtsi +5 -0
index 464b7565d085d..eb71523e85c36 100644
@@ -203,6 +203,11 @@ k3_reset: reset-controller {
 			compatible = "ti,sci-reset";
 			#reset-cells = <2>;
 		};
+
+		k3_reboot: reboot-controller {
+			bootph-all;
+			compatible = "ti,sci-reboot";
+		};
 	};
 
 	crypto: crypto@40900000 {
Signature · 1 line
2.39.2
#12 lore raw

PATCH 6/12 arm64: dts: ti: k3-am62a: Add reboot-controller node

In reply to Andrew Davis

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. Add direct reboot TI-SCI node to system-controller.

---
 arch/arm64/boot/dts/ti/k3-am62a-main.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/ti/k3-am62a-main.dtsi +4 -0
index f0b8c9ab14593..222505edc15bb 100644
@@ -215,6 +215,10 @@ k3_reset: reset-controller {
 			compatible = "ti,sci-reset";
 			#reset-cells = <2>;
 		};
+
+		k3_reboot: reboot-controller {
+			compatible = "ti,sci-reboot";
+		};
 	};
 
 	secure_proxy_sa3: mailbox@43600000 {
Signature · 1 line
2.39.2
#13 lore raw

PATCH 7/12 arm64: dts: ti: k3-am62p: Add reboot-controller node

In reply to Andrew Davis

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. Add direct reboot TI-SCI node to system-controller.

---
 arch/arm64/boot/dts/ti/k3-am62p-main.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/ti/k3-am62p-main.dtsi +5 -0
index 4c51bae06b57e..7a10ed7a41a23 100644
@@ -185,6 +185,11 @@ k3_reset: reset-controller {
 			#reset-cells = <2>;
 			bootph-all;
 		};
+
+		k3_reboot: reboot-controller {
+			compatible = "ti,sci-reboot";
+			bootph-all;
+		};
 	};
 
 	crypto: crypto@40900000 {
Signature · 1 line
2.39.2
#14 lore raw

PATCH 8/12 arm64: dts: ti: k3-am65: Add reboot-controller node

In reply to Andrew Davis

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. Add direct reboot TI-SCI node to system-controller.

---
 arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi +4 -0
index f037b36243ced..986684b7a7c43 100644
@@ -32,6 +32,10 @@ k3_reset: reset-controller {
 			compatible = "ti,sci-reset";
 			#reset-cells = <2>;
 		};
+
+		k3_reboot: reboot-controller {
+			compatible = "ti,sci-reboot";
+		};
 	};
 
 	wkup_conf: bus@43000000 {
Signature · 1 line
2.39.2
#15 lore raw

PATCH 9/12 arm64: dts: ti: k3-j7200: Add reboot-controller node

In reply to Andrew Davis

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. Add direct reboot TI-SCI node to system-controller.

---
 arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi +4 -0
index 60b26374ae0cc..a37d66bcf93e9 100644
@@ -32,6 +32,10 @@ k3_reset: reset-controller {
 			compatible = "ti,sci-reset";
 			#reset-cells = <2>;
 		};
+
+		k3_reboot: reboot-controller {
+			compatible = "ti,sci-reboot";
+		};
 	};
 
 	mcu_timer0: timer@40400000 {
Signature · 1 line
2.39.2
#16 lore raw

PATCH 10/12 arm64: dts: ti: k3-j721e: Add reboot-controller node

In reply to Andrew Davis

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. Add direct reboot TI-SCI node to system-controller.

---
 arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi +4 -0
index a74912d9e4daf..a1512d9fbb92f 100644
@@ -32,6 +32,10 @@ k3_reset: reset-controller {
 			compatible = "ti,sci-reset";
 			#reset-cells = <2>;
 		};
+
+		k3_reboot: reboot-controller {
+			compatible = "ti,sci-reboot";
+		};
 	};
 
 	mcu_conf: syscon@40f00000 {
Signature · 1 line
2.39.2
#17 lore raw

PATCH 11/12 arm64: dts: ti: k3-j721s2: Add reboot-controller node

In reply to Andrew Davis

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. Add direct reboot TI-SCI node to system-controller.

---
 arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi +4 -0
index 80aa33c58a452..1f1125208dedf 100644
@@ -32,6 +32,10 @@ k3_reset: reset-controller {
 			compatible = "ti,sci-reset";
 			#reset-cells = <2>;
 		};
+
+		k3_reboot: reboot-controller {
+			compatible = "ti,sci-reboot";
+		};
 	};
 
 	wkup_conf: bus@43000000 {
Signature · 1 line
2.39.2
#18 lore raw

PATCH 12/12 arm64: dts: ti: k3-j784s4: Add reboot-controller node

In reply to Andrew Davis

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. Add direct reboot TI-SCI node to system-controller.

---
 arch/arm64/boot/dts/ti/k3-j784s4-mcu-wakeup.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/ti/k3-j784s4-mcu-wakeup.dtsi +5 -0
index 3902a921d7e58..6a66de4f6e549 100644
@@ -36,6 +36,11 @@ k3_reset: reset-controller {
 			compatible = "ti,sci-reset";
 			#reset-cells = <2>;
 		};
+
+		k3_reboot: reboot-controller {
+			bootph-all;
+			compatible = "ti,sci-reboot";
+		};
 	};
 
 	wkup_conf: bus@43000000 {
Signature · 1 line
2.39.2
maintainer
#19 lore raw
In reply to Andrew Davis
Quoted 16 lines · Andrew Davis

Hello all,

While PCSI normally handles reboot for K3, this is an available fallback in case PCSI reboot fails. This driver is registered with low priority as we want PSCI to remain the main way these devices are rebooted.

The important part is the binding/DT changes. Currently in U-Boot (which use the Linux device trees) we may not have PSCI available yet (pre TF-A) and so we need this node to correctly reboot. Adding this node in U-Boot is one of the last remaining deltas between the two project DT files.

Thanks,
Andrew

Quoted 13 lines

Andrew Davis (12):
dt-bindings: power: reset: Document ti,sci-reboot compatible
dt-bindings: arm: keystone: ti-sci: Add reboot-controller child node
power: reset: Add TI-SCI reboot driver
arm64: dts: ti: k3-am64: Add reboot-controller node
arm64: dts: ti: k3-am62: Add reboot-controller node
arm64: dts: ti: k3-am62a: Add reboot-controller node
arm64: dts: ti: k3-am62p: Add reboot-controller node
arm64: dts: ti: k3-am65: Add reboot-controller node
arm64: dts: ti: k3-j7200: Add reboot-controller node
arm64: dts: ti: k3-j721e: Add reboot-controller node
arm64: dts: ti: k3-j721s2: Add reboot-controller node
arm64: dts: ti: k3-j784s4: Add reboot-controller node

Maybe after the driver has been accepted, a defconfig patch(module) might be useful?

Quoted 19 lines
 .../bindings/arm/keystone/ti,sci.yaml         |  8 +++
 .../bindings/power/reset/ti,sci-reboot.yaml   | 33 ++++++++++
 MAINTAINERS                                   |  2 +
 arch/arm64/boot/dts/ti/k3-am62-main.dtsi      |  5 ++
 arch/arm64/boot/dts/ti/k3-am62a-main.dtsi     |  4 ++
 arch/arm64/boot/dts/ti/k3-am62p-main.dtsi     |  5 ++
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi      |  5 ++
 arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi    |  4 ++
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi      |  4 ++
 .../boot/dts/ti/k3-j721e-mcu-wakeup.dtsi      |  4 ++
 .../boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi     |  4 ++
 .../boot/dts/ti/k3-j784s4-mcu-wakeup.dtsi     |  5 ++
 drivers/power/reset/Kconfig                   |  7 +++
 drivers/power/reset/Makefile                  |  1 +
 drivers/power/reset/ti-sci-reboot.c           | 63 +++++++++++++++++++
 15 files changed, 154 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml
 create mode 100644 drivers/power/reset/ti-sci-reboot.c
Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D