From patchwork Tue Jan 19 14:51:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 8063231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A61829F744 for ; Tue, 19 Jan 2016 14:56:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD10120411 for ; Tue, 19 Jan 2016 14:56:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 03CDF2038A for ; Tue, 19 Jan 2016 14:56:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLXg4-0000Iw-T2; Tue, 19 Jan 2016 14:54:36 +0000 Received: from 212-186-180-163.dynamic.surfer.at ([212.186.180.163] helo=cgate.sperl.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLXeJ-0007IH-3L; Tue, 19 Jan 2016 14:52:49 +0000 Received: from raspcm.intern.sperl.org (account martin@sperl.org [10.10.10.41] verified) by sperl.org (CommuniGate Pro SMTP 6.1.2) with ESMTPSA id 6392118; Tue, 19 Jan 2016 14:51:50 +0000 From: kernel@martin.sperl.org To: Rob Herring , Stephen Warren , Lee Jones , Eric Anholt , Michael Turquette , Stephen Boyd , Remi Pommarel , devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC 6/9] clk: bcm2835: allow to define a minimum fractional divider in DT Date: Tue, 19 Jan 2016 14:51:37 +0000 Message-Id: <1453215100-2382-7-git-send-email-kernel@martin.sperl.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1453215100-2382-1-git-send-email-kernel@martin.sperl.org> References: <1453215100-2382-1-git-send-email-kernel@martin.sperl.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160119_065247_437631_9795B799 X-CRM114-Status: GOOD ( 10.98 ) X-Spam-Score: -0.9 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Sperl MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Sperl Allow to define a minimum fractional divider to use in the devicetree. This is primarily used to reduce clock-jitter introduced by the fractional/MASH divider. Signed-off-by: Martin Sperl --- drivers/clk/bcm/clk-bcm2835.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index e5313ba..7048ca5 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -711,6 +711,8 @@ struct bcm2835_clock_data { u32 int_bits; /* Number of fractional bits in the divider */ u32 frac_bits; + /* the minimum divider to allow when fractional */ + u32 min_frac_div; /* the mash value to use - see CM_MASH */ enum bcm2835_clock_mash_type mash; bool mash_forced; @@ -1709,13 +1711,21 @@ static int bcm2835_clock_determine_closest_rate(struct clk_hw *hw, struct bcm2835_rates *rates, size_t rate_cnt) { + struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw); + const struct bcm2835_clock_data *data = clock->data; struct bcm2835_rates *best = NULL; size_t i; /* find best matching */ for (i = 0; i < rate_cnt; i++) { + /* do not look at anything above the requested rate */ if (rates[i].rate > req->rate) continue; + /* if we have a divider that is not "safe", then ignore */ + if (divmash_get_divf(rates[i].dmash) && + (rates[i].div < data->min_frac_div)) + continue; + /* if we are the first */ if (!best) { best = &rates[i]; continue; @@ -2094,6 +2104,10 @@ static const struct bcm2835_clock_data *bcm2835_register_clock_of( break; } } + /* add support for min fractional divider */ + err = of_property_read_u32(nc, "brcm,min-fract-div", &value); + if (!err) + data->min_frac_div = value << CM_DIV_FRAC_BITS; /* and return the result */ return data;