aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/bcm/clk-kona.h
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2014-04-21 17:11:41 -0400
committerMike Turquette <mturquette@linaro.org>2014-04-30 14:51:35 -0400
commit03548ec06ad3ec75d5b212fa832e4e617334ea09 (patch)
tree3746d54ef058113437fea44065947de4aa05a47f /drivers/clk/bcm/clk-kona.h
parentb12151ca5cd76e5ed9c75ef02b2f5d2aa5b45808 (diff)
clk: bcm281xx: define CCU clock data statically
Rather than "manually" setting up each CCU's clock entries at run time, define a flexible array of generic Kona clock structures within the CCU structure itself. Each of these entries contains generic kona clock information (like its CCU pointer and clock framework initialization data). Each also has a pointer to a structure contianing clock type-dependent initialization data (like register definitions). Since we'll iterate over these arrays we need to be sure they have slots for all potential clock index values. (E.g. for the root CCU we must have at least BCM281XX_ROOT_CCU_CLOCK_COUNT slots.) To ensure this we always define an extra entry and fill it using the special initializer LAST_KONA_CLK. Just about everything we need to know about a clock can be defined statically. As a result, kona_clk_setup() can be changed to take just a kona_clk structure as its argument, and peri_clk_setup() can be simplified. With the information pre-defined we are also able to handle most clock setup genericially. We can do away with the CCU-specific callback functions that previously were needed to set up the entries in CCU's clock array. Move the definition of the ccu_data structure down in "clk-kona.h" to avoid a forward dependency. 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.h84
1 files changed, 44 insertions, 40 deletions
diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h
index 108c2647ca28..05d74779a564 100644
--- a/drivers/clk/bcm/clk-kona.h
+++ b/drivers/clk/bcm/clk-kona.h
@@ -71,35 +71,6 @@ enum bcm_clk_type {
71}; 71};
72 72
73/* 73/*
74 * Each CCU defines a mapped area of memory containing registers
75 * used to manage clocks implemented by the CCU. Access to memory
76 * within the CCU's space is serialized by a spinlock. Before any
77 * (other) address can be written, a special access "password" value
78 * must be written to its WR_ACCESS register (located at the base
79 * address of the range). We keep track of the name of each CCU as
80 * it is set up, and maintain them in a list.
81 */
82struct ccu_data {
83 void __iomem *base; /* base of mapped address space */
84 spinlock_t lock; /* serialization lock */
85 bool write_enabled; /* write access is currently enabled */
86 struct list_head links; /* for ccu_list */
87 struct device_node *node;
88 struct clk_onecell_data clk_data;
89 const char *name;
90 u32 range; /* byte range of address space */
91};
92
93/* Initialization for common fields in a Kona ccu_data structure */
94#define KONA_CCU_COMMON(_prefix, _name, _ucase_name) \
95 .name = #_name "_ccu", \
96 .lock = __SPIN_LOCK_UNLOCKED(_name ## _ccu_data.lock), \
97 .links = LIST_HEAD_INIT(_name ## _ccu_data.links), \
98 .clk_data = { \
99 .clk_num = _prefix ## _ ## _ucase_name ## _CCU_CLOCK_COUNT, \
100 }
101
102/*
103 * Gating control and status is managed by a 32-bit gate register. 74 * Gating control and status is managed by a 32-bit gate register.
104 * 75 *
105 * There are several types of gating available: 76 * There are several types of gating available:
@@ -393,17 +364,52 @@ struct kona_clk {
393#define to_kona_clk(_hw) \ 364#define to_kona_clk(_hw) \
394 container_of(_hw, struct kona_clk, hw) 365 container_of(_hw, struct kona_clk, hw)
395 366
396/* Exported globals */ 367/* Initialization macro for an entry in a CCU's kona_clks[] array. */
368#define KONA_CLK(_ccu_name, _clk_name, _type) \
369 { \
370 .init_data = { \
371 .name = #_clk_name, \
372 .ops = &kona_ ## _type ## _clk_ops, \
373 }, \
374 .ccu = &_ccu_name ## _ccu_data, \
375 .type = bcm_clk_ ## _type, \
376 .u.data = &_clk_name ## _data, \
377 }
378#define LAST_KONA_CLK { .type = bcm_clk_none }
397 379
398extern struct clk_ops kona_peri_clk_ops; 380/*
381 * Each CCU defines a mapped area of memory containing registers
382 * used to manage clocks implemented by the CCU. Access to memory
383 * within the CCU's space is serialized by a spinlock. Before any
384 * (other) address can be written, a special access "password" value
385 * must be written to its WR_ACCESS register (located at the base
386 * address of the range). We keep track of the name of each CCU as
387 * it is set up, and maintain them in a list.
388 */
389struct ccu_data {
390 void __iomem *base; /* base of mapped address space */
391 spinlock_t lock; /* serialization lock */
392 bool write_enabled; /* write access is currently enabled */
393 struct list_head links; /* for ccu_list */
394 struct device_node *node;
395 struct clk_onecell_data clk_data;
396 const char *name;
397 u32 range; /* byte range of address space */
398 struct kona_clk kona_clks[]; /* must be last */
399};
399 400
400/* Help functions */ 401/* Initialization for common fields in a Kona ccu_data structure */
402#define KONA_CCU_COMMON(_prefix, _name, _ccuname) \
403 .name = #_name "_ccu", \
404 .lock = __SPIN_LOCK_UNLOCKED(_name ## _ccu_data.lock), \
405 .links = LIST_HEAD_INIT(_name ## _ccu_data.links), \
406 .clk_data = { \
407 .clk_num = _prefix ## _ ## _ccuname ## _CCU_CLOCK_COUNT, \
408 }
401 409
402#define KONA_CLK_SETUP(_ccu, _type, _name) \ 410/* Exported globals */
403 kona_clk_setup((_ccu), #_name, bcm_clk_## _type, &_name ## _data)
404 411
405#define PERI_CLK_SETUP(_ccu, _id, _name) \ 412extern struct clk_ops kona_peri_clk_ops;
406 (_ccu)->clk_data.clks[_id] = KONA_CLK_SETUP((_ccu), peri, _name)
407 413
408/* Externally visible functions */ 414/* Externally visible functions */
409 415
@@ -412,11 +418,9 @@ extern u64 scaled_div_max(struct bcm_clk_div *div);
412extern u64 scaled_div_build(struct bcm_clk_div *div, u32 div_value, 418extern u64 scaled_div_build(struct bcm_clk_div *div, u32 div_value,
413 u32 billionths); 419 u32 billionths);
414 420
415extern struct clk *kona_clk_setup(struct ccu_data *ccu, const char *name, 421extern struct clk *kona_clk_setup(struct kona_clk *bcm_clk);
416 enum bcm_clk_type type, void *data);
417extern void __init kona_dt_ccu_setup(struct ccu_data *ccu, 422extern void __init kona_dt_ccu_setup(struct ccu_data *ccu,
418 struct device_node *node, 423 struct device_node *node);
419 int (*ccu_clks_setup)(struct ccu_data *));
420extern bool __init kona_ccu_init(struct ccu_data *ccu); 424extern bool __init kona_ccu_init(struct ccu_data *ccu);
421 425
422#endif /* _CLK_KONA_H */ 426#endif /* _CLK_KONA_H */