diff options
| author | Tomeu Vizoso <tomeu.vizoso@collabora.com> | 2015-01-23 06:03:30 -0500 |
|---|---|---|
| committer | Michael Turquette <mturquette@linaro.org> | 2015-02-02 17:22:19 -0500 |
| commit | 035a61c314eb3dab5bcc5683afaf4d412689858a (patch) | |
| tree | 3c325fc76191cf1319c4a3399dfdd9f777033d6d /include/linux | |
| parent | af0f349b2996f9f3d83e5aac1edf58fff727a0e0 (diff) | |
clk: Make clk API return per-user struct clk instances
Moves clock state to struct clk_core, but takes care to change as little API as
possible.
struct clk_hw still has a pointer to a struct clk, which is the
implementation's per-user clk instance, for backwards compatibility.
The struct clk that clk_get_parent() returns isn't owned by the caller, but by
the clock implementation, so the former shouldn't call clk_put() on it.
Because some boards in mach-omap2 still register clocks statically, their clock
registration had to be updated to take into account that the clock information
is stored in struct clk_core now.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
[mturquette@linaro.org: adapted clk_has_parent to struct clk_core
applied OMAP3+ DPLL fix from Tero & Tony]
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/clk-private.h | 35 | ||||
| -rw-r--r-- | include/linux/clk-provider.h | 12 |
2 files changed, 34 insertions, 13 deletions
diff --git a/include/linux/clk-private.h b/include/linux/clk-private.h index c5f40d07686c..ae55d99a2313 100644 --- a/include/linux/clk-private.h +++ b/include/linux/clk-private.h | |||
| @@ -28,20 +28,20 @@ | |||
| 28 | 28 | ||
| 29 | struct module; | 29 | struct module; |
| 30 | 30 | ||
| 31 | struct clk { | 31 | struct clk_core { |
| 32 | const char *name; | 32 | const char *name; |
| 33 | const struct clk_ops *ops; | 33 | const struct clk_ops *ops; |
| 34 | struct clk_hw *hw; | 34 | struct clk_hw *hw; |
| 35 | struct module *owner; | 35 | struct module *owner; |
| 36 | struct clk *parent; | 36 | struct clk_core *parent; |
| 37 | const char **parent_names; | 37 | const char **parent_names; |
| 38 | struct clk **parents; | 38 | struct clk_core **parents; |
| 39 | u8 num_parents; | 39 | u8 num_parents; |
| 40 | u8 new_parent_index; | 40 | u8 new_parent_index; |
| 41 | unsigned long rate; | 41 | unsigned long rate; |
| 42 | unsigned long new_rate; | 42 | unsigned long new_rate; |
| 43 | struct clk *new_parent; | 43 | struct clk_core *new_parent; |
| 44 | struct clk *new_child; | 44 | struct clk_core *new_child; |
| 45 | unsigned long flags; | 45 | unsigned long flags; |
| 46 | unsigned int enable_count; | 46 | unsigned int enable_count; |
| 47 | unsigned int prepare_count; | 47 | unsigned int prepare_count; |
| @@ -57,6 +57,12 @@ struct clk { | |||
| 57 | struct kref ref; | 57 | struct kref ref; |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | struct clk { | ||
| 61 | struct clk_core *core; | ||
| 62 | const char *dev_id; | ||
| 63 | const char *con_id; | ||
| 64 | }; | ||
| 65 | |||
| 60 | /* | 66 | /* |
| 61 | * DOC: Basic clock implementations common to many platforms | 67 | * DOC: Basic clock implementations common to many platforms |
| 62 | * | 68 | * |
| @@ -69,6 +75,9 @@ struct clk { | |||
| 69 | #define DEFINE_CLK(_name, _ops, _flags, _parent_names, \ | 75 | #define DEFINE_CLK(_name, _ops, _flags, _parent_names, \ |
| 70 | _parents) \ | 76 | _parents) \ |
| 71 | static struct clk _name = { \ | 77 | static struct clk _name = { \ |
| 78 | .core = &_name##_core \ | ||
| 79 | }; \ | ||
| 80 | static struct clk_core _name##_core = { \ | ||
| 72 | .name = #_name, \ | 81 | .name = #_name, \ |
| 73 | .ops = &_ops, \ | 82 | .ops = &_ops, \ |
| 74 | .hw = &_name##_hw.hw, \ | 83 | .hw = &_name##_hw.hw, \ |
| @@ -81,9 +90,11 @@ struct clk { | |||
| 81 | #define DEFINE_CLK_FIXED_RATE(_name, _flags, _rate, \ | 90 | #define DEFINE_CLK_FIXED_RATE(_name, _flags, _rate, \ |
| 82 | _fixed_rate_flags) \ | 91 | _fixed_rate_flags) \ |
| 83 | static struct clk _name; \ | 92 | static struct clk _name; \ |
| 93 | static struct clk_core _name##_core; \ | ||
| 84 | static const char *_name##_parent_names[] = {}; \ | 94 | static const char *_name##_parent_names[] = {}; \ |
| 85 | static struct clk_fixed_rate _name##_hw = { \ | 95 | static struct clk_fixed_rate _name##_hw = { \ |
| 86 | .hw = { \ | 96 | .hw = { \ |
| 97 | .core = &_name##_core, \ | ||
| 87 | .clk = &_name, \ | 98 | .clk = &_name, \ |
| 88 | }, \ | 99 | }, \ |
| 89 | .fixed_rate = _rate, \ | 100 | .fixed_rate = _rate, \ |
| @@ -96,14 +107,16 @@ struct clk { | |||
| 96 | _flags, _reg, _bit_idx, \ | 107 | _flags, _reg, _bit_idx, \ |
| 97 | _gate_flags, _lock) \ | 108 | _gate_flags, _lock) \ |
| 98 | static struct clk _name; \ | 109 | static struct clk _name; \ |
| 110 | static struct clk_core _name##_core; \ | ||
| 99 | static const char *_name##_parent_names[] = { \ | 111 | static const char *_name##_parent_names[] = { \ |
| 100 | _parent_name, \ | 112 | _parent_name, \ |
| 101 | }; \ | 113 | }; \ |
| 102 | static struct clk *_name##_parents[] = { \ | 114 | static struct clk_core *_name##_parents[] = { \ |
| 103 | _parent_ptr, \ | 115 | _parent_ptr, \ |
| 104 | }; \ | 116 | }; \ |
| 105 | static struct clk_gate _name##_hw = { \ | 117 | static struct clk_gate _name##_hw = { \ |
| 106 | .hw = { \ | 118 | .hw = { \ |
| 119 | .core = &_name##_core, \ | ||
| 107 | .clk = &_name, \ | 120 | .clk = &_name, \ |
| 108 | }, \ | 121 | }, \ |
| 109 | .reg = _reg, \ | 122 | .reg = _reg, \ |
| @@ -118,14 +131,16 @@ struct clk { | |||
| 118 | _flags, _reg, _shift, _width, \ | 131 | _flags, _reg, _shift, _width, \ |
| 119 | _divider_flags, _table, _lock) \ | 132 | _divider_flags, _table, _lock) \ |
| 120 | static struct clk _name; \ | 133 | static struct clk _name; \ |
| 134 | static struct clk_core _name##_core; \ | ||
| 121 | static const char *_name##_parent_names[] = { \ | 135 | static const char *_name##_parent_names[] = { \ |
| 122 | _parent_name, \ | 136 | _parent_name, \ |
| 123 | }; \ | 137 | }; \ |
| 124 | static struct clk *_name##_parents[] = { \ | 138 | static struct clk_core *_name##_parents[] = { \ |
| 125 | _parent_ptr, \ | 139 | _parent_ptr, \ |
| 126 | }; \ | 140 | }; \ |
| 127 | static struct clk_divider _name##_hw = { \ | 141 | static struct clk_divider _name##_hw = { \ |
| 128 | .hw = { \ | 142 | .hw = { \ |
| 143 | .core = &_name##_core, \ | ||
| 129 | .clk = &_name, \ | 144 | .clk = &_name, \ |
| 130 | }, \ | 145 | }, \ |
| 131 | .reg = _reg, \ | 146 | .reg = _reg, \ |
| @@ -157,8 +172,10 @@ struct clk { | |||
| 157 | _reg, _shift, _width, \ | 172 | _reg, _shift, _width, \ |
| 158 | _mux_flags, _lock) \ | 173 | _mux_flags, _lock) \ |
| 159 | static struct clk _name; \ | 174 | static struct clk _name; \ |
| 175 | static struct clk_core _name##_core; \ | ||
| 160 | static struct clk_mux _name##_hw = { \ | 176 | static struct clk_mux _name##_hw = { \ |
| 161 | .hw = { \ | 177 | .hw = { \ |
| 178 | .core = &_name##_core, \ | ||
| 162 | .clk = &_name, \ | 179 | .clk = &_name, \ |
| 163 | }, \ | 180 | }, \ |
| 164 | .reg = _reg, \ | 181 | .reg = _reg, \ |
| @@ -174,14 +191,16 @@ struct clk { | |||
| 174 | _parent_ptr, _flags, \ | 191 | _parent_ptr, _flags, \ |
| 175 | _mult, _div) \ | 192 | _mult, _div) \ |
| 176 | static struct clk _name; \ | 193 | static struct clk _name; \ |
| 194 | static struct clk_core _name##_core; \ | ||
| 177 | static const char *_name##_parent_names[] = { \ | 195 | static const char *_name##_parent_names[] = { \ |
| 178 | _parent_name, \ | 196 | _parent_name, \ |
| 179 | }; \ | 197 | }; \ |
| 180 | static struct clk *_name##_parents[] = { \ | 198 | static struct clk_core *_name##_parents[] = { \ |
| 181 | _parent_ptr, \ | 199 | _parent_ptr, \ |
| 182 | }; \ | 200 | }; \ |
| 183 | static struct clk_fixed_factor _name##_hw = { \ | 201 | static struct clk_fixed_factor _name##_hw = { \ |
| 184 | .hw = { \ | 202 | .hw = { \ |
| 203 | .core = &_name##_core, \ | ||
| 185 | .clk = &_name, \ | 204 | .clk = &_name, \ |
| 186 | }, \ | 205 | }, \ |
| 187 | .mult = _mult, \ | 206 | .mult = _mult, \ |
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 0ed5bf2209ad..12f13b0673af 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | #define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */ | 33 | #define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */ |
| 34 | 34 | ||
| 35 | struct clk_hw; | 35 | struct clk_hw; |
| 36 | struct clk_core; | ||
| 36 | struct dentry; | 37 | struct dentry; |
| 37 | 38 | ||
| 38 | /** | 39 | /** |
| @@ -216,13 +217,17 @@ struct clk_init_data { | |||
| 216 | * clk_foo and then referenced by the struct clk instance that uses struct | 217 | * clk_foo and then referenced by the struct clk instance that uses struct |
| 217 | * clk_foo's clk_ops | 218 | * clk_foo's clk_ops |
| 218 | * | 219 | * |
| 219 | * @clk: pointer to the struct clk instance that points back to this struct | 220 | * @core: pointer to the struct clk_core instance that points back to this |
| 220 | * clk_hw instance | 221 | * struct clk_hw instance |
| 222 | * | ||
| 223 | * @clk: pointer to the per-user struct clk instance that can be used to call | ||
| 224 | * into the clk API | ||
| 221 | * | 225 | * |
| 222 | * @init: pointer to struct clk_init_data that contains the init data shared | 226 | * @init: pointer to struct clk_init_data that contains the init data shared |
| 223 | * with the common clock framework. | 227 | * with the common clock framework. |
| 224 | */ | 228 | */ |
| 225 | struct clk_hw { | 229 | struct clk_hw { |
| 230 | struct clk_core *core; | ||
| 226 | struct clk *clk; | 231 | struct clk *clk; |
| 227 | const struct clk_init_data *init; | 232 | const struct clk_init_data *init; |
| 228 | }; | 233 | }; |
| @@ -577,9 +582,6 @@ long __clk_mux_determine_rate_closest(struct clk_hw *hw, unsigned long rate, | |||
| 577 | /* | 582 | /* |
| 578 | * FIXME clock api without lock protection | 583 | * FIXME clock api without lock protection |
| 579 | */ | 584 | */ |
| 580 | int __clk_prepare(struct clk *clk); | ||
| 581 | void __clk_unprepare(struct clk *clk); | ||
| 582 | void __clk_reparent(struct clk *clk, struct clk *new_parent); | ||
| 583 | unsigned long __clk_round_rate(struct clk *clk, unsigned long rate); | 585 | unsigned long __clk_round_rate(struct clk *clk, unsigned long rate); |
| 584 | 586 | ||
| 585 | struct of_device_id; | 587 | struct of_device_id; |
