Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5651808imb; Thu, 7 Mar 2019 22:21:18 -0800 (PST) X-Google-Smtp-Source: APXvYqyPv5e9gTNWw83xtH/QYvn+hUlAnJMpA+bpzdc8YwKD0L8YHepxF5l8Y5CweqJWPYDoJUlc X-Received: by 2002:a17:902:846:: with SMTP id 64mr16856758plk.266.1552026078297; Thu, 07 Mar 2019 22:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552026078; cv=none; d=google.com; s=arc-20160816; b=s+J/dT7xPYt/EA5s/1ohAr/Yu8NoMS0Pw8G9aSVkgCDd2sfwfDKAcqB4rLUP0rkHfW hYuSxGdnOISbGVUYb+UwkZiDDXQF5FY6uZuXodEXh5FVlGIGUOMUsxx3waEwhx/iSEto xkfNcsYZxjgw3frApCIk18sdnNcq6NOOFxOspAw3iB7d/FxjTQgqHL2RtplN3BSIWdG7 GJtsC7qF1F5M/0FbdR7OfSTRLYCRqOF58E5rL8F/5JQl6TMQpD6rXLp/oa7F7gZO67rv zRYWw4XtL0l43zZhSWAHtCpi/H12xVbucPkpqZi6Oja/Wx+xnBWYqZwhNNlL3lYjwWCg nfow== 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=R+gdPO7fY5tTH/m3FxX3K7mDEJi/gpdfcz2YIq3CUUg=; b=Dky4DID+qQx5axc5tmS8qA74DNV2MYDlFNGfPtkfWJf4ILFtcT5qQP2zKP0jmg70xU /5DC56Qz5Zbqeb+8qBoLBgxbFrOAybtBirBc7YFstmm2cYt+15wlAxJ5JcECK51dpi0L vrkaFqCaOvkq3HAuhQjFMRVJtIjPBz9wdOrPMeuHoCrR0J7Y2JxR8rT+QXBOAd0l81ru tFwXOhAu7WxJ9xs5XtcQdIzFA5yJEHEytHfy18d3NHfSkp9oAwz+GmBkr6a5nvnsONAb Mpe5ACAvr4Ga36yb5LoViwvWbItXpb9DARLr8sflB0lPOgTX0pBGqH6RIhSD6EeBNSIn ntAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GapW1JLa; 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 s139si6713250pfs.56.2019.03.07.22.21.02; Thu, 07 Mar 2019 22:21:18 -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=GapW1JLa; 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 S1726313AbfCHGUk (ORCPT + 99 others); Fri, 8 Mar 2019 01:20:40 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:40880 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbfCHGUj (ORCPT ); Fri, 8 Mar 2019 01:20:39 -0500 Received: by mail-qt1-f195.google.com with SMTP id f11so2852804qti.7 for ; Thu, 07 Mar 2019 22:20:38 -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=R+gdPO7fY5tTH/m3FxX3K7mDEJi/gpdfcz2YIq3CUUg=; b=GapW1JLaJ6exck5zqur7H9xa6LmAY04nZ3nBYz09k36u0oV7tN2jIGNBTpqtrCPbdT cXLy7gjRYRVxbcX52KBPEgSDcEEEKEcudHSbHZvpKpN5kHIhhQwtEFiaUX/dVqnucA+T 054dUzDhQbEo9zz9G+XjSUcx5vUkoOvzrtNOM= 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=R+gdPO7fY5tTH/m3FxX3K7mDEJi/gpdfcz2YIq3CUUg=; b=MeL2lIviuiiiqX1CS15xy08zPXyFf6xXByelln5hDq2WEcyX93VqREmZJxz92kPYDH 8Z1il1sXt1NVjj88mmPPzOItAwJpbKBSu5qwjx80ZY9mFyxr27egb11ugtORAWIPtlzd QU9scqBx1D4kw4v6QrXCsPSUE6eCy82FNqjhqKYodzl5IkPJ+60IEU75tfUtWrY0H9da KFEmfxvevMjggSGwcEAUenkc1Gr78v2er4uGahKREzflc+ctFuLJNU5O252Zw5Q606PJ mEccoNJuOk9W/+sY1yr1hrf7kiHg8TIWCw0fW3a3bA3k+b10V0f1tnGnuP1JXa9tFfNb /bQw== X-Gm-Message-State: APjAAAUptzrdSoOOFyfXYnfHfOamOmDsgypapAImD8bxLL7yVpl4QjcA L4NHwinsPmx/8sJOpVEMnStCE79jU79Vg6xV6vV8eA== X-Received: by 2002:ac8:3015:: with SMTP id f21mr664920qte.144.1552026038286; Thu, 07 Mar 2019 22:20:38 -0800 (PST) MIME-Version: 1.0 References: <20190305050546.23431-1-weiyi.lu@mediatek.com> <20190305050546.23431-5-weiyi.lu@mediatek.com> In-Reply-To: <20190305050546.23431-5-weiyi.lu@mediatek.com> From: Nicolas Boichat Date: Fri, 8 Mar 2019 14:20:27 +0800 Message-ID: Subject: Re: [PATCH v5 3/9] clk: mediatek: Add configurable pcwibits and fmin to mtk_pll_data To: Weiyi Lu Cc: Matthias Brugger , Stephen Boyd , Rob Herring , James Liao , Fan Chen , linux-arm Mailing List , lkml , "moderated list:ARM/Mediatek SoC support" , linux-clk@vger.kernel.org, srv_heupstream , stable@vger.kernel.org, Owen Chen 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 Tue, Mar 5, 2019 at 1:06 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 Minor nit: frequency (Stephen I guess you could fix that when applying...) > 1.5Ghz, add a variable to indicate platform-dependent. > > Signed-off-by: Owen Chen > Signed-off-by: Weiyi Lu > Acked-by: Sean Wang Reviewed-and-tested-by: Nicolas Boichat > --- > drivers/clk/mediatek/clk-mtk.h | 2 ++ > drivers/clk/mediatek/clk-pll.c | 15 +++++++++++---- > 2 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h > index f83c2bbb677e..11b5517903d0 100644 > --- a/drivers/clk/mediatek/clk-mtk.h > +++ b/drivers/clk/mediatek/clk-mtk.h > @@ -214,8 +214,10 @@ struct mtk_pll_data { > unsigned int flags; > const struct clk_ops *ops; > u32 rst_bar_mask; > + unsigned long fmin; > unsigned long fmax; > 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 18842d660317..67aaa3082d9b 100644 > --- a/drivers/clk/mediatek/clk-pll.c > +++ b/drivers/clk/mediatek/clk-pll.c > @@ -32,6 +32,8 @@ > #define AUDPLL_TUNER_EN BIT(31) > > #define POSTDIV_MASK 0x7 > + > +/* default 7 bits integer, can be overridden with pcwibits. */ > #define INTEGER_BITS 7 > > /* > @@ -68,12 +70,15 @@ static unsigned long __mtk_pll_recalc_rate(struct mtk_clk_pll *pll, u32 fin, > u32 pcw, int postdiv) > { > int pcwbits = pll->data->pcwbits; > - int pcwfbits; > + int pcwfbits = 0; > + 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; > + if (pcwbits > ibits) > + pcwfbits = pcwbits - ibits; > > vco = (u64)fin * pcw; > > @@ -170,9 +175,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); > const struct mtk_pll_div_table *div_table = pll->data->div_table; > u64 _pcw; > + int ibits; > u32 val; > > if (freq > pll->data->fmax) > @@ -196,7 +202,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 >