From patchwork Thu May 18 14:02:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 95919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp542553vqo; Thu, 18 May 2023 07:38:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42nIpCa58CpDpV1IAEHlq8m0MyFYoLuTOwH/xm18AkqXCMgL/gXPWL3ezQAOgN6SZfJc5x X-Received: by 2002:a17:903:230f:b0:1a6:9762:6eed with SMTP id d15-20020a170903230f00b001a697626eedmr3060863plh.22.1684420736622; Thu, 18 May 2023 07:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684420736; cv=none; d=google.com; s=arc-20160816; b=FGELjJr3eiIEpRRb04gUf/ffKQGwhQ6HcVbP2muU8GQNdn2xAWbyJMnzruiRfOBGt0 98E83s+Nqy0xRIKsDqi9IgtsBi5T4I70rt7/eolvH5HMgyX5QZRvjj6X+x5F1JxJyPq3 YA0CfVc8fgIn+8qmuWt+0B5aI58aTQu28xTxUH3VpVJwBBcz+juk+eRk7LIG1ZTVblDB ZkO0fwQl0+dSHBfvGZcsPK4R//mjbTCPTqJaplj2JL9C19ReDYUT/YY64Y5ogNxH81jG W6j2jv1g9tqlAG6EaiSEpcmIgGoGOiUcRmzx8QZ2BUHpbBn7twbxi/oQB9uyPmm7ouVy cL+Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MOCIa/CAbEbWwY2wcBgLkKevxCcqHsPJBCWi4Dwjoy8=; b=ularLlbXdzAZkFGAb6LbOoKq1+j+f/bckzriKB6euuuxeoHfpFQuAMIvHOEBPANuIQ PtGFOJ1BA6d/OvqRbPYHy2dN9vwEXeUlYIP3+/wy5Ynk6UxU+xIHPF7OGBmtvu/PjX5T IXbqcg8uRqtWHv6KMktmcOm02m4D1bkpP0AvKBumM5M4X0LjDn1czU9xX2GV3VqiGWH7 DJreQn0qVeRsZpIGIzbakQykOI0FiUIWSMS7WquH+XhQihKYw71OfS1ZWh+VtIAnsjbg dLBwzoTepyskY/MzSN25t0GVGK+M5gj3SScRr6bmsRA2qpt3ny4Gx+StjjdqXuJd9Hwr xT0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=C71hGwpN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij5-20020a170902ab4500b001ab115a96c7si1339716plb.340.2023.05.18.07.38.41; Thu, 18 May 2023 07:38:56 -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=@gmail.com header.s=20221208 header.b=C71hGwpN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231559AbjEROCe (ORCPT + 99 others); Thu, 18 May 2023 10:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230144AbjEROCb (ORCPT ); Thu, 18 May 2023 10:02:31 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEF5A1B5; Thu, 18 May 2023 07:02:29 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9661047f8b8so373186166b.0; Thu, 18 May 2023 07:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684418548; x=1687010548; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MOCIa/CAbEbWwY2wcBgLkKevxCcqHsPJBCWi4Dwjoy8=; b=C71hGwpN1sn4os+rxtfcFFLDRAcsUmHzUvZcQQdWItrerPLa7/A1kb5Fzh9rgsn4vD 1S8jPUf5hvxMUQ4UncqPvoqz4RvTIP1FSkwgidBtXYrRtEuEWMiglnx5aThi6T8afSWr ltow4vfCDDeagoBVWmA23ANXpM2PfXbr3Wg6fUz9nBmQa0iokEknbj+NnwbQBJ/lTZQm DOABSrpi8bKwOKcEQjnzvmgA1RcJeFXvL1+X8zBCss+K5/YoeLy/Xfl0XMK4AOVpaKyD vHA7srwVMihmRlG0MzW5zciTpTRarPcAawWgvwboUfwZZ9yBEV8N8X3477iXJgFIla78 aRqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684418548; x=1687010548; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MOCIa/CAbEbWwY2wcBgLkKevxCcqHsPJBCWi4Dwjoy8=; b=QLsQw6DFMWZlfXQlbisiTZrtFdCs0WCvPjINjfkYyi1ZOZXOtBgdrMdHEo0/bhObjM f7+2SVK9BdBBwmKPDtodXiXQmUPOBAxeVvamERC1DrQ/P/T1D30JNuY+c8LSTlfap8xC qC5Z48VVrqD8gZTJimmxM3zoQfL+hnLooNIYjCyzW5MLMjUrnGNtd1XaF1LRm/i8vVQH fiapD0zZnuojYV5i5bo7SxuyN97aDXDSQTf/wTpO5AVy/i0kGLthNhRbmKoR25vsCzRj zREAE3Ro4/ngd4XvgOGE09GPC+vWFs0IqETIgVDy4PDA1np4CXm/Z7INKGpxEFDR23Fd osiA== X-Gm-Message-State: AC+VfDzDrSVeXvZwORujnXpq4a5QNfyIUOuzKB0gDcxmFOYpjhfPJ7r/ hNXULD+Zd+/S8PZbdTXPA2g= X-Received: by 2002:a17:907:2d92:b0:966:612b:c292 with SMTP id gt18-20020a1709072d9200b00966612bc292mr40975307ejc.11.1684418548073; Thu, 18 May 2023 07:02:28 -0700 (PDT) Received: from fedora.. (cpezg-94-253-130-143-cbl.xnet.hr. [94.253.130.143]) by smtp.googlemail.com with ESMTPSA id m14-20020a170906258e00b0096f272206b3sm997025ejb.125.2023.05.18.07.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 07:02:27 -0700 (PDT) From: Robert Marko To: agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, srichara@quicinc.com Cc: Robert Marko Subject: [RESEND,PATCH 1/2] firmware: qcom: scm: Add SDI disable support Date: Thu, 18 May 2023 16:02:23 +0200 Message-Id: <20230518140224.2248782-1-robimarko@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766241585651663633?= X-GMAIL-MSGID: =?utf-8?q?1766243158394058954?= Some SoC-s like IPQ5018 require SDI(Secure Debug Image) to be disabled before trying to reboot, otherwise board will just hang after reboot has been issued via PSCI. So, provide a call to SCM that allows disabling it. Signed-off-by: Robert Marko Acked-by: Mukesh Ojha --- drivers/firmware/qcom_scm.c | 23 +++++++++++++++++++++++ drivers/firmware/qcom_scm.h | 1 + 2 files changed, 24 insertions(+) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index fde33acd46b7..bdc9324d4e62 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -407,6 +407,29 @@ int qcom_scm_set_remote_state(u32 state, u32 id) } EXPORT_SYMBOL(qcom_scm_set_remote_state); +static int qcom_scm_disable_sdi(void) +{ + int ret; + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_BOOT, + .cmd = QCOM_SCM_BOOT_SDI_CONFIG, + .args[0] = 1, /* Disable watchdog debug */ + .args[1] = 0, /* Disable SDI */ + .arginfo = QCOM_SCM_ARGS(2), + .owner = ARM_SMCCC_OWNER_SIP, + }; + struct qcom_scm_res res; + + ret = qcom_scm_clk_enable(); + if (ret) + return ret; + ret = qcom_scm_call(__scm->dev, &desc, &res); + + qcom_scm_clk_disable(); + + return ret ? : res.result[0]; +} + static int __qcom_scm_set_dload_mode(struct device *dev, bool enable) { struct qcom_scm_desc desc = { diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h index e6e512bd57d1..7b68fa820495 100644 --- a/drivers/firmware/qcom_scm.h +++ b/drivers/firmware/qcom_scm.h @@ -80,6 +80,7 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc, #define QCOM_SCM_SVC_BOOT 0x01 #define QCOM_SCM_BOOT_SET_ADDR 0x01 #define QCOM_SCM_BOOT_TERMINATE_PC 0x02 +#define QCOM_SCM_BOOT_SDI_CONFIG 0x09 #define QCOM_SCM_BOOT_SET_DLOAD_MODE 0x10 #define QCOM_SCM_BOOT_SET_ADDR_MC 0x11 #define QCOM_SCM_BOOT_SET_REMOTE_STATE 0x0a