Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5559514imu; Tue, 13 Nov 2018 08:20:13 -0800 (PST) X-Google-Smtp-Source: AJdET5djysVIXOteUe+6M9vJvJf0eHnHw0mjp0QW7LS5Gsz0liydNeCS2ZXrA/R5/mD9fXExq5K7 X-Received: by 2002:a63:6704:: with SMTP id b4mr5366419pgc.100.1542126013157; Tue, 13 Nov 2018 08:20:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542126013; cv=none; d=google.com; s=arc-20160816; b=Dxae+tfYuHhJWEJYXBTKt6PeUwLQMpkHUd+nLZjWzHWIRkjB1cHX43ffStblYBKGnB SipDv57KP25bCvso9doina8Q0p+iJmac9YsTjOOvBuUS8gnGhMxj4c8jc6xjBRAomDbw Jkw99fzxy3J/HGaty8y+tJdY4Vig3Sb74/zLLNVXgqE4q2hsPtD2HcJlme13xCnngnX2 Xff+QBoYsIpgs229BY4bHsTRBe8uYSYbaBWnhtHf+hvqLfD+I4D8kOj3yUYvsaIgYKb/ ZZ2YROvK+in9obfEVb651ibVxXSwTPTmYUd8rb3+73hXmkAqAj924yBZx/vgpFEK011D 1Jxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=bkcA76kiBVDSNlarx+wWtzK/pLcw9lf11p7HWYIi3cc=; b=jskOIQ8giUtoF4QTuq+f98KDbGFFE2fbnWwGu+TWQ/ndKQqp/I+GHHX7muNMAp8SVt DCLKVvjt+NigTsijSfbpwXyt5NhjeoqQ1lwNnisR8lkZ7yWdIzKZk7/ENF+Av4ushy0i qAkvdrqcYp471qRQQ8fCb7uTravvVcQzfdR1kf4vvBbOvNTtoAU8GoyMabJrmTJseYVe HLcUD39Z3RuxQv80XYz7LntpOxFCFDEI6MHSunA66TcG/4JrurwfuWFh3Mg6NuiN66wo zFFqq1FE3XxnOX5yr7T4QSTi8v5MI3HrGvlPWPMKZjDD75m3ahAIxKY7qVvVcHtW5o6V o5XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LzzPLtDi; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5-v6si22466210pfg.52.2018.11.13.08.19.40; Tue, 13 Nov 2018 08:20:13 -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=@chromium.org header.s=google header.b=LzzPLtDi; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730867AbeKNCRv (ORCPT + 99 others); Tue, 13 Nov 2018 21:17:51 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34220 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbeKNCRv (ORCPT ); Tue, 13 Nov 2018 21:17:51 -0500 Received: by mail-pg1-f196.google.com with SMTP id 17so5654488pgg.1 for ; Tue, 13 Nov 2018 08:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bkcA76kiBVDSNlarx+wWtzK/pLcw9lf11p7HWYIi3cc=; b=LzzPLtDih4Wbnvq5bgFynkK6HCCP8QI2m4/kG/xcZoSewbxHZ7VwK6l68/Y2tP0sQC uKaor9+wO3wlgx95aY0T35kfThmfxSlZ0TjvKgAAL+0Oz7oyyIiXigiZun9cbmI/nobv avp4BB8JiD3MIualVG8JG76BJcMq3ZWUWabIo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bkcA76kiBVDSNlarx+wWtzK/pLcw9lf11p7HWYIi3cc=; b=j59en2hVZJMd9DBq02N8UPacfGAmqk4hoUiD1IlOqL0uElC10ktXSLK4Q2gEphsn5p pf9+lbC1/E5sVyOgRrS2XZXP1SoPEl103INbG4K/HdA3ZC/RE10RnkhVDiaFkxxVDVr7 RrIBS89vjE52HO77ZnDZEO8uXtMPRTiNUAgwDmrvuL+zamQv5huwoGCTsD6x5YIZrZ5F 5mlpl1qEtJAJFHDe3dvf5m3t5ByER+IfTNHOsoZaezAuYsfkGvyQfYrDZyD5DnG9mc5l vUscSUIPjW2VY2TyeZCHvYX1Oxu7bLCWdZFdMXOUBEpBDyLtLa8mLSGj1RsimK52qtpk RAzA== X-Gm-Message-State: AGRZ1gI4+L46OH8w5F201d1GdUNV4G/2rmPS9dkEuc3rfrx6rcTN/rx2 LKwF4QVabrxDvX+06xWswkrQDiq+KIiM3Gm/31lF2g== X-Received: by 2002:a62:cac4:: with SMTP id y65-v6mr5743033pfk.27.1542125944467; Tue, 13 Nov 2018 08:19:04 -0800 (PST) MIME-Version: 1.0 References: <20181106064206.17535-1-weiyi.lu@mediatek.com> <20181106064206.17535-4-weiyi.lu@mediatek.com> In-Reply-To: <20181106064206.17535-4-weiyi.lu@mediatek.com> From: Nicolas Boichat Date: Tue, 13 Nov 2018 08:18:52 -0800 Message-ID: Subject: Re: [PATCH v1 02/11] clk: mediatek: add new member to mtk_pll_data To: weiyi.lu@mediatek.com Cc: Matthias Brugger , sboyd@codeaurora.org, Rob Herring , jamesjj.liao@mediatek.com, fan.chen@mediatek.com, linux-arm Mailing List , lkml , linux-mediatek@lists.infradead.org, linux-clk@vger.kernel.org, srv_heupstream@mediatek.com, owen.chen@mediatek.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 5, 2018 at 10:43 PM Weiyi Lu wrote: > > From: Owen Chen > > 1. pcwibits: The integer bits of pcw for plls is extend to 8 bits, > add a variable to indicate this change and > backward-compatible. > 2. fmin: The pll freqency lower-bound is vary from 1GMhz to > 1.5Ghz, add a variable to indicate platform-dependent. > > Signed-off-by: Owen Chen > --- > drivers/clk/mediatek/clk-mtk.h | 2 ++ > drivers/clk/mediatek/clk-pll.c | 10 +++++++--- > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h > index f83c2bbb677e..1882221fe994 100644 > --- a/drivers/clk/mediatek/clk-mtk.h > +++ b/drivers/clk/mediatek/clk-mtk.h > @@ -215,7 +215,9 @@ struct mtk_pll_data { > const struct clk_ops *ops; > u32 rst_bar_mask; > unsigned long fmax; > + unsigned long fmin; Minor nit: I'd put fmin before fmax in the structure. > int pcwbits; > + int pcwibits; > uint32_t pcw_reg; > int pcw_shift; > const struct mtk_pll_div_table *div_table; > diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c > index f54e4015b0b1..0ec2c62d9383 100644 > --- a/drivers/clk/mediatek/clk-pll.c > +++ b/drivers/clk/mediatek/clk-pll.c I'd add a note next to: #define INTEGER_BITS 7 to say that this is the default, and can be overridden with pcwibits. > @@ -69,11 +69,13 @@ static unsigned long __mtk_pll_recalc_rate(struct mtk_clk_pll *pll, u32 fin, > { > int pcwbits = pll->data->pcwbits; > int pcwfbits; > + int ibits; > u64 vco; > u8 c = 0; > > /* The fractional part of the PLL divider. */ > - pcwfbits = pcwbits > INTEGER_BITS ? pcwbits - INTEGER_BITS : 0; > + ibits = pll->data->pcwibits ? pll->data->pcwibits : INTEGER_BITS; > + pcwfbits = pcwbits > ibits ? pcwbits - ibits : 0; > > vco = (u64)fin * pcw; > > @@ -138,9 +140,10 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, > static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv, > u32 freq, u32 fin) > { > - unsigned long fmin = 1000 * MHZ; > + unsigned long fmin = pll->data->fmin ? pll->data->fmin : 1000 * MHZ; I'd put parentheses around (1000 * MHZ), to avoid the need to think about precedence... > const struct mtk_pll_div_table *div_table = pll->data->div_table; > u64 _pcw; > + int ibits; > u32 val; > > if (freq > pll->data->fmax) > @@ -164,7 +167,8 @@ static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv, > } > > /* _pcw = freq * postdiv / fin * 2^pcwfbits */ > - _pcw = ((u64)freq << val) << (pll->data->pcwbits - INTEGER_BITS); > + ibits = pll->data->pcwibits ? pll->data->pcwibits : INTEGER_BITS; > + _pcw = ((u64)freq << val) << (pll->data->pcwbits - ibits); > do_div(_pcw, fin); > > *pcw = (u32)_pcw; > -- > 2.18.0 >