diff options
Diffstat (limited to 'arch/arm/plat-spear/include/plat/clock.h')
-rw-r--r-- | arch/arm/plat-spear/include/plat/clock.h | 166 |
1 files changed, 144 insertions, 22 deletions
diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h index 2572260f990f..2ae6606930a6 100644 --- a/arch/arm/plat-spear/include/plat/clock.h +++ b/arch/arm/plat-spear/include/plat/clock.h | |||
@@ -21,6 +21,7 @@ | |||
21 | /* clk structure flags */ | 21 | /* clk structure flags */ |
22 | #define ALWAYS_ENABLED (1 << 0) /* clock always enabled */ | 22 | #define ALWAYS_ENABLED (1 << 0) /* clock always enabled */ |
23 | #define RESET_TO_ENABLE (1 << 1) /* reset register bit to enable clk */ | 23 | #define RESET_TO_ENABLE (1 << 1) /* reset register bit to enable clk */ |
24 | #define ENABLED_ON_INIT (1 << 2) /* clocks enabled at init */ | ||
24 | 25 | ||
25 | /** | 26 | /** |
26 | * struct clkops - clock operations | 27 | * struct clkops - clock operations |
@@ -35,13 +36,11 @@ struct clkops { | |||
35 | /** | 36 | /** |
36 | * struct pclk_info - parents info | 37 | * struct pclk_info - parents info |
37 | * @pclk: pointer to parent clk | 38 | * @pclk: pointer to parent clk |
38 | * @pclk_mask: value to be written for selecting this parent | 39 | * @pclk_val: value to be written for selecting this parent |
39 | * @scalable: Is parent scalable (1 - YES, 0 - NO) | ||
40 | */ | 40 | */ |
41 | struct pclk_info { | 41 | struct pclk_info { |
42 | struct clk *pclk; | 42 | struct clk *pclk; |
43 | u8 pclk_mask; | 43 | u8 pclk_val; |
44 | u8 scalable; | ||
45 | }; | 44 | }; |
46 | 45 | ||
47 | /** | 46 | /** |
@@ -54,11 +53,23 @@ struct pclk_info { | |||
54 | struct pclk_sel { | 53 | struct pclk_sel { |
55 | struct pclk_info *pclk_info; | 54 | struct pclk_info *pclk_info; |
56 | u8 pclk_count; | 55 | u8 pclk_count; |
57 | unsigned int *pclk_sel_reg; | 56 | void __iomem *pclk_sel_reg; |
58 | unsigned int pclk_sel_mask; | 57 | unsigned int pclk_sel_mask; |
59 | }; | 58 | }; |
60 | 59 | ||
61 | /** | 60 | /** |
61 | * struct rate_config - clk rate configurations | ||
62 | * @tbls: array of device specific clk rate tables, in ascending order of rates | ||
63 | * @count: size of tbls array | ||
64 | * @default_index: default setting when originally disabled | ||
65 | */ | ||
66 | struct rate_config { | ||
67 | void *tbls; | ||
68 | u8 count; | ||
69 | u8 default_index; | ||
70 | }; | ||
71 | |||
72 | /** | ||
62 | * struct clk - clock structure | 73 | * struct clk - clock structure |
63 | * @usage_count: num of users who enabled this clock | 74 | * @usage_count: num of users who enabled this clock |
64 | * @flags: flags for clock properties | 75 | * @flags: flags for clock properties |
@@ -67,21 +78,32 @@ struct pclk_sel { | |||
67 | * @en_reg_bit: clk enable/disable bit | 78 | * @en_reg_bit: clk enable/disable bit |
68 | * @ops: clk enable/disable ops - generic_clkops selected if NULL | 79 | * @ops: clk enable/disable ops - generic_clkops selected if NULL |
69 | * @recalc: pointer to clock rate recalculate function | 80 | * @recalc: pointer to clock rate recalculate function |
81 | * @set_rate: pointer to clock set rate function | ||
82 | * @calc_rate: pointer to clock get rate function for index | ||
83 | * @rate_config: rate configuration information, used by set_rate | ||
84 | * @div_factor: division factor to parent clock. | ||
70 | * @pclk: current parent clk | 85 | * @pclk: current parent clk |
71 | * @pclk_sel: pointer to parent selection structure | 86 | * @pclk_sel: pointer to parent selection structure |
72 | * @pclk_sel_shift: register shift for selecting parent of this clock | 87 | * @pclk_sel_shift: register shift for selecting parent of this clock |
73 | * @children: list for childrens or this clock | 88 | * @children: list for childrens or this clock |
74 | * @sibling: node for list of clocks having same parents | 89 | * @sibling: node for list of clocks having same parents |
75 | * @private_data: clock specific private data | 90 | * @private_data: clock specific private data |
91 | * @node: list to maintain clocks linearly | ||
92 | * @cl: clocklook up assoicated with this clock | ||
93 | * @dent: object for debugfs | ||
76 | */ | 94 | */ |
77 | struct clk { | 95 | struct clk { |
78 | unsigned int usage_count; | 96 | unsigned int usage_count; |
79 | unsigned int flags; | 97 | unsigned int flags; |
80 | unsigned long rate; | 98 | unsigned long rate; |
81 | unsigned int *en_reg; | 99 | void __iomem *en_reg; |
82 | u8 en_reg_bit; | 100 | u8 en_reg_bit; |
83 | const struct clkops *ops; | 101 | const struct clkops *ops; |
84 | void (*recalc) (struct clk *); | 102 | int (*recalc) (struct clk *); |
103 | int (*set_rate) (struct clk *, unsigned long rate); | ||
104 | unsigned long (*calc_rate)(struct clk *, int index); | ||
105 | struct rate_config rate_config; | ||
106 | unsigned int div_factor; | ||
85 | 107 | ||
86 | struct clk *pclk; | 108 | struct clk *pclk; |
87 | struct pclk_sel *pclk_sel; | 109 | struct pclk_sel *pclk_sel; |
@@ -90,37 +112,137 @@ struct clk { | |||
90 | struct list_head children; | 112 | struct list_head children; |
91 | struct list_head sibling; | 113 | struct list_head sibling; |
92 | void *private_data; | 114 | void *private_data; |
115 | #ifdef CONFIG_DEBUG_FS | ||
116 | struct list_head node; | ||
117 | struct clk_lookup *cl; | ||
118 | struct dentry *dent; | ||
119 | #endif | ||
93 | }; | 120 | }; |
94 | 121 | ||
95 | /* pll configuration structure */ | 122 | /* pll configuration structure */ |
123 | struct pll_clk_masks { | ||
124 | u32 mode_mask; | ||
125 | u32 mode_shift; | ||
126 | |||
127 | u32 norm_fdbk_m_mask; | ||
128 | u32 norm_fdbk_m_shift; | ||
129 | u32 dith_fdbk_m_mask; | ||
130 | u32 dith_fdbk_m_shift; | ||
131 | u32 div_p_mask; | ||
132 | u32 div_p_shift; | ||
133 | u32 div_n_mask; | ||
134 | u32 div_n_shift; | ||
135 | }; | ||
136 | |||
96 | struct pll_clk_config { | 137 | struct pll_clk_config { |
97 | unsigned int *mode_reg; | 138 | void __iomem *mode_reg; |
98 | unsigned int *cfg_reg; | 139 | void __iomem *cfg_reg; |
140 | struct pll_clk_masks *masks; | ||
141 | }; | ||
142 | |||
143 | /* pll clk rate config structure */ | ||
144 | struct pll_rate_tbl { | ||
145 | u8 mode; | ||
146 | u16 m; | ||
147 | u8 n; | ||
148 | u8 p; | ||
99 | }; | 149 | }; |
100 | 150 | ||
101 | /* ahb and apb bus configuration structure */ | 151 | /* ahb and apb bus configuration structure */ |
152 | struct bus_clk_masks { | ||
153 | u32 mask; | ||
154 | u32 shift; | ||
155 | }; | ||
156 | |||
102 | struct bus_clk_config { | 157 | struct bus_clk_config { |
103 | unsigned int *reg; | 158 | void __iomem *reg; |
104 | unsigned int mask; | 159 | struct bus_clk_masks *masks; |
105 | unsigned int shift; | 160 | }; |
161 | |||
162 | /* ahb and apb clk bus rate config structure */ | ||
163 | struct bus_rate_tbl { | ||
164 | u8 div; | ||
165 | }; | ||
166 | |||
167 | /* Aux clk configuration structure: applicable to UART and FIRDA */ | ||
168 | struct aux_clk_masks { | ||
169 | u32 eq_sel_mask; | ||
170 | u32 eq_sel_shift; | ||
171 | u32 eq1_mask; | ||
172 | u32 eq2_mask; | ||
173 | u32 xscale_sel_mask; | ||
174 | u32 xscale_sel_shift; | ||
175 | u32 yscale_sel_mask; | ||
176 | u32 yscale_sel_shift; | ||
106 | }; | 177 | }; |
107 | 178 | ||
108 | /* | ||
109 | * Aux clk configuration structure: applicable to GPT, UART and FIRDA | ||
110 | */ | ||
111 | struct aux_clk_config { | 179 | struct aux_clk_config { |
112 | unsigned int *synth_reg; | 180 | void __iomem *synth_reg; |
181 | struct aux_clk_masks *masks; | ||
182 | }; | ||
183 | |||
184 | /* aux clk rate config structure */ | ||
185 | struct aux_rate_tbl { | ||
186 | u16 xscale; | ||
187 | u16 yscale; | ||
188 | u8 eq; | ||
189 | }; | ||
190 | |||
191 | /* GPT clk configuration structure */ | ||
192 | struct gpt_clk_masks { | ||
193 | u32 mscale_sel_mask; | ||
194 | u32 mscale_sel_shift; | ||
195 | u32 nscale_sel_mask; | ||
196 | u32 nscale_sel_shift; | ||
197 | }; | ||
198 | |||
199 | struct gpt_clk_config { | ||
200 | void __iomem *synth_reg; | ||
201 | struct gpt_clk_masks *masks; | ||
202 | }; | ||
203 | |||
204 | /* gpt clk rate config structure */ | ||
205 | struct gpt_rate_tbl { | ||
206 | u16 mscale; | ||
207 | u16 nscale; | ||
208 | }; | ||
209 | |||
210 | /* clcd clk configuration structure */ | ||
211 | struct clcd_synth_masks { | ||
212 | u32 div_factor_mask; | ||
213 | u32 div_factor_shift; | ||
214 | }; | ||
215 | |||
216 | struct clcd_clk_config { | ||
217 | void __iomem *synth_reg; | ||
218 | struct clcd_synth_masks *masks; | ||
219 | }; | ||
220 | |||
221 | /* clcd clk rate config structure */ | ||
222 | struct clcd_rate_tbl { | ||
223 | u16 div; | ||
113 | }; | 224 | }; |
114 | 225 | ||
115 | /* platform specific clock functions */ | 226 | /* platform specific clock functions */ |
116 | void clk_register(struct clk_lookup *cl); | 227 | void clk_register(struct clk_lookup *cl); |
117 | void recalc_root_clocks(void); | 228 | void recalc_root_clocks(void); |
118 | 229 | ||
119 | /* clock recalc functions */ | 230 | /* clock recalc & set rate functions */ |
120 | void follow_parent(struct clk *clk); | 231 | int follow_parent(struct clk *clk); |
121 | void pll1_clk_recalc(struct clk *clk); | 232 | unsigned long pll_calc_rate(struct clk *clk, int index); |
122 | void bus_clk_recalc(struct clk *clk); | 233 | int pll_clk_recalc(struct clk *clk); |
123 | void gpt_clk_recalc(struct clk *clk); | 234 | int pll_clk_set_rate(struct clk *clk, unsigned long desired_rate); |
124 | void aux_clk_recalc(struct clk *clk); | 235 | unsigned long bus_calc_rate(struct clk *clk, int index); |
236 | int bus_clk_recalc(struct clk *clk); | ||
237 | int bus_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
238 | unsigned long gpt_calc_rate(struct clk *clk, int index); | ||
239 | int gpt_clk_recalc(struct clk *clk); | ||
240 | int gpt_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
241 | unsigned long aux_calc_rate(struct clk *clk, int index); | ||
242 | int aux_clk_recalc(struct clk *clk); | ||
243 | int aux_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
244 | unsigned long clcd_calc_rate(struct clk *clk, int index); | ||
245 | int clcd_clk_recalc(struct clk *clk); | ||
246 | int clcd_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
125 | 247 | ||
126 | #endif /* __PLAT_CLOCK_H */ | 248 | #endif /* __PLAT_CLOCK_H */ |