devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kernel@martin.sperl.org
To: Rob Herring <robh+dt@kernel.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Lee Jones <lee@kernel.org>, Eric Anholt <eric@anholt.net>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Remi Pommarel <repk@triplefau.lt>,
	devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org
Cc: Martin Sperl <kernel@martin.sperl.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	[thread overview]
Message-ID: <1453215100-2382-7-git-send-email-kernel@martin.sperl.org> (raw)
In-Reply-To: <1453215100-2382-1-git-send-email-kernel@martin.sperl.org>

From: Martin Sperl <kernel@martin.sperl.org>

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 <kernel@martin.sperl.org>
---
 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;
-- 
1.7.10.4


  parent reply	other threads:[~2016-01-19 14:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 14:51 [RFC 0/9] Allow modifications of specific clocks via DT and more kernel-TqfNSX0MhmxHKSADF0wUEw
2016-01-19 14:51 ` [RFC 2/9] clk: bcm2835: add support for parent selection in DT kernel
2016-01-21  8:26   ` Sascha Hauer
2016-02-08 13:30     ` Martin Sperl
2016-01-19 14:51 ` [RFC 3/9] clk: bcm2835: add ability to control mash level via device-tree kernel
2016-01-19 14:51 ` [RFC 4/9] clk: bcm2835: reorganize bcm2835_clock_determine_rate kernel
2016-01-19 14:51 ` [RFC 5/9] clk: bcm2835: prefer clocks that use integer dividers kernel
2016-01-19 14:51 ` kernel [this message]
     [not found] ` <1453215100-2382-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-01-19 14:51   ` [RFC 1/9] clk: bcm2835: add basic device tree support for per clock settings kernel-TqfNSX0MhmxHKSADF0wUEw
2016-01-19 14:51   ` [RFC 7/9] clk: bcm2835: allow clock choosing mechanims to be selected in DT kernel-TqfNSX0MhmxHKSADF0wUEw
2016-01-19 14:51 ` [RFC 8/9] dt-bindings: bcm2835: document optional per clock dt-nodes kernel
2016-01-19 14:51 ` [RFC 9/9] clk: bcm2835: expose raw clock-registers via debugfs kernel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453215100-2382-7-git-send-email-kernel@martin.sperl.org \
    --to=kernel@martin.sperl.org \
    --cc=devicetree@vger.kernel.org \
    --cc=eric@anholt.net \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=mturquette@baylibre.com \
    --cc=repk@triplefau.lt \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=swarren@wwwdotorg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).