Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3484253imu; Wed, 7 Nov 2018 11:01:57 -0800 (PST) X-Google-Smtp-Source: AJdET5cq4RNC1rnYg2dPOJ+NNjtK7bH0SUnvnHqhhnosZnUWBM0P96OyX2puzt4qDLjQGs09mLW0 X-Received: by 2002:a17:902:ac8f:: with SMTP id h15-v6mr1408245plr.46.1541617317221; Wed, 07 Nov 2018 11:01:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541617317; cv=none; d=google.com; s=arc-20160816; b=FPU0UwQNdgmo4DzyKcxzNBx9STgBNgWXChD7dPcS2XqrnrruHcY2X7xL8roKm5MZ0f 3MJtNGlKiSYUxf+biYOV9+pyWLK/FpHrbqrhVOZqksMtXtPIW12Mn/+htQnB10Hi6E/B Pc29ckB7n6Ip83ALZNxntbPQZdy5997FVrbpaxN6l059qgb29vYO7+Dnw14cI/sNWM3C xRP+gDpXRLnx3+LIJnoHMSBjbubtQ7EAl9pUYskeGGmtRXR6QZFmznc0klfR0T70FjeF UlF0f24hZ5x6rwcaU+CpelzZFpEKQRKcLUGDMqxdVfAtECRuNQgOqrJTkzqh0KNGLBE2 mR9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature; bh=rEucXQQIfj5QHbHIzwtC2HhQhgL7XQs8A26gtRZAtAE=; b=Dce7sAg9e4Zug9lexGsM0dDgOvrld5c4/711RyswAKESXcNHkVvgD1CjfDlTM/jWKE 2ZPsaj14GJNFas681qUg0hucY6ZJWBpY0+pf1a6KP+m8SCUntXP6sCxS6NuhcbjYYOKT wg3sySOu39K+rGaSrWiHIseIa/wEQGGAx78DJ+FMjTvOKU4JtwO+tS5pOxTLpr7Mt7p3 T1bj48hAMU51YEu0PUXEp4zGgEOlYlx6IR+q/NBFdikH/DnGLwm0ppu0r9F7TWdOHcDM w/B2G3p8V/yVpwbkqCRJuhBGHkFOAvT/WUkJ7TT4zqar+O7dBGZgZO7JO8FfLZoN+ACA oigw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sNOqtyQj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k135-v6si1431732pfd.239.2018.11.07.11.01.38; Wed, 07 Nov 2018 11:01:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sNOqtyQj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729338AbeKHEco (ORCPT + 99 others); Wed, 7 Nov 2018 23:32:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:51742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725727AbeKHEcn (ORCPT ); Wed, 7 Nov 2018 23:32:43 -0500 Received: from localhost (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 208B420862; Wed, 7 Nov 2018 19:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541617263; bh=HY3iJm3Ccw0G4LKGVA8FPkjVKVLj2rK3qzm7WAZOftI=; h=To:From:In-Reply-To:Cc:References:Subject:Date:From; b=sNOqtyQjfit9uionxGXkE5iuD+Lo2caTTT5WM+Slfl6MNlOph7ZYVKZMAbyZlm43B HiqDnQDoqVMIqNF51+KOT15dgkfiP6V13z9NlurkA78VS8Nwn7d+ziRNDdJscmCCo8 rITaL9fKdrC0R12jQqhjBv6IDvQ6PNNaXx7ndmds= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Abel Vesa From: Stephen Boyd In-Reply-To: <20181107115444.gscxwud7e57nx3c7@fsr-ub1664-175> Cc: Andrey Smirnov , Anson Huang , "A.s. Dong" , Fabio Estevam , Lucas Stach , Rob Herring , Sascha Hauer , dl-linux-imx , Abel Vesa , Shawn Guo , Sascha Hauer , Michael Turquette , open list , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , "open list:COMMON CLK FRAMEWORK" References: <1537785597-26499-1-git-send-email-abel.vesa@nxp.com> <1537785597-26499-4-git-send-email-abel.vesa@nxp.com> <153980615257.5275.13866740376184829057@swboyd.mtv.corp.google.com> <20181107115444.gscxwud7e57nx3c7@fsr-ub1664-175> Message-ID: <154161726247.88331.15629902810537417880@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v9 3/5] clk: imx: add SCCG PLL type Date: Wed, 07 Nov 2018 11:01:02 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Abel Vesa (2018-11-07 03:54:45) > On Wed, Oct 17, 2018 at 12:55:52PM -0700, Stephen Boyd wrote: > > Quoting Abel Vesa (2018-09-24 03:39:55) > > > +static unsigned long clk_pll2_recalc_rate(struct clk_hw *hw, > > > + unsigned long parent_rate) > > > +{ > > > + struct clk_sccg_pll *pll =3D to_clk_sccg_pll(hw); > > > + u32 val, ref, divr1, divf1, divr2, divf2; > > > + u64 temp64; > > > + > > > + val =3D readl_relaxed(pll->base + PLL_CFG0); > > > + switch (FIELD_GET(PLL_REF_MASK, val)) { > > > + case 0: > > > + ref =3D OSC_25M; > > > + break; > > > + case 1: > > > + ref =3D OSC_27M; > > > + break; > > > + default: > > > + ref =3D OSC_25M; > > = > > Does this information not come through 'parent_rate'? > > = > = > No. So basically both pll1 and pll2 and the divider after it form togethe= r this SCCG: > = > https://www.nxp.com/docs/en/reference-manual/IMX8MDQLQRM.pdf#page=3D834 > = > See: Figure 5-8. SSCG PLL Block Diagram Thanks for the link! > = > We're basically reading the input of the pll 1 in order to compute the ou= tput of the entire SCCG. > = > I know it's a mess. I'm working on cleaning it up, but for now we need th= is in in order to boot up. What's the plan to clean it up? > = > > > + break; > > > + } > > > + > > > + val =3D readl_relaxed(pll->base + PLL_CFG2); > > > + divr1 =3D FIELD_GET(PLL_DIVR1_MASK, val); > > > + divr2 =3D FIELD_GET(PLL_DIVR2_MASK, val); > > > + divf1 =3D FIELD_GET(PLL_DIVF1_MASK, val); > > > + divf2 =3D FIELD_GET(PLL_DIVF2_MASK, val); > > > + > > > + temp64 =3D ref * 2; > > > + temp64 *=3D (divf1 + 1) * (divf2 + 1); > > > + > > > + do_div(temp64, (divr1 + 1) * (divr2 + 1)); > > = > > Nitpicks: A comment with the equation may be helpful to newcomers. > = > Since the SCCG is contructed by multiple different types of clocks here, = the equation doesn't help > since it is spread in all constructing blocks. Ok.