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 * clk_get_accuracy - obtain the clock accuracy in ppb (parts per billion)
115 * @clk: clock source
120 long clk_get_accuracy(struct clk *clk);
123 * clk_set_phase - adjust the phase shift of a clock signal
124 * @clk: clock signal source
127 * Shifts the phase of a clock signal by the specified degrees. Returns 0 on
128 * success, -EERROR otherwise.
130 int clk_set_phase(struct clk *clk, int degrees);
133 * clk_get_phase - return the phase shift of a clock signal
134 * @clk: clock signal source
136 * Returns the phase shift of a clock node in degrees, otherwise returns
137 * -EERROR.
139 int clk_get_phase(struct clk *clk);
142 * clk_set_duty_cycle - adjust the duty cycle ratio of a clock signal
143 * @clk: clock signal source
148 * success, -EERROR otherwise.
150 int clk_set_duty_cycle(struct clk *clk, unsigned int num, unsigned int den);
153 * clk_get_duty_cycle - return the duty cycle ratio of a clock signal
154 * @clk: clock signal source
158 * returns -EERROR.
160 int clk_get_scaled_duty_cycle(struct clk *clk, unsigned int scale);
163 * clk_is_match - check if two clk's point to the same hardware clock
164 * @p: clk compared against q
165 * @q: clk compared against p
167 * Returns true if the two struct clk pointers both point to the same hardware
173 bool clk_is_match(const struct clk *p, const struct clk *q);
177 static inline int clk_notifier_register(struct clk *clk, in clk_notifier_register() argument
180 return -ENOTSUPP; in clk_notifier_register()
183 static inline int clk_notifier_unregister(struct clk *clk, in clk_notifier_unregister() argument
186 return -ENOTSUPP; in clk_notifier_unregister()
189 static inline long clk_get_accuracy(struct clk *clk) in clk_get_accuracy() argument
191 return -ENOTSUPP; in clk_get_accuracy()
194 static inline long clk_set_phase(struct clk *clk, int phase) in clk_set_phase() argument
196 return -ENOTSUPP; in clk_set_phase()
199 static inline long clk_get_phase(struct clk *clk) in clk_get_phase() argument
201 return -ENOTSUPP; in clk_get_phase()
204 static inline int clk_set_duty_cycle(struct clk *clk, unsigned int num, in clk_set_duty_cycle() argument
207 return -ENOTSUPP; in clk_set_duty_cycle()
210 static inline unsigned int clk_get_scaled_duty_cycle(struct clk *clk, in clk_get_scaled_duty_cycle() argument
216 static inline bool clk_is_match(const struct clk *p, const struct clk *q) in clk_is_match()
224 * clk_prepare - prepare a clock source
225 * @clk: clock source
232 int clk_prepare(struct clk *clk);
236 static inline int clk_prepare(struct clk *clk) in clk_prepare() argument
251 * clk_unprepare - undo preparation of a clock source
252 * @clk: clock source
260 void clk_unprepare(struct clk *clk);
263 static inline void clk_unprepare(struct clk *clk) in clk_unprepare() argument
276 * clk_get - lookup and obtain a reference to a clock producer.
280 * Returns a struct clk corresponding to the clock producer, or
290 struct clk *clk_get(struct device *dev, const char *id);
293 * clk_bulk_get - lookup and obtain a number of references to clock producer.
298 * This helper function allows drivers to get several clk consumers in one
299 * operation. If any of the clk cannot be acquired then any clks
306 * The clock returned is stored in each @clk_bulk_data.clk field.
315 * clk_bulk_get_all - lookup and obtain all available references to clock
320 * This helper function allows drivers to get all clk consumers in one
321 * operation. If any of the clk cannot be acquired then any clks
336 * clk_bulk_get_optional - lookup and obtain a number of references to clock producer
342 * In this case, instead of returning -ENOENT, the function returns 0 and
343 * NULL for a clk for which a clock producer could not be determined.
348 * devm_clk_bulk_get - managed get multiple clk consumers
355 * This helper function allows drivers to get several clk
362 * devm_clk_bulk_get_optional - managed get multiple optional consumer clocks
368 * producer. In this case, instead of returning -ENOENT, the function returns
369 * NULL for given clk. It is assumed all clocks in clk_bulk_data are optional.
372 * successfully or for any clk there was no clk provider available, otherwise
376 * The clock returned is stored in each @clk_bulk_data.clk field.
385 * devm_clk_bulk_get_all - managed get multiple clk consumers
393 * This helper function allows drivers to get several clk
402 * devm_clk_get - lookup and obtain a managed reference to a clock producer.
406 * Returns a struct clk corresponding to the clock producer, or
419 struct clk *devm_clk_get(struct device *dev, const char *id);
422 * devm_clk_get_optional - lookup and obtain a managed reference to an optional
428 * In this case, instead of returning -ENOENT, the function returns NULL.
430 struct clk *devm_clk_get_optional(struct device *dev, const char *id);
433 * devm_get_clk_from_child - lookup and obtain a managed reference to a
440 * struct clk from the registered list of clock providers by using
446 struct clk *devm_get_clk_from_child(struct device *dev,
449 * clk_rate_exclusive_get - get exclusivity over the rate control of a
451 * @clk: clock source
464 int clk_rate_exclusive_get(struct clk *clk);
467 * clk_rate_exclusive_put - release exclusivity over the rate control of a
469 * @clk: clock source
479 void clk_rate_exclusive_put(struct clk *clk);
482 * clk_enable - inform the system when the clock source should be running.
483 * @clk: clock source
491 int clk_enable(struct clk *clk);
494 * clk_bulk_enable - inform the system when the set of clks should be running.
506 * clk_disable - inform the system when the clock source is no longer required.
507 * @clk: clock source
519 void clk_disable(struct clk *clk);
522 * clk_bulk_disable - inform the system when the set of clks is no
540 * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
542 * @clk: clock source
544 unsigned long clk_get_rate(struct clk *clk);
547 * clk_put - "free" the clock source
548 * @clk: clock source
556 void clk_put(struct clk *clk);
559 * clk_bulk_put - "free" the clock source
572 * clk_bulk_put_all - "free" all the clock source
585 * devm_clk_put - "free" a managed clock source
587 * @clk: clock source acquired with devm_clk_get()
595 void devm_clk_put(struct device *dev, struct clk *clk);
603 * clk_round_rate - adjust a rate to the exact rate a clock can provide
604 * @clk: clock source
611 * rate = clk_round_rate(clk, r);
615 * clk_set_rate(clk, r);
616 * rate = clk_get_rate(clk);
623 long clk_round_rate(struct clk *clk, unsigned long rate);
626 * clk_set_rate - set the clock rate for a clock source
627 * @clk: clock source
630 * Updating the rate starts at the top-most affected clock and then
631 * walks the tree down to the bottom-most clock that needs updating.
635 int clk_set_rate(struct clk *clk, unsigned long rate);
638 * clk_set_rate_exclusive- set the clock rate and claim exclusivity over
640 * @clk: clock source
652 int clk_set_rate_exclusive(struct clk *clk, unsigned long rate);
655 * clk_has_parent - check if a clock is a possible parent for another
656 * @clk: clock source
662 * Returns true if @parent is a possible parent for @clk, false otherwise.
664 bool clk_has_parent(struct clk *clk, struct clk *parent);
667 * clk_set_rate_range - set a rate range for a clock source
668 * @clk: clock source
674 int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max);
677 * clk_set_min_rate - set a minimum clock rate for a clock source
678 * @clk: clock source
683 int clk_set_min_rate(struct clk *clk, unsigned long rate);
686 * clk_set_max_rate - set a maximum clock rate for a clock source
687 * @clk: clock source
692 int clk_set_max_rate(struct clk *clk, unsigned long rate);
695 * clk_set_parent - set the parent clock source for this clock
696 * @clk: clock source
701 int clk_set_parent(struct clk *clk, struct clk *parent);
704 * clk_get_parent - get the parent clock source for this clock
705 * @clk: clock source
707 * Returns struct clk corresponding to parent clock source, or
710 struct clk *clk_get_parent(struct clk *clk);
713 * clk_get_sys - get a clock based upon the device name
717 * Returns a struct clk corresponding to the clock producer, or
727 struct clk *clk_get_sys(const char *dev_id, const char *con_id);
730 * clk_save_context - save clock context for poweroff
739 * clk_restore_context - restore clock context after poweroff
748 static inline struct clk *clk_get(struct device *dev, const char *id) in clk_get()
771 static inline struct clk *devm_clk_get(struct device *dev, const char *id) in devm_clk_get()
776 static inline struct clk *devm_clk_get_optional(struct device *dev, in devm_clk_get_optional()
801 static inline struct clk *devm_get_clk_from_child(struct device *dev, in devm_get_clk_from_child()
807 static inline void clk_put(struct clk *clk) {} in clk_put() argument
813 static inline void devm_clk_put(struct device *dev, struct clk *clk) {} in devm_clk_put() argument
816 static inline int clk_rate_exclusive_get(struct clk *clk) in clk_rate_exclusive_get() argument
821 static inline void clk_rate_exclusive_put(struct clk *clk) {} in clk_rate_exclusive_put() argument
823 static inline int clk_enable(struct clk *clk) in clk_enable() argument
834 static inline void clk_disable(struct clk *clk) {} in clk_disable() argument
840 static inline unsigned long clk_get_rate(struct clk *clk) in clk_get_rate() argument
845 static inline int clk_set_rate(struct clk *clk, unsigned long rate) in clk_set_rate() argument
850 static inline int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) in clk_set_rate_exclusive() argument
855 static inline long clk_round_rate(struct clk *clk, unsigned long rate) in clk_round_rate() argument
860 static inline bool clk_has_parent(struct clk *clk, struct clk *parent) in clk_has_parent() argument
865 static inline int clk_set_rate_range(struct clk *clk, unsigned long min, in clk_set_rate_range() argument
871 static inline int clk_set_min_rate(struct clk *clk, unsigned long rate) in clk_set_min_rate() argument
876 static inline int clk_set_max_rate(struct clk *clk, unsigned long rate) in clk_set_max_rate() argument
881 static inline int clk_set_parent(struct clk *clk, struct clk *parent) in clk_set_parent() argument
886 static inline struct clk *clk_get_parent(struct clk *clk) in clk_get_parent() argument
891 static inline struct clk *clk_get_sys(const char *dev_id, const char *con_id) in clk_get_sys()
905 /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
906 static inline int clk_prepare_enable(struct clk *clk) in clk_prepare_enable() argument
910 ret = clk_prepare(clk); in clk_prepare_enable()
913 ret = clk_enable(clk); in clk_prepare_enable()
915 clk_unprepare(clk); in clk_prepare_enable()
920 /* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */
921 static inline void clk_disable_unprepare(struct clk *clk) in clk_disable_unprepare() argument
923 clk_disable(clk); in clk_disable_unprepare()
924 clk_unprepare(clk); in clk_disable_unprepare()
950 * clk_get_optional - lookup and obtain a reference to an optional clock
956 * this case, instead of returning -ENOENT, the function returns NULL.
958 static inline struct clk *clk_get_optional(struct device *dev, const char *id) in clk_get_optional()
960 struct clk *clk = clk_get(dev, id); in clk_get_optional() local
962 if (clk == ERR_PTR(-ENOENT)) in clk_get_optional()
965 return clk; in clk_get_optional()
969 struct clk *of_clk_get(struct device_node *np, int index);
970 struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
971 struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
973 static inline struct clk *of_clk_get(struct device_node *np, int index) in of_clk_get()
975 return ERR_PTR(-ENOENT); in of_clk_get()
977 static inline struct clk *of_clk_get_by_name(struct device_node *np, in of_clk_get_by_name()
980 return ERR_PTR(-ENOENT); in of_clk_get_by_name()
982 static inline struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) in of_clk_get_from_provider()
984 return ERR_PTR(-ENOENT); in of_clk_get_from_provider()