summaryrefslogtreecommitdiffstats
path: root/drivers/clk/bcm/clk-kona.h
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2014-04-21 16:11:40 -0500
committerMike Turquette <mturquette@linaro.org>2014-04-30 11:51:33 -0700
commitb12151ca5cd76e5ed9c75ef02b2f5d2aa5b45808 (patch)
tree9d652df3ddbffed17b6a7f9145534de7f727b56e /drivers/clk/bcm/clk-kona.h
parent9d3d87c750f30af0e8e268c122ffec4489bc9638 (diff)
downloadlinux-b12151ca5cd76e5ed9c75ef02b2f5d2aa5b45808.tar.bz2
clk: bcm281xx: initialize CCU structures statically
We know up front how many CCU's we'll support, so there's no need to allocate their data structures dynamically. Define a macro KONA_CCU_COMMON() to simplify the initialization of many of the fields in a ccu_data structure. Pass the address of a statically defined CCU structure to kona_dt_ccu_setup() rather than having that function allocate one. We also know at build time how many clocks a given CCU will provide, though the number of of them for each CCU is different. Record the number of clocks we need in the CCU's clk_onecell_data struct (which is used when we register the CCU with the common clock code as a clock provider). Rename that struct field "clk_data" (because "data" alone gets a little confusing). Use the known clock count to move the allocation of each CCU's clocks array into ccu_clks_setup() rather than having each CCU's setup callback function do it. (The real motivation behind all of this is that we'll be doing some static initialization of some additional CCU-specific data soon.) Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/bcm/clk-kona.h')
-rw-r--r--drivers/clk/bcm/clk-kona.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h
index 1a7eba4ac33a..108c2647ca28 100644
--- a/drivers/clk/bcm/clk-kona.h
+++ b/drivers/clk/bcm/clk-kona.h
@@ -85,11 +85,20 @@ struct ccu_data {
bool write_enabled; /* write access is currently enabled */
struct list_head links; /* for ccu_list */
struct device_node *node;
- struct clk_onecell_data data;
+ struct clk_onecell_data clk_data;
const char *name;
u32 range; /* byte range of address space */
};
+/* Initialization for common fields in a Kona ccu_data structure */
+#define KONA_CCU_COMMON(_prefix, _name, _ucase_name) \
+ .name = #_name "_ccu", \
+ .lock = __SPIN_LOCK_UNLOCKED(_name ## _ccu_data.lock), \
+ .links = LIST_HEAD_INIT(_name ## _ccu_data.links), \
+ .clk_data = { \
+ .clk_num = _prefix ## _ ## _ucase_name ## _CCU_CLOCK_COUNT, \
+ }
+
/*
* Gating control and status is managed by a 32-bit gate register.
*
@@ -390,8 +399,11 @@ extern struct clk_ops kona_peri_clk_ops;
/* Help functions */
-#define PERI_CLK_SETUP(clks, ccu, id, name) \
- clks[id] = kona_clk_setup(ccu, #name, bcm_clk_peri, &name ## _data)
+#define KONA_CLK_SETUP(_ccu, _type, _name) \
+ kona_clk_setup((_ccu), #_name, bcm_clk_## _type, &_name ## _data)
+
+#define PERI_CLK_SETUP(_ccu, _id, _name) \
+ (_ccu)->clk_data.clks[_id] = KONA_CLK_SETUP((_ccu), peri, _name)
/* Externally visible functions */
@@ -402,7 +414,8 @@ extern u64 scaled_div_build(struct bcm_clk_div *div, u32 div_value,
extern struct clk *kona_clk_setup(struct ccu_data *ccu, const char *name,
enum bcm_clk_type type, void *data);
-extern void __init kona_dt_ccu_setup(struct device_node *node,
+extern void __init kona_dt_ccu_setup(struct ccu_data *ccu,
+ struct device_node *node,
int (*ccu_clks_setup)(struct ccu_data *));
extern bool __init kona_ccu_init(struct ccu_data *ccu);