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: 13246858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC7E5C77B7D for ; Thu, 18 May 2023 13:59:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbjERN7z (ORCPT ); Thu, 18 May 2023 09:59:55 -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-Google-Smtp-Source: ACHHUZ5Y0by3v8Yl1Lw6NT7oS57WKekUeoZOfbdpm/ePKEDwLD2A/FGlPgTnC7gDk/Gr0b1JWxM8hA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 From patchwork Thu May 18 13:59:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 13246859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BB42C7EE24 for ; Thu, 18 May 2023 13:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231434AbjERN74 (ORCPT ); Thu, 18 May 2023 09:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231183AbjERN7y (ORCPT ); Thu, 18 May 2023 09:59:54 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E5D0E5C; Thu, 18 May 2023 06:59:53 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-965ab8ed1fcso370060166b.2; Thu, 18 May 2023 06:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684418392; x=1687010392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y2Hw87l7Ts/Jxr3HsiObApCTHPM3x3z16x4yMMIWg7U=; b=ha+I138R37UHZdgIlxPcdThYdbs6YEMmtrfjUKYO4mEEWUIkxEbBvhIlitda1qGTR8 DFPeF3QECr8G62AP0XOTaasC52PsLKCsNqCJpzibJZMUk+BwHQkVabqxN/3/w9gFvEzu A+bxxU25eSDFaFCDyTUmcLi5ZZ+YE5DcKw41oNAF0+SiB/e+7HNQE2JY6fmrrfFag+s8 xJeaNkVsabjcepOGAa+X2y2W2eB4X+rhqDL4Yp94CzGB4rFYWhDyuK5E5mWOJdDOyXjp 6EToNJtjkC7rVOX2l1rdFMGCwhwg0gtko5RXiwb3lEPcIw8E/mmZJnKQft8CYzQ4+6kR 8kdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684418392; x=1687010392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y2Hw87l7Ts/Jxr3HsiObApCTHPM3x3z16x4yMMIWg7U=; b=fJPr/19hvuCvC1vP/a2pa1wNeBiqMisMbvx81GSGa0v4NYvZ6CCI6KWnYbu9NFmpam 1gfxNmYtOBVXj209rJ14g4FoIRM3VAie7P+fWruELjpNMCHMkAt6+yFIZ9/V6LbGFejJ TLowF+g/xnyepEoh/H5Ukuk/qEmbsESyHTpANOqoXLOzoSu5d9p7hmVNGhAmPfH37TgG LTFCzUchjiUu0hRUrraq9xYPeRR+kOFhzw5hztbrFo/Ae6uLNildzvfh7tPkqBVL4f8i qaOFvC6UFeTczSBAd6MfgcL9dzw9n/fsyCcID0ocoGGOGthIgUPMFJMik3RY0pAEOlD3 b8Rg== X-Gm-Message-State: AC+VfDxwT8EipsX15qQEqvskHYV1XzhOKCaVwlzfGF7jgbnz8V60mIBQ V6SbmGN9xmzHXhYCDJwp+2k= X-Google-Smtp-Source: ACHHUZ6KBM5XBHs+4pu1U3pGzNjbd8A+aABNxvAEb37wiK/VlxqXDZEZsCOoDDky+vdHIXzysgvKBw== X-Received: by 2002:a17:907:8a14:b0:8ae:11ca:81de with SMTP id sc20-20020a1709078a1400b008ae11ca81demr38023635ejc.34.1684418391309; Thu, 18 May 2023 06:59:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 06:59:50 -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 2/2] firmware: qcom: scm: disable SDI on IPQ5018 Date: Thu, 18 May 2023 15:59:45 +0200 Message-Id: <20230518135945.2248451-2-robimarko@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518135945.2248451-1-robimarko@gmail.com> References: <20230518135945.2248451-1-robimarko@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org IPQ5018 seems to have SDI (Secure Debug Image) enabled by default which prevents normal reboot from working causing the board to just hang after reboot is called. So, let disable SDI during SCM probe for IPQ5018. Signed-off-by: Robert Marko --- drivers/firmware/qcom_scm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index bdc9324d4e62..c6a38ce49fb0 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1525,6 +1525,14 @@ static int qcom_scm_probe(struct platform_device *pdev) if (download_mode) qcom_scm_set_download_mode(true); + /* IPQ5018 seems to have SDI (Secure Debug Image) enabled by default + * which will prevent normal reboot causing the board to hang after + * making the reboot call. + * So, make a call to SCM to disable SDI. + */ + if (of_machine_is_compatible("qcom,ipq5018")) + qcom_scm_disable_sdi(); + return 0; }