From patchwork Sun Mar 13 19:04:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 550979 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 84220C4167B for ; Sun, 13 Mar 2022 19:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235328AbiCMTGT (ORCPT ); Sun, 13 Mar 2022 15:06:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235319AbiCMTGR (ORCPT ); Sun, 13 Mar 2022 15:06:17 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2B754BBAB; Sun, 13 Mar 2022 12:05:04 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id yy13so29628843ejb.2; Sun, 13 Mar 2022 12:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8P3wAYvgFlPve71dG0z5aPiI1G8WoaU4vYr3l4vmoOE=; b=mNHZ2HwvOU0rfN62Ty/YCb8SbLQ6QuDavrDPDiTkmFYkV4/JnHmHB7Or51GDN5+pT0 sGf3y7gY8ZM0aQCWBiZjUmoEglvaRmnGKmHqjlO+h44R/UGT7/15ftGEqNJMlpDMGedv MrbI+avm5+dToHe7WADil4FPPKqKcnLmG5QZSaPRTi9Y8vW97M1rrSFhPqT54ShkQffM qXfEJBanjpqpP4w8XOMNkEIkGzh3CYkacd7GQ6Y0it53u1YvA8Bf6QjO/jAn6kOW0WrP 3n5Aj7hgh8BNSMnmJEcF30r7R2nEY6BjVsnztuP+Nts75MGQkuJvYWpyCf3RGUmaXcCD dvlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8P3wAYvgFlPve71dG0z5aPiI1G8WoaU4vYr3l4vmoOE=; b=UYEoYMuwotcEAVRUIElTkEnhSblYpolD4UPUBezOTOhEXcVHuWDYvoZhsAwa/V/3RR yoEaEWeAcCYctJqUnD+WAzZkT1N7QCMdeKEpOduJxJc8ge8QRnnUTSIL9TgupXVs6KAh SnG6bRj3QCV8hJmIAuqdzF8jBnkNZoxEFe0AJabrKAYaF7v+6ZrCE7k5nHbH/1M25DSl UUh1ZbxjCRh/HfA69QS2nBf1rM9/kZt9KZrSQNG3xC1HzpXLEiKW7xN1DVWbKsuqL/1M s4Bx/GXvlscj8yjSC38yLvX6XBEkHaBibQTc9E6ZmGEPhYOOT6wSMxCDNJFcX6ZoZR46 H3SQ== X-Gm-Message-State: AOAM531lyU+Yd5qEmrqXf6wOuwQtgdUFKX8xVnrnPygpL/CAy67zkBB0 qGgpdZstPK0hAfpT+9PMhLtQAGDrF9U= X-Google-Smtp-Source: ABdhPJz5jVjxW9w997O8Vre9I2Mw79xpEHQfkAKrTiTOdLWduAIIPD3FmQ/hxHT56jQl/yzN44QvgQ== X-Received: by 2002:a17:906:5d0f:b0:6da:bb7a:4da with SMTP id g15-20020a1709065d0f00b006dabb7a04damr13484301ejt.183.1647198303261; Sun, 13 Mar 2022 12:05:03 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm5856697ejk.119.2022.03.13.12.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 12:05:02 -0700 (PDT) From: Ansuel Smith To: Rob Herring , Bjorn Andersson , Andy Gross , Michael Turquette , Stephen Boyd , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Ansuel Smith , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 02/16] clk: qcom: gcc-ipq806x: skip pxo/cxo fixed clk if already present Date: Sun, 13 Mar 2022 20:04:05 +0100 Message-Id: <20220313190419.2207-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220313190419.2207-1-ansuelsmth@gmail.com> References: <20220313190419.2207-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Skip pxo/cxo clock registration if they are already defined in DTS as fixed clock. Signed-off-by: Ansuel Smith --- drivers/clk/qcom/gcc-ipq806x.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/clk/qcom/gcc-ipq806x.c b/drivers/clk/qcom/gcc-ipq806x.c index d6b7adb4be38..27f6d7626abb 100644 --- a/drivers/clk/qcom/gcc-ipq806x.c +++ b/drivers/clk/qcom/gcc-ipq806x.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -3061,15 +3062,22 @@ static int gcc_ipq806x_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct regmap *regmap; + struct clk *clk; int ret; - ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 25000000); - if (ret) - return ret; + clk = clk_get(dev, "cxo"); + if (IS_ERR(clk)) { + ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 25000000); + if (ret) + return ret; + } - ret = qcom_cc_register_board_clk(dev, "pxo_board", "pxo", 25000000); - if (ret) - return ret; + clk = clk_get(dev, "pxo"); + if (IS_ERR(clk)) { + ret = qcom_cc_register_board_clk(dev, "pxo_board", "pxo", 25000000); + if (ret) + return ret; + } ret = qcom_cc_probe(pdev, &gcc_ipq806x_desc); if (ret) From patchwork Sun Mar 13 19:04:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 550980 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 3C97EC43217 for ; Sun, 13 Mar 2022 19:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235063AbiCMTGS (ORCPT ); Sun, 13 Mar 2022 15:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235320AbiCMTGR (ORCPT ); Sun, 13 Mar 2022 15:06:17 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 128EF4BFD2; Sun, 13 Mar 2022 12:05:06 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id kt27so29712064ejb.0; Sun, 13 Mar 2022 12:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XhL5PcXPAVYZIaqVjbCyrF3IgCwpUk1BeN4L/hsgGTo=; b=D2y43uQNu2B9yDOF3YS3L8VYNVn6768Gl3ngt+1HuCil5SpthBL2RL8oGAbbQ/bjx6 ak1cP31XU1tdsTT17466uxqN6UdZi/zchiSDQpSxPIwBUJ+XjMDyhmHxT//rSRlYVodq 1AizAPq3jDiSeE8daDw7zL5ZghbpWO3858OyiAN47TjfKzLEu52MzNCsbw50B6IjyIMp wVNYphBWpACAGHJ5oc6wuJnXZROaxTXQSxyFcqBnRoen3tU7qTg9hI6Itth/sK39tb4E stlhNwl96F4NN8QNEz4V6EMIEp8O0abMJ22Zi0hrrFvm8dMFVrBC5NNayZr2IURR06C8 raUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XhL5PcXPAVYZIaqVjbCyrF3IgCwpUk1BeN4L/hsgGTo=; b=BETsvQ1XQXYvS3yVZJunptrFMDS2neKy0j9JxlIrK90pKB+F+GMmz0thFKcy4Rfkt9 KHHd67M3N8pN0/wLNIuhxhRfiGoVbg/BIkWWVNCcom4ZgfLThBxoRtw6fcsDKBxpx60w RGb7prBt1QdXdCukpeLIJdEBt+TL3WeLT32+m8Rwj3WVPl0ELT9bgFrf3xROA/w1Ru3C 1oD19UXe2oYoHH4SoVkAC0sjndQMkb25JmdUctiwngpgOjGEJXzstmhWfARydc1ddbBE AYrHlI7z7D23QZvva6CoVjCTxUu5w9I+RWs3o2DM6BK9tXeTqWmCOQ9BT6ZYTK1/Og3c 9sww== X-Gm-Message-State: AOAM532cTvz2q2UKntUqoWJnJJjGMqmDVA1YRQeS7j8gWhiiwCHgalF4 2G3ExgRqpCd6zhf9rmB3OaQ= X-Google-Smtp-Source: ABdhPJwyjTA7JsQ7NVKZF5OlzDXji+GJxq4tntg0MoUAznuP+aKEgxBAXZAj0YpBe5WB4AdcTdiZGw== X-Received: by 2002:a17:906:4fc4:b0:6da:b4c6:fadb with SMTP id i4-20020a1709064fc400b006dab4c6fadbmr17160389ejw.282.1647198304451; Sun, 13 Mar 2022 12:05:04 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm5856697ejk.119.2022.03.13.12.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 12:05:04 -0700 (PDT) From: Ansuel Smith To: Rob Herring , Bjorn Andersson , Andy Gross , Michael Turquette , Stephen Boyd , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Ansuel Smith , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 03/16] clk: qcom: gcc-ipq806x: add PXO_SRC in clk table Date: Sun, 13 Mar 2022 20:04:06 +0100 Message-Id: <20220313190419.2207-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220313190419.2207-1-ansuelsmth@gmail.com> References: <20220313190419.2207-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org PXO_SRC is currently defined in the gcc include and referenced in the ipq8064 DTSI. Correctly provide a clk after gcc probe to fix kernel panic if a driver starts to actually use it. Signed-off-by: Ansuel Smith --- drivers/clk/qcom/gcc-ipq806x.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/clk/qcom/gcc-ipq806x.c b/drivers/clk/qcom/gcc-ipq806x.c index 27f6d7626abb..7271d3afdc89 100644 --- a/drivers/clk/qcom/gcc-ipq806x.c +++ b/drivers/clk/qcom/gcc-ipq806x.c @@ -26,6 +26,8 @@ #include "clk-hfpll.h" #include "reset.h" +static struct clk_regmap pxo = { }; + static struct clk_pll pll0 = { .l_reg = 0x30c4, .m_reg = 0x30c8, @@ -2754,6 +2756,7 @@ static struct clk_dyn_rcg ubi32_core2_src_clk = { }; static struct clk_regmap *gcc_ipq806x_clks[] = { + [PXO_SRC] = NULL, [PLL0] = &pll0.clkr, [PLL0_VOTE] = &pll0_vote, [PLL3] = &pll3.clkr, @@ -3083,6 +3086,10 @@ static int gcc_ipq806x_probe(struct platform_device *pdev) if (ret) return ret; + clk = clk_get(dev, "pxo"); + pxo.hw = *__clk_get_hw(clk); + gcc_ipq806x_clks[PXO_SRC] = &pxo; + regmap = dev_get_regmap(dev, NULL); if (!regmap) return -ENODEV; From patchwork Sun Mar 13 19:04:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 550978 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 2ED57C43217 for ; Sun, 13 Mar 2022 19:05:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235355AbiCMTGX (ORCPT ); Sun, 13 Mar 2022 15:06:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235333AbiCMTGU (ORCPT ); Sun, 13 Mar 2022 15:06:20 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 860764D26E; Sun, 13 Mar 2022 12:05:08 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id qt6so29527006ejb.11; Sun, 13 Mar 2022 12:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=KJy+bVD9Yq3kRrz9Gx7NWpfnxrb/beBV0JaHxbyWaTA=; b=RhjoKg2TAtw2kRjJHA3327WIjt7HBO2PZad5agpL27SQmL0gIx9ul6/DCku/ZDrRLw wqTUHvktBYFAyXbwzV7T9U+jx4EpMuaZnwc+RhFzE8eEMJB1uTfeO84+w9jTQAQT18Wm SzMzYR4KtBhlrkiXR+08o7nyuZGvS5DEJaYGaV8HrTsTBuAwwnZwE/yvunhq/LMIyxdZ lAG65bhgQP40a1UwWoxzx8Tyg2d+t24+s5DMY2XyFyTiL0EYWRB31GBZuo0FyF2QhJkQ HxSSQIipexM27lemK6XwI7iP6oO+0Ln9r8TAgcjnZplnJD8N0anFqPlHf5uuIpr1Fie0 L4Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KJy+bVD9Yq3kRrz9Gx7NWpfnxrb/beBV0JaHxbyWaTA=; b=MdjhCPUYJ/sx68W+8q8/LjNxOjSa3HNWX2+OtFLMgzI+q0DtZBm0ClZ6L2/XmvD2Jn XC9y7bSPN5YZlB73MO4yL5ex0a1rbwgqvBcC1ROQY26B8iksOVMiY0UTC3sBeXmljavi J7Q9UUc1ev0tOsOdkBH/eeelAkaa8OARiDi87HELQDR8D6lZ5M9XwQ0t94niBQMc0xSc wPcBf8QPWQZUx8ItqJm5ke3oe2ZqSulInf78aaU5zRiWZW+Kz8UQ3l7cfygHlZbQIT2m Wuw3fJ5mUBHESp6Y/XpladAJbrq6wV8NhG1Se8jtQ1hv749D+xEQ+yDnEquhuefuLdtC BAFw== X-Gm-Message-State: AOAM530EcCUW6Jk2HxSFAmRolKU6zAEreQ/AWceTJyja0bNPeIqu+pe2 CNwKJzCtW04vnG4gyVIWImEjTxLPN9g= X-Google-Smtp-Source: ABdhPJyQJEvHRc6MxKB+uK8bAiCI+Qm3tlTDPdqbpqUaQE99wDwsEotW2XQ4RapLeZS4mZKIRpuiXQ== X-Received: by 2002:a17:907:7685:b0:6db:67:7218 with SMTP id jv5-20020a170907768500b006db00677218mr16323326ejc.461.1647198306882; Sun, 13 Mar 2022 12:05:06 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm5856697ejk.119.2022.03.13.12.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 12:05:06 -0700 (PDT) From: Ansuel Smith To: Rob Herring , Bjorn Andersson , Andy Gross , Michael Turquette , Stephen Boyd , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Ansuel Smith , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 05/16] clk: qcom: kpss-xcc: convert to parent data API Date: Sun, 13 Mar 2022 20:04:08 +0100 Message-Id: <20220313190419.2207-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220313190419.2207-1-ansuelsmth@gmail.com> References: <20220313190419.2207-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Convert the driver to parent data API. From the Documentation pll8_vote and pxo should be declared in the DTS so fw_name can be used instead of parent_names. Name is still used to save regression on old definition. Signed-off-by: Ansuel Smith --- drivers/clk/qcom/kpss-xcc.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/clk/qcom/kpss-xcc.c b/drivers/clk/qcom/kpss-xcc.c index 4fec1f9142b8..347f70e9f5fe 100644 --- a/drivers/clk/qcom/kpss-xcc.c +++ b/drivers/clk/qcom/kpss-xcc.c @@ -12,9 +12,9 @@ #include #include -static const char *aux_parents[] = { - "pll8_vote", - "pxo", +static const struct clk_parent_data aux_parents[] = { + { .name = "pll8_vote", .fw_name = "pll8_vote" }, + { .name = "pxo", .fw_name = "pxo" }, }; static unsigned int aux_parent_map[] = { @@ -32,8 +32,8 @@ MODULE_DEVICE_TABLE(of, kpss_xcc_match_table); static int kpss_xcc_driver_probe(struct platform_device *pdev) { const struct of_device_id *id; - struct clk *clk; void __iomem *base; + struct clk_hw *hw; const char *name; id = of_match_device(kpss_xcc_match_table, &pdev->dev); @@ -55,24 +55,15 @@ static int kpss_xcc_driver_probe(struct platform_device *pdev) base += 0x28; } - clk = clk_register_mux_table(&pdev->dev, name, aux_parents, - ARRAY_SIZE(aux_parents), 0, base, 0, 0x3, - 0, aux_parent_map, NULL); + hw = __devm_clk_hw_register_mux(&pdev->dev, NULL, name, ARRAY_SIZE(aux_parents), + NULL, NULL, aux_parents, 0, base, 0, 0x3, + 0, aux_parent_map, NULL); - platform_set_drvdata(pdev, clk); - - return PTR_ERR_OR_ZERO(clk); -} - -static int kpss_xcc_driver_remove(struct platform_device *pdev) -{ - clk_unregister_mux(platform_get_drvdata(pdev)); - return 0; + return PTR_ERR_OR_ZERO(hw); } static struct platform_driver kpss_xcc_driver = { .probe = kpss_xcc_driver_probe, - .remove = kpss_xcc_driver_remove, .driver = { .name = "kpss-xcc", .of_match_table = kpss_xcc_match_table, From patchwork Sun Mar 13 19:04:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 550977 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 8A286C3527E for ; Sun, 13 Mar 2022 19:05:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235363AbiCMTGZ (ORCPT ); Sun, 13 Mar 2022 15:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235349AbiCMTGX (ORCPT ); Sun, 13 Mar 2022 15:06:23 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95C0D4D62F; Sun, 13 Mar 2022 12:05:09 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id y22so17068149eds.2; Sun, 13 Mar 2022 12:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fDLuIDyRCuRCH3Dc/gWWNAl91bj4g20Fwm4jwXMbE5A=; b=XskXl0dWUiZDjMV75GJUYOdUWBNXrTgYu3bGRKZZHL/+ZwJh7A/WyRWEvg+41zTqsV qxLLxzmxJi+YTjhjtYk487wsoQxY5JPW1XSV5ediPlSVPsDFDaPtFSu6ee9IUFFRmwTj B0uQ6b0pQS+32RbOmmq4z1lAuC3iFQQzQCjvKAA+GAT5Q6nl/FfMFMgqsyV9HncLZnHl XpbYDf/SpNJu6F36zqsjILb/Fm0SW3Ku3psCk6OBAXgrGGP8HQR3jFImQkBMQumpwWkY fWpw9bSnZfT1Q3AZlRmNj2/59fufsDT9tRiG4vwUMq6D4C3BlWvfE8p83mIJYbSpzrFw pqjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fDLuIDyRCuRCH3Dc/gWWNAl91bj4g20Fwm4jwXMbE5A=; b=f3KnQj09xxe25KBVYCrysu1NX+l20TAYaTvrFvbHIkqwJU7yBa8o3Lk1sObqmJGY5+ hfAivoA88309Evw8U8LBCBUV8/431KFELdom/s9CefprwzD7rSz/mr8vW7hJSChvE1YN Va6s2F4s08O/dmeGa0TjmXpnl7hhe126kONWQWluPxPVhE4CGfrC1AR0zK3sTPON1aX3 L/5EgYgpDv6iXvEMTcYcSyHfamBfj6vO37F3zmx0Vtk5ICKKMjTHmlS8ZPUGfPVHW4pc w6DGRq62cS3mHQ+6I8vUoISUOr7msntx2gfF5ga0zkFPUxwHyFjUUjfCkf0rFNaimlZY cVBQ== X-Gm-Message-State: AOAM530npi/3xMc6LI2a0Ouqe1fymzgbzsXwQJi9sXkMpYWgapB6cvpD su6rjC+uVRN44mxIF51w9j4= X-Google-Smtp-Source: ABdhPJxEd19rUdqjOvPTG3FNBKH26QTry81M7HjqFvgqGaJxNmoVRMrAdqyNY1orYsRzigbHw4UWDQ== X-Received: by 2002:aa7:ce1a:0:b0:416:460:9df5 with SMTP id d26-20020aa7ce1a000000b0041604609df5mr17215194edv.277.1647198308027; Sun, 13 Mar 2022 12:05:08 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm5856697ejk.119.2022.03.13.12.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 12:05:07 -0700 (PDT) From: Ansuel Smith To: Rob Herring , Bjorn Andersson , Andy Gross , Michael Turquette , Stephen Boyd , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Ansuel Smith , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 06/16] clk: qcom: clk-krait: unlock spin after mux completion Date: Sun, 13 Mar 2022 20:04:09 +0100 Message-Id: <20220313190419.2207-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220313190419.2207-1-ansuelsmth@gmail.com> References: <20220313190419.2207-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Unlock spinlock after the mux switch is completed to prevent any corner case of mux request while the switch still needs to be done. Signed-off-by: Ansuel Smith --- drivers/clk/qcom/clk-krait.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/clk-krait.c b/drivers/clk/qcom/clk-krait.c index 59f1af415b58..e447fcc3806d 100644 --- a/drivers/clk/qcom/clk-krait.c +++ b/drivers/clk/qcom/clk-krait.c @@ -32,11 +32,12 @@ static void __krait_mux_set_sel(struct krait_mux_clk *mux, int sel) regval |= (sel & mux->mask) << (mux->shift + LPL_SHIFT); } krait_set_l2_indirect_reg(mux->offset, regval); - spin_unlock_irqrestore(&krait_clock_reg_lock, flags); /* Wait for switch to complete. */ mb(); udelay(1); + + spin_unlock_irqrestore(&krait_clock_reg_lock, flags); } static int krait_mux_set_parent(struct clk_hw *hw, u8 index) From patchwork Sun Mar 13 19:04:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 550976 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 9B553C43217 for ; Sun, 13 Mar 2022 19:05:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235380AbiCMTGf (ORCPT ); Sun, 13 Mar 2022 15:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235305AbiCMTGd (ORCPT ); Sun, 13 Mar 2022 15:06:33 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A98D5006C; Sun, 13 Mar 2022 12:05:14 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id p15so29580790ejc.7; Sun, 13 Mar 2022 12:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Q3b6ElFuNAjEzox0VnbXAUoCVQRKSTTTamOGAckJEC4=; b=K022jRyjFjm8Ok5yoeqDM32OVXzRct5OUuieKyISOdxr22+ycrTGo5K3KHX+6LU6wT 6IVQtnRAKscm9CPZyPaRnH81Wydx/ChpEJ0MHpXoZpXgk69qAM+hrXcci9rhvFdedQHq tIEbaUyZXsgHvEWVETGT1VLUgDzHddjzcYudS1O22621dEb/IJuJHMSMAOD4Dt/drlmK JcSpPvyc/ZkADj1zIWDUwYyHkYWbMd1vA7l6jYNBgs872GP7CLPPxHvMsaKERm1xo08D vkj3v6h0L5d7D7OsdZgrcOi/gIURKDHZ39DE8ZjR2lk3NXP0kiJabI0+nJM9ckbrzW2c 1Tjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q3b6ElFuNAjEzox0VnbXAUoCVQRKSTTTamOGAckJEC4=; b=pKSGf743lqWvpi19uSoqaEQLVtQA4UnwYhgi9Sa1te8oqLHUtAWRJZ0OHPCrbzd4Hr 49NRjfgd+Nks4nGUuQNvOdRSBH00ajZbhE0y7CTSGq7qZ+/UTxwyug/eBX3TwWDqNpxU sKJAj29W05QG5D8LI1I8vtId1Y85OaLG5ULbwgufS3mcvozcIDRrXBlyGKotu5+9pM3t wr1GH81Mdoh2iahiI0QuCnX+vfWofnOgVth25/MixwWN6cS9/pZmVOUGziHZrbjmrm0D BaAHJzDXOB5V1XUtwI5WJs6qMiYKpoe381RWniPXaKTBcFxP1ldfrVmv1HLAT3FbSImO XymA== X-Gm-Message-State: AOAM533MSwA5qWHmkj5nXb6Wv28KRggVSKamiCPg/cKIE6Yy8Lb3D9qf whMfuNwTgkyaJbamJOHK6fw= X-Google-Smtp-Source: ABdhPJy9z9Eor0s/HxJ4petV2/EuaBbA89rk6mQ7GAunlGLTlMHPvl9J1+ArysqMKsvzzVwT0deoQw== X-Received: by 2002:a17:906:7706:b0:6d6:e521:5471 with SMTP id q6-20020a170906770600b006d6e5215471mr16050002ejm.387.1647198312484; Sun, 13 Mar 2022 12:05:12 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm5856697ejk.119.2022.03.13.12.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 12:05:12 -0700 (PDT) From: Ansuel Smith To: Rob Herring , Bjorn Andersson , Andy Gross , Michael Turquette , Stephen Boyd , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Ansuel Smith , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 10/16] clk: qcom: krait-cc: drop hardcoded safe_sel Date: Sun, 13 Mar 2022 20:04:13 +0100 Message-Id: <20220313190419.2207-11-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220313190419.2207-1-ansuelsmth@gmail.com> References: <20220313190419.2207-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Drop hardcoded safe_sel definition and use helper to correctly calculate it. We assume qsb clk is always present as it should be declared in DTS per Documentation and in the absence of that, it's declared as a fixed clk. Signed-off-by: Ansuel Smith --- drivers/clk/qcom/krait-cc.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/clk/qcom/krait-cc.c b/drivers/clk/qcom/krait-cc.c index 50352ff0ac67..6530f10a546f 100644 --- a/drivers/clk/qcom/krait-cc.c +++ b/drivers/clk/qcom/krait-cc.c @@ -26,6 +26,13 @@ static unsigned int pri_mux_map[] = { 0, }; +static u8 krait_get_mux_sel(struct krait_mux_clk *mux, struct clk *safe_clk) +{ + struct clk_hw *safe_hw = __clk_get_hw(safe_clk); + + return clk_hw_get_parent_index(&mux->hw, safe_hw); +} + /* * Notifier function for switching the muxes to safe parent * while the hfpll is getting reprogrammed. @@ -117,8 +124,8 @@ krait_add_div(struct device *dev, int id, const char *s, unsigned int offset) } static struct clk * -krait_add_sec_mux(struct device *dev, int id, const char *s, - unsigned int offset, bool unique_aux) +krait_add_sec_mux(struct device *dev, struct clk *qsb, int id, + const char *s, unsigned int offset, bool unique_aux) { static struct clk_parent_data sec_mux_list[2] = { { .name = "qsb", .fw_name = "qsb" }, @@ -145,7 +152,6 @@ krait_add_sec_mux(struct device *dev, int id, const char *s, mux->shift = 2; mux->parent_map = sec_mux_map; mux->hw.init = &init; - mux->safe_sel = 0; init.name = kasprintf(GFP_KERNEL, "krait%s_sec_mux", s); if (!init.name) @@ -167,6 +173,7 @@ krait_add_sec_mux(struct device *dev, int id, const char *s, if (IS_ERR(clk)) goto err_clk; + mux->safe_sel = krait_get_mux_sel(mux, qsb); ret = krait_notifier_register(dev, clk, mux); if (ret) clk = ERR_PTR(ret); @@ -205,7 +212,6 @@ krait_add_pri_mux(struct device *dev, struct clk *hfpll_div, struct clk *sec_mux mux->lpl = id >= 0; mux->parent_map = pri_mux_map; mux->hw.init = &init; - mux->safe_sel = 2; init.name = kasprintf(GFP_KERNEL, "krait%s_pri_mux", s); if (!init.name) @@ -227,6 +233,7 @@ krait_add_pri_mux(struct device *dev, struct clk *hfpll_div, struct clk *sec_mux if (IS_ERR(clk)) goto err_clk; + mux->safe_sel = krait_get_mux_sel(mux, sec_mux); ret = krait_notifier_register(dev, clk, mux); if (ret) clk = ERR_PTR(ret); @@ -239,7 +246,9 @@ krait_add_pri_mux(struct device *dev, struct clk *hfpll_div, struct clk *sec_mux } /* id < 0 for L2, otherwise id == physical CPU number */ -static struct clk *krait_add_clks(struct device *dev, int id, bool unique_aux) +static struct clk * +krait_add_clks(struct device *dev, struct clk *qsb, int id, + bool unique_aux) { struct clk *hfpll_div, *sec_mux, *clk; unsigned int offset; @@ -262,7 +271,7 @@ static struct clk *krait_add_clks(struct device *dev, int id, bool unique_aux) goto err; } - sec_mux = krait_add_sec_mux(dev, id, s, offset, unique_aux); + sec_mux = krait_add_sec_mux(dev, qsb, id, s, offset, unique_aux); if (IS_ERR(sec_mux)) { clk = sec_mux; goto err; @@ -296,8 +305,8 @@ MODULE_DEVICE_TABLE(of, krait_cc_match_table); static int krait_cc_probe(struct platform_device *pdev) { + struct clk *l2_pri_mux_clk, *qsb, *clk; unsigned long cur_rate, aux_rate; - struct clk *l2_pri_mux_clk, *clk; struct device *dev = &pdev->dev; const struct of_device_id *id; struct clk **clks; @@ -308,11 +317,12 @@ static int krait_cc_probe(struct platform_device *pdev) return -ENODEV; /* Rate is 1 because 0 causes problems for __clk_mux_determine_rate */ - if (IS_ERR(clk_get(dev, "qsb"))) - clk = clk_register_fixed_rate(dev, "qsb", NULL, 0, 1); + qsb = clk_get(dev, "qsb"); + if (IS_ERR(qsb)) + qsb = clk_register_fixed_rate(dev, "qsb", NULL, 0, 1); - if (IS_ERR(clk)) - return PTR_ERR(clk); + if (IS_ERR(qsb)) + return PTR_ERR(qsb); if (!id->data) { clk = clk_register_fixed_factor(dev, "acpu_aux", @@ -327,13 +337,13 @@ static int krait_cc_probe(struct platform_device *pdev) return -ENOMEM; for_each_possible_cpu(cpu) { - clk = krait_add_clks(dev, cpu, id->data); + clk = krait_add_clks(dev, qsb, cpu, id->data); if (IS_ERR(clk)) return PTR_ERR(clk); clks[cpu] = clk; } - l2_pri_mux_clk = krait_add_clks(dev, -1, id->data); + l2_pri_mux_clk = krait_add_clks(dev, qsb, -1, id->data); if (IS_ERR(l2_pri_mux_clk)) return PTR_ERR(l2_pri_mux_clk); clks[4] = l2_pri_mux_clk; From patchwork Sun Mar 13 19:04:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 550975 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 B59FAC433EF for ; Sun, 13 Mar 2022 19:05:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235352AbiCMTGh (ORCPT ); Sun, 13 Mar 2022 15:06:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231828AbiCMTGg (ORCPT ); Sun, 13 Mar 2022 15:06:36 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B6365046A; Sun, 13 Mar 2022 12:05:15 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id p15so29580829ejc.7; Sun, 13 Mar 2022 12:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=R2fOLGJy54v/l8o8t90lry+jkIkH1FCiYeOZyRDynbg=; b=HJljWlHBCKVH/TmR5iHLP9OzViczF/GUVvexZ/Kda8869jV/EzPq/TfNHXTNUr0Ih9 +3xzp7v2i1JlUGKFs69kKOMnxzTmtsKc9LsQb7X6Ldo7bzvc+kuuJL2+hVxQWJewQ+9h 2fDknuZ4sGm76rlK+1esp8khStQJcTj0s7M3AVJx7DW+2o3cG9Y2QrUug4EVM0H3fg4s +VVsSljih/hUv9zPL26rpgVgMeshBxWE7ieCyldU1loP4vMbn8ln8wcddnQXh4BBlFoz yqJUGt5C0RZvC2SK1zuWWWUwgEQDtf/xhRTjcY0U297WVSgHi2gSwIpqvlTm+bGj2kth Wyzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R2fOLGJy54v/l8o8t90lry+jkIkH1FCiYeOZyRDynbg=; b=Nh09kG9ignyEpliqCRDney2sp+HDOrQogjDxSUeq23P5Qk/rBgwZKqDr55XAuj8MTX 9CkLO5j63D0nGMoJ0vTt9r3WLXiEJtUacV9DndJzsm8mjspisN+MaziqpHsR/YSNjPg9 JqD0UZ2qV5tbGEGMsC2Z2C+zxt7299ghHuQEt8poHWrY2D+UXZi7g178473Y3jtFmfmc bO+6sVvHv9X+hD7v5ndB7gAjJTBa4YdMwUB3JiHn9XmuQa1zN6JLDn3xyDkAEC1n/a82 kSl1OV3hf1DdcV+2PdBj/jERbDwJybIorDGqG9xD80gNAMgiXxBT9Vf8lh26kpYjpV+L FzvA== X-Gm-Message-State: AOAM533OAU5/1KrkDSCFPmZGXDKrIOQMU/JqYMxjva1WkENtmkiWTrKG FrryIsQRwvBC3dxL5+VNr6U= X-Google-Smtp-Source: ABdhPJzvI7DgVwAOqW+xsXzrTfiec88NrdouKuOnUuB+vKBdoNs9RaryvElzZYoFnITBSgrD8IRdGg== X-Received: by 2002:a17:906:3a55:b0:6ce:c2ee:3e10 with SMTP id a21-20020a1709063a5500b006cec2ee3e10mr15185399ejf.210.1647198313618; Sun, 13 Mar 2022 12:05:13 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm5856697ejk.119.2022.03.13.12.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 12:05:13 -0700 (PDT) From: Ansuel Smith To: Rob Herring , Bjorn Andersson , Andy Gross , Michael Turquette , Stephen Boyd , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Ansuel Smith , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 11/16] clk: qcom: krait-cc: force sec_mux to QSB Date: Sun, 13 Mar 2022 20:04:14 +0100 Message-Id: <20220313190419.2207-12-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220313190419.2207-1-ansuelsmth@gmail.com> References: <20220313190419.2207-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Now that we have converted every driver to parent_data, it was notice that the bootloader can't really leave the system in a strange state where l2 or the cpu0/1 can be sourced in a number of ways for example cpu1 sourcing out of qsb, l2 sourcing out of pxo. To correctly reset the mux and the HFPLL force the sec_mux to QSB. Signed-off-by: Ansuel Smith --- drivers/clk/qcom/krait-cc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/clk/qcom/krait-cc.c b/drivers/clk/qcom/krait-cc.c index 6530f10a546f..1bdc89c097e6 100644 --- a/drivers/clk/qcom/krait-cc.c +++ b/drivers/clk/qcom/krait-cc.c @@ -15,6 +15,8 @@ #include "clk-krait.h" +#define QSB_RATE 1 + static unsigned int sec_mux_map[] = { 2, 0, @@ -178,6 +180,12 @@ krait_add_sec_mux(struct device *dev, struct clk *qsb, int id, if (ret) clk = ERR_PTR(ret); + /* Force the sec_mux to be set to QSB rate. + * This is needed to correctly set the parents and + * to later reset mux and HFPLL to a known freq. + */ + clk_set_rate(clk, QSB_RATE); + err_clk: if (unique_aux) kfree(parent_name); @@ -374,7 +382,7 @@ static int krait_cc_probe(struct platform_device *pdev) */ cur_rate = clk_get_rate(l2_pri_mux_clk); aux_rate = 384000000; - if (cur_rate == 1) { + if (cur_rate == QSB_RATE) { dev_info(dev, "L2 @ QSB rate. Forcing new rate.\n"); cur_rate = aux_rate; } @@ -385,7 +393,7 @@ static int krait_cc_probe(struct platform_device *pdev) for_each_possible_cpu(cpu) { clk = clks[cpu]; cur_rate = clk_get_rate(clk); - if (cur_rate == 1) { + if (cur_rate == QSB_RATE) { dev_info(dev, "CPU%d @ QSB rate. Forcing new rate.\n", cpu); cur_rate = aux_rate; } From patchwork Sun Mar 13 19:04:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 550974 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 8342AC43217 for ; Sun, 13 Mar 2022 19:05:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235408AbiCMTGn (ORCPT ); Sun, 13 Mar 2022 15:06:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235349AbiCMTGl (ORCPT ); Sun, 13 Mar 2022 15:06:41 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BEE9506E5; Sun, 13 Mar 2022 12:05:16 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id qa43so29422021ejc.12; Sun, 13 Mar 2022 12:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sEQR7AHep43bwZwVHXAE2cEONvRXMp4DrDQG9qka08M=; b=Sz87HYVsoKtiiOuHvJ2WAz9s27Dc7vz6VwvczrwWbn33hJLQ7c5xQzRrqfHvgoitpp MOq1Y5c6rlONCTvZt1iU0y/TC4L4L6bKo9tfo0kHqWffk1ILj2AbeHq/2lwgV5kmxAtg kARmmXJOO5Aq5tSsaOF9gJCValwDoMB1lirS392xbQJdDHUKEMquUNhecxBCldbJD51/ pkyNNtXjDv4204rz52OLTKHwP4GT6UlY1dz3q26FIkbvo36wSST3OmrouGVc9JAkvEYq 8OYJ+QgwTnIrUiH0dH42LT7aC2c8cK7jhQ7JTyB80/JHvYSlTWIXTfAQJqWFNPUwtsah Q/Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sEQR7AHep43bwZwVHXAE2cEONvRXMp4DrDQG9qka08M=; b=Z1319PC1eM9zndNBBaBXKkKRwwXG42F7lploNSPkz+n7aCLeX2u0lPyLEB0txhKzTA PxXPHtDJg+8qPbMwvSB0CQWb7n0AatFzduX8Zo+CyANVkSNBD4YRk3a06g7rOG6r534b bjcjT4xVVYUYxXbdT6rbPwUe3mWAhXP5OzY2ogt2hUnCcJ5r8IdaLywPa6T4uA7sC6ca aZMF97Nn/xPQI8LNOZeKdR4+LDpwr/nR831ro3NZeAMdqtO6Mpg8N4X6E9PqC/3usqvr SwvPu/TpNaB1XxE3+3X91hJZtHlHnwnmvejgwzIvBWkQGDYBMsKmX/Mb2MrUhq8oQUcE Vxjg== X-Gm-Message-State: AOAM531MVnEiO4/9xHUQ8zAIk1qoYn/kD3WEmm5mvOBa94KwTKGIzviv kOO0OJwarSo3DI8dxwlcZUo= X-Google-Smtp-Source: ABdhPJzJSvZYpZkmGjsnohew5wdo1ux3J5zVQpqlGhuzOBMbIRj96up6V93GUgT0NEoWBVVpsA1piw== X-Received: by 2002:a17:906:7954:b0:6da:9ee0:2e54 with SMTP id l20-20020a170906795400b006da9ee02e54mr16921227ejo.630.1647198314701; Sun, 13 Mar 2022 12:05:14 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm5856697ejk.119.2022.03.13.12.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 12:05:14 -0700 (PDT) From: Ansuel Smith To: Rob Herring , Bjorn Andersson , Andy Gross , Michael Turquette , Stephen Boyd , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Ansuel Smith , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 12/16] clk: qcom: clk-krait: add 8064 errata workaround Date: Sun, 13 Mar 2022 20:04:15 +0100 Message-Id: <20220313190419.2207-13-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220313190419.2207-1-ansuelsmth@gmail.com> References: <20220313190419.2207-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add 8064 errata workaround where the sec_src clock gating needs to be disabled during switching. To enable this set disable_sec_src_gating in the mux struct. Signed-off-by: Ansuel Smith --- drivers/clk/qcom/clk-krait.c | 16 ++++++++++++++++ drivers/clk/qcom/clk-krait.h | 1 + drivers/clk/qcom/krait-cc.c | 1 + 3 files changed, 18 insertions(+) diff --git a/drivers/clk/qcom/clk-krait.c b/drivers/clk/qcom/clk-krait.c index d8af281eba0e..82fe7031e1f4 100644 --- a/drivers/clk/qcom/clk-krait.c +++ b/drivers/clk/qcom/clk-krait.c @@ -18,13 +18,23 @@ static DEFINE_SPINLOCK(krait_clock_reg_lock); #define LPL_SHIFT 8 +#define SECCLKAGD BIT(4) + static void __krait_mux_set_sel(struct krait_mux_clk *mux, int sel) { unsigned long flags; u32 regval; spin_lock_irqsave(&krait_clock_reg_lock, flags); + regval = krait_get_l2_indirect_reg(mux->offset); + + /* 8064 Errata: disable sec_src clock gating during switch. */ + if (mux->disable_sec_src_gating) { + regval |= SECCLKAGD; + krait_set_l2_indirect_reg(mux->offset, regval); + } + regval &= ~(mux->mask << mux->shift); regval |= (sel & mux->mask) << mux->shift; if (mux->lpl) { @@ -33,6 +43,12 @@ static void __krait_mux_set_sel(struct krait_mux_clk *mux, int sel) } krait_set_l2_indirect_reg(mux->offset, regval); + /* 8064 Errata: re-enabled sec_src clock gating. */ + if (mux->disable_sec_src_gating) { + regval &= ~SECCLKAGD; + krait_set_l2_indirect_reg(mux->offset, regval); + } + /* Wait for switch to complete. */ mb(); udelay(1); diff --git a/drivers/clk/qcom/clk-krait.h b/drivers/clk/qcom/clk-krait.h index 9120bd2f5297..f930538c539e 100644 --- a/drivers/clk/qcom/clk-krait.h +++ b/drivers/clk/qcom/clk-krait.h @@ -15,6 +15,7 @@ struct krait_mux_clk { u8 safe_sel; u8 old_index; bool reparent; + bool disable_sec_src_gating; struct clk_hw hw; struct notifier_block clk_nb; diff --git a/drivers/clk/qcom/krait-cc.c b/drivers/clk/qcom/krait-cc.c index 1bdc89c097e6..533a770332be 100644 --- a/drivers/clk/qcom/krait-cc.c +++ b/drivers/clk/qcom/krait-cc.c @@ -154,6 +154,7 @@ krait_add_sec_mux(struct device *dev, struct clk *qsb, int id, mux->shift = 2; mux->parent_map = sec_mux_map; mux->hw.init = &init; + mux->disable_sec_src_gating = true; init.name = kasprintf(GFP_KERNEL, "krait%s_sec_mux", s); if (!init.name) From patchwork Sun Mar 13 19:04:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 550973 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 090BDC4321E for ; Sun, 13 Mar 2022 19:06:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235456AbiCMTHJ (ORCPT ); Sun, 13 Mar 2022 15:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235430AbiCMTGs (ORCPT ); Sun, 13 Mar 2022 15:06:48 -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 1401751336; Sun, 13 Mar 2022 12:05:19 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id d10so29556480eje.10; Sun, 13 Mar 2022 12:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fMAOn8pwa3go68WYxvsLY0rJlkkqdpP8FjSo1TfU57o=; b=iaD4nEn8TP5faC6pEMwcRqU4nV8uFaV9PEQjF0q819n6g75l3gqLEmvDn6SR6sYuV+ DCgflnLnhDNhSzN5eiK+Q7VHwoGya248hwgVjixVOL9qKnZ75yervrC1g1kdnPqne20P AM3Ew2vYgv5Hzo1tDItHRm2Y6gSqHM1tnabgWPs9jcwGPk7WDh9aK9I8MbKNurHbmxgI sVM3CW3AyTXWXrcXWAxk/YP7AaSibMyJhBWIqDN47jDKVtoSSqH5G63Fy+KEBund/KBB GhQZ/kl0gKvA508xxGZAn8yydbF2gDyMLr60+0TdzARkz06lnHaEfEQgI0ozOU3V4lkW OhHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fMAOn8pwa3go68WYxvsLY0rJlkkqdpP8FjSo1TfU57o=; b=TH2BxIWsWTZGzc2ScvfhWobX0cG8OU8eXHPbsZLN7+U3UoakaBHWWyLTiKCtCA+Mj9 UEFeyLiCbcIuNd+C1EWcHY7/tgHy4gFB/z+vRsBozvWiNUzr2hRftgK/cJPVc2FL9LfS QjEGRjx/fCq3orLlQYPI/td+Hi0jRdXSrq/rzaBjNLj0cxeI6P7Jm4KbiMXX0zT2h1cJ EpS4subBKt2HE4GTxgS+r2UPgtJTdlvwvjduKoiY3MfRY17k+Kk2hvCRMgr9wmjKhmAd S5FwqKpCChrXSkmyg44Vgh2FKS6o/ujExsOwCq9znjYTciI/wtQR39qBa12RwLnxFgzh ivug== X-Gm-Message-State: AOAM532Wz6VpCRrt5oM0s4AaEwcQaMJf66gMqKWuRCi4c3GDA/k9U5fG jNJeXukRe6vhYxAX0QNR3SU= X-Google-Smtp-Source: ABdhPJzf4xDkkfnpb+RM9j0/iSL/WQMVi2u50zBYUZftCYGQ6lnYQdMtI5BTO8qZKzaTYy27FrYP6A== X-Received: by 2002:a17:907:8a0d:b0:6d6:dae9:7263 with SMTP id sc13-20020a1709078a0d00b006d6dae97263mr16380785ejc.671.1647198317421; Sun, 13 Mar 2022 12:05:17 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm5856697ejk.119.2022.03.13.12.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 12:05:17 -0700 (PDT) From: Ansuel Smith To: Rob Herring , Bjorn Andersson , Andy Gross , Michael Turquette , Stephen Boyd , Peter De Schrijver , Prashant Gaikwad , Thierry Reding , Jonathan Hunter , Ansuel Smith , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 14/16] dt-bindings: clock: Convert qcom,krait-cc to yaml Date: Sun, 13 Mar 2022 20:04:17 +0100 Message-Id: <20220313190419.2207-15-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220313190419.2207-1-ansuelsmth@gmail.com> References: <20220313190419.2207-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Convert qcom,krait-cc to yaml and add missing l2 clocks and names definiton. Signed-off-by: Ansuel Smith --- .../bindings/clock/qcom,krait-cc.txt | 34 ---------- .../bindings/clock/qcom,krait-cc.yaml | 63 +++++++++++++++++++ 2 files changed, 63 insertions(+), 34 deletions(-) delete mode 100644 Documentation/devicetree/bindings/clock/qcom,krait-cc.txt create mode 100644 Documentation/devicetree/bindings/clock/qcom,krait-cc.yaml diff --git a/Documentation/devicetree/bindings/clock/qcom,krait-cc.txt b/Documentation/devicetree/bindings/clock/qcom,krait-cc.txt deleted file mode 100644 index 030ba60dab08..000000000000 --- a/Documentation/devicetree/bindings/clock/qcom,krait-cc.txt +++ /dev/null @@ -1,34 +0,0 @@ -Krait Clock Controller - -PROPERTIES - -- compatible: - Usage: required - Value type: - Definition: must be one of: - "qcom,krait-cc-v1" - "qcom,krait-cc-v2" - -- #clock-cells: - Usage: required - Value type: - Definition: must be 1 - -- clocks: - Usage: required - Value type: - Definition: reference to the clock parents of hfpll, secondary muxes. - -- clock-names: - Usage: required - Value type: - Definition: must be "hfpll0", "hfpll1", "acpu0_aux", "acpu1_aux", "qsb". - -Example: - - kraitcc: clock-controller { - compatible = "qcom,krait-cc-v1"; - clocks = <&hfpll0>, <&hfpll1>, <&acpu0_aux>, <&acpu1_aux>, ; - clock-names = "hfpll0", "hfpll1", "acpu0_aux", "acpu1_aux", "qsb"; - #clock-cells = <1>; - }; diff --git a/Documentation/devicetree/bindings/clock/qcom,krait-cc.yaml b/Documentation/devicetree/bindings/clock/qcom,krait-cc.yaml new file mode 100644 index 000000000000..f89b70ab01ae --- /dev/null +++ b/Documentation/devicetree/bindings/clock/qcom,krait-cc.yaml @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/qcom,krait-cc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Krait Clock Controller + +maintainers: + - Ansuel Smith + +description: | + Qualcomm Krait Clock Controller used to correctly scale the CPU and the L2 + rates. + +properties: + compatible: + enum: + - qcom,krait-cc-v1 + - qcom,krait-cc-v2 + + clocks: + items: + - description: phandle to hfpll for CPU0 mux + - description: phandle to hfpll for CPU1 mux + - description: phandle to hfpll for L2 mux + - description: phandle to CPU0 aux clock + - description: phandle to CPU1 aux clock + - description: phandle to L2 aux clock + - description: phandle to QSB fixed clk + + clock-names: + items: + - const: hfpll0 + - const: hfpll1 + - const: hfpll_l2 + - const: acpu0_aux + - const: acpu1_aux + - const: acpu_l2_aux + - const: qsb + + '#clock-cells': + const: 1 + +required: + - compatible + - clocks + - clock-names + - '#clock-cells' + +additionalProperties: false + +examples: + - | + clock-controller { + compatible = "qcom,krait-cc-v1"; + clocks = <&hfpll0>, <&hfpll1>, <&hfpll_l2>, + <&acpu0_aux>, <&acpu1_aux>, <&acpu_l2_aux>, <&qsb>; + clock-names = "hfpll0", "hfpll1", "hfpll_l2", + "acpu0_aux", "acpu1_aux", "acpu_l2_aux", "qsb"; + #clock-cells = <1>; + }; +...