This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / asm-arm / hardware / clock.h
1 /*
2  *  linux/include/asm-arm/hardware/clock.h
3  *
4  *  Copyright (C) 2004 ARM Limited.
5  *  Written by Deep Blue Solutions Limited.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11 #ifndef ASMARM_CLOCK_H
12 #define ASMARM_CLOCK_H
13
14 struct device;
15
16 /*
17  * The base API.
18  */
19
20
21 /*
22  * struct clk - an machine class defined object / cookie.
23  */
24 struct clk;
25
26 /**
27  * clk_get - lookup and obtain a reference to a clock producer.
28  * @dev: device for clock "consumer"
29  * @id: device ID
30  *
31  * Returns a struct clk corresponding to the clock producer, or
32  * valid IS_ERR() condition containing errno.
33  */
34 struct clk *clk_get(struct device *dev, const char *id);
35
36 /**
37  * clk_enable - inform the system when the clock source should be running.
38  * @clk: clock source
39  *
40  * If the clock can not be enabled/disabled, this should return success.
41  *
42  * Returns success (0) or negative errno.
43  */
44 int clk_enable(struct clk *clk);
45
46 /**
47  * clk_disable - inform the system when the clock source is no longer required.
48  * @clk: clock source
49  */
50 void clk_disable(struct clk *clk);
51
52 /**
53  * clk_use - increment the use count
54  * @clk: clock source
55  *
56  * Returns success (0) or negative errno.
57  */
58 int clk_use(struct clk *clk);
59
60 /**
61  * clk_unuse - decrement the use count
62  * @clk: clock source
63  */
64 void clk_unuse(struct clk *clk);
65
66 /**
67  * clk_get_rate - obtain the current clock rate for a clock source.
68  *                This is only valid once the clock source has been enabled.
69  * @clk: clock source
70  */
71 unsigned long clk_get_rate(struct clk *clk);
72
73 /**
74  * clk_put      - "free" the clock source
75  * @clk: clock source
76  */
77 void clk_put(struct clk *clk);
78
79
80 /*
81  * The remaining APIs are optional for machine class support.
82  */
83
84
85 /**
86  * clk_round_rate - adjust a rate to the exact rate a clock can provide
87  * @clk: clock source
88  * @rate: desired clock rate in kHz
89  *
90  * Returns rounded clock rate, or negative errno.
91  */
92 long clk_round_rate(struct clk *clk, unsigned long rate);
93  
94 /**
95  * clk_set_rate - set the clock rate for a clock source
96  * @clk: clock source
97  * @rate: desired clock rate in kHz
98  *
99  * Returns success (0) or negative errno.
100  */
101 int clk_set_rate(struct clk *clk, unsigned long rate);
102  
103 /**
104  * clk_set_parent - set the parent clock source for this clock
105  * @clk: clock source
106  * @parent: parent clock source
107  *
108  * Returns success (0) or negative errno.
109  */
110 int clk_set_parent(struct clk *clk, struct clk *parent);
111                                                                                 
112 /**
113  * clk_get_parent - get the parent clock source for this clock
114  * @clk: clock source
115  *
116  * Returns struct clk corresponding to parent clock source, or
117  * valid IS_ERR() condition containing errno.
118  */
119 struct clk *clk_get_parent(struct clk *clk);
120
121 #endif