aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/clock.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/clock.h')
-rw-r--r--arch/arm/mach-omap2/clock.h221
1 files changed, 1 insertions, 220 deletions
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index baeaff229506..9917f793c3b6 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -20,6 +20,7 @@
20#include <linux/list.h> 20#include <linux/list.h>
21 21
22#include <linux/clkdev.h> 22#include <linux/clkdev.h>
23#include <linux/clk-provider.h>
23 24
24struct omap_clk { 25struct omap_clk {
25 u16 cpu; 26 u16 cpu;
@@ -52,9 +53,6 @@ struct omap_clk {
52#define CK_34XX (CK_3430ES1 | CK_3430ES2PLUS) 53#define CK_34XX (CK_3430ES1 | CK_3430ES2PLUS)
53#define CK_3XXX (CK_34XX | CK_AM35XX | CK_36XX) 54#define CK_3XXX (CK_34XX | CK_AM35XX | CK_36XX)
54 55
55#ifdef CONFIG_COMMON_CLK
56#include <linux/clk-provider.h>
57
58struct clockdomain; 56struct clockdomain;
59#define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw) 57#define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw)
60 58
@@ -134,48 +132,6 @@ struct clockdomain;
134 }; \ 132 }; \
135 DEFINE_STRUCT_CLK(_name, _name##_parent_names, omap_hsdivider_ops); 133 DEFINE_STRUCT_CLK(_name, _name##_parent_names, omap_hsdivider_ops);
136 134
137
138#else
139
140struct module;
141struct clk;
142struct clockdomain;
143
144/* Temporary, needed during the common clock framework conversion */
145#define __clk_get_name(clk) (clk->name)
146#define __clk_get_parent(clk) (clk->parent)
147#define __clk_get_rate(clk) (clk->rate)
148
149/**
150 * struct clkops - some clock function pointers
151 * @enable: fn ptr that enables the current clock in hardware
152 * @disable: fn ptr that enables the current clock in hardware
153 * @find_idlest: function returning the IDLEST register for the clock's IP blk
154 * @find_companion: function returning the "companion" clk reg for the clock
155 * @allow_idle: fn ptr that enables autoidle for the current clock in hardware
156 * @deny_idle: fn ptr that disables autoidle for the current clock in hardware
157 *
158 * A "companion" clk is an accompanying clock to the one being queried
159 * that must be enabled for the IP module connected to the clock to
160 * become accessible by the hardware. Neither @find_idlest nor
161 * @find_companion should be needed; that information is IP
162 * block-specific; the hwmod code has been created to handle this, but
163 * until hwmod data is ready and drivers have been converted to use PM
164 * runtime calls in place of clk_enable()/clk_disable(), @find_idlest and
165 * @find_companion must, unfortunately, remain.
166 */
167struct clkops {
168 int (*enable)(struct clk *);
169 void (*disable)(struct clk *);
170 void (*find_idlest)(struct clk *, void __iomem **,
171 u8 *, u8 *);
172 void (*find_companion)(struct clk *, void __iomem **,
173 u8 *);
174 void (*allow_idle)(struct clk *);
175 void (*deny_idle)(struct clk *);
176};
177#endif
178
179/* struct clksel_rate.flags possibilities */ 135/* struct clksel_rate.flags possibilities */
180#define RATE_IN_242X (1 << 0) 136#define RATE_IN_242X (1 << 0)
181#define RATE_IN_243X (1 << 1) 137#define RATE_IN_243X (1 << 1)
@@ -314,7 +270,6 @@ struct dpll_data {
314#define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */ 270#define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */
315#define CLOCK_CLKOUTX2 (1 << 5) 271#define CLOCK_CLKOUTX2 (1 << 5)
316 272
317#ifdef CONFIG_COMMON_CLK
318/** 273/**
319 * struct clk_hw_omap - OMAP struct clk 274 * struct clk_hw_omap - OMAP struct clk
320 * @node: list_head connecting this clock into the full clock list 275 * @node: list_head connecting this clock into the full clock list
@@ -367,114 +322,6 @@ struct clk_hw_omap_ops {
367 322
368unsigned long omap_fixed_divisor_recalc(struct clk_hw *hw, 323unsigned long omap_fixed_divisor_recalc(struct clk_hw *hw,
369 unsigned long parent_rate); 324 unsigned long parent_rate);
370#else
371/**
372 * struct clk - OMAP struct clk
373 * @node: list_head connecting this clock into the full clock list
374 * @ops: struct clkops * for this clock
375 * @name: the name of the clock in the hardware (used in hwmod data and debug)
376 * @parent: pointer to this clock's parent struct clk
377 * @children: list_head connecting to the child clks' @sibling list_heads
378 * @sibling: list_head connecting this clk to its parent clk's @children
379 * @rate: current clock rate
380 * @enable_reg: register to write to enable the clock (see @enable_bit)
381 * @recalc: fn ptr that returns the clock's current rate
382 * @set_rate: fn ptr that can change the clock's current rate
383 * @round_rate: fn ptr that can round the clock's current rate
384 * @init: fn ptr to do clock-specific initialization
385 * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg)
386 * @usecount: number of users that have requested this clock to be enabled
387 * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div
388 * @flags: see "struct clk.flags possibilities" above
389 * @clksel_reg: for clksel clks, register va containing src/divisor select
390 * @clksel_mask: bitmask in @clksel_reg for the src/divisor selector
391 * @clksel: for clksel clks, pointer to struct clksel for this clock
392 * @dpll_data: for DPLLs, pointer to struct dpll_data for this clock
393 * @clkdm_name: clockdomain name that this clock is contained in
394 * @clkdm: pointer to struct clockdomain, resolved from @clkdm_name at runtime
395 * @rate_offset: bitshift for rate selection bitfield (OMAP1 only)
396 * @src_offset: bitshift for source selection bitfield (OMAP1 only)
397 *
398 * XXX @rate_offset, @src_offset should probably be removed and OMAP1
399 * clock code converted to use clksel.
400 *
401 * XXX @usecount is poorly named. It should be "enable_count" or
402 * something similar. "users" in the description refers to kernel
403 * code (core code or drivers) that have called clk_enable() and not
404 * yet called clk_disable(); the usecount of parent clocks is also
405 * incremented by the clock code when clk_enable() is called on child
406 * clocks and decremented by the clock code when clk_disable() is
407 * called on child clocks.
408 *
409 * XXX @clkdm, @usecount, @children, @sibling should be marked for
410 * internal use only.
411 *
412 * @children and @sibling are used to optimize parent-to-child clock
413 * tree traversals. (child-to-parent traversals use @parent.)
414 *
415 * XXX The notion of the clock's current rate probably needs to be
416 * separated from the clock's target rate.
417 */
418struct clk {
419 struct list_head node;
420 const struct clkops *ops;
421 const char *name;
422 struct clk *parent;
423 struct list_head children;
424 struct list_head sibling; /* node for children */
425 unsigned long rate;
426 void __iomem *enable_reg;
427 unsigned long (*recalc)(struct clk *);
428 int (*set_rate)(struct clk *, unsigned long);
429 long (*round_rate)(struct clk *, unsigned long);
430 void (*init)(struct clk *);
431 u8 enable_bit;
432 s8 usecount;
433 u8 fixed_div;
434 u8 flags;
435 void __iomem *clksel_reg;
436 u32 clksel_mask;
437 const struct clksel *clksel;
438 struct dpll_data *dpll_data;
439 const char *clkdm_name;
440 struct clockdomain *clkdm;
441#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
442 struct dentry *dent; /* For visible tree hierarchy */
443#endif
444};
445
446struct clk_functions {
447 int (*clk_enable)(struct clk *clk);
448 void (*clk_disable)(struct clk *clk);
449 long (*clk_round_rate)(struct clk *clk, unsigned long rate);
450 int (*clk_set_rate)(struct clk *clk, unsigned long rate);
451 int (*clk_set_parent)(struct clk *clk, struct clk *parent);
452 void (*clk_allow_idle)(struct clk *clk);
453 void (*clk_deny_idle)(struct clk *clk);
454 void (*clk_disable_unused)(struct clk *clk);
455};
456
457extern int mpurate;
458
459extern int clk_init(struct clk_functions *custom_clocks);
460extern void clk_preinit(struct clk *clk);
461extern int clk_register(struct clk *clk);
462extern void clk_reparent(struct clk *child, struct clk *parent);
463extern void clk_unregister(struct clk *clk);
464extern void propagate_rate(struct clk *clk);
465extern void recalculate_root_clocks(void);
466extern unsigned long followparent_recalc(struct clk *clk);
467extern void clk_enable_init_clocks(void);
468unsigned long omap_fixed_divisor_recalc(struct clk *clk);
469extern struct clk *omap_clk_get_by_name(const char *name);
470extern int omap_clk_enable_autoidle_all(void);
471extern int omap_clk_disable_autoidle_all(void);
472
473extern const struct clkops clkops_null;
474
475extern struct clk dummy_ck;
476
477#endif /* CONFIG_COMMON_CLK */
478 325
479/* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */ 326/* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */
480#define CORE_CLK_SRC_32K 0x0 327#define CORE_CLK_SRC_32K 0x0
@@ -505,15 +352,6 @@ extern struct clk dummy_ck;
505/* DPLL Type and DCO Selection Flags */ 352/* DPLL Type and DCO Selection Flags */
506#define DPLL_J_TYPE 0x1 353#define DPLL_J_TYPE 0x1
507 354
508#ifndef CONFIG_COMMON_CLK
509int omap2_clk_enable(struct clk *clk);
510void omap2_clk_disable(struct clk *clk);
511long omap2_clk_round_rate(struct clk *clk, unsigned long rate);
512int omap2_clk_set_rate(struct clk *clk, unsigned long rate);
513int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent);
514#endif /* CONFIG_COMMON_CLK */
515
516#ifdef CONFIG_COMMON_CLK
517long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate, 355long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
518 unsigned long *parent_rate); 356 unsigned long *parent_rate);
519unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate); 357unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate);
@@ -534,37 +372,11 @@ unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw,
534long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw, 372long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
535 unsigned long target_rate, 373 unsigned long target_rate,
536 unsigned long *parent_rate); 374 unsigned long *parent_rate);
537#else
538long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate);
539unsigned long omap3_dpll_recalc(struct clk *clk);
540unsigned long omap3_clkoutx2_recalc(struct clk *clk);
541void omap3_dpll_allow_idle(struct clk *clk);
542void omap3_dpll_deny_idle(struct clk *clk);
543u32 omap3_dpll_autoidle_read(struct clk *clk);
544int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
545int omap3_noncore_dpll_enable(struct clk *clk);
546void omap3_noncore_dpll_disable(struct clk *clk);
547int omap4_dpllmx_gatectrl_read(struct clk *clk);
548void omap4_dpllmx_allow_gatectrl(struct clk *clk);
549void omap4_dpllmx_deny_gatectrl(struct clk *clk);
550long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate);
551unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk);
552#endif
553 375
554#ifdef CONFIG_OMAP_RESET_CLOCKS
555void omap2_clk_disable_unused(struct clk *clk);
556#else
557#define omap2_clk_disable_unused NULL
558#endif
559#ifdef CONFIG_COMMON_CLK
560void omap2_init_clk_clkdm(struct clk_hw *clk); 376void omap2_init_clk_clkdm(struct clk_hw *clk);
561#else
562void omap2_init_clk_clkdm(struct clk *clk);
563#endif
564void __init omap2_clk_disable_clkdm_control(void); 377void __init omap2_clk_disable_clkdm_control(void);
565 378
566/* clkt_clksel.c public functions */ 379/* clkt_clksel.c public functions */
567#ifdef CONFIG_COMMON_CLK
568u32 omap2_clksel_round_rate_div(struct clk_hw_omap *clk, 380u32 omap2_clksel_round_rate_div(struct clk_hw_omap *clk,
569 unsigned long target_rate, 381 unsigned long target_rate,
570 u32 *new_div); 382 u32 *new_div);
@@ -575,29 +387,14 @@ long omap2_clksel_round_rate(struct clk_hw *hw, unsigned long target_rate,
575int omap2_clksel_set_rate(struct clk_hw *hw, unsigned long rate, 387int omap2_clksel_set_rate(struct clk_hw *hw, unsigned long rate,
576 unsigned long parent_rate); 388 unsigned long parent_rate);
577int omap2_clksel_set_parent(struct clk_hw *hw, u8 field_val); 389int omap2_clksel_set_parent(struct clk_hw *hw, u8 field_val);
578#else
579u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
580 u32 *new_div);
581void omap2_init_clksel_parent(struct clk *clk);
582unsigned long omap2_clksel_recalc(struct clk *clk);
583long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate);
584int omap2_clksel_set_rate(struct clk *clk, unsigned long rate);
585int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent);
586#endif
587 390
588/* clkt_iclk.c public functions */ 391/* clkt_iclk.c public functions */
589extern void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk); 392extern void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk);
590extern void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk); 393extern void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk);
591 394
592#ifdef CONFIG_COMMON_CLK
593u8 omap2_init_dpll_parent(struct clk_hw *hw); 395u8 omap2_init_dpll_parent(struct clk_hw *hw);
594unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk); 396unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk);
595#else
596u32 omap2_get_dpll_rate(struct clk *clk);
597void omap2_init_dpll_parent(struct clk *clk);
598#endif
599 397
600#ifdef CONFIG_COMMON_CLK
601int omap2_dflt_clk_enable(struct clk_hw *hw); 398int omap2_dflt_clk_enable(struct clk_hw *hw);
602void omap2_dflt_clk_disable(struct clk_hw *hw); 399void omap2_dflt_clk_disable(struct clk_hw *hw);
603int omap2_dflt_clk_is_enabled(struct clk_hw *hw); 400int omap2_dflt_clk_is_enabled(struct clk_hw *hw);
@@ -611,14 +408,6 @@ void omap2_init_clk_hw_omap_clocks(struct clk *clk);
611int omap2_clk_enable_autoidle_all(void); 408int omap2_clk_enable_autoidle_all(void);
612int omap2_clk_disable_autoidle_all(void); 409int omap2_clk_disable_autoidle_all(void);
613void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks); 410void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks);
614#else
615int omap2_dflt_clk_enable(struct clk *clk);
616void omap2_dflt_clk_disable(struct clk *clk);
617void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg,
618 u8 *other_bit);
619void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg,
620 u8 *idlest_bit, u8 *idlest_val);
621#endif
622int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name); 411int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name);
623void omap2_clk_print_new_rates(const char *hfclkin_ck_name, 412void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
624 const char *core_ck_name, 413 const char *core_ck_name,
@@ -665,17 +454,9 @@ extern const struct clksel_rate div_1_3_rates[];
665extern const struct clksel_rate div_1_4_rates[]; 454extern const struct clksel_rate div_1_4_rates[];
666extern const struct clksel_rate div31_1to31_rates[]; 455extern const struct clksel_rate div31_1to31_rates[];
667 456
668#ifndef CONFIG_COMMON_CLK
669/* clocks shared between various OMAP SoCs */
670extern struct clk virt_19200000_ck;
671extern struct clk virt_26000000_ck;
672#endif
673
674extern int am33xx_clk_init(void); 457extern int am33xx_clk_init(void);
675 458
676#ifdef CONFIG_COMMON_CLK
677extern int omap2_clkops_enable_clkdm(struct clk_hw *hw); 459extern int omap2_clkops_enable_clkdm(struct clk_hw *hw);
678extern void omap2_clkops_disable_clkdm(struct clk_hw *hw); 460extern void omap2_clkops_disable_clkdm(struct clk_hw *hw);
679#endif
680 461
681#endif 462#endif