Lines Matching +full:clk +full:- +full:phase +full:-

1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/include/linux/clk.h
7 * Copyright (C) 2011-2012 Linaro Ltd <mturquette@linaro.org>
17 struct clk;
22 * DOC: clk notifier callback types
24 * PRE_RATE_CHANGE - called immediately before the clk rate is changed,
32 * the clk will be called with ABORT_RATE_CHANGE. Callbacks must
35 * POST_RATE_CHANGE - called after the clk rate change has successfully
44 * struct clk_notifier - associate a clk with a notifier
45 * @clk: struct clk * to associate the notifier with
46 * @notifier_head: a blocking_notifier_head for this clk
51 * particular @clk. Future notifiers on that @clk are added to the
55 struct clk *clk; member
61 * struct clk_notifier_data - rate data to pass to the notifier callback
62 * @clk: struct clk * being changed
63 * @old_rate: previous rate of this clk
64 * @new_rate: new rate of this clk
66 * For a pre-notifier, old_rate is the clk's rate before this rate
68 * post-notifier, old_rate and new_rate are both set to the clk's
72 struct clk *clk; member
78 * struct clk_bulk_data - Data used for bulk clk operations.
81 * @clk: struct clk * to store the associated clock
83 * The CLK APIs provide a series of clk_bulk_() API calls as
89 struct clk *clk; member
95 * clk_notifier_register - register a clock rate-change notifier callback
96 * @clk: clock whose rate we are interested in
103 int clk_notifier_register(struct clk *clk, struct notifier_block *nb);
106 * clk_notifier_unregister - unregister a clock rate-change notifier callback
107 * @clk: clock whose rate we are no longer interested in
110 int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb);
113 * devm_clk_notifier_register - register a managed rate-change notifier callback
115 * @clk: clock whose rate we are interested in
118 * Returns 0 on success, -EERROR otherwise
120 int devm_clk_notifier_register(struct device *dev, struct clk *clk,
124 * clk_get_accuracy - obtain the clock accuracy in ppb (parts per billion)
126 * @clk: clock source
131 long clk_get_accuracy(struct clk *clk);
134 * clk_set_phase - adjust the phase shift of a clock signal
135 * @clk: clock signal source
138 * Shifts the phase of a clock signal by the specified degrees. Returns 0 on
139 * success, -EERROR otherwise.
141 int clk_set_phase(struct clk *clk, int degrees);
144 * clk_get_phase - return the phase shift of a clock signal
145 * @clk: clock signal source
147 * Returns the phase shift of a clock node in degrees, otherwise returns
148 * -EERROR.
150 int clk_get_phase(struct clk *clk);
153 * clk_set_duty_cycle - adjust the duty cycle ratio of a clock signal
154 * @clk: clock signal source
159 * success, -EERROR otherwise.
161 int clk_set_duty_cycle(struct clk *clk, unsigned int num, unsigned int den);
164 * clk_get_scaled_duty_cycle - return the duty cycle ratio of a clock signal
165 * @clk: clock signal source
169 * returns -EERROR.
171 int clk_get_scaled_duty_cycle(struct clk *clk, unsigned int scale);
174 * clk_is_match - check if two clk's point to the same hardware clock
175 * @p: clk compared against q
176 * @q: clk compared against p
178 * Returns true if the two struct clk pointers both point to the same hardware
184 bool clk_is_match(const struct clk *p, const struct clk *q);
187 * clk_rate_exclusive_get - get exclusivity over the rate control of a
189 * @clk: clock source
202 int clk_rate_exclusive_get(struct clk *clk);
205 * clk_rate_exclusive_put - release exclusivity over the rate control of a
207 * @clk: clock source
217 void clk_rate_exclusive_put(struct clk *clk);
221 static inline int clk_notifier_register(struct clk *clk, in clk_notifier_register() argument
224 return -ENOTSUPP; in clk_notifier_register()
227 static inline int clk_notifier_unregister(struct clk *clk, in clk_notifier_unregister() argument
230 return -ENOTSUPP; in clk_notifier_unregister()
234 struct clk *clk, in devm_clk_notifier_register() argument
237 return -ENOTSUPP; in devm_clk_notifier_register()
240 static inline long clk_get_accuracy(struct clk *clk) in clk_get_accuracy() argument
242 return -ENOTSUPP; in clk_get_accuracy()
245 static inline long clk_set_phase(struct clk *clk, int phase) in clk_set_phase() argument
247 return -ENOTSUPP; in clk_set_phase()
250 static inline long clk_get_phase(struct clk *clk) in clk_get_phase() argument
252 return -ENOTSUPP; in clk_get_phase()
255 static inline int clk_set_duty_cycle(struct clk *clk, unsigned int num, in clk_set_duty_cycle() argument
258 return -ENOTSUPP; in clk_set_duty_cycle()
261 static inline unsigned int clk_get_scaled_duty_cycle(struct clk *clk, in clk_get_scaled_duty_cycle() argument
267 static inline bool clk_is_match(const struct clk *p, const struct clk *q) in clk_is_match()
272 static inline int clk_rate_exclusive_get(struct clk *clk) in clk_rate_exclusive_get() argument
277 static inline void clk_rate_exclusive_put(struct clk *clk) {} in clk_rate_exclusive_put() argument
283 * clk_prepare - prepare a clock source
284 * @clk: clock source
290 int clk_prepare(struct clk *clk);
295 * clk_is_enabled_when_prepared - indicate if preparing a clock also enables it.
296 * @clk: clock source
299 * making clk_enable()/clk_disable() no-ops, false otherwise.
309 bool clk_is_enabled_when_prepared(struct clk *clk);
311 static inline int clk_prepare(struct clk *clk) in clk_prepare() argument
324 static inline bool clk_is_enabled_when_prepared(struct clk *clk) in clk_is_enabled_when_prepared() argument
331 * clk_unprepare - undo preparation of a clock source
332 * @clk: clock source
340 void clk_unprepare(struct clk *clk);
343 static inline void clk_unprepare(struct clk *clk) in clk_unprepare() argument
356 * clk_get - lookup and obtain a reference to a clock producer.
360 * Returns a struct clk corresponding to the clock producer, or
370 struct clk *clk_get(struct device *dev, const char *id);
373 * clk_bulk_get - lookup and obtain a number of references to clock producer.
378 * This helper function allows drivers to get several clk consumers in one
379 * operation. If any of the clk cannot be acquired then any clks
386 * The clock returned is stored in each @clk_bulk_data.clk field.
395 * clk_bulk_get_all - lookup and obtain all available references to clock
400 * This helper function allows drivers to get all clk consumers in one
401 * operation. If any of the clk cannot be acquired then any clks
416 * clk_bulk_get_optional - lookup and obtain a number of references to clock producer
422 * In this case, instead of returning -ENOENT, the function returns 0 and
423 * NULL for a clk for which a clock producer could not be determined.
428 * devm_clk_bulk_get - managed get multiple clk consumers
435 * This helper function allows drivers to get several clk
442 * devm_clk_bulk_get_optional - managed get multiple optional consumer clocks
448 * producer. In this case, instead of returning -ENOENT, the function returns
449 * NULL for given clk. It is assumed all clocks in clk_bulk_data are optional.
452 * successfully or for any clk there was no clk provider available, otherwise
456 * The clock returned is stored in each @clk_bulk_data.clk field.
465 * devm_clk_bulk_get_all - managed get multiple clk consumers
473 * This helper function allows drivers to get several clk
482 * devm_clk_get - lookup and obtain a managed reference to a clock producer.
488 * Return: a struct clk corresponding to the clock producer, or
500 struct clk *devm_clk_get(struct device *dev, const char *id);
503 * devm_clk_get_prepared - devm_clk_get() + clk_prepare()
509 * Return: a struct clk corresponding to the clock producer, or
515 * The returned clk (if valid) is prepared. Drivers must however assume
521 struct clk *devm_clk_get_prepared(struct device *dev, const char *id);
524 * devm_clk_get_enabled - devm_clk_get() + clk_prepare_enable()
530 * Return: a struct clk corresponding to the clock producer, or
536 * The returned clk (if valid) is prepared and enabled.
541 struct clk *devm_clk_get_enabled(struct device *dev, const char *id);
544 * devm_clk_get_optional - lookup and obtain a managed reference to an optional
551 * Return: a struct clk corresponding to the clock producer, or
554 * the clock producer. If no such clk is found, it returns NULL
555 * which serves as a dummy clk. That's the only difference compared
564 struct clk *devm_clk_get_optional(struct device *dev, const char *id);
567 * devm_clk_get_optional_prepared - devm_clk_get_optional() + clk_prepare()
573 * Return: a struct clk corresponding to the clock producer, or
576 * the clock producer. If no such clk is found, it returns NULL
577 * which serves as a dummy clk. That's the only difference compared
580 * The returned clk (if valid) is prepared. Drivers must however
586 struct clk *devm_clk_get_optional_prepared(struct device *dev, const char *id);
589 * devm_clk_get_optional_enabled - devm_clk_get_optional() +
596 * Return: a struct clk corresponding to the clock producer, or
599 * the clock producer. If no such clk is found, it returns NULL
600 * which serves as a dummy clk. That's the only difference compared
603 * The returned clk (if valid) is prepared and enabled.
608 struct clk *devm_clk_get_optional_enabled(struct device *dev, const char *id);
611 * devm_get_clk_from_child - lookup and obtain a managed reference to a
618 * struct clk from the registered list of clock providers by using
624 struct clk *devm_get_clk_from_child(struct device *dev,
628 * clk_enable - inform the system when the clock source should be running.
629 * @clk: clock source
637 int clk_enable(struct clk *clk);
640 * clk_bulk_enable - inform the system when the set of clks should be running.
652 * clk_disable - inform the system when the clock source is no longer required.
653 * @clk: clock source
665 void clk_disable(struct clk *clk);
668 * clk_bulk_disable - inform the system when the set of clks is no
686 * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
688 * @clk: clock source
690 unsigned long clk_get_rate(struct clk *clk);
693 * clk_put - "free" the clock source
694 * @clk: clock source
702 void clk_put(struct clk *clk);
705 * clk_bulk_put - "free" the clock source
718 * clk_bulk_put_all - "free" all the clock source
731 * devm_clk_put - "free" a managed clock source
733 * @clk: clock source acquired with devm_clk_get()
741 void devm_clk_put(struct device *dev, struct clk *clk);
749 * clk_round_rate - adjust a rate to the exact rate a clock can provide
750 * @clk: clock source
757 * rate = clk_round_rate(clk, r);
761 * clk_set_rate(clk, r);
762 * rate = clk_get_rate(clk);
769 long clk_round_rate(struct clk *clk, unsigned long rate);
772 * clk_set_rate - set the clock rate for a clock source
773 * @clk: clock source
776 * Updating the rate starts at the top-most affected clock and then
777 * walks the tree down to the bottom-most clock that needs updating.
781 int clk_set_rate(struct clk *clk, unsigned long rate);
784 * clk_set_rate_exclusive- set the clock rate and claim exclusivity over
786 * @clk: clock source
798 int clk_set_rate_exclusive(struct clk *clk, unsigned long rate);
801 * clk_has_parent - check if a clock is a possible parent for another
802 * @clk: clock source
808 * Returns true if @parent is a possible parent for @clk, false otherwise.
810 bool clk_has_parent(const struct clk *clk, const struct clk *parent);
813 * clk_set_rate_range - set a rate range for a clock source
814 * @clk: clock source
820 int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max);
823 * clk_set_min_rate - set a minimum clock rate for a clock source
824 * @clk: clock source
829 int clk_set_min_rate(struct clk *clk, unsigned long rate);
832 * clk_set_max_rate - set a maximum clock rate for a clock source
833 * @clk: clock source
838 int clk_set_max_rate(struct clk *clk, unsigned long rate);
841 * clk_set_parent - set the parent clock source for this clock
842 * @clk: clock source
847 int clk_set_parent(struct clk *clk, struct clk *parent);
850 * clk_get_parent - get the parent clock source for this clock
851 * @clk: clock source
853 * Returns struct clk corresponding to parent clock source, or
856 struct clk *clk_get_parent(struct clk *clk);
859 * clk_get_sys - get a clock based upon the device name
863 * Returns a struct clk corresponding to the clock producer, or
873 struct clk *clk_get_sys(const char *dev_id, const char *con_id);
876 * clk_save_context - save clock context for poweroff
885 * clk_restore_context - restore clock context after poweroff
894 static inline struct clk *clk_get(struct device *dev, const char *id) in clk_get()
917 static inline struct clk *devm_clk_get(struct device *dev, const char *id) in devm_clk_get()
922 static inline struct clk *devm_clk_get_prepared(struct device *dev, in devm_clk_get_prepared()
928 static inline struct clk *devm_clk_get_enabled(struct device *dev, in devm_clk_get_enabled()
934 static inline struct clk *devm_clk_get_optional(struct device *dev, in devm_clk_get_optional()
940 static inline struct clk *devm_clk_get_optional_prepared(struct device *dev, in devm_clk_get_optional_prepared()
946 static inline struct clk *devm_clk_get_optional_enabled(struct device *dev, in devm_clk_get_optional_enabled()
971 static inline struct clk *devm_get_clk_from_child(struct device *dev, in devm_get_clk_from_child()
977 static inline void clk_put(struct clk *clk) {} in clk_put() argument
983 static inline void devm_clk_put(struct device *dev, struct clk *clk) {} in devm_clk_put() argument
985 static inline int clk_enable(struct clk *clk) in clk_enable() argument
996 static inline void clk_disable(struct clk *clk) {} in clk_disable() argument
1002 static inline unsigned long clk_get_rate(struct clk *clk) in clk_get_rate() argument
1007 static inline int clk_set_rate(struct clk *clk, unsigned long rate) in clk_set_rate() argument
1012 static inline int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) in clk_set_rate_exclusive() argument
1017 static inline long clk_round_rate(struct clk *clk, unsigned long rate) in clk_round_rate() argument
1022 static inline bool clk_has_parent(struct clk *clk, struct clk *parent) in clk_has_parent() argument
1027 static inline int clk_set_rate_range(struct clk *clk, unsigned long min, in clk_set_rate_range() argument
1033 static inline int clk_set_min_rate(struct clk *clk, unsigned long rate) in clk_set_min_rate() argument
1038 static inline int clk_set_max_rate(struct clk *clk, unsigned long rate) in clk_set_max_rate() argument
1043 static inline int clk_set_parent(struct clk *clk, struct clk *parent) in clk_set_parent() argument
1048 static inline struct clk *clk_get_parent(struct clk *clk) in clk_get_parent() argument
1053 static inline struct clk *clk_get_sys(const char *dev_id, const char *con_id) in clk_get_sys()
1067 /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
1068 static inline int clk_prepare_enable(struct clk *clk) in clk_prepare_enable() argument
1072 ret = clk_prepare(clk); in clk_prepare_enable()
1075 ret = clk_enable(clk); in clk_prepare_enable()
1077 clk_unprepare(clk); in clk_prepare_enable()
1082 /* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */
1083 static inline void clk_disable_unprepare(struct clk *clk) in clk_disable_unprepare() argument
1085 clk_disable(clk); in clk_disable_unprepare()
1086 clk_unprepare(clk); in clk_disable_unprepare()
1112 * clk_drop_range - Reset any range set on that clock
1113 * @clk: clock source
1117 static inline int clk_drop_range(struct clk *clk) in clk_drop_range() argument
1119 return clk_set_rate_range(clk, 0, ULONG_MAX); in clk_drop_range()
1123 * clk_get_optional - lookup and obtain a reference to an optional clock
1129 * this case, instead of returning -ENOENT, the function returns NULL.
1131 static inline struct clk *clk_get_optional(struct device *dev, const char *id) in clk_get_optional()
1133 struct clk *clk = clk_get(dev, id); in clk_get_optional() local
1135 if (clk == ERR_PTR(-ENOENT)) in clk_get_optional()
1138 return clk; in clk_get_optional()
1142 struct clk *of_clk_get(struct device_node *np, int index);
1143 struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
1144 struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
1146 static inline struct clk *of_clk_get(struct device_node *np, int index) in of_clk_get()
1148 return ERR_PTR(-ENOENT); in of_clk_get()
1150 static inline struct clk *of_clk_get_by_name(struct device_node *np, in of_clk_get_by_name()
1153 return ERR_PTR(-ENOENT); in of_clk_get_by_name()
1155 static inline struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) in of_clk_get_from_provider()
1157 return ERR_PTR(-ENOENT); in of_clk_get_from_provider()