From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF76FC2D0E4 for ; Fri, 20 Nov 2020 15:25:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DB9922252 for ; Fri, 20 Nov 2020 15:25:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="d8vZ0FSK"; dkim=temperror (0-bit key) header.d=cerno.tech header.i=@cerno.tech header.b="KxGtUuA8"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FGEpp27G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DB9922252 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FVFtjiyQX15iIHgGoDPdkIlA7gxfBPtoRawj3vBx33M=; b=d8vZ0FSKwRsidgRMzzp/AHuHH yxiETzmFa0Tzs1BLBQWEJgFoLYoefl/BNbpEKdJhMCza/sAQnqcGlb4rOcGcMzj5Ov42Q50+UNbEY Rb0QbANSzhzs77OhQiryJ0OmbTwlJ9grbhH1zXsdDhZa9176Kx1OA638DkLiKhUwbFXcaOYuKjqkY PJkmsQ9IhdJzlh6DHVzPBbcWL9HFJO40bnI42Pbpm8DWjGmWzKvujMvcxC2dvmc5dzzywY/KR1xNj gVvd+Eka1sflOH7FF5TCdIqH9lHOn65q/TlMRXzpjZEKVY+hZVFWxIAxe8KLDhnGYnHr9KHwZ4z2/ tU0/VEB/A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kg8Hj-0005zT-2w; Fri, 20 Nov 2020 15:25:15 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kg8HL-0005nS-DB for linux-arm-kernel@lists.infradead.org; Fri, 20 Nov 2020 15:24:54 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 267755C00C4; Fri, 20 Nov 2020 10:24:50 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 20 Nov 2020 10:24:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=UaoxLfN7wRJfSNyGLfSNLFU9/o5 5mjdfEsw0wlHPgV8=; b=KxGtUuA8uFNlGXoldryWeW2jsmxPDTHiNnZ4W0FB9GM WbNBJu3f3VLJfxTUMsAenrw9b2WlsMgFh07f7XIUVubJdsBij2hZzftK7yrhTCHX H1Zg3IEQ1V+nUE7kKOVpyxJJfaCJjBXb7iIRhSElav0cjQH9B+xF8x6LQKlztOvo 3EWuo7SgLlG+j6LbNJrMB/sHAq9jcXq5WjXqJEQZPt7Ugyukt1Xut8yidY+4Hugv eoBbNqSC9DYKKPSa3axwxLRL7AxBP/VjqzWwbbo3UMNTPAWTA/8Hzu0/DTTDcVXr HpAJ4tR4ApkxPqupHIscvlBIrfl1AyXDP6H23I5Y9Lw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=UaoxLf N7wRJfSNyGLfSNLFU9/o55mjdfEsw0wlHPgV8=; b=FGEpp27Gf/TYzfjC6JAPTE CyhKhhOfU0wFjuNnQpygGm6qOniCM9U4ntLrBDCULjN9OdEJhGRLa50wGMCXxdP6 Hml2hixrnLRM0Da1uyXkTsRqU4hROTfOg2xeGUHiZlMwAcFbVdeW+EHH5ONdPrPV /49IVO74jabTyzaOQuwBLHn13J+MQNirF8aD7X5FtBa/w9waftWNl0zEgNdAMWtX +UDmEr7Wl97owoIJx3G7wpikxqFN8itKiMAEszoLemJuVUaD3DskzsndKpTjVKQM pXwCIc7oGq+QNO4G6MW3q6722q0N0Jel8cHHiythxF5kq6nxtGL9XPnqgY4KIP6Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudegtddgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepleekgeehhfdutdeljefgleejffehfffgieejhffgueefhfdtveetgeehieeh gedunecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id CF1CC3064AAF; Fri, 20 Nov 2020 10:24:47 -0500 (EST) Date: Fri, 20 Nov 2020 16:24:46 +0100 From: Maxime Ripard To: Icenowy Zheng Subject: Re: [RFC PATCH 1/2] clk: sunxi-ng: a64: disable dividers in PLL-CPUX Message-ID: <20201120152446.qk7lfeq7lsoylnma@gilmour> References: <20201109053358.54220-1-icenowy@aosc.io> <20201109053358.54220-2-icenowy@aosc.io> MIME-Version: 1.0 In-Reply-To: <20201109053358.54220-2-icenowy@aosc.io> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201120_102451_829818_291CB823 X-CRM114-Status: GOOD ( 29.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ondrej Jirman , Jernej Skrabec , linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, Chen-Yu Tsai , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============1867147551479423634==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============1867147551479423634== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3nf5hzcf5bhrpdqk" Content-Disposition: inline --3nf5hzcf5bhrpdqk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 09, 2020 at 01:33:57PM +0800, Icenowy Zheng wrote: > According to the user manual, PLL-CPUX have two dividers, in which P is > only allowed when the desired rate is less than 240MHz. As the CCU > framework have no such feature yet and the clock rate that allows P is > much lower than where we normally operate, disallow the usage of P > factor now. >=20 > M is not restricted in the user manual, however according to the BSP PLL > setup table (see [1]), it's not used at all. To follow what the BSP > does, disable this factor too. >=20 > Disabling the dividers will make it possible to remove the need to > switch to osc24M when doing frequency scaling on PLL-CPUX. >=20 > In order to prevent boot-time usage of dividers (current known mainline > U-Boot implementation use m =3D 2), tweaking of the factors are done when > probing CCU driver. >=20 > Signed-off-by: Icenowy Zheng > --- > drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 79 ++++++++++++++++++++++++++- > 1 file changed, 77 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c b/drivers/clk/sunxi-ng= /ccu-sun50i-a64.c > index 5f66bf879772..6108d150a0e3 100644 > --- a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c > +++ b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c > @@ -4,6 +4,7 @@ > */ > =20 > #include > +#include > #include > #include > #include > @@ -23,13 +24,14 @@ > =20 > #include "ccu-sun50i-a64.h" > =20 > +#define SUN50I_A64_PLL_CPUX_REG 0x000 > static struct ccu_nkmp pll_cpux_clk =3D { > .enable =3D BIT(31), > .lock =3D BIT(28), > .n =3D _SUNXI_CCU_MULT(8, 5), > .k =3D _SUNXI_CCU_MULT(4, 2), > - .m =3D _SUNXI_CCU_DIV(0, 2), > - .p =3D _SUNXI_CCU_DIV_MAX(16, 2, 4), > + .m =3D _SUNXI_CCU_DIV_MAX(16, 2, 1), > + .p =3D _SUNXI_CCU_DIV_MAX(0, 2, 1), > .common =3D { > .reg =3D 0x000, > .hw.init =3D CLK_HW_INIT("pll-cpux", > @@ -215,6 +217,7 @@ static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll= -ddr1", > BIT(28), /* lock */ > CLK_SET_RATE_UNGATE); > =20 > +#define SUN50I_A64_CPUX_AXI_REG 0x050 > static const char * const cpux_parents[] =3D { "osc32k", "osc24M", > "pll-cpux", "pll-cpux" }; > static SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents, > @@ -954,6 +957,78 @@ static int sun50i_a64_ccu_probe(struct platform_devi= ce *pdev) > =20 > writel(0x515, reg + SUN50I_A64_PLL_MIPI_REG); > =20 > + /* Disable any possible dividers on PLL-CPUX */ > + val =3D readl(reg + SUN50I_A64_PLL_CPUX_REG); > + if (val & (GENMASK(17, 16) | GENMASK(1, 0))) { > + unsigned int n, k, m, p; > + > + n =3D ((val & GENMASK(12, 8)) >> 8) + 1; > + k =3D ((val & GENMASK(5, 4)) >> 4) + 1; > + m =3D (val & GENMASK(1, 0)) + 1; > + p =3D 1 << ((val & GENMASK(17, 16)) >> 16); > + > + /* > + * Known mainline U-Boot revisions never uses > + * divider p, and it will only use m when k =3D 3 or 4. > + * Specially judge for these cases, to satisfy > + * what will most possibly happen. > + * For m =3D 2 and k =3D 3, fractional change will be > + * applied to n, to mostly keep the clock rate. > + * For m =3D 2 and k =3D 4, just change to m =3D 1 and k =3D 2. > + * For other cases, just try to divide it from N. > + */ > + if (p >=3D 2) { > + n /=3D p; > + p =3D 1; > + } > + > + if (m =3D=3D 2) { > + if (k =3D=3D 3) { > + k =3D 2; > + n =3D n * 3 / 4; > + m =3D 1; > + } > + if (k =3D=3D 4) { > + k =3D 2; > + m =3D 1; > + } > + } > + > + if (m >=3D 2) { > + n /=3D m; > + m =3D 1; > + } I'm not sure we should rely on the behavior of U-Boot there, and ideally we should move that code to a function of its own, but on principle I'm fine with that code. Maxime --3nf5hzcf5bhrpdqk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCX7ffvgAKCRDj7w1vZxhR xd28AQD9w1xokupfQdYriTJcn9l3o+Q7XBMp/B63TSz5v6fQuAD/TXna8QEDRCcW bhI9SqhKPRexFI7avDFLV4TT/KsGGwA= =NH26 -----END PGP SIGNATURE----- --3nf5hzcf5bhrpdqk-- --===============1867147551479423634== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============1867147551479423634==--