From patchwork Thu May 18 13:59:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 95912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp525331vqo; Thu, 18 May 2023 07:13:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7LXd9SzJipWUhANcydrKGFWzru0ls/boxaNhFKSb+nuYZtTlOlGakxTMLl9x894XxdQiSm X-Received: by 2002:a17:903:234c:b0:1aa:ffa9:9260 with SMTP id c12-20020a170903234c00b001aaffa99260mr3016663plh.7.1684419236687; Thu, 18 May 2023 07:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684419236; cv=none; d=google.com; s=arc-20160816; b=eoLoMVP6FyKPafwNNrXDzPESwV3ZrL7MuFULv+4aCmBUArM+Hw917lLbZSWI8zzfix PW6YNWvk8iRJfdDhPfxUFt+Wxru1sIzb/BgMx8sWoVxo/mb/NDgq5/S/gi/RsevObMds C4s8zyPLTJcHn5j7BI3cQmjPykudKU9mK0YD1s9wbVeYP9w9vy7YRcRqR03GyzZVqYhO oNtnkNd4fgGsC6D80/7BeLQq/xBkp+3JTwbUWbQgTrRaykuX7qmNnhUCjSlnC+l3hPRG gIzBjBZWYSTZUjJM1Vy9kKtPHIKfnUw8wiikYW4JDa99+pf50PIeesb4awtj45bL2l+g pwaQ== 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=wYO/Yg3XawqMvcTbQvVGF7sRmAAkz7hHN5gY9mM8y2QwdbmeDd7qMVYiPXagruPlmv n2fqLSJcGTtd+inrknclkHz/+osHrd2e1QyaprtpnnAje9HnbreWVGZYxizcF2DOSEWd pE0zfCtA/+G+SQuMu4xXEydDKFZ+jyMoTkR8t+I4+/SLhixABT9UHUpbL2GqdMuSKvG8 IfxOgdGZBREbOP5iHzfuHNcWlJDcDYKcL1Gt61Y9W1jFTILPGzHPf/2oiHByQcP9hLpl RmNuhQFP03YCWd9wXlkf6pNr/xUhLxaGf/aG5un31j9Y3wdQV9OY59AjRtkfG5Tc+mxQ BC9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MYElUonJ; 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 p2-20020a170902eac200b001aafb6fcf51si1384205pld.253.2023.05.18.07.13.41; Thu, 18 May 2023 07:13: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=MYElUonJ; 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 S231444AbjERN74 (ORCPT + 99 others); Thu, 18 May 2023 09:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjERN7y (ORCPT ); Thu, 18 May 2023 09:59:54 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AF910DA; Thu, 18 May 2023 06:59:51 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-510dabb39aeso2286704a12.2; Thu, 18 May 2023 06:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684418390; x=1687010390; 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=MYElUonJ2j2KjZKx7Twde5yHiRkQvW/PdI3AGMfGxdtGnfN8dXzGvaimrUD8FcBHJe PW54Pz8LSWQBma9IT0kE53k8gko9rFIW2YurwaQuJxnFYTKMl5d8gF8V9/FjpFJZfKra MtoJ4mo7QjDTy6dxI47j70KtPuKqnrFrHqmzq9tPTt26NFJV3fshXz1NujNyfwXsayKM uxoMGUHgvudN7OEJ7UWVa/U7NMPGrCrGNrK2Bw+raikLhdQZWdbBjWSyiuoDVlDYomcQ cZukX+z5eDJPjtvS9iwxXOki9iYqcHStNTO6C79TkxzgX9ewtkz2Vet5L8QblPa3dk1K SqOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684418390; x=1687010390; 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=LTfCPL09JFwoSowWLr3BkFvMj67CGwRL6xMdWQvsKWMNUjWMf4wU4z1CbZQ88ZKgUc UE7dhlNEgLyvyU4D5VTZ1m/bVg0Qw01oCc/kXd83+USFpYVBxMa3RFVYQf6FUnter2Gr sA/OXr85ka+lw7ftmEGQeJ+UW/ZFRtyW/9Ue9H0bOnwX32DBu+QykX/6VVo+2fzrnmNA yg/cCI9CCLMK03mSydZ4VB6ryVfDhtlwlUVmc8FXw6YigmyqJwFiDYlmCKnSEOo90fcR hqHGZxiwGIu0g5bBIy4p122h8fDQQ7AH32y+B8MQL55O12f5R6LVYL3fXYdjCjAxCrIC /0GA== X-Gm-Message-State: AC+VfDyqOunkKLtl3D/xkjFspJDKvzvv2Tti1drtFrHz8wGtuJ0PTW4r c62nqzO6P9AT9HzwgtrurSg= X-Received: by 2002:aa7:dd51:0:b0:50c:52d:7197 with SMTP id o17-20020aa7dd51000000b0050c052d7197mr4459858edw.2.1684418390174; Thu, 18 May 2023 06:59:50 -0700 (PDT) Received: from fedora.. (cpezg-94-253-130-143-cbl.xnet.hr. [94.253.130.143]) by smtp.googlemail.com with ESMTPSA id t28-20020a50d71c000000b0050d89daaa70sm669003edi.2.2023.05.18.06.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 06:59:49 -0700 (PDT) From: Robert Marko To: agross@kernel.org, andersson@kernel.orgm, konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_srichara@quicinc.com Cc: Robert Marko Subject: [PATCH 1/2] firmware: qcom: scm: Add SDI disable support Date: Thu, 18 May 2023 15:59:44 +0200 Message-Id: <20230518135945.2248451-1-robimarko@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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?1766241585651663633?= 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 --- 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