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 3/9] clk: bcm2835: add ability to control mash level via device-tree
Date: Tue, 19 Jan 2016 14:51:34 +0000 [thread overview]
Message-ID: <1453215100-2382-4-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>
Control maximum mash levels that can get used via the device tree.
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
---
drivers/clk/bcm/clk-bcm2835.c | 39 +++++++++++++++++++++++++++--------
include/dt-bindings/clock/bcm2835.h | 9 ++++++++
2 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 8fccbd3..48c1ad0 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -303,10 +303,10 @@
#define BCM2835_MASH_MAX_FREQ 25000000u
enum bcm2835_clock_mash_type {
- MASH_NONE = 0,
- MASH_FRAC = 1,
- MASH_2ND_ORDER = 2,
- MASH_3RD_ORDER = 3
+ MASH_NONE = BCM2835_MASH_NONE,
+ MASH_FRAC = BCM2835_MASH_FRAC,
+ MASH_ORDER_2 = BCM2835_MASH_ORDER_2,
+ MASH_ORDER_3 = BCM2835_MASH_ORDER_3
};
/*
@@ -713,6 +713,7 @@ struct bcm2835_clock_data {
u32 frac_bits;
/* the mash value to use - see CM_MASH */
enum bcm2835_clock_mash_type mash;
+ bool mash_forced;
bool is_vpu_clock;
};
@@ -1508,7 +1509,7 @@ static divmash bcm2835_clock_choose_div(struct clk_hw *hw,
/* select mash mode */
if (data->frac_bits && divf)
- mash = data->mash ? data->mash : MASH_FRAC;
+ mash = data->mash_forced ? data->mash : MASH_FRAC;
/*
* handle possible limits for different mash levels with fall-tru
@@ -1517,17 +1518,17 @@ static divmash bcm2835_clock_choose_div(struct clk_hw *hw,
* http://elinux.org/BCM2835_datasheet_errata#p105_table
*/
switch (mash) {
- case MASH_3RD_ORDER:
+ case MASH_ORDER_3:
if ((divi >= divi_min + 3) &&
(divi + 4 <= divi_max) &&
(parent_rate / (divi - 3) <= BCM2835_MASH_MAX_FREQ))
- return divmash_calc(MASH_3RD_ORDER, div);
+ return divmash_calc(MASH_ORDER_3, div);
/* fall tru if not in bounds */
- case MASH_2ND_ORDER:
+ case MASH_ORDER_2:
if ((divi >= divi_min + 1) &&
(divi + 2 <= divi_max) &&
(parent_rate / (divi - 1) <= BCM2835_MASH_MAX_FREQ))
- return divmash_calc(MASH_2ND_ORDER, div);
+ return divmash_calc(MASH_ORDER_2, div);
/* fall tru if not in bounds */
case MASH_FRAC:
if ((divi >= divi_min) &&
@@ -1993,6 +1994,8 @@ static const struct bcm2835_clock_data *bcm2835_register_clock_of(
struct device *dev = cprman->dev;
struct device_node *nc;
struct bcm2835_clock_data *data;
+ int err;
+ u32 value;
/* find the corresponding dt-node */
nc = bcm2835_find_dt_node(cprman, id);
@@ -2008,6 +2011,24 @@ static const struct bcm2835_clock_data *bcm2835_register_clock_of(
/* apply overrides */
bcm2835_register_clock_of_parents(cprman, data, nc);
+ /* check for mash */
+ err = of_property_read_u32(nc, "brcm,mash-max-order", &value);
+ if (!err) {
+ switch (value) {
+ case MASH_NONE:
+ case MASH_FRAC:
+ case MASH_ORDER_2:
+ case MASH_ORDER_3:
+ data->mash = value;
+ data->mash_forced = 1;
+ break;
+ default:
+ dev_err(dev, "clock %s: undefined mash type: %d\n",
+ data->name, value);
+ break;
+ }
+ }
+
/* and return the result */
return data;
}
diff --git a/include/dt-bindings/clock/bcm2835.h b/include/dt-bindings/clock/bcm2835.h
index d29f181..eb73380 100644
--- a/include/dt-bindings/clock/bcm2835.h
+++ b/include/dt-bindings/clock/bcm2835.h
@@ -67,3 +67,12 @@
#define BCM2835_CLOCK_TD0 51
#define BCM2835_CLOCK_TD1 52
#define BCM2835_CLOCK_TEC 53
+
+/* the mash divider options */
+#define BCM2835_MASH_NONE 0
+#define BCM2835_MASH_ORDER_1 1
+#define BCM2835_MASH_ORDER_2 2
+#define BCM2835_MASH_ORDER_3 3
+
+#define BCM2835_MASH_INTEGER BCM2835_MASH_NONE
+#define BCM2835_MASH_FRAC BCM2835_MASH_ORDER_1
--
1.7.10.4
next prev 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
[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 2/9] clk: bcm2835: add support for parent selection " kernel
2016-01-21 8:26 ` Sascha Hauer
2016-02-08 13:30 ` Martin Sperl
2016-01-19 14:51 ` kernel [this message]
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 ` [RFC 6/9] clk: bcm2835: allow to define a minimum fractional divider in DT kernel
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-4-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).