From patchwork Mon Jul 24 22:30:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 125227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2135045vqg; Mon, 24 Jul 2023 17:15:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlFd1QK4qfU1oHAggGPBbxQix+gtPARi9zHW8Eed9JpE1bh9L5iBZ7nkAyeo57KgXdLQSKMq X-Received: by 2002:a05:6a20:607:b0:12b:fe14:907e with SMTP id 7-20020a056a20060700b0012bfe14907emr11510136pzl.20.1690244107890; Mon, 24 Jul 2023 17:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690244107; cv=none; d=google.com; s=arc-20160816; b=akQi2tS2zJUhMR8yhqiyiuxG1Go3ylB2K57GGLIrJvjE/2S+01WkuWcYhNweQaU8j0 NmpUEPTyUunfWu0brf+FySr/59HjQDlXWa4XvCV8h8CqVqgoSaDZsNfXMwy9LntQBSUk aX/yb8dtWeKu+xPNO8qVrzFfECWOZ1NCZy4HLpVabQB2621Z/0SPYHcRAwgzLSJoaoXw 0Me35NaOWtOnJWMQ4FUSr+pdTJgFjP2o8ZAJdB+INeaJ268yz4XIjNtg1xyxHUuOivjw /XhDw/yMvtnaFlgs2s9mn52lJyFl5imyoBi3HLlZxvwQQpWoi+F8/BpoWFADNcIelxFP TzUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nN0DJtoEROST43YwVQQar5B/uJDpBZz6QURRfq3efdA=; fh=esKqhhqT9kv/WnJQoh5OP9uyzs69uMFfrxulQS9k9KQ=; b=L7qNaOwHZHEOV/zHjSdLHQCgayZDDz+k1vXNMkns3H+UPxHLfBDdQR2VP8uvfzRLwI YTNH20jGp91fZ41ye87zhn0ALMLYhIIGvZPAz4rle0IHzJ4i5RUgRUbMhl8QXrApZXQu EobW+W+cn+gdPLeoZpwbwADXapxoA8IJ0noFPyuPueAWu6EYC+xxgClNYdLGof8Qqf+w 3Grk8FbAvFkSk1Ambq3uGUko7VgfiLMro3m27rmZmvWVVIBUA3v05wMO2EMd1YJhVbOH 4z5F9am/yjODJCP3PXDdADfMrJzS0bJ6K+IFeAKhhVDJD6EPQmByLRjM4hBGK8oQUYi9 2EVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FuvxLIZ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k18-20020a6568d2000000b0055fedbf226esi9910778pgt.674.2023.07.24.17.14.55; Mon, 24 Jul 2023 17:15:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=FuvxLIZ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbjGXWbt (ORCPT + 99 others); Mon, 24 Jul 2023 18:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230251AbjGXWbr (ORCPT ); Mon, 24 Jul 2023 18:31:47 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E76371735; Mon, 24 Jul 2023 15:31:36 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36OMMYf8017581; Mon, 24 Jul 2023 22:31:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=nN0DJtoEROST43YwVQQar5B/uJDpBZz6QURRfq3efdA=; b=FuvxLIZ0/vlLyXC6DzO2ISgcd8RaUzhxm+hMWEKruPKEeVdxbEA1QijLvuqgIRVIRLTW /SckP/wSk7pNlFYP6u5KZOk1TYLZgeE//nRNfkiMC1gYzwMUns9d0RjTNc9f+8r//Es5 kfV/EAAI1JCP+R8ZyAwervbi2jD5wyzDpCYbtnEA+TNqzCtLG8/4ivxHWLysMLeZ3iar nuOe2fJoQS/lYM58gzg4IKCQgJRT3J4kgFzW/PkGFVtmI0wdHt8Xgrf7Et4KIhcoV4ZN AwJFCN1hmstd68601ZE/1KHTQ8CFs9QU41bjCsunZ5j5FA4I+VHOnCrGsQ8gFqZkrhux +g== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s1qcysk2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 22:31:28 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36OMVRDh003758 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 22:31:27 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 24 Jul 2023 15:31:27 -0700 From: Elliot Berman To: Mark Rutland , Lorenzo Pieralisi , Sebastian Reichel CC: Elliot Berman , Krzysztof Kozlowski , Conor Dooley , "Rob Herring" , , , , , , , Satya Durga Srinivasu Prabhala , Melody Olvera , "Prasad Sodagudi" Subject: [RFC PATCH 1/4] power: reset: reboot-mode: Allow magic to be 0 Date: Mon, 24 Jul 2023 15:30:51 -0700 Message-ID: <20230724223057.1208122-2-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724223057.1208122-1-quic_eberman@quicinc.com> References: <20230724223057.1208122-1-quic_eberman@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: AO2zXQZKTTZ9AQV95k8OBBjoBe9P4s9R X-Proofpoint-GUID: AO2zXQZKTTZ9AQV95k8OBBjoBe9P4s9R X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_16,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 mlxscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240196 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772349405558547411 X-GMAIL-MSGID: 1772349405558547411 Allow magic from the reboot-mode driver to be defined, but 0. This is useful when the register/command to trigger reboot needs 0 to be written. This is the case when the "default" reboot mode is to enter a crash dump collection mode (e.g. when triggered by a watchdog) and Linux doing a normal reboot requires the setting to be explicitly reset to zero. Signed-off-by: Elliot Berman --- drivers/power/reset/reboot-mode.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c index b4076b10b893..a646aefa041b 100644 --- a/drivers/power/reset/reboot-mode.c +++ b/drivers/power/reset/reboot-mode.c @@ -19,11 +19,10 @@ struct mode_info { struct list_head list; }; -static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot, - const char *cmd) +static bool get_reboot_mode_magic(struct reboot_mode_driver *reboot, + const char *cmd, unsigned int *magic) { const char *normal = "normal"; - int magic = 0; struct mode_info *info; if (!cmd) @@ -31,12 +30,12 @@ static unsigned int get_reboot_mode_magic(struct reboot_mode_driver *reboot, list_for_each_entry(info, &reboot->head, list) { if (!strcmp(info->mode, cmd)) { - magic = info->magic; - break; + *magic = info->magic; + return true; } } - return magic; + return false; } static int reboot_mode_notify(struct notifier_block *this, @@ -46,8 +45,7 @@ static int reboot_mode_notify(struct notifier_block *this, unsigned int magic; reboot = container_of(this, struct reboot_mode_driver, reboot_notifier); - magic = get_reboot_mode_magic(reboot, cmd); - if (magic) + if (get_reboot_mode_magic(reboot, cmd, &magic)) reboot->write(reboot, magic); return NOTIFY_DONE; From patchwork Mon Jul 24 22:30:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 125213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2100831vqg; Mon, 24 Jul 2023 15:56:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFXOd/lbYuZE08duZ1Ce4vIkoIE2hR8OgsRfYqkxFl0LPUXMa+1ZP/480s/Y5SPUOLD9KTp X-Received: by 2002:a17:906:cc46:b0:98e:370c:be69 with SMTP id mm6-20020a170906cc4600b0098e370cbe69mr593418ejb.6.1690239413795; Mon, 24 Jul 2023 15:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690239413; cv=none; d=google.com; s=arc-20160816; b=uk/599RhN61grcwIrSjjZzLEmuWsM8n2b0nCF0b9dOWR8GXKm4KwYRqGszwOKC2W0c EzBVccxrdK+yz+A8mIHLnK//EKsxnca7pPn3/3Hs9NsWpfR73BvIgbGtf8+rz5QePX9q b3bhQaaNk6yWlQeFRzLoTNgAu7staK4QWtDTleMEPNsg0D05yXwK9r7s/GyQx0+93l36 O/rMv0DQW0ouecPkveRjbfyqPiE80IXhZ6RWZJfVie7SLSb1jQpY8PEoyxH74BMpek/l EYonahXDMHsENwOUVJ2LIYhmO/HowI4oLwmsdBsiZvLYrzxKA22ZgYqPjcNXeRxFH4Cu sozQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ImFe609Eic1YBB5kSpNALZ36/D9/d6110fqekqekEdU=; fh=esKqhhqT9kv/WnJQoh5OP9uyzs69uMFfrxulQS9k9KQ=; b=Ys/b3+OeiOUe80/WMaQKPWGhE6Bqr7y+djgcrnK6AzufqaWwducflXh8cYcA9X0xdK UFL/Hx+MgDPrNhyJEE2oGu3/XLl54N6THvIMO9jLafwlc67PbOxFW85JBiXlQDd4BkTM Np9fwX4nKLh/zZrECoC4h3xlk4ftWwF62+lvLxAH5Bz+hnlV/Rs4P+51ghK1wulm1RN5 lrXIWpkhRp6rFnxvU3S3ydRWLA2p8VawDTv9sN3VZrVxDmuaRcfch2EIeMRGgyfSKauh hx7+a1esHCflACxqFwRqRJFIDh1p/J/+NaVWUwcwk6gsKrSjpa9mY/ZwAOvv2O+O6iDi +Dig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="RM7/TIcj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a1709063acb00b0099b4b6db8a4si6959324ejd.868.2023.07.24.15.56.30; Mon, 24 Jul 2023 15:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="RM7/TIcj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231180AbjGXWb4 (ORCPT + 99 others); Mon, 24 Jul 2023 18:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbjGXWbx (ORCPT ); Mon, 24 Jul 2023 18:31:53 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E31381BD0; Mon, 24 Jul 2023 15:31:38 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36OLRSgb009885; Mon, 24 Jul 2023 22:31:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=ImFe609Eic1YBB5kSpNALZ36/D9/d6110fqekqekEdU=; b=RM7/TIcjBTros3NwHz5w6TUhD3B1oqS6vIwMCf/5/84gNecd8GwzaGK2aQzJz5so6jp5 S7us/4lx4b06ow+8N0JYgOgo00i/jyHcPOLoYMNyNUDJvFD2iCtK3Tjstt8DTtcCTIG+ H72/Ndrdwm9m+pRKiN6QEhYVz7fIaRKXlvjp6RHNkR7ap+tuwurdnCT3Ln3qGhQKIhoK 7/KmULTjPS86Pwq3zNlZurq+GJza5mYx/QOlMuGRXYajnW2CrX3gDC1pGhJSr3BjIGVd qJOjozdYRAbZXDw8DQxoFocUUWucm/T32rKpLeRj60Sqzpneb2sCJY8r7fVWdoRE5Ap6 TQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s1y6m0dfm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 22:31:29 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36OMVSNX005786 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 22:31:28 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 24 Jul 2023 15:31:27 -0700 From: Elliot Berman To: Mark Rutland , Lorenzo Pieralisi , Sebastian Reichel CC: Elliot Berman , Krzysztof Kozlowski , Conor Dooley , "Rob Herring" , , , , , , , Satya Durga Srinivasu Prabhala , Melody Olvera , "Prasad Sodagudi" Subject: [RFC PATCH 2/4] power: reset: reboot-mode: Wire reboot_mode enum to magic Date: Mon, 24 Jul 2023 15:30:52 -0700 Message-ID: <20230724223057.1208122-3-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724223057.1208122-1-quic_eberman@quicinc.com> References: <20230724223057.1208122-1-quic_eberman@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 1aDI5-AxIkTpNB5CgK5-o3dkItqfZphT X-Proofpoint-ORIG-GUID: 1aDI5-AxIkTpNB5CgK5-o3dkItqfZphT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_17,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240196 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772344483623836653 X-GMAIL-MSGID: 1772344483623836653 Allow the reboot mode type to be wired to magic. Signed-off-by: Elliot Berman --- drivers/power/reset/reboot-mode.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c index a646aefa041b..4ea97ccbaf51 100644 --- a/drivers/power/reset/reboot-mode.c +++ b/drivers/power/reset/reboot-mode.c @@ -22,12 +22,8 @@ struct mode_info { static bool get_reboot_mode_magic(struct reboot_mode_driver *reboot, const char *cmd, unsigned int *magic) { - const char *normal = "normal"; struct mode_info *info; - if (!cmd) - cmd = normal; - list_for_each_entry(info, &reboot->head, list) { if (!strcmp(info->mode, cmd)) { *magic = info->magic; @@ -45,6 +41,32 @@ static int reboot_mode_notify(struct notifier_block *this, unsigned int magic; reboot = container_of(this, struct reboot_mode_driver, reboot_notifier); + + if (!cmd) { + switch (mode) { + case REBOOT_COLD: + cmd = "cold"; + break; + case REBOOT_WARM: + cmd = "warm"; + break; + case REBOOT_HARD: + cmd = "hard"; + break; + case REBOOT_SOFT: + cmd = "soft"; + break; + case REBOOT_GPIO: + cmd = "gpio"; + break; + } + if (get_reboot_mode_magic(reboot, cmd, &magic)) { + reboot->write(reboot, magic); + return NOTIFY_DONE; + } + cmd = "normal"; + } + if (get_reboot_mode_magic(reboot, cmd, &magic)) reboot->write(reboot, magic); From patchwork Mon Jul 24 22:30:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 125233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2147940vqg; Mon, 24 Jul 2023 17:48:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGSWsh2y3E93yg50ZYV65x1R/S5KCve7OafbO/iDJG2iNqkMce0p2e4czgRGQq4T8Q0sVez X-Received: by 2002:a17:907:9625:b0:993:f664:ce25 with SMTP id gb37-20020a170907962500b00993f664ce25mr1006231ejc.19.1690246118758; Mon, 24 Jul 2023 17:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690246118; cv=none; d=google.com; s=arc-20160816; b=xjiDN5HhH040r3ejiVq4DyUhM6YpMAnvUNDeBjYg0r9rBfUahbnAHw+arSReOREw1g 2DObLblvvGOcrv67F4qeUWABFEZHi/hdOwBEB5UP2Y0XsEzpUbXwkbB0JaT4DVPOlLxo gUHfEfho/IB9TTx2zj8NYjkRrc/5j0D1q+Plmtc8+w+F59pIXop1zh0g7gItzygexVsa vhI18rWblgxS96UxfnWN6ndYNbjC8JOomOe94OjVDTYjkjbnU8q0X0/R2AiSKCQa29MM +bkq5Fm1SiHhmFzpGuPLe/61SaUTlwnd6eaw3/IjmPmn9m9+ET0NAVDGhNjt+Cc+HghO lq/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0RiqDvAsRoz+wat/BUC+Un9PsqnWtL24OIyCvnctV6A=; fh=Wq7/RrAzg7plO8nCfcGB/F1Jc7X55ArYFwKApxRIU/4=; b=Wk7UIcIgExU4ARKs9vZykdJFv9eroG09iN8NTyiu9q+f9ymr3+rE1qqi/1Rx+1TMWP 5eMwkmDlUxcmwFp8BF4ZtDJjtU365hlGPQWGRgGgK+4zcT0vETGLKQFKGg67fMgDef7B fwq29Iuf884IHPP+RsgDKXC4QOTYH+SEKDcFw995ldYtBvjAZgWVkx/xEDZrh619aT0p 6EE+O+i/KA5S90hf6Y1L1a5TxPeYXF0sAZ69AchKgmLc3l6qofLaEM2y06HFA3W7UZq9 mb49WMRzS0fHh8Q3zUgcVK+AbMBDQxougPkwyr2UIywxkRKkQW/wZO4lCjdtOfG9jG1j iTug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jSwYOX3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a1709064e8100b00993689daad1si7410772eju.116.2023.07.24.17.48.15; Mon, 24 Jul 2023 17:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jSwYOX3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231389AbjGXWcD (ORCPT + 99 others); Mon, 24 Jul 2023 18:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230362AbjGXWb6 (ORCPT ); Mon, 24 Jul 2023 18:31:58 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD6F01BD9; Mon, 24 Jul 2023 15:31:40 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36OKj0sR025253; Mon, 24 Jul 2023 22:31:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=0RiqDvAsRoz+wat/BUC+Un9PsqnWtL24OIyCvnctV6A=; b=jSwYOX3NDyEvudpBV/16k7U/XSFzhxw9l4D1MRLontm/ufK26H3VGUP4LzOzYmxzhRYk IQlihyVSfxWt+nC0rm6pOyGvIUS4CYmO05DBnGv07ifMqhPzb2igH9s2fpNLSB1d08RZ 2PUjxHVVLH3La7D0aX0CGN0TQx9I6dg3AhJCRh0MzQlCjP9TzAtuTDmNM+LyRP23t3fn BqxjCQQ9WRMgSJNkX3AT+SBL3/enTVlIMY9PIo5wgshBKMQfxrNiwFn55FTP3vZhmZiX ekaXlgGi9ZnbTBYmz6XDWnsmKBJvJCQCvk0hewBY5+/xuE/hDCxIbAoi/tsSmkqhCC8k jg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s1u3t92my-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 22:31:30 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36OMVTga000964 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 22:31:29 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 24 Jul 2023 15:31:28 -0700 From: Elliot Berman To: Mark Rutland , Lorenzo Pieralisi , Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Elliot Berman CC: , , , , , , "Satya Durga Srinivasu Prabhala" , Melody Olvera , Prasad Sodagudi Subject: [RFC PATCH 3/4] dt-bindings: power: reset: Document arm,psci-vendor-reset Date: Mon, 24 Jul 2023 15:30:53 -0700 Message-ID: <20230724223057.1208122-4-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724223057.1208122-1-quic_eberman@quicinc.com> References: <20230724223057.1208122-1-quic_eberman@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: mRLoo05zWGFRJvpu-xQK8I2LCYpYz64R X-Proofpoint-ORIG-GUID: mRLoo05zWGFRJvpu-xQK8I2LCYpYz64R X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_18,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240198 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772348794189129194 X-GMAIL-MSGID: 1772351514063103345 Add devicetree bindings for using PSCI SYSTEM_RESET2 with vendor reset types. Signed-off-by: Elliot Berman --- .../power/reset/arm,psci-vendor-reset.yaml | 35 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/reset/arm,psci-vendor-reset.yaml diff --git a/Documentation/devicetree/bindings/power/reset/arm,psci-vendor-reset.yaml b/Documentation/devicetree/bindings/power/reset/arm,psci-vendor-reset.yaml new file mode 100644 index 000000000000..18b0b8c167a1 --- /dev/null +++ b/Documentation/devicetree/bindings/power/reset/arm,psci-vendor-reset.yaml @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/reset/arm,psci-vendor-reset.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PSCI SYSTEM_RESET2 Vendor Resets + +maintainers: + - Elliot Berman + +description: | + PSCI SYSTEM_RESET2 supports vendor-defined reset types. This describes + the conversion of reboot modes to the reset types. + +properties: + compatible: + const: arm,psci-vendor-reset + +allOf: + - $ref: reboot-mode.yaml# + +additionalProperties: false + +examples: + - | + firmware { + psci-vendor-resets { + compatible = "arm,psci-vendor-reset"; + reboot-normal = <0x100>; + reboot-bootloader = <0x101>; + reboot-fastboot = <0x102>; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index d516295978a4..2da4c5f1917b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16982,6 +16982,7 @@ M: Mark Rutland M: Lorenzo Pieralisi L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained +F: Documentation/devicetree/bindings/power/reset/arm,psci-vendor-reset.yaml F: drivers/firmware/psci/ F: include/linux/psci.h F: include/uapi/linux/psci.h From patchwork Mon Jul 24 22:30:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 125217 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2111385vqg; Mon, 24 Jul 2023 16:18:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBmB+8C1JTLbPX4hYrVmX8jIKA6LOyhPTGQZmgAHy5kXxY9cFy1VbE/PYekakX4uuyNNxW X-Received: by 2002:a17:907:1dc3:b0:99b:5862:1fc9 with SMTP id og3-20020a1709071dc300b0099b58621fc9mr11229581ejc.46.1690240693164; Mon, 24 Jul 2023 16:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690240693; cv=none; d=google.com; s=arc-20160816; b=GMJGnafC6P2jaAR1zedRLMz0v5SS3EbKA2ZDKVqhbzAcPbGWViyyPYIBkeDl5M+JWi IBWiki8R3fFMv+A/XyVkWDB5uIHrTzK/evpBnyAHsxHuheiB6seDYItUAP9rnaE9ZLXw scnJxmjwvrBI4lCq1nGD+oM9K8yl5IZIAQqS3Obu5XLsGNSKGkXcbVr6wHeipcc8fpe5 Ev2BnJsKEo0KVO09ZIUimbl+laZKj9uL71CPERx31EXjgdNG8b/WlH8Cuoo1Nu6CyUEh Qsx8K63m8Vo1VlVL0mKkyjL/DM2Bufp7NF41BajPzh04ngO/4Z80n6GcVwQ+wt5qTBww d29w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7zCDwDuNPEk6XuxGoTgy162uXdxAuBzpKTYh0NZ7KkE=; fh=esKqhhqT9kv/WnJQoh5OP9uyzs69uMFfrxulQS9k9KQ=; b=cBGcKD7Fr32P1vKn07f/XpplUcpt2/CLHueANjUDdnC9c5OvQo/w9+G5LeOZlgTseh GCh1ENkPg3D/HhBPKNG5qfYhsOM5xFSozDidhUbDuo5uA/14eqVzI9sXtsqeHx3kH4Jw 8pT1FdZjYNPeYEpg5+SwenFUBwtsoq7uj7y3ij3ROFYQRZnKodEnDGEIFwgczzMJMKpI 6oNEL1MMKL63xZ4G4+eA5ZVMlQLO/f5sac/SFsCcHqe2LwAUbboikNz/bjEx7/5at03V mW8RqbpjpOcwYdQPaqyUjbR+Gy/o9ieqYL8wmf6/Vq3beGFpBGL4KGwYMNVC1SoBfdkA hWdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Wj5J1Nzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m5-20020a170906258500b00992d8355decsi6917855ejb.249.2023.07.24.16.17.49; Mon, 24 Jul 2023 16:18:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Wj5J1Nzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbjGXWcM (ORCPT + 99 others); Mon, 24 Jul 2023 18:32:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjGXWcB (ORCPT ); Mon, 24 Jul 2023 18:32:01 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDFDD19A0; Mon, 24 Jul 2023 15:31:41 -0700 (PDT) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36OLnIoq014121; Mon, 24 Jul 2023 22:31:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=7zCDwDuNPEk6XuxGoTgy162uXdxAuBzpKTYh0NZ7KkE=; b=Wj5J1Nzxf62puMxfMeKOecG44yRQ1iq9552b1upl7TSY3rw1LXuq8MHmecYkMQZPTbfQ pTcdrfTsShMVqPOl21aX+/Z9/zjcOtPGVf92RnbjxXOOPuH3QhMm+aB54dut8lXbfn1s N5lLOELHWkkitrepblp5J2kxCm4Xz9ZieecqfhHwmTP4sPtgW3MmeqvuWIT3KLy+EIB0 QfLjxef2fB8lBWSIDo/cR2x0PRSHJ26mv4aWZbLKrD3gA2tolXREX4ocHwfbmkheWODG HfMiMI8RbvveiB8MsiFdxcb8mK6G4OiJYabAvTh/CoDP7UdXfbXpQ4Sa1M7wLtrp/D4p iA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s1pfh9nqb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 22:31:31 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36OMVVYL000969 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 22:31:31 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 24 Jul 2023 15:31:30 -0700 From: Elliot Berman To: Mark Rutland , Lorenzo Pieralisi , Sebastian Reichel CC: Elliot Berman , Krzysztof Kozlowski , Conor Dooley , "Rob Herring" , , , , , , , Satya Durga Srinivasu Prabhala , Melody Olvera , "Prasad Sodagudi" Subject: [RFC PATCH 4/4] power: reset: Implement a PSCI SYSTEM_RESET2 reboot-mode driver Date: Mon, 24 Jul 2023 15:30:54 -0700 Message-ID: <20230724223057.1208122-5-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724223057.1208122-1-quic_eberman@quicinc.com> References: <20230724223057.1208122-1-quic_eberman@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: OamcRKc4R8jr9pYGFvttDRzCQiyKt5mV X-Proofpoint-GUID: OamcRKc4R8jr9pYGFvttDRzCQiyKt5mV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_18,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 phishscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240198 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772345825094547741 X-GMAIL-MSGID: 1772345825094547741 PSCI implements a restart notifier for architectural defined resets. The SYSTEM_RESET2 allows vendor firmware to define additional reset types which could be mapped to the reboot reason. Implement a driver to wire the reboot-mode framework to make vendor SYSTEM_RESET2 calls on reboot. Signed-off-by: Elliot Berman --- MAINTAINERS | 1 + drivers/firmware/psci/psci.c | 9 +++++ drivers/power/reset/Kconfig | 9 +++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/psci-vendor-reset.c | 49 +++++++++++++++++++++++++ include/linux/psci.h | 2 + 6 files changed, 71 insertions(+) create mode 100644 drivers/power/reset/psci-vendor-reset.c diff --git a/MAINTAINERS b/MAINTAINERS index 2da4c5f1917b..214b14c1da63 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16984,6 +16984,7 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/power/reset/arm,psci-vendor-reset.yaml F: drivers/firmware/psci/ +F: drivers/power/reset/psci-vendor-reset.c F: include/linux/psci.h F: include/uapi/linux/psci.h diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index d9629ff87861..6db73f9d2304 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -328,6 +328,15 @@ static struct notifier_block psci_sys_reset_nb = { .priority = 129, }; +void psci_vendor_sys_reset2(u32 reset_type, u32 cookie) +{ + if (psci_system_reset2_supported) + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), + reset_type | BIT_ULL(31), + cookie, 0); +} +EXPORT_SYMBOL_GPL(psci_vendor_sys_reset2); + static void psci_sys_poweroff(void) { invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0); diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index fff07b2bd77b..1474b9d51089 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -311,4 +311,13 @@ config POWER_MLXBF help This driver supports reset or low power mode handling for Mellanox BlueField. +config POWER_RESET_PSCI_VENDOR_RESET + tristate "PSCI Vendor SYSTEM_RESET2 driver" + depends on ARM64 || ARM || COMPILE_TEST + select ARM_PSCI_FW + select REBOOT_MODE + help + Say y/m here to enable driver to use Vendor SYSTEM_RESET2 types on + chips which have firmware implementing custom SYSTEM_RESET2 types. + endif diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index d763e6735ee3..d09243966b74 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -37,3 +37,4 @@ obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o obj-$(CONFIG_POWER_RESET_SC27XX) += sc27xx-poweroff.o obj-$(CONFIG_NVMEM_REBOOT_MODE) += nvmem-reboot-mode.o obj-$(CONFIG_POWER_MLXBF) += pwr-mlxbf.o +obj-$(CONFIG_POWER_RESET_PSCI_VENDOR_RESET) += psci-vendor-reset.o diff --git a/drivers/power/reset/psci-vendor-reset.c b/drivers/power/reset/psci-vendor-reset.c new file mode 100644 index 000000000000..95d027225185 --- /dev/null +++ b/drivers/power/reset/psci-vendor-reset.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0-only +/** + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +static int psci_vendor_system_reset2(struct reboot_mode_driver *reboot, unsigned int magic) +{ + psci_vendor_sys_reset2(magic, 0); + + return NOTIFY_DONE; +} + +static int psci_vendor_reset_probe(struct platform_device *pdev) +{ + struct reboot_mode_driver *reboot; + + reboot = devm_kzalloc(&pdev->dev, sizeof(*reboot), GFP_KERNEL); + if (!reboot) + return -ENOMEM; + + reboot->write = psci_vendor_system_reset2; + + return devm_reboot_mode_register(&pdev->dev, reboot); +} + +static const struct of_device_id psci_vendor_reset_id_table[] = { + { .compatible = "arm,psci-vendor-reset" }, + { } +}; +MODULE_DEVICE_TABLE(of, psci_vendor_reset_id_table); + +static struct platform_driver psci_vendor_reset_driver = { + .probe = psci_vendor_reset_probe, + .driver = { + .name = "psci-vendor-reset", + .of_match_table = of_match_ptr(psci_vendor_reset_id_table), + }, +}; +module_platform_driver(psci_vendor_reset_driver); + +MODULE_DESCRIPTION("PSCI Vendor SYSTEM_RESET2 Driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/psci.h b/include/linux/psci.h index 4ca0060a3fc4..0c652c12e0a8 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -21,6 +21,8 @@ bool psci_power_state_is_valid(u32 state); int psci_set_osi_mode(bool enable); bool psci_has_osi_support(void); +void psci_vendor_sys_reset2(u32 reset_type, u32 cookie); + struct psci_operations { u32 (*get_version)(void); int (*cpu_suspend)(u32 state, unsigned long entry_point);