sh: add shared clock framework frequency table code
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / sh / include / asm / clock.h
blob60d5d2bc714a7737a97384b017b8eb4516b144e1
1 #ifndef __ASM_SH_CLOCK_H
2 #define __ASM_SH_CLOCK_H
4 #include <linux/list.h>
5 #include <linux/seq_file.h>
6 #include <linux/clk.h>
7 #include <linux/err.h>
9 struct clk;
11 struct clk_ops {
12 void (*init)(struct clk *clk);
13 int (*enable)(struct clk *clk);
14 void (*disable)(struct clk *clk);
15 unsigned long (*recalc)(struct clk *clk);
16 int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
17 int (*set_parent)(struct clk *clk, struct clk *parent);
18 long (*round_rate)(struct clk *clk, unsigned long rate);
19 void (*build_rate_table)(struct clk *clk);
22 struct clk {
23 struct list_head node;
24 const char *name;
25 int id;
26 struct module *owner;
28 struct clk *parent;
29 struct clk_ops *ops;
31 struct list_head children;
32 struct list_head sibling; /* node for children */
34 int usecount;
36 unsigned long rate;
37 unsigned long flags;
39 void __iomem *enable_reg;
40 unsigned int enable_bit;
42 unsigned long arch_flags;
43 void *priv;
44 struct dentry *dentry;
47 struct clk_lookup {
48 struct list_head node;
49 const char *dev_id;
50 const char *con_id;
51 struct clk *clk;
54 #define CLK_ENABLE_ON_INIT (1 << 0)
56 /* Should be defined by processor-specific code */
57 void __deprecated arch_init_clk_ops(struct clk_ops **, int type);
58 int __init arch_clk_init(void);
60 /* arch/sh/kernel/cpu/clock.c */
61 int clk_init(void);
62 unsigned long followparent_recalc(struct clk *);
63 void recalculate_root_clocks(void);
64 void propagate_rate(struct clk *);
65 int clk_reparent(struct clk *child, struct clk *parent);
66 int clk_register(struct clk *);
67 void clk_unregister(struct clk *);
69 /* arch/sh/kernel/cpu/clock-cpg.c */
70 int __init __deprecated cpg_clk_init(void);
72 /* the exported API, in addition to clk_set_rate */
73 /**
74 * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
75 * @clk: clock source
76 * @rate: desired clock rate in Hz
77 * @algo_id: algorithm id to be passed down to ops->set_rate
79 * Returns success (0) or negative errno.
81 int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id);
83 enum clk_sh_algo_id {
84 NO_CHANGE = 0,
86 IUS_N1_N1,
87 IUS_322,
88 IUS_522,
89 IUS_N11,
91 SB_N1,
93 SB3_N1,
94 SB3_32,
95 SB3_43,
96 SB3_54,
98 BP_N1,
100 IP_N1,
103 struct clk_div_mult_table {
104 unsigned int *divisors;
105 unsigned int nr_divisors;
106 unsigned int *multipliers;
107 unsigned int nr_multipliers;
110 struct cpufreq_frequency_table;
111 void clk_rate_table_build(struct clk *clk,
112 struct cpufreq_frequency_table *freq_table,
113 int nr_freqs,
114 struct clk_div_mult_table *src_table,
115 unsigned long *bitmap);
117 long clk_rate_table_round(struct clk *clk,
118 struct cpufreq_frequency_table *freq_table,
119 unsigned long rate);
121 #endif /* __ASM_SH_CLOCK_H */