Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1954377rdb; Wed, 31 Jan 2024 14:40:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2h5TMK0PnDBEmMD/WQMqU6gXrDHG5mjLJzsYDxyXl35isgH0P69+CuiU9OcVi9EWdK+Vo X-Received: by 2002:a05:6358:7241:b0:178:9756:34c4 with SMTP id i1-20020a056358724100b00178975634c4mr3167898rwa.30.1706740821022; Wed, 31 Jan 2024 14:40:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706740820; cv=pass; d=google.com; s=arc-20160816; b=x5z70/kfNsxAcUkbGkV4sSlBMtU/5FvoWvStNKGF8hihGbTkS/wI7fXoMFjE1m8W2d EfjmisC+GxwXk8AzrWFHMbTYOUDuEpdjsXGGkuv02IxrL4bfUk4cfhQ96gC4JTEWnDiM md8dvTUjHU82PPbVUIiyfi3Zw/bEj2EGe8khqwJfgR5OpzuUft8WO67ra87tOol0Lap0 YxuOwNnKC/Bu3U5F5Mkk6q/oXTEMgXP/p0B+8L/QENCpbkMoa9Qhm/ioQmyT7mQ/j3D0 LW3n/gZZJaNjCzd+e41Dve2FSDzw6Wv7wApSpIrwrTS8U/AWCQiW+t0wvO2ujOxs63hb qOeA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1YUSJDF+znyudL9/WwRSORWM+cm2PVwYB2DPgs0ZaYU=; fh=9tNMzTGQjVTiEZ6bFrktvWOlO5i5ZA3qr8ONpk7G/MA=; b=JZPcyua6Ur8wVZf616+GNgjwKMimaE9dU22wzE+PErhrhkhzOtot5iW06nSu6F31C3 CYqDJzWoPT1tK1XADXI9/iwo6stJdLDOLAhm2nEuhsK7p2L4/SQdoz5jVaAVblkdAaMI aWQwP+RcsWFkmBLdfdq1LEokvLbSAk9cwVijg18t80VwUHiUgwy79249UeMyQSk0hWJt IXhS2vyp8du+S7aPoiZLR5FDlsr1xFKMM96zBwSWN6Tk5vJAhLe0zJMTs6o9YGLhu5F0 /FhvJQ6MvbXn0uHVlzTRp4KfZqIXoZxHYiMI3dRDixmNLAJY8jgt+uQq2x72BJMGwudP puFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="hTi6l/P5"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-47240-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47240-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCXIKF0fAKsU6IDy8NGjgrq8PiThNhQ/a8BbDFMTF3Ob4+w9AawvKh+3OkmNd0avlCQTM+A8OJ2Lh7BKRJbkN9uFVbyJr+GWi1POjRCUKw== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id r18-20020aa78b92000000b006ddc1bf70ecsi10179592pfd.34.2024.01.31.14.40.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 14:40:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47240-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="hTi6l/P5"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-47240-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47240-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 23FDAB232DB for ; Wed, 31 Jan 2024 22:20:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D94EE3A294; Wed, 31 Jan 2024 22:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="hTi6l/P5" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A2C039AFE; Wed, 31 Jan 2024 22:20:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706739608; cv=none; b=K/itngneC1WAiGo4Moww2LJN+0CMfvCDaUdghUaZjb55NfcJH4myAxfpb+OyQa2Q7GGKGrkVl05x+8uj7Y7R+ySLPa4UXlr3GyCIZiXrpTtOaA9MqESzrvt47W3QqiUxj72Oc2dq1acofdT98tw70OeDUWl4Ygsnw/HQr0Mlt5A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706739608; c=relaxed/simple; bh=3XrBhJ7lFcCw9u4MVsQS//A6rOZ4Nmr3IhSO+twZxug=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SIrVcEEoSRcA77KNoyanwi3ys4weqnKXkBVKro4jYJ8YTsi9Dm2ibEAFzrz3qN2hPmL9Mti8SW7seoTUY2cubDK2nFMLYr3/Pjyqly/Vd5gPIKakxmYmv8DzEUI2l/b9p4f1SjhtLn7toWpdEjhOMPgENlDpPCPd9abzayg+rYs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=hTi6l/P5; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40VMK1tM060758; Wed, 31 Jan 2024 16:20:01 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706739601; bh=1YUSJDF+znyudL9/WwRSORWM+cm2PVwYB2DPgs0ZaYU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hTi6l/P5C2NPqg6vQf12o1wOyHOl6v5Jxm7TN+Qd3oaoBR2tG/W2eX748unjJtzA1 ASJEJQE6KYw+bUVBWAuDZrtlUGyIkNTyxm42ICu6wIUQS/QNbhPhvjw0XJzev86EvO BpwTFw9eA4n/ZhFBxvh12ho+mVqQDdp1aEMk68Bc= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40VMK1wi021515 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Jan 2024 16:20:01 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 31 Jan 2024 16:20:00 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 31 Jan 2024 16:20:00 -0600 Received: from lelvsmtp5.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 40VMJwx5102504; Wed, 31 Jan 2024 16:20:00 -0600 From: Andrew Davis To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sebastian Reichel , Vignesh Raghavendra CC: , , , , Andrew Davis Subject: [PATCH 03/12] power: reset: Add TI-SCI reboot driver Date: Wed, 31 Jan 2024 16:19:48 -0600 Message-ID: <20240131221957.213717-4-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131221957.213717-1-afd@ti.com> References: <20240131221957.213717-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 --- 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 + */ + +#include +#include +#include +#include + +#include + +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 "); +MODULE_DESCRIPTION("TI System Control Interface (TI SCI) Reboot driver"); +MODULE_LICENSE("GPL"); -- 2.39.2