aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/clk-provider.h
diff options
context:
space:
mode:
authorMike Turquette <mturquette@linaro.org>2012-03-16 02:11:20 -0400
committerArnd Bergmann <arnd@arndb.de>2012-03-16 16:35:02 -0400
commit9d9f78ed9af0e465d2fd15550471956e7f559b9f (patch)
tree8a65fc0844a35c928162f65b671a8a5786ea03ee /include/linux/clk-provider.h
parentb2476490ef11134b65544d8f062cff96c53e941b (diff)
clk: basic clock hardware types
Many platforms support simple gateable clocks, fixed-rate clocks, adjustable divider clocks and multi-parent multiplexer clocks. This patch introduces basic clock types for the above-mentioned hardware which share some common characteristics. Based on original work by Jeremy Kerr and contribution by Jamie Iles. Dividers and multiplexor clocks originally contributed by Richard Zhao & Sascha Hauer. Signed-off-by: Mike Turquette <mturquette@linaro.org> Signed-off-by: Mike Turquette <mturquette@ti.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Rob Herring <rob.herring@calxeda.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Jeremy Kerr <jeremy.kerr@canonical.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Arnd Bergman <arnd.bergmann@linaro.org> Cc: Paul Walmsley <paul@pwsan.com> Cc: Shawn Guo <shawn.guo@freescale.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Jamie Iles <jamie@jamieiles.com> Cc: Richard Zhao <richard.zhao@linaro.org> Cc: Saravana Kannan <skannan@codeaurora.org> Cc: Magnus Damm <magnus.damm@gmail.com> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Linus Walleij <linus.walleij@stericsson.com> Cc: Stephen Boyd <sboyd@codeaurora.org> Cc: Amit Kucheria <amit.kucheria@linaro.org> Cc: Deepak Saxena <dsaxena@linaro.org> Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include/linux/clk-provider.h')
-rw-r--r--include/linux/clk-provider.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index b18b0e7888a8..5508897ad376 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -129,6 +129,133 @@ struct clk_ops {
129 void (*init)(struct clk_hw *hw); 129 void (*init)(struct clk_hw *hw);
130}; 130};
131 131
132/*
133 * DOC: Basic clock implementations common to many platforms
134 *
135 * Each basic clock hardware type is comprised of a structure describing the
136 * clock hardware, implementations of the relevant callbacks in struct clk_ops,
137 * unique flags for that hardware type, a registration function and an
138 * alternative macro for static initialization
139 */
140
141/**
142 * struct clk_fixed_rate - fixed-rate clock
143 * @hw: handle between common and hardware-specific interfaces
144 * @fixed_rate: constant frequency of clock
145 */
146struct clk_fixed_rate {
147 struct clk_hw hw;
148 unsigned long fixed_rate;
149 u8 flags;
150};
151
152struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
153 const char *parent_name, unsigned long flags,
154 unsigned long fixed_rate);
155
156/**
157 * struct clk_gate - gating clock
158 *
159 * @hw: handle between common and hardware-specific interfaces
160 * @reg: register controlling gate
161 * @bit_idx: single bit controlling gate
162 * @flags: hardware-specific flags
163 * @lock: register lock
164 *
165 * Clock which can gate its output. Implements .enable & .disable
166 *
167 * Flags:
168 * CLK_GATE_SET_DISABLE - by default this clock sets the bit at bit_idx to
169 * enable the clock. Setting this flag does the opposite: setting the bit
170 * disable the clock and clearing it enables the clock
171 */
172struct clk_gate {
173 struct clk_hw hw;
174 void __iomem *reg;
175 u8 bit_idx;
176 u8 flags;
177 spinlock_t *lock;
178 char *parent[1];
179};
180
181#define CLK_GATE_SET_TO_DISABLE BIT(0)
182
183struct clk *clk_register_gate(struct device *dev, const char *name,
184 const char *parent_name, unsigned long flags,
185 void __iomem *reg, u8 bit_idx,
186 u8 clk_gate_flags, spinlock_t *lock);
187
188/**
189 * struct clk_divider - adjustable divider clock
190 *
191 * @hw: handle between common and hardware-specific interfaces
192 * @reg: register containing the divider
193 * @shift: shift to the divider bit field
194 * @width: width of the divider bit field
195 * @lock: register lock
196 *
197 * Clock with an adjustable divider affecting its output frequency. Implements
198 * .recalc_rate, .set_rate and .round_rate
199 *
200 * Flags:
201 * CLK_DIVIDER_ONE_BASED - by default the divisor is the value read from the
202 * register plus one. If CLK_DIVIDER_ONE_BASED is set then the divider is
203 * the raw value read from the register, with the value of zero considered
204 * invalid
205 * CLK_DIVIDER_POWER_OF_TWO - clock divisor is 2 raised to the value read from
206 * the hardware register
207 */
208struct clk_divider {
209 struct clk_hw hw;
210 void __iomem *reg;
211 u8 shift;
212 u8 width;
213 u8 flags;
214 spinlock_t *lock;
215 char *parent[1];
216};
217
218#define CLK_DIVIDER_ONE_BASED BIT(0)
219#define CLK_DIVIDER_POWER_OF_TWO BIT(1)
220
221struct clk *clk_register_divider(struct device *dev, const char *name,
222 const char *parent_name, unsigned long flags,
223 void __iomem *reg, u8 shift, u8 width,
224 u8 clk_divider_flags, spinlock_t *lock);
225
226/**
227 * struct clk_mux - multiplexer clock
228 *
229 * @hw: handle between common and hardware-specific interfaces
230 * @reg: register controlling multiplexer
231 * @shift: shift to multiplexer bit field
232 * @width: width of mutliplexer bit field
233 * @num_clks: number of parent clocks
234 * @lock: register lock
235 *
236 * Clock with multiple selectable parents. Implements .get_parent, .set_parent
237 * and .recalc_rate
238 *
239 * Flags:
240 * CLK_MUX_INDEX_ONE - register index starts at 1, not 0
241 * CLK_MUX_INDEX_BITWISE - register index is a single bit (power of two)
242 */
243struct clk_mux {
244 struct clk_hw hw;
245 void __iomem *reg;
246 u8 shift;
247 u8 width;
248 u8 flags;
249 spinlock_t *lock;
250};
251
252#define CLK_MUX_INDEX_ONE BIT(0)
253#define CLK_MUX_INDEX_BIT BIT(1)
254
255struct clk *clk_register_mux(struct device *dev, const char *name,
256 char **parent_names, u8 num_parents, unsigned long flags,
257 void __iomem *reg, u8 shift, u8 width,
258 u8 clk_mux_flags, spinlock_t *lock);
132 259
133/** 260/**
134 * clk_register - allocate a new clock, register it and return an opaque cookie 261 * clk_register - allocate a new clock, register it and return an opaque cookie