Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp118658rbe; Wed, 28 Feb 2024 14:18:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU5zxZAEW7eUFkoerwhXRVaAFKmvJBn68sgmWPJ8N86YkgLLwflASGoZ18L2eq7BTHW5iFEgMJkYgwyrGRiui7CJjEAEWcELV8Bb59ZAg== X-Google-Smtp-Source: AGHT+IGq0gkQ5jW3WbJpiI3ueYWI1CSfT1nTL7VY8pC7i2PlgB4fhnkcyw+KZK1wqjQPXbd+MZwj X-Received: by 2002:a05:6a21:910c:b0:1a0:e475:c0ac with SMTP id tn12-20020a056a21910c00b001a0e475c0acmr868452pzb.53.1709158692642; Wed, 28 Feb 2024 14:18:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709158692; cv=pass; d=google.com; s=arc-20160816; b=XWwS2P9IA95pjXAbIo8J28foGv5MMFU/QGVnESJ930O/Igw1uaHHr38OgzbdSIsoP9 hwjoy3sDpoRVD877jayOAdrKA3GRrKWhyfh/x+nbcOEJecn7nVSSoLAHYNzI2D2yPKKf FDDRyloFdd4JAnmfVEh7KNIPj4nTQPNIu10VF+UUqv1vo81NI8U4vsUNqF+gwbpLJ+dW MYDvVhLrHf7yzFb6TnmtFEZRyPxzlE4H1Q95m/E0aP+5G60lqoMnkXpjkl52j16OBV9z fUzjKJyuwMveSwCC2CpeG/e4frL4A+NYPTL0lGAOrBdRuGSd4f8e7YD8FP4x3JJmwllQ rx9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:date:to:cc:from:subject:references:in-reply-to :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:dkim-signature; bh=n0Ri08gjsB7Zo6HMAk7l8iPz44z7trNNQSdcHeiB4SU=; fh=StyeAn85hxv6kUDX9MfWMK4Gs52RsmsFUF1bk4LPEEM=; b=zwYC9IhdIMTv7zNDG/kLpMwU01PAgRX9iB+a9GGtsKHe/Ul+5egYYDcx+O6qobOEU7 Twu2ERzkKRLxvqvIcAeS70KHXILswx1Fw4kDXCPdLRTzBVHcb6NgYoDimYZMO3mdoBFT QE4yzLQi34g9OtWu1Lfs/8LUa7u9qYRExBdtIC9zCfgJT9EzsEkBgyz9htC9AE5EqWP6 Sc/tEpnSQCw0JG56+E/mEFmtlyNnoKiMQBz34sMZSQeytSUCChCyQBCCyCJbF6qLbl0X r1kJXWHR/BSfqQLeu0S8Fc3aBXToEw8nX3WzoNEeU2FxkBkdQ8/aSeGe6Ek3XgCgUtUv V5uQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kn6KZG+V; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85780-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bm10-20020a656e8a000000b005dc6d16be5csi412264pgb.439.2024.02.28.14.18.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 14:18:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85780-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kn6KZG+V; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85780-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2A73628BA3B for ; Wed, 28 Feb 2024 22:18:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 65BBF1361C2; Wed, 28 Feb 2024 22:18:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kn6KZG+V" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 890341361A3; Wed, 28 Feb 2024 22:18:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709158686; cv=none; b=oKCqi2/Qo0AY+FWjh9Xm1fxv0FnqA5E5Bb6iSoX6q8p+G5WyJr1qRgLud+7gQzW/dBDS17TX9IOtjKi6yrtW3j878l6DWs6a93RH5qJ5jqfyOBvWvMGkCo6sq9JS9ZgNNjYnlynAefyPP8MrablYknZUyuneNiSdxQYkTABL+o4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709158686; c=relaxed/simple; bh=XgRBeERvVGVRTMKOSp0B+k8IqLT4mFYWBW+Ok+EN2DY=; h=Message-ID:Content-Type:MIME-Version:In-Reply-To:References: Subject:From:Cc:To:Date; b=Bz1gpzGBO2Srj/CEej96d6glVY74JzfSZubyk4SF/OKhPXXp70Ur/mQntdt7etNNVsrp3ZKa1d1WxqS7Ify4a/j4MIG3e/DR1lDG848pEffzI6Fch+IEYdrtIKK6MgUowoGpsAuMdHeDT6nHvyTxLJAgwHF2MkciDpHbzXu7jok= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kn6KZG+V; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15252C433F1; Wed, 28 Feb 2024 22:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709158686; bh=XgRBeERvVGVRTMKOSp0B+k8IqLT4mFYWBW+Ok+EN2DY=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=kn6KZG+Vo9H4uSUtWN/Ywm+W5t5mRmUSu3k9ZH+K3+uqq/kvsbHZnqY4LYfPY/h8Y lIKUBFxU4WV4+V3F1d5FugkOWz9puNZlgBu2WX1+Ej8rOaHjyxVxgD+M+8bIuNnIgl UqQf/CRzIFaGFb3aF1T5BNfVYBSeXUzmLxmOZHSn8sF1FYYDmwZibZYAZekzOLB+kf j8hms/IgHk5aLwFfRtV9KyB0/NigVAXa0nEQ1CbG+6dycDdp/0SPNRjgGuYdqER3w5 5FvSizj73YbMEVlSrDZasqDhsHirKEzaKCHdt9e6lO8d2D+X2ZM2Nd+SUeq3ioRjwb tqfy9isPUs6sQ== Message-ID: Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20240228082649.1633083-1-peng.fan@oss.nxp.com> References: <20240228082649.1633083-1-peng.fan@oss.nxp.com> Subject: Re: [PATCH] clk: imx: lpcg-scu: SW workaround for errata (e10858) From: Stephen Boyd Cc: imx@lists.linux.dev, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan To: Peng Fan (OSS) , abelvesa@kernel.org, festevam@gmail.com, kernel@pengutronix.de, mturquette@baylibre.com, s.hauer@pengutronix.de, shawnguo@kernel.org Date: Wed, 28 Feb 2024 14:18:03 -0800 User-Agent: alot/0.10 Quoting Peng Fan (OSS) (2024-02-28 00:26:49) > diff --git a/drivers/clk/imx/clk-lpcg-scu.c b/drivers/clk/imx/clk-lpcg-sc= u.c > index dd5abd09f3e2..b30d0f8b5bca 100644 > --- a/drivers/clk/imx/clk-lpcg-scu.c > +++ b/drivers/clk/imx/clk-lpcg-scu.c > @@ -6,6 +6,7 @@ > =20 > #include > #include > +#include > #include > #include > #include > @@ -41,6 +42,31 @@ struct clk_lpcg_scu { > =20 > #define to_clk_lpcg_scu(_hw) container_of(_hw, struct clk_lpcg_scu, hw) > =20 > +/* e10858 -LPCG clock gating register synchronization errata */ > +static void do_lpcg_workaround(u32 rate, void __iomem *reg, u32 val) unsigned long rate > +{ > + writel(val, reg); > + > + if (rate >=3D 24000000 || rate =3D=3D 0) { > + u32 reg1; Please declare this variable at the start of the function. > + > + /* > + * The time taken to access the LPCG registers from the A= P core > + * through the interconnect is longer than the minimum de= lay > + * of 4 clock cycles required by the errata. > + * Adding a readl will provide sufficient delay to prevent > + * back-to-back writes. > + */ > + reg1 =3D readl(reg); > + } else { > + /* > + * For clocks running below 24MHz, wait a minimum of > + * 4 clock cycles. > + */ > + ndelay(4 * (DIV_ROUND_UP(1000000000, rate))); > + } > +} > + > static int clk_lpcg_scu_enable(struct clk_hw *hw) > { > struct clk_lpcg_scu *clk =3D to_clk_lpcg_scu(hw); > @@ -57,7 +83,8 @@ static int clk_lpcg_scu_enable(struct clk_hw *hw) > val |=3D CLK_GATE_SCU_LPCG_HW_SEL; > =20 > reg |=3D val << clk->bit_idx; > - writel(reg, clk->reg); > + > + do_lpcg_workaround(clk_hw_get_rate(hw), clk->reg, reg); I'd prefer the name had 'writel' in it somewhere. > =20 > spin_unlock_irqrestore(&imx_lpcg_scu_lock, flags); >