Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965260AbaFQVX1 (ORCPT ); Tue, 17 Jun 2014 17:23:27 -0400 Received: from mail-ve0-f179.google.com ([209.85.128.179]:42855 "EHLO mail-ve0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964976AbaFQVXY (ORCPT ); Tue, 17 Jun 2014 17:23:24 -0400 MIME-Version: 1.0 In-Reply-To: <1403016777-15121-6-git-send-email-wens@csie.org> References: <1403016777-15121-1-git-send-email-wens@csie.org> <1403016777-15121-6-git-send-email-wens@csie.org> From: Rob Herring Date: Tue, 17 Jun 2014 16:23:02 -0500 Message-ID: Subject: Re: [PATCH v2 05/20] clk: sunxi: Support factor clocks with N multiplier factor starting from 1 To: Chen-Yu Tsai Cc: Greg Kroah-Hartman , Samuel Ortiz , Lee Jones , Maxime Ripard , Rob Herring , Mike Turquette , Emilio Lopez , Linus Walleij , "linux-serial@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , linux-sunxi@googlegroups.com, "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Boris BREZILLON , Luc Verhaegen Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 17, 2014 at 9:52 AM, Chen-Yu Tsai wrote: > The PLLs on newer Allwinner SoC's, such as the A31 and A23, have a > N multiplier factor that starts from 1, not 0. > > This patch adds an option to the clock driver's config data structures > to define the difference. > > Signed-off-by: Chen-Yu Tsai > Acked-by: Maxime Ripard > --- > drivers/clk/sunxi/clk-factors.c | 5 ++++- > drivers/clk/sunxi/clk-factors.h | 1 + > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c > index 3806d97..399cf4d 100644 > --- a/drivers/clk/sunxi/clk-factors.c > +++ b/drivers/clk/sunxi/clk-factors.c > @@ -62,7 +62,10 @@ static unsigned long clk_factors_recalc_rate(struct clk_hw *hw, > p = FACTOR_GET(config->pshift, config->pwidth, reg); > > /* Calculate the rate */ > - rate = (parent_rate * n * (k + 1) >> p) / (m + 1); > + if (config->n_from_one) > + rate = (parent_rate * (n + 1) * (k + 1) >> p) / (m + 1); > + else > + rate = (parent_rate * n * (k + 1) >> p) / (m + 1); This can be simplified and support any base with: rate = (parent_rate * (n + config->n_base) * (k + 1) >> p) / (m + 1); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/