From patchwork Wed Jan 31 22:19:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 194991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp59799dyc; Wed, 31 Jan 2024 14:22:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdick7hcLCT95VmVa6W4FMKZjz7ppAma+BJ1JbDezkc8A5zhKva7QNk5FKLzVNA69ANZb8 X-Received: by 2002:a05:620a:2987:b0:785:43d7:25e9 with SMTP id r7-20020a05620a298700b0078543d725e9mr586656qkp.56.1706739723684; Wed, 31 Jan 2024 14:22:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706739723; cv=pass; d=google.com; s=arc-20160816; b=Zsh9ylQ7M8kIRu9EklqgEEJt/auyKqKyaX/cP4fRMdPGgI1PMkj9839bhZfEaRjMQF slHkTJVqWhmSgpVf2aO0wd1+jcyTbMqVAbUvfocoq6M31bN3z8j24jurArSjE8G23PTj mWwscsZkBUlHP0iYzEMvLFr2vcnrjZTM0hmzzz9ufLhgTB2Ybp9+QtZ/FOdb5egVgW2z v+yOrdxMRslh1p0HdjiV8DkgEH2DSgIqkSRj3Oy/k7ZQ+/QeNI7+E0JlVrkQL3FV0Ow/ IsxBKs6wnATYi/2fzvTl6FEJhZcC9b8tudbNpInrLkL0mTHlAPKUNVfKiR9IjP0Va245 0Zhw== 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=2i4VGRXIXTD6NiuG3+N/9QFov/3ElOs3IzDYQt+Uoq4=; b=KvbJXnmoyBnxDMQsY1vc/kC3FG63gnOkfKYUWMaM58JagJv3Kp+RAmcuZsfqv21TtV XSFCkF05pXjb2WlaO4mGnMvRsPnzIfYBzPG+ZZYGDWph6mfidgVe1Jxrtk5Abk/n39Ox 2mL2Xm6gHDk9N5OIUUv1+1yJLpd2qn51BN/9m+12QBOaAoZfwuzNtkL6U+1576mqIIXI mCZYg7AfKrn8O0IV93YrZKQ8eRSD2Kc7jAWSMbdh6wiIN3F9TvInyIZjkEJQ2DVTqVy2 JsOc20FO80cOwuqEwUknpsrFjBUK9N/SoinZItON0FsqLPs77KbQwEqL7iqOUZocygkQ NTqA==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47240-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCWseEvxs8rC8fOxfxoEoyOIHah06uCtYT0z+5Vn1bpFTiKCOaCVV8MHZUoDSr67d3tp/p1prsN0GClQuAGOojRL+vjsdA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m15-20020a05620a290f00b00783daee4340si13184436qkp.782.2024.01.31.14.22.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 14:22:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47240-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47240-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6B7EA1C216D2 for ; Wed, 31 Jan 2024 22:22:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6430C3C465; Wed, 31 Jan 2024 22:20:12 +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 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789646312279489290 X-GMAIL-MSGID: 1789646312279489290 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 Reviewed-by: Nishanth Menon --- 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");