Lines Matching +full:clock +full:- +full:name

1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2010-2011 Jeremy Kerr <jeremy.kerr@canonical.com>
4 * Copyright (C) 2011-2012 Linaro Ltd <mturquette@linaro.org>
14 * top-level framework. custom flags for dealing with hardware specifics
20 #define CLK_SET_PARENT_GATE BIT(1) /* must be gated across re-parent */
26 #define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */
29 #define CLK_SET_RATE_UNGATE BIT(10) /* clock needs to run to set rate */
31 /* parents need enable during gate/ungate, set rate and re-parent */
33 /* duty cycle call may be forwarded to the parent clock */
42 * struct clk_rate_request - Structure encoding the clk constraints that
43 * a clock user might require.
45 * @rate: Requested clock rate. This field will be adjusted by
46 * clock drivers according to hardware capabilities.
51 * @best_parent_hw: The most appropriate parent clock that fulfills the
64 * struct clk_duty - Struture encoding the duty cycle ratio of a clock
75 * struct clk_ops - Callback operations for hardware clocks; these are to
76 * be provided by the clock implementation, and will be called by drivers
79 * @prepare: Prepare the clock for enabling. This must not return until
80 * the clock is fully prepared, and it's safe to call clk_enable.
81 * This callback is intended to allow clock implementations to
85 * @unprepare: Release the clock from its prepared state. This will typically
89 * @is_prepared: Queries the hardware to determine if the clock is prepared.
93 * @unprepare_unused: Unprepare the clock atomically. Only called from
97 * @enable: Enable the clock atomically. This must not return until the
98 * clock is generating a valid clock signal, usable by consumer
102 * @disable: Disable the clock atomically. Called with enable_lock held.
105 * @is_enabled: Queries the hardware to determine if the clock is enabled.
109 * @disable_unused: Disable the clock atomically. Only called from
114 * @save_context: Save the context of the clock in prepration for poweroff.
116 * @restore_context: Restore the context of the clock after a restoration
119 * @recalc_rate Recalculate the rate of this clock, by querying hardware. The
122 * Returns the calculated rate. Optional, but recommended - if
123 * this op is not set then clock rate will be initialized to 0.
126 * supported by the clock. The parent rate is an input/output
130 * actually supported by the clock, and optionally the parent clock
131 * that should be used to provide the clock rate.
133 * @set_parent: Change the input source of this clock; for clocks with multiple
138 * Returns 0 on success, -EERROR otherwise.
140 * @get_parent: Queries the hardware to determine the parent of a clock. The
142 * the parent clock. This index can be applied to either the
145 * index. Currently only called when the clock is initialized by
150 * @set_rate: Change the rate of this clock. The requested rate is specified
154 * Returns 0 on success, -EERROR otherwise.
156 * @set_rate_and_parent: Change the rate and the parent of this clock. The
165 * Returns 0 on success, -EERROR otherwise.
167 * @recalc_accuracy: Recalculate the accuracy of this clock. The clock accuracy
170 * Returns the calculated accuracy. Optional - if this op is not
171 * set then clock accuracy will be initialized to parent accuracy
172 * or 0 (perfect clock) if clock has no parent.
174 * @get_phase: Queries the hardware to get the current phase of a clock.
175 * Returned values are 0-359 degrees on success, negative
178 * @set_phase: Shift the phase this clock signal in degrees specified
180 * 0-359. Return 0 on success, otherwise -EERROR.
183 * of a clock. Returned values denominator cannot be 0 and must be
186 * @set_duty_cycle: Apply the duty cycle ratio to this clock signal specified by
189 * and >= numerator) Return 0 on success, otherwise -EERROR.
191 * @init: Perform platform-specific initialization magic.
192 * This is not used by any of the basic clock types.
195 * clock. It may also be used dynamic resource allocation is
196 * required. It shall not used to deal with clock parameters,
198 * Returns 0 on success, -EERROR otherwise.
202 * @debug_init: Set up type-specific debugfs entries for this clock. This
204 * clock has been created. The dentry pointer representing that
206 * prepare_lock held. Returns 0 on success, -EERROR otherwise.
211 * (prepare) contexts. If enabling a clock requires code that might sleep,
212 * this must be done in clk_prepare. Clock enable code that will never be
215 * Typically, drivers will call clk_prepare when a clock may be needed later
216 * (eg. when a device is opened), and clk_enable when the clock is actually
258 * struct clk_parent_data - clk parent information
260 * @fw_name: parent name local to provider registering clk
261 * @name: globally unique parent name (used as a fallback)
267 const char *name; member
272 * struct clk_init_data - holds init data that's common to all clocks and is
273 * shared between the clock provider and the common clock framework.
275 * @name: clock name
276 * @ops: operations this clock supports
283 * @flags: framework-level hints and quirks
286 const char *name; member
297 * struct clk_hw - handle for traversing from a struct clk to its corresponding
298 * hardware-specific structure. struct clk_hw should be declared within struct
305 * @clk: pointer to the per-user struct clk instance that can be used to call
309 * with the common clock framework. This pointer will be set to NULL once
319 * DOC: Basic clock implementations common to many platforms
321 * Each basic clock hardware type is comprised of a structure describing the
322 * clock hardware, implementations of the relevant callbacks in struct clk_ops,
328 * struct clk_fixed_rate - fixed-rate clock
329 * @hw: handle between common and hardware-specific interfaces
330 * @fixed_rate: constant frequency of clock
331 * @fixed_accuracy: constant accuracy of clock in ppb (parts per billion)
335 * * CLK_FIXED_RATE_PARENT_ACCURACY - Use the accuracy of the parent clk
349 struct device_node *np, const char *name,
354 struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
358 * clk_hw_register_fixed_rate - register fixed-rate clock with the clock
360 * @dev: device that is registering this clock
361 * @name: name of this clock
362 * @parent_name: name of clock's parent
363 * @flags: framework-specific flags
364 * @fixed_rate: non-adjustable clock rate
366 #define clk_hw_register_fixed_rate(dev, name, parent_name, flags, fixed_rate) \ argument
367 __clk_hw_register_fixed_rate((dev), NULL, (name), (parent_name), NULL, \
370 * clk_hw_register_fixed_rate_parent_hw - register fixed-rate clock with
371 * the clock framework
372 * @dev: device that is registering this clock
373 * @name: name of this clock
375 * @flags: framework-specific flags
376 * @fixed_rate: non-adjustable clock rate
378 #define clk_hw_register_fixed_rate_parent_hw(dev, name, parent_hw, flags, \ argument
380 __clk_hw_register_fixed_rate((dev), NULL, (name), NULL, (parent_hw), \
383 * clk_hw_register_fixed_rate_parent_data - register fixed-rate clock with
384 * the clock framework
385 * @dev: device that is registering this clock
386 * @name: name of this clock
388 * @flags: framework-specific flags
389 * @fixed_rate: non-adjustable clock rate
391 #define clk_hw_register_fixed_rate_parent_data(dev, name, parent_hw, flags, \ argument
393 __clk_hw_register_fixed_rate((dev), NULL, (name), NULL, NULL, \
397 * clk_hw_register_fixed_rate_with_accuracy - register fixed-rate clock with
398 * the clock framework
399 * @dev: device that is registering this clock
400 * @name: name of this clock
401 * @parent_name: name of clock's parent
402 * @flags: framework-specific flags
403 * @fixed_rate: non-adjustable clock rate
404 * @fixed_accuracy: non-adjustable clock accuracy
406 #define clk_hw_register_fixed_rate_with_accuracy(dev, name, parent_name, \ argument
409 __clk_hw_register_fixed_rate((dev), NULL, (name), (parent_name), \
413 * clk_hw_register_fixed_rate_with_accuracy_parent_hw - register fixed-rate
414 * clock with the clock framework
415 * @dev: device that is registering this clock
416 * @name: name of this clock
418 * @flags: framework-specific flags
419 * @fixed_rate: non-adjustable clock rate
420 * @fixed_accuracy: non-adjustable clock accuracy
422 #define clk_hw_register_fixed_rate_with_accuracy_parent_hw(dev, name, \ argument
424 __clk_hw_register_fixed_rate((dev), NULL, (name), NULL, (parent_hw) \
428 * clk_hw_register_fixed_rate_with_accuracy_parent_data - register fixed-rate
429 * clock with the clock framework
430 * @dev: device that is registering this clock
431 * @name: name of this clock
432 * @parent_name: name of clock's parent
433 * @flags: framework-specific flags
434 * @fixed_rate: non-adjustable clock rate
435 * @fixed_accuracy: non-adjustable clock accuracy
437 #define clk_hw_register_fixed_rate_with_accuracy_parent_data(dev, name, \ argument
439 __clk_hw_register_fixed_rate((dev), NULL, (name), NULL, NULL, \
449 * struct clk_gate - gating clock
451 * @hw: handle between common and hardware-specific interfaces
454 * @flags: hardware-specific flags
457 * Clock which can gate its output. Implements .enable & .disable
460 * CLK_GATE_SET_TO_DISABLE - by default this clock sets the bit at bit_idx to
461 * enable the clock. Setting this flag does the opposite: setting the bit
462 * disable the clock and clearing it enables the clock
463 * CLK_GATE_HIWORD_MASK - The gate settings are only in lower 16-bit
464 * of this register, and mask of gate bits are in higher 16-bit of this
465 * register. While setting the gate bits, higher 16-bit should also be
467 * CLK_GATE_BIG_ENDIAN - by default little endian register accesses are used for
487 struct device_node *np, const char *name,
493 struct clk *clk_register_gate(struct device *dev, const char *name,
498 * clk_hw_register_gate - register a gate clock with the clock framework
499 * @dev: device that is registering this clock
500 * @name: name of this clock
501 * @parent_name: name of this clock's parent
502 * @flags: framework-specific flags for this clock
503 * @reg: register address to control gating of this clock
504 * @bit_idx: which bit in the register controls gating of this clock
505 * @clk_gate_flags: gate-specific flags for this clock
506 * @lock: shared register lock for this clock
508 #define clk_hw_register_gate(dev, name, parent_name, flags, reg, bit_idx, \ argument
510 __clk_hw_register_gate((dev), NULL, (name), (parent_name), NULL, \
514 * clk_hw_register_gate_parent_hw - register a gate clock with the clock
516 * @dev: device that is registering this clock
517 * @name: name of this clock
519 * @flags: framework-specific flags for this clock
520 * @reg: register address to control gating of this clock
521 * @bit_idx: which bit in the register controls gating of this clock
522 * @clk_gate_flags: gate-specific flags for this clock
523 * @lock: shared register lock for this clock
525 #define clk_hw_register_gate_parent_hw(dev, name, parent_hw, flags, reg, \ argument
527 __clk_hw_register_gate((dev), NULL, (name), NULL, (parent_hw), \
531 * clk_hw_register_gate_parent_data - register a gate clock with the clock
533 * @dev: device that is registering this clock
534 * @name: name of this clock
536 * @flags: framework-specific flags for this clock
537 * @reg: register address to control gating of this clock
538 * @bit_idx: which bit in the register controls gating of this clock
539 * @clk_gate_flags: gate-specific flags for this clock
540 * @lock: shared register lock for this clock
542 #define clk_hw_register_gate_parent_data(dev, name, parent_data, flags, reg, \ argument
544 __clk_hw_register_gate((dev), NULL, (name), NULL, NULL, (parent_data), \
557 * struct clk_divider - adjustable divider clock
559 * @hw: handle between common and hardware-specific interfaces
566 * Clock with an adjustable divider affecting its output frequency. Implements
570 * CLK_DIVIDER_ONE_BASED - by default the divisor is the value read from the
574 * CLK_DIVIDER_POWER_OF_TWO - clock divisor is 2 raised to the value read from
576 * CLK_DIVIDER_ALLOW_ZERO - Allow zero divisors. For dividers which have
579 * zero divisor by not modifying their input clock
581 * CLK_DIVIDER_HIWORD_MASK - The divider settings are only in lower 16-bit
582 * of this register, and mask of divider bits are in higher 16-bit of this
583 * register. While setting the divider bits, higher 16-bit should also be
585 * CLK_DIVIDER_ROUND_CLOSEST - Makes the best calculated divider to be rounded
587 * CLK_DIVIDER_READ_ONLY - The divider settings are preconfigured and should
588 * not be changed by the clock framework.
589 * CLK_DIVIDER_MAX_AT_ZERO - For dividers which are like CLK_DIVIDER_ONE_BASED
592 * CLK_DIVIDER_BIG_ENDIAN - By default little endian register accesses are used
606 #define clk_div_mask(width) ((1 << (width)) - 1)
643 struct device_node *np, const char *name,
649 struct device_node *np, const char *name,
654 struct clk *clk_register_divider_table(struct device *dev, const char *name,
660 * clk_register_divider - register a divider clock with the clock framework
661 * @dev: device registering this clock
662 * @name: name of this clock
663 * @parent_name: name of clock's parent
664 * @flags: framework-specific flags
668 * @clk_divider_flags: divider-specific flags for this clock
669 * @lock: shared register lock for this clock
671 #define clk_register_divider(dev, name, parent_name, flags, reg, shift, width, \ argument
673 clk_register_divider_table((dev), (name), (parent_name), (flags), \
677 * clk_hw_register_divider - register a divider clock with the clock framework
678 * @dev: device registering this clock
679 * @name: name of this clock
680 * @parent_name: name of clock's parent
681 * @flags: framework-specific flags
685 * @clk_divider_flags: divider-specific flags for this clock
686 * @lock: shared register lock for this clock
688 #define clk_hw_register_divider(dev, name, parent_name, flags, reg, shift, \ argument
690 __clk_hw_register_divider((dev), NULL, (name), (parent_name), NULL, \
694 * clk_hw_register_divider_parent_hw - register a divider clock with the clock
696 * @dev: device registering this clock
697 * @name: name of this clock
699 * @flags: framework-specific flags
703 * @clk_divider_flags: divider-specific flags for this clock
704 * @lock: shared register lock for this clock
706 #define clk_hw_register_divider_parent_hw(dev, name, parent_hw, flags, reg, \ argument
709 __clk_hw_register_divider((dev), NULL, (name), NULL, (parent_hw), \
713 * clk_hw_register_divider_parent_data - register a divider clock with the clock
715 * @dev: device registering this clock
716 * @name: name of this clock
718 * @flags: framework-specific flags
722 * @clk_divider_flags: divider-specific flags for this clock
723 * @lock: shared register lock for this clock
725 #define clk_hw_register_divider_parent_data(dev, name, parent_data, flags, \ argument
728 __clk_hw_register_divider((dev), NULL, (name), NULL, NULL, \
732 * clk_hw_register_divider_table - register a table based divider clock with
733 * the clock framework
734 * @dev: device registering this clock
735 * @name: name of this clock
736 * @parent_name: name of clock's parent
737 * @flags: framework-specific flags
741 * @clk_divider_flags: divider-specific flags for this clock
743 * @lock: shared register lock for this clock
745 #define clk_hw_register_divider_table(dev, name, parent_name, flags, reg, \ argument
748 __clk_hw_register_divider((dev), NULL, (name), (parent_name), NULL, \
752 * clk_hw_register_divider_table_parent_hw - register a table based divider
753 * clock with the clock framework
754 * @dev: device registering this clock
755 * @name: name of this clock
757 * @flags: framework-specific flags
761 * @clk_divider_flags: divider-specific flags for this clock
763 * @lock: shared register lock for this clock
765 #define clk_hw_register_divider_table_parent_hw(dev, name, parent_hw, flags, \ argument
769 __clk_hw_register_divider((dev), NULL, (name), NULL, (parent_hw), \
773 * clk_hw_register_divider_table_parent_data - register a table based divider
774 * clock with the clock framework
775 * @dev: device registering this clock
776 * @name: name of this clock
778 * @flags: framework-specific flags
782 * @clk_divider_flags: divider-specific flags for this clock
784 * @lock: shared register lock for this clock
786 #define clk_hw_register_divider_table_parent_data(dev, name, parent_data, \ argument
790 __clk_hw_register_divider((dev), NULL, (name), NULL, NULL, \
795 * devm_clk_hw_register_divider - register a divider clock with the clock framework
796 * @dev: device registering this clock
797 * @name: name of this clock
798 * @parent_name: name of clock's parent
799 * @flags: framework-specific flags
803 * @clk_divider_flags: divider-specific flags for this clock
804 * @lock: shared register lock for this clock
806 #define devm_clk_hw_register_divider(dev, name, parent_name, flags, reg, shift, \ argument
808 __devm_clk_hw_register_divider((dev), NULL, (name), (parent_name), NULL, \
812 * devm_clk_hw_register_divider_table - register a table based divider clock
813 * with the clock framework (devres variant)
814 * @dev: device registering this clock
815 * @name: name of this clock
816 * @parent_name: name of clock's parent
817 * @flags: framework-specific flags
821 * @clk_divider_flags: divider-specific flags for this clock
823 * @lock: shared register lock for this clock
825 #define devm_clk_hw_register_divider_table(dev, name, parent_name, flags, \ argument
828 __devm_clk_hw_register_divider((dev), NULL, (name), (parent_name), \
837 * struct clk_mux - multiplexer clock
839 * @hw: handle between common and hardware-specific interfaces
844 * @flags: hardware-specific flags
847 * Clock with multiple selectable parents. Implements .get_parent, .set_parent
851 * CLK_MUX_INDEX_ONE - register index starts at 1, not 0
852 * CLK_MUX_INDEX_BIT - register index is a single bit (power of two)
853 * CLK_MUX_HIWORD_MASK - The mux settings are only in lower 16-bit of this
854 * register, and mask of mux bits are in higher 16-bit of this register.
855 * While setting the mux bits, higher 16-bit should also be updated to
857 * CLK_MUX_READ_ONLY - The mux registers can't be written, only read in the
859 * CLK_MUX_ROUND_CLOSEST - Use the parent rate that is closest to the desired
861 * CLK_MUX_BIG_ENDIAN - By default little endian register accesses are used for
888 const char *name, u8 num_parents,
895 const char *name, u8 num_parents,
901 struct clk *clk_register_mux_table(struct device *dev, const char *name,
906 #define clk_register_mux(dev, name, parent_names, num_parents, flags, reg, \ argument
908 clk_register_mux_table((dev), (name), (parent_names), (num_parents), \
909 (flags), (reg), (shift), BIT((width)) - 1, \
911 #define clk_hw_register_mux_table(dev, name, parent_names, num_parents, \ argument
914 __clk_hw_register_mux((dev), NULL, (name), (num_parents), \
918 #define clk_hw_register_mux(dev, name, parent_names, num_parents, flags, reg, \ argument
920 __clk_hw_register_mux((dev), NULL, (name), (num_parents), \
922 (shift), BIT((width)) - 1, (clk_mux_flags), \
924 #define clk_hw_register_mux_hws(dev, name, parent_hws, num_parents, flags, \ argument
926 __clk_hw_register_mux((dev), NULL, (name), (num_parents), NULL, \
928 BIT((width)) - 1, (clk_mux_flags), NULL, (lock))
929 #define clk_hw_register_mux_parent_data(dev, name, parent_data, num_parents, \ argument
932 __clk_hw_register_mux((dev), NULL, (name), (num_parents), NULL, NULL, \
934 BIT((width)) - 1, (clk_mux_flags), NULL, (lock))
935 #define devm_clk_hw_register_mux(dev, name, parent_names, num_parents, flags, reg, \ argument
937 __devm_clk_hw_register_mux((dev), NULL, (name), (num_parents), \
939 (shift), BIT((width)) - 1, (clk_mux_flags), \
952 * struct clk_fixed_factor - fixed multiplier and divider clock
954 * @hw: handle between common and hardware-specific interfaces
958 * Clock with a fixed multiplier and divider. The output frequency is the
959 * parent clock rate divided by div and multiplied by mult.
972 struct clk *clk_register_fixed_factor(struct device *dev, const char *name,
977 const char *name, const char *parent_name, unsigned long flags,
981 const char *name, const char *parent_name, unsigned long flags,
984 * struct clk_fractional_divider - adjustable fractional divider clock
986 * @hw: handle between common and hardware-specific interfaces
994 * Clock with adjustable fractional divider affecting its output frequency.
997 * CLK_FRAC_DIVIDER_ZERO_BASED - by default the numerator and denominator
1001 * CLK_FRAC_DIVIDER_BIG_ENDIAN - By default little endian register accesses are
1004 * CLK_FRAC_DIVIDER_POWER_OF_TWO_PS - By default the resulting fraction might
1009 * caller's side the power-of-two capable prescaler exists.
1034 const char *name, const char *parent_name, unsigned long flags,
1038 const char *name, const char *parent_name, unsigned long flags,
1044 * struct clk_multiplier - adjustable multiplier clock
1046 * @hw: handle between common and hardware-specific interfaces
1052 * Clock with an adjustable multiplier affecting its output frequency.
1056 * CLK_MULTIPLIER_ZERO_BYPASS - By default, the multiplier is the value read
1058 * zeroing the output clock rate. If CLK_MULTIPLIER_ZERO_BYPASS is
1061 * CLK_MULTIPLIER_ROUND_CLOSEST - Makes the best calculated divider to be
1063 * CLK_MULTIPLIER_BIG_ENDIAN - By default little endian register accesses are
1085 * struct clk_composite - aggregate clock of mux, divider and gate clocks
1087 * @hw: handle between common and hardware-specific interfaces
1088 * @mux_hw: handle between composite and hardware-specific mux clock
1089 * @rate_hw: handle between composite and hardware-specific rate clock
1090 * @gate_hw: handle between composite and hardware-specific gate clock
1091 * @mux_ops: clock ops for mux
1092 * @rate_ops: clock ops for rate
1093 * @gate_ops: clock ops for gate
1110 struct clk *clk_register_composite(struct device *dev, const char *name,
1116 struct clk *clk_register_composite_pdata(struct device *dev, const char *name,
1123 struct clk_hw *clk_hw_register_composite(struct device *dev, const char *name,
1130 const char *name,
1137 const char *name, const struct clk_parent_data *parent_data,
1190 struct clk *__clk_lookup(const char *name);
1205 dst->clk = src->clk; in __clk_hw_set_clk()
1206 dst->core = src->core; in __clk_hw_set_clk()
1230 * FIXME clock api without lock protection
1244 #define CLK_OF_DECLARE(name, compat, fn) OF_DECLARE_1(clk, name, compat, fn) argument
1250 #define CLK_OF_DECLARE_DRIVER(name, compat, fn) \ argument
1251 static void __init name##_of_clk_init_driver(struct device_node *np) \
1256 OF_DECLARE_1(clk, name, compat, name##_of_clk_init_driver)
1261 .name = _name, \
1270 .name = _name, \
1284 .name = _name, \
1293 .name = _name, \
1304 .name = _name, \
1313 .name = _name, \
1322 .name = _name, \
1331 .name = _name, \
1440 return ERR_PTR(-ENOENT); in of_clk_src_simple_get()
1445 return ERR_PTR(-ENOENT); in of_clk_hw_simple_get()
1450 return ERR_PTR(-ENOENT); in of_clk_src_onecell_get()
1455 return ERR_PTR(-ENOENT); in of_clk_hw_onecell_get()