2024-01-31 22:20:45

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 00/12] 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

--
2.39.2



2024-01-31 22:21:00

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 04/12] arm64: dts: ti: k3-am64: Add reboot-controller node

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.

Signed-off-by: Andrew Davis <[email protected]>
---
arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
index e348114f42e01..f9d2d1b67282d 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
@@ -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 {
--
2.39.2


2024-01-31 22:21:06

by Andrew Davis

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

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

Signed-off-by: Andrew Davis <[email protected]>
---
.../devicetree/bindings/arm/keystone/ti,sci.yaml | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
index c24ad0968f3ef..e392175b33c74 100644
--- a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
+++ b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
@@ -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";
+ };
};
--
2.39.2


2024-01-31 22:22:53

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 09/12] arm64: dts: ti: k3-j7200: Add reboot-controller node

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.

Signed-off-by: Andrew Davis <[email protected]>
---
arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
index 60b26374ae0cc..a37d66bcf93e9 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
@@ -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 {
--
2.39.2


2024-01-31 22:22:54

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 10/12] arm64: dts: ti: k3-j721e: Add reboot-controller node

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.

Signed-off-by: Andrew Davis <[email protected]>
---
arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi
index a74912d9e4daf..a1512d9fbb92f 100644
--- a/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi
@@ -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 {
--
2.39.2


2024-01-31 22:23:31

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 06/12] arm64: dts: ti: k3-am62a: Add reboot-controller node

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.

Signed-off-by: Andrew Davis <[email protected]>
---
arch/arm64/boot/dts/ti/k3-am62a-main.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am62a-main.dtsi b/arch/arm64/boot/dts/ti/k3-am62a-main.dtsi
index f0b8c9ab14593..222505edc15bb 100644
--- a/arch/arm64/boot/dts/ti/k3-am62a-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am62a-main.dtsi
@@ -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 {
--
2.39.2


2024-01-31 22:32:19

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 12/12] arm64: dts: ti: k3-j784s4: Add reboot-controller node

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.

Signed-off-by: Andrew Davis <[email protected]>
---
arch/arm64/boot/dts/ti/k3-j784s4-mcu-wakeup.dtsi | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j784s4-mcu-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-j784s4-mcu-wakeup.dtsi
index 3902a921d7e58..6a66de4f6e549 100644
--- a/arch/arm64/boot/dts/ti/k3-j784s4-mcu-wakeup.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j784s4-mcu-wakeup.dtsi
@@ -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 {
--
2.39.2


2024-01-31 22:33:25

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 08/12] arm64: dts: ti: k3-am65: Add reboot-controller node

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.

Signed-off-by: Andrew Davis <[email protected]>
---
arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi
index f037b36243ced..986684b7a7c43 100644
--- a/arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi
@@ -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 {
--
2.39.2


2024-01-31 22:40:21

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 03/12] power: reset: Add TI-SCI reboot driver

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 <[email protected]>
---
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 <[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");
--
2.39.2


2024-01-31 22:40:47

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 05/12] arm64: dts: ti: k3-am62: Add reboot-controller node

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.

Signed-off-by: Andrew Davis <[email protected]>
---
arch/arm64/boot/dts/ti/k3-am62-main.dtsi | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am62-main.dtsi b/arch/arm64/boot/dts/ti/k3-am62-main.dtsi
index 464b7565d085d..eb71523e85c36 100644
--- a/arch/arm64/boot/dts/ti/k3-am62-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am62-main.dtsi
@@ -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 {
--
2.39.2


2024-01-31 22:40:52

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 01/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.

Signed-off-by: Andrew Davis <[email protected]>
---
.../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

diff --git a/Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml b/Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml
new file mode 100644
index 0000000000000..aa628be33d122
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml
@@ -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";
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index 8999497011a26..45983bb174fe4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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
--
2.39.2


2024-01-31 22:42:09

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 07/12] arm64: dts: ti: k3-am62p: Add reboot-controller node

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.

Signed-off-by: Andrew Davis <[email protected]>
---
arch/arm64/boot/dts/ti/k3-am62p-main.dtsi | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am62p-main.dtsi b/arch/arm64/boot/dts/ti/k3-am62p-main.dtsi
index 4c51bae06b57e..7a10ed7a41a23 100644
--- a/arch/arm64/boot/dts/ti/k3-am62p-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am62p-main.dtsi
@@ -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 {
--
2.39.2


2024-01-31 22:43:02

by Andrew Davis

[permalink] [raw]
Subject: [PATCH 11/12] arm64: dts: ti: k3-j721s2: Add reboot-controller node

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.

Signed-off-by: Andrew Davis <[email protected]>
---
arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi
index 80aa33c58a452..1f1125208dedf 100644
--- a/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi
@@ -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 {
--
2.39.2


2024-02-01 18:54:01

by Conor Dooley

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

On Wed, Jan 31, 2024 at 04:19:46PM -0600, Andrew Davis wrote:
> 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.
>
> Signed-off-by: Andrew Davis <[email protected]>
> ---
> .../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
>
> diff --git a/Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml b/Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml
> new file mode 100644
> index 0000000000000..aa628be33d122
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/reset/ti,sci-reboot.yaml
> @@ -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";
> + };

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.

Acked-by: Conor Dooley <[email protected]>


Attachments:
(No filename) (2.13 kB)
signature.asc (235.00 B)
Download all attachments

2024-02-01 19:14:46

by Conor Dooley

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

On Wed, Jan 31, 2024 at 04:19:47PM -0600, Andrew Davis wrote:
> The TI-SCI firmware supports rebooting the system in addition to the
> functions already listed here, document child node for the same.
>
> Signed-off-by: Andrew Davis <[email protected]>

Acked-by: Conor Dooley <[email protected]>

Cheers,
Conor.

> ---
> .../devicetree/bindings/arm/keystone/ti,sci.yaml | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
> index c24ad0968f3ef..e392175b33c74 100644
> --- a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
> +++ b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
> @@ -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";
> + };
> };
> --
> 2.39.2
>


Attachments:
(No filename) (1.25 kB)
signature.asc (235.00 B)
Download all attachments

2024-02-01 21:14:28

by Nishanth Menon

[permalink] [raw]
Subject: Re: [PATCH 00/12] Add TI-SCI reboot driver

On 16:19-20240131, Andrew Davis wrote:
> 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

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

>
> .../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

--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D

2024-02-01 21:15:58

by Nishanth Menon

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

On 16:19-20240131, Andrew Davis wrote:
> 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 <[email protected]>
> ---
> 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 <[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");
> --
> 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.

Reviewed-by: Nishanth Menon <[email protected]>
--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D

2024-02-01 23:04:09

by Rob Herring (Arm)

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

On Wed, Jan 31, 2024 at 04:19:47PM -0600, Andrew Davis wrote:
> The TI-SCI firmware supports rebooting the system in addition to the
> functions already listed here, document child node for the same.
>
> Signed-off-by: Andrew Davis <[email protected]>
> ---
> .../devicetree/bindings/arm/keystone/ti,sci.yaml | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
> index c24ad0968f3ef..e392175b33c74 100644
> --- a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
> +++ b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
> @@ -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

2024-02-01 23:50:24

by Andrew Davis

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

On 2/1/24 5:03 PM, Rob Herring wrote:
> On Wed, Jan 31, 2024 at 04:19:47PM -0600, Andrew Davis wrote:
>> The TI-SCI firmware supports rebooting the system in addition to the
>> functions already listed here, document child node for the same.
>>
>> Signed-off-by: Andrew Davis <[email protected]>
>> ---
>> .../devicetree/bindings/arm/keystone/ti,sci.yaml | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
>> index c24ad0968f3ef..e392175b33c74 100644
>> --- a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
>> +++ b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml
>> @@ -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.
>

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

> Rob

2024-02-02 17:07:11

by Sebastian Reichel

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

Hi,

On Thu, Feb 01, 2024 at 03:15:34PM -0600, Nishanth Menon wrote:
> On 16:19-20240131, Andrew Davis wrote:
> > 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 <[email protected]>
> > ---
> > 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 <[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");
> > --
> > 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


Attachments:
(No filename) (5.09 kB)
signature.asc (849.00 B)
Download all attachments