From: Rob Herring <robherring2@gmail.com>
To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Cc: Mike Turquette <mturquette@linaro.org>,
Rob Herring <rob.herring@calxeda.com>
Subject: [PATCH 5/7] clk: highbank: allow for different PLL frequency range
Date: Wed, 4 Dec 2013 17:35:25 -0600 [thread overview]
Message-ID: <1386200127-23143-6-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1386200127-23143-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <rob.herring@calxeda.com>
Newer versions of Calxeda PLLs have a different frequency range. Make
the max frequency a variable and add a DT property to handle different
maximum frequencies for the PLLs.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Mike Turquette <mturquette@linaro.org>
---
drivers/clk/clk-highbank.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/drivers/clk/clk-highbank.c b/drivers/clk/clk-highbank.c
index dc7ca30..89efcbc 100644
--- a/drivers/clk/clk-highbank.c
+++ b/drivers/clk/clk-highbank.c
@@ -30,7 +30,7 @@
#define HB_PLL_DIVQ_SHIFT 16
#define HB_PLL_DIVQ_MASK 0x00070000
#define HB_PLL_DIVR_SHIFT 8
-#define HB_PLL_DIVR_MASK 0x00001f00
+#define HB_PLL_DIVR_MASK 0x00003f00
#define HB_PLL_RANGE_SHIFT 4
#define HB_PLL_RANGE_MASK 0x00000070
#define HB_PLL_BYPASS 0x00000008
@@ -38,9 +38,7 @@
#define HB_PLL_EXT_BYPASS 0x00000002
#define HB_PLL_EXT_ENA 0x00000001
-#define HB_PLL_VCO_MIN_FREQ 2133000000
-#define HB_PLL_MAX_FREQ HB_PLL_VCO_MIN_FREQ
-#define HB_PLL_MIN_FREQ (HB_PLL_VCO_MIN_FREQ / 64)
+#define HB_PLL_MAX_FREQ 2133000000
#define HB_A9_BCLK_DIV_MASK 0x00000006
#define HB_A9_BCLK_DIV_SHIFT 1
@@ -49,6 +47,7 @@
struct hb_clk {
struct clk_hw hw;
void __iomem *reg;
+ u32 max_freq;
char *parent_name;
};
#define to_hb_clk(p) container_of(p, struct hb_clk, hw)
@@ -119,19 +118,21 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk,
return vco_freq / (1 << divq);
}
-static void clk_pll_calc(unsigned long rate, unsigned long ref_freq,
+static void clk_pll_calc(struct clk_hw *hwclk, unsigned long rate,
+ unsigned long ref_freq,
u32 *pdivq, u32 *pdivf)
{
+ u32 pll_max_freq = to_hb_clk(hwclk)->max_freq;
u32 divq, divf;
unsigned long vco_freq;
- if (rate < HB_PLL_MIN_FREQ)
- rate = HB_PLL_MIN_FREQ;
- if (rate > HB_PLL_MAX_FREQ)
- rate = HB_PLL_MAX_FREQ;
+ if (rate < (pll_max_freq / 64))
+ rate = pll_max_freq / 64;
+ if (rate > pll_max_freq)
+ rate = pll_max_freq;
for (divq = 1; divq <= 6; divq++) {
- if ((rate * (1 << divq)) >= HB_PLL_VCO_MIN_FREQ)
+ if ((rate * (1 << divq)) >= pll_max_freq)
break;
}
@@ -149,7 +150,7 @@ static long clk_pll_round_rate(struct clk_hw *hwclk, unsigned long rate,
u32 divq, divf;
unsigned long ref_freq = *parent_rate;
- clk_pll_calc(rate, ref_freq, &divq, &divf);
+ clk_pll_calc(hwclk, rate, ref_freq, &divq, &divf);
return (ref_freq * (divf + 1)) / (1 << divq);
}
@@ -161,7 +162,7 @@ static int clk_pll_set_rate(struct clk_hw *hwclk, unsigned long rate,
u32 divq, divf;
u32 reg;
- clk_pll_calc(rate, parent_rate, &divq, &divf);
+ clk_pll_calc(hwclk, rate, parent_rate, &divq, &divf);
reg = readl(hbclk->reg);
if (divf != ((reg & HB_PLL_DIVF_MASK) >> HB_PLL_DIVF_SHIFT)) {
@@ -304,6 +305,10 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk
of_property_read_string(node, "clock-output-names", &clk_name);
+ of_property_read_u32(node, "calxeda,pll-max-hz", &hb_clk->max_freq);
+ if (!hb_clk->max_freq)
+ hb_clk->max_freq = HB_PLL_MAX_FREQ;
+
init.name = clk_name;
init.ops = ops;
init.flags = 0;
--
1.8.3.2
next prev parent reply other threads:[~2013-12-04 23:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-04 23:35 [PATCH 0/7] Calxeda arm64 clock updates Rob Herring
2013-12-04 23:35 ` [PATCH 1/7] dt-bindings: add Calxeda ECX-3000 clock binding Rob Herring
2013-12-04 23:35 ` [PATCH 2/7] dt-bindings: Add property calxeda,pll-max-hz for Calxeda clocks Rob Herring
2013-12-04 23:35 ` [PATCH 3/7] dt-bindings: Add Calxeda system registers binding Rob Herring
2013-12-04 23:35 ` [PATCH 4/7] clk: highbank: prevent glitching when going into bypass mode Rob Herring
2013-12-04 23:35 ` Rob Herring [this message]
2013-12-04 23:35 ` [PATCH 6/7] clk: highbank: allow enabling by user Rob Herring
2013-12-04 23:35 ` [PATCH 7/7] clk: highbank: add DT match for calxeda,ecx-3000-sregs Rob Herring
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=1386200127-23143-6-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=rob.herring@calxeda.com \
/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