Received: by 10.223.185.116 with SMTP id b49csp7926073wrg; Thu, 1 Mar 2018 13:42:34 -0800 (PST) X-Google-Smtp-Source: AG47ELuTkHyR3xxu5xjgloXfroYecKpOE8XekfoZFRAN4gKTpBK2nW36+HHwqxzuCdZZ4g854Nee X-Received: by 10.98.36.25 with SMTP id r25mr3424472pfj.106.1519940554459; Thu, 01 Mar 2018 13:42:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519940554; cv=none; d=google.com; s=arc-20160816; b=wdPn9e14LBN27kwqVY0gwh6HR+QY9fEK2ovQfzrxjKwMIqrB9zBLyX7ncMdwy6/Cb0 xbfVqFiMZFSdxB6CtiRn5nQX8nNa23Th3Fm7koDpY42rVLGrL4afTFn3UB2OkcTGHWmh 42JYfGlM7rg32vHbEeo4KlhFruzUya6uIk87Rf+ZueUuiqj7ug4CwWcL7GdMTwmoAKGd KDjELRAyZE53giN00739J4KbwzWPgbVlCK1uyqEXL2BeZ1Dw1eksfX8/DJhO3V1X1KCg YunfZC++s9r0qcDasVYB6VnH43tAQpWirPSDshzz+xT6DdQzbksmxSQLT3T9XPnV56+w wFVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=78o7FOMCdNM6yPxtKWuvia0RMvah8IiKKQLm6vhmNGY=; b=VdelOUGkNfh6NVJiZVY1XedufgZdufqOk4h8GOx7mTnMB1Pi5AyFDkuDBdwfpNK1RJ NX82BJo4Vlit+ucdDEFeX60xhf7xbmo1AC9Ns+xO084mSleFFhdRZQa8Z2GMQiAkbABW 4FpAxjcaHT0WzRJEZgjoGyNsoUGuuzL6TxDHfQ4vYsl9ZzehNBMhlBhO5xo6AOKUylxY eaENdhjfWbyT56Op70z+dahc4HX2Ech6/eutn2aU1FTQhqW0Dgo3fpEz2wkQRzhwtw15 hVndGmmxDtPZxmdnWjlPiyPRR+6gp6RRzS4ty8OEjNMm50b2wg1h4YzWdmu3qD001bSt x/ZA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15si2949770pgq.51.2018.03.01.13.42.19; Thu, 01 Mar 2018 13:42:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162169AbeCAVk7 (ORCPT + 99 others); Thu, 1 Mar 2018 16:40:59 -0500 Received: from mailoutvs4.siol.net ([213.250.19.137]:33025 "EHLO mail.siol.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1162062AbeCAVe5 (ORCPT ); Thu, 1 Mar 2018 16:34:57 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id 919D4522F83; Thu, 1 Mar 2018 22:34:55 +0100 (CET) X-Virus-Scanned: amavisd-new at psrvmta11.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta11.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id xrv4aJ8gZ64W; Thu, 1 Mar 2018 22:34:55 +0100 (CET) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id F0E0C522F8A; Thu, 1 Mar 2018 22:34:54 +0100 (CET) Received: from localhost.localdomain (cpe-86-58-68-135.ftth.triera.net [86.58.68.135]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPSA id 48B76522F83; Thu, 1 Mar 2018 22:34:52 +0100 (CET) From: Jernej Skrabec To: maxime.ripard@free-electrons.com, wens@csie.org, airlied@linux.ie, robh+dt@kernel.org, mark.rutland@arm.com, mturquette@baylibre.com, sboyd@kernel.org Cc: jernej.skrabec@siol.net, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-sunxi@googlegroups.com Subject: [PATCH v3 01/16] clk: sunxi-ng: Add check for minimal rate to NM PLLs Date: Thu, 1 Mar 2018 22:34:27 +0100 Message-Id: <20180301213442.16677-2-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180301213442.16677-1-jernej.skrabec@siol.net> References: <20180301213442.16677-1-jernej.skrabec@siol.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some NM PLLs doesn't work well when their output clock rate is set below certain rate. Add support for that constrain. Signed-off-by: Jernej Skrabec --- drivers/clk/sunxi-ng/ccu_nm.c | 7 +++++++ drivers/clk/sunxi-ng/ccu_nm.h | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/clk/sunxi-ng/ccu_nm.c b/drivers/clk/sunxi-ng/ccu_nm.c index a16de092bf94..4e2073307f34 100644 --- a/drivers/clk/sunxi-ng/ccu_nm.c +++ b/drivers/clk/sunxi-ng/ccu_nm.c @@ -117,6 +117,13 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate, if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV) rate *= nm->fixed_post_div; + if (rate < nm->min_rate) { + rate = nm->min_rate; + if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV) + rate /= nm->fixed_post_div; + return rate; + } + if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) { if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV) rate /= nm->fixed_post_div; diff --git a/drivers/clk/sunxi-ng/ccu_nm.h b/drivers/clk/sunxi-ng/ccu_nm.h index eba586b4c7d0..1d8b459c50b7 100644 --- a/drivers/clk/sunxi-ng/ccu_nm.h +++ b/drivers/clk/sunxi-ng/ccu_nm.h @@ -37,6 +37,7 @@ struct ccu_nm { struct ccu_sdm_internal sdm; unsigned int fixed_post_div; + unsigned int min_rate; struct ccu_common common; }; @@ -88,6 +89,32 @@ struct ccu_nm { }, \ } +#define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN(_struct, _name, _parent, \ + _reg, _min_rate, \ + _nshift, _nwidth, \ + _mshift, _mwidth, \ + _frac_en, _frac_sel, \ + _frac_rate_0, _frac_rate_1,\ + _gate, _lock, _flags) \ + struct ccu_nm _struct = { \ + .enable = _gate, \ + .lock = _lock, \ + .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \ + .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \ + .frac = _SUNXI_CCU_FRAC(_frac_en, _frac_sel, \ + _frac_rate_0, \ + _frac_rate_1), \ + .min_rate = _min_rate, \ + .common = { \ + .reg = _reg, \ + .features = CCU_FEATURE_FRACTIONAL, \ + .hw.init = CLK_HW_INIT(_name, \ + _parent, \ + &ccu_nm_ops, \ + _flags), \ + }, \ + } + #define SUNXI_CCU_NM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \ _nshift, _nwidth, \ _mshift, _mwidth, \ -- 2.16.2