From patchwork Sat Mar 4 13:27:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13159859 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 E38F7C6FD19 for ; Sat, 4 Mar 2023 13:27:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbjCDN1w (ORCPT ); Sat, 4 Mar 2023 08:27:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbjCDN1v (ORCPT ); Sat, 4 Mar 2023 08:27:51 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 745631E28D for ; Sat, 4 Mar 2023 05:27:48 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id k14so7022392lfj.7 for ; Sat, 04 Mar 2023 05:27:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677936467; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CE+JnL554VLPGrdcTc20YFzCGjPgavHLDXyWnjlT8uQ=; b=hFDetAD7Gf3Uoj9lcHwDSwjbA+lpTNVXi9aHpKFB9gJOVRf6NZ287JAKeFQZAT5I4H Q5C/XumQWPXNO0bIN4ZIWaw3eFojXM49nlbFqWFbB4v/QHyjk27LbIBVIQNhuOMpsCmT cIHvA7bWUl+ddj8XnggIDpf6/aG+VInJvMLqoF2Tl8oBPZ0lrNkqlal6AzuWDCdUp50Z bIgpBuCG/uWpHt9EIYUerv9yW6ROHy7AY/7NOhGe5zf3zz6cp1XzeNSQki5jkRCfdsK5 nuGylEvFzQAkf7hNobrBhFetuWyxTvmv+FNt1tHPV187WkUOf/MfuqeWBtBgDV9P3T9p f2kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677936467; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CE+JnL554VLPGrdcTc20YFzCGjPgavHLDXyWnjlT8uQ=; b=EdGoi1Qb81XKXqVqfbkY2Dgn64RdcQnzxu7lAnmnUAYp8WxYkxVYAEl7BlT7o8vbwy dfiSUlNYHYsqaoRNqXuLcfA2Nw6I2WAnCeBxYIaqsVABQK4eGKWRwHJmAz6SbJH3DPX1 dTLKrVrX605TbgwJApzX+o3nkh6ZA/oMG7R7jPi5FcI5JebZv8P8gi0EhibJp4aOJY/r 1nI81/OK1XsTJGLTSgii02DQBj6PZirfUsyNQFhIrxX1FnwQQ51buRO+0AuHfMn+ovDC nN6NVLV8yJNZ+CiiCA2A+CXN3c4ktlGvLh8kjTfRPkM8KI/xr5/PyBla4Heq8wOkMdIE ccWg== X-Gm-Message-State: AO0yUKVZrQ2jl+2TJeQF1T5l5mPynLb4SARirN7ygbcRmJjkRhbQ0F/2 aZq0CvKm0lHPyOTVgDscaOu48w== X-Google-Smtp-Source: AK7set9Cqm4WAuyCFKHRyedsaPR4X+/m2vJJOe9x8dDgR1qnb9vqqd4H+k3gbsPWadxEbxydFh7MWQ== X-Received: by 2002:a05:6512:249:b0:4dc:4cb6:6752 with SMTP id b9-20020a056512024900b004dc4cb66752mr1399674lfo.52.1677936466825; Sat, 04 Mar 2023 05:27:46 -0800 (PST) Received: from [192.168.1.101] (abym99.neoplus.adsl.tpnet.pl. [83.9.32.99]) by smtp.gmail.com with ESMTPSA id j15-20020a19f50f000000b004e7fa99f2b5sm342975lfb.186.2023.03.04.05.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Mar 2023 05:27:46 -0800 (PST) From: Konrad Dybcio Date: Sat, 04 Mar 2023 14:27:38 +0100 Subject: [PATCH RFT 03/20] clk: qcom: smd-rpm: Add support for keepalive votes MIME-Version: 1.0 Message-Id: <20230303-topic-rpmcc_sleep-v1-3-d9cfaf9b27a7@linaro.org> References: <20230303-topic-rpmcc_sleep-v1-0-d9cfaf9b27a7@linaro.org> In-Reply-To: <20230303-topic-rpmcc_sleep-v1-0-d9cfaf9b27a7@linaro.org> To: Andy Gross , Bjorn Andersson , Michael Turquette , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Shawn Guo , Taniya Das X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1677936461; l=2703; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=VBzwbaXA+dk9JgBRximop+B+UNGSjqkXnpU8yOYDpzg=; b=vRvRa3GKRs17Whe+QiRk3sO5TcIbgjnytITqODU1Z5zQCAVGQX2c1QUVNHaml1lKhqyNINZN7wAh 2up2QNTxBKgrxReKmOcfWimBYf+3AVFi4y7oV5nKza0tDL5Kx8v3 X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Some bus clock should always have a minimum (19.2 MHz) vote cast on them, otherwise the platform will fall apart, hang and reboot. Add support for specifying which clocks should be kept alive and always keep a vote on XO_A to make sure the clock tree doesn't collapse. This removes the need to keep a maximum vote that was previously guaranteed by clk_smd_rpm_handoff. This commit is a combination of existing (not-exactly-upstream) work by Taniya Das, Shawn Guo and myself. Co-developed-by: Shawn Guo Co-developed-by: Taniya Das Signed-off-by: Konrad Dybcio --- drivers/clk/qcom/clk-smd-rpm.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c index cce7daa97c1e..8e017c575361 100644 --- a/drivers/clk/qcom/clk-smd-rpm.c +++ b/drivers/clk/qcom/clk-smd-rpm.c @@ -4,6 +4,7 @@ * Copyright (c) 2014, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -178,6 +179,8 @@ struct clk_smd_rpm_req { struct rpm_smd_clk_desc { struct clk_smd_rpm **clks; size_t num_clks; + struct clk_hw **keepalive_clks; + size_t num_keepalive_clks; }; static DEFINE_MUTEX(rpm_smd_clk_lock); @@ -1278,6 +1281,7 @@ static int rpm_smd_clk_probe(struct platform_device *pdev) struct qcom_smd_rpm *rpm; struct clk_smd_rpm **rpm_smd_clks; const struct rpm_smd_clk_desc *desc; + struct clk_hw **keepalive_clks; rpm = dev_get_drvdata(pdev->dev.parent); if (!rpm) { @@ -1291,6 +1295,7 @@ static int rpm_smd_clk_probe(struct platform_device *pdev) rpm_smd_clks = desc->clks; num_clks = desc->num_clks; + keepalive_clks = desc->keepalive_clks; for (i = 0; i < num_clks; i++) { if (!rpm_smd_clks[i]) @@ -1321,6 +1326,24 @@ static int rpm_smd_clk_probe(struct platform_device *pdev) if (ret) goto err; + /* Leave a permanent active vote on clocks that require it. */ + for (i = 0; i < desc->num_keepalive_clks; i++) { + if (WARN_ON(!keepalive_clks[i])) + continue; + + ret = clk_prepare_enable(keepalive_clks[i]->clk); + if (ret) + return ret; + + ret = clk_set_rate(keepalive_clks[i]->clk, 19200000); + if (ret) + return ret; + } + + /* Keep an active vote on CXO in case no other driver votes for it. */ + if (rpm_smd_clks[RPM_SMD_XO_A_CLK_SRC]) + return clk_prepare_enable(rpm_smd_clks[RPM_SMD_XO_A_CLK_SRC]->hw.clk); + return 0; err: dev_err(&pdev->dev, "Error registering SMD clock driver (%d)\n", ret);