From: kernel@martin.sperl.org (kernel at martin.sperl.org)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/5] clk: bcm2835: allow setting clocks flags via the dt
Date: Thu, 5 May 2016 15:53:27 +0000 [thread overview]
Message-ID: <1462463608-22940-5-git-send-email-kernel@martin.sperl.org> (raw)
In-Reply-To: <1462463608-22940-1-git-send-email-kernel@martin.sperl.org>
From: Martin Sperl <kernel@martin.sperl.org>
Allow setting flags for each clock via the device tree.
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
---
drivers/clk/bcm/clk-bcm2835.c | 57 +++++++++++++++++++++++++++++++++++--------
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 8a44ebf..c80487e 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1125,7 +1125,8 @@ static const struct clk_ops bcm2835_vpu_clock_clk_ops = {
};
static struct clk *bcm2835_register_pll(struct bcm2835_cprman *cprman,
- const struct bcm2835_pll_data *data)
+ const struct bcm2835_pll_data *data,
+ u32 flags)
{
struct bcm2835_pll *pll;
struct clk_init_data init;
@@ -1152,7 +1153,8 @@ static struct clk *bcm2835_register_pll(struct bcm2835_cprman *cprman,
static struct clk *
bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
- const struct bcm2835_pll_divider_data *data)
+ const struct bcm2835_pll_divider_data *data,
+ u32 flags)
{
struct bcm2835_pll_divider *divider;
struct clk_init_data init;
@@ -1223,8 +1225,10 @@ static u32 bcm2835_register_clock_default_parents(
struct device *dev,
const struct bcm2835_clock_data *data);
-static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman,
- const struct bcm2835_clock_data *data)
+static struct clk *
+bcm2835_register_clock(struct bcm2835_cprman *cprman,
+ const struct bcm2835_clock_data *data,
+ u32 flags)
{
struct bcm2835_clock *clock;
struct clk_init_data init;
@@ -1270,14 +1274,19 @@ static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman,
clock->cprman = cprman;
clock->data = data;
clock->hw.init = &init;
- clock->flags = bcm2835_register_clock_default_parents(
- cprman->dev, data);
+
+ clock->flags = flags;
+ if ((clock->flags & (BIT(data->num_mux_parents) - 1)) == 0)
+ clock->flags |= bcm2835_register_clock_default_parents(
+ cprman->dev, data);
return devm_clk_register(cprman->dev, &clock->hw);
}
-static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman,
- const struct bcm2835_gate_data *data)
+static struct clk *
+bcm2835_register_gate(struct bcm2835_cprman *cprman,
+ const struct bcm2835_gate_data *data,
+ u32 flags)
{
return clk_register_gate(cprman->dev, data->name, data->parent,
CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
@@ -1286,7 +1295,7 @@ static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman,
}
typedef struct clk *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,
- const void *data);
+ const void *data, int flags);
struct bcm2835_clk_desc {
bcm2835_clk_register clk_register;
const void *data;
@@ -1861,6 +1870,10 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
struct resource *res;
const struct bcm2835_clk_desc *desc;
const size_t asize = ARRAY_SIZE(clk_desc_array);
+ u32 flags[asize], index;
+ struct property *prop;
+ const __be32 *cur;
+ int ret;
size_t i;
cprman = devm_kzalloc(dev,
@@ -1869,6 +1882,29 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
if (!cprman)
return -ENOMEM;
+ /* fill in flags from dt */
+ memset(flags, 0, sizeof(flags));
+ i = 0;
+ of_property_for_each_u32(dev->of_node, "brcm,clock-index",
+ prop, cur, index) {
+ if (index >= asize) {
+ dev_err(dev,
+ "clock-index %d in \"brcm,clock-index\" is out of bounds at position %d\n",
+ index, i);
+ } else {
+ ret = of_property_read_u32_index(dev->of_node,
+ "brcm,clock-flags",
+ i, &flags[index]);
+ if (ret) {
+ dev_err(dev,
+ "no value at position %d in \"brcm,clock-flags\" - %d\n",
+ i, ret);
+ }
+ }
+ /* increment index */
+ i++;
+ }
+
spin_lock_init(&cprman->regs_lock);
cprman->dev = dev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1889,7 +1925,8 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
for (i = 0; i < asize; i++) {
desc = &clk_desc_array[i];
if (desc->clk_register && desc->data)
- clks[i] = desc->clk_register(cprman, desc->data);
+ clks[i] = desc->clk_register(cprman, desc->data,
+ flags[i]);
}
return of_clk_add_provider(dev->of_node, of_clk_src_onecell_get,
--
2.1.4
next prev parent reply other threads:[~2016-05-05 15:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-05 15:53 [PATCH 0/5] clk: bcm2835: add flags for mash and parent clocks kernel at martin.sperl.org
2016-05-05 15:53 ` [PATCH 1/5] dt: bindings: add means to control flags of specific clocks kernel at martin.sperl.org
2016-05-09 19:11 ` Rob Herring
2016-05-05 15:53 ` [PATCH 2/5] clk: bcm2835: expose the parent clocks via include/dt-bindings kernel at martin.sperl.org
2016-05-05 15:53 ` [PATCH 3/5] clk: bcm2835: enable default filtering for parent clocks kernel at martin.sperl.org
2016-05-05 15:53 ` kernel at martin.sperl.org [this message]
2016-05-05 15:53 ` [PATCH 5/5] clk: bcm2835: add support for BCM2835_CLOCK_FLAG_USE_MASH/INTEGER kernel at martin.sperl.org
2016-05-10 1:05 ` [PATCH 0/5] clk: bcm2835: add flags for mash and parent clocks Eric Anholt
2016-05-10 8:32 ` Martin Sperl
2016-05-10 17:45 ` Eric Anholt
2016-05-12 9:19 ` Martin Sperl
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=1462463608-22940-5-git-send-email-kernel@martin.sperl.org \
--to=kernel@martin.sperl.org \
--cc=linux-arm-kernel@lists.infradead.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).