From patchwork Mon Mar 21 14:48:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 12787357 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 849A6C4332F for ; Mon, 21 Mar 2022 15:18:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350030AbiCUPTz (ORCPT ); Mon, 21 Mar 2022 11:19:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350031AbiCUPTi (ORCPT ); Mon, 21 Mar 2022 11:19:38 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4EC8DE9B; Mon, 21 Mar 2022 08:17:59 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id r64so8744973wmr.4; Mon, 21 Mar 2022 08:17:59 -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=/RImxULSEIcXltj7eh82B63gODFmYdSpUPrpbmj5VVA=; b=lIfhCzfLy8lVMkI9i0S4a71CBpAv9SaZaRLEDlF+6tJ5tmic3SPtgrWRverjRbYJeH dDqcknMKxkpjvodnvkpudHSm4Rd2ona7SEar7+5fCeVOjQyFJ9ub+O71DTS5vSE1rjDB 9kHtT26WwecZakYkCO6mIuFQH7KW3yoQkmnXK7uFVQ/+mO9RWU94puTNaP12WUizuVh3 wAGHx1bS0vsUBkJbDCLzDc3pJwGO6Qn1TFqyKVkYcJopt3shwNPldg1m0w7HBDbHRN0P XIQQZiIT8XrdBiPA/ZpORssziaQGW/zsVu6xhbQQE1E3jSK3CB1iOjqeorvCTX5kZaf5 RXDg== 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=/RImxULSEIcXltj7eh82B63gODFmYdSpUPrpbmj5VVA=; b=cQ/+dv9k+am1beKE4avwPPYtF066PbXFwt/IZoVfKHrATbJArL3lQifm9cId0eA8Mt gHEYtL5xbUFvV1q1KpSI036NBsq9k7TNI2umboDPgUD6iR5R7cbONEhdzbDIwjdNk43k U0Q7BVUibh25arjhB7Q6zHcGGSkOuSjRlhbtolLyTMXSt986n4dKiN2UXuNCvtWg6SYL OZa4Aejiyc+BPG2bnISzkJxzTCLdh1v/AfRhY151AwwqS5emU3spigeXjosaQsrlEuPY CZjhwINgiQk3WYgqzL9E0BvIXUwyNXCVsGP4GDMuzfmtckPox+T6mSIWQIV03AX6nRvk yWLw== X-Gm-Message-State: AOAM5301cQsyuQbjNN5vUUrf3JR9SEdnFOAzbkXZ5HaDya2JHo36dKmJ qLHF/pH9nu0L5bdD+Y9skI0= X-Google-Smtp-Source: ABdhPJzhD6tELuW4WMixBD8AkcvV6OyRV79msPVV3nDOS83g1aP3X5KQagC/ktozrtTnxm5EFTfHSw== X-Received: by 2002:a05:600c:3506:b0:389:d567:e9fa with SMTP id h6-20020a05600c350600b00389d567e9famr19837957wmq.74.1647875878315; Mon, 21 Mar 2022 08:17:58 -0700 (PDT) Received: from Ansuel-xps.localdomain (93-42-69-170.ip85.fastwebnet.it. [93.42.69.170]) by smtp.googlemail.com with ESMTPSA id 10-20020a5d47aa000000b00204012e4373sm7239729wrb.101.2022.03.21.08.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 08:17:57 -0700 (PDT) From: Ansuel Smith To: Rob Herring , Bjorn Andersson , Andy Gross , Michael Turquette , Stephen Boyd , Ansuel Smith , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v4 12/18] clk: qcom: clk-krait: add apq/ipq8064 errata workaround Date: Mon, 21 Mar 2022 15:48:19 +0100 Message-Id: <20220321144825.11736-13-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220321144825.11736-1-ansuelsmth@gmail.com> References: <20220321144825.11736-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add apq/ipq8064 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 b6b7650dbf15..7ba5dbc72bce 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); + + /* apq/ipq8064 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); + /* apq/ipq8064 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 299eb4c81d96..cb8b267f1dc5 100644 --- a/drivers/clk/qcom/krait-cc.c +++ b/drivers/clk/qcom/krait-cc.c @@ -157,6 +157,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)