Lines Matching +full:clk +full:- +full:source

4  * Copyright GreenSocs 2016-2020
11 * See the COPYING file in the top-level directory.
19 #include "qemu/host-utils.h"
39 * clock store a value representing the clock's period in 2^-32ns unit.
41 * + periods from 2^-32ns up to 4seconds
65 * @source: source (or parent in clock tree) of the clock
66 * @children: list of clocks connected to this one (it is their source)
89 Clock *source; member
110 * @clk: clock
114 void clock_setup_canonical_path(Clock *clk);
131 * @clk: the clock to register the callback into
141 void clock_set_callback(Clock *clk, ClockCallback *cb,
146 * @clk: the clock.
147 * @src: the source clock
149 * Setup @src as the clock source of @clk. The current @src period
150 * value is also copied to @clk and its subtree but no callback is
152 * Further @src update will be propagated to @clk and its subtree.
154 void clock_set_source(Clock *clk, Clock *src);
158 * @clk: the clock
160 * Returns true if the clock has a source clock connected to it.
166 static inline bool clock_has_source(const Clock *clk) in clock_has_source() argument
168 return clk->source != NULL; in clock_has_source()
173 * @clk: the clock to initialize.
176 * Set the local cached period value of @clk to @value.
180 bool clock_set(Clock *clk, uint64_t value);
182 static inline bool clock_set_hz(Clock *clk, unsigned hz) in clock_set_hz() argument
184 return clock_set(clk, CLOCK_PERIOD_FROM_HZ(hz)); in clock_set_hz()
187 static inline bool clock_set_ns(Clock *clk, unsigned ns) in clock_set_ns() argument
189 return clock_set(clk, CLOCK_PERIOD_FROM_NS(ns)); in clock_set_ns()
194 * @clk: the clock
198 * It is an error to call this function on a clock which has a source.
202 void clock_propagate(Clock *clk);
206 * @clk: the clock to update.
209 * Update the @clk to the new @value. All connected clocks will be informed
213 static inline void clock_update(Clock *clk, uint64_t value) in clock_update() argument
215 if (clock_set(clk, value)) { in clock_update()
216 clock_propagate(clk); in clock_update()
220 static inline void clock_update_hz(Clock *clk, unsigned hz) in clock_update_hz() argument
222 clock_update(clk, CLOCK_PERIOD_FROM_HZ(hz)); in clock_update_hz()
225 static inline void clock_update_ns(Clock *clk, unsigned ns) in clock_update_ns() argument
227 clock_update(clk, CLOCK_PERIOD_FROM_NS(ns)); in clock_update_ns()
232 * @clk: the clk to fetch the clock
236 static inline uint64_t clock_get(const Clock *clk) in clock_get() argument
238 return clk->period; in clock_get()
241 static inline unsigned clock_get_hz(Clock *clk) in clock_get_hz() argument
243 return CLOCK_PERIOD_TO_HZ(clock_get(clk)); in clock_get_hz()
248 * @clk: the clock to query
259 * The result could in theory be too large to fit in a 64-bit
265 * and callers can reasonably not special-case the saturated result.
267 static inline uint64_t clock_ticks_to_ns(const Clock *clk, uint64_t ticks) in clock_ticks_to_ns() argument
272 * clk->period is the period in units of 2^-32 ns, so in clock_ticks_to_ns()
273 * (clk->period * ticks) is the required length of time in those in clock_ticks_to_ns()
275 * 2^32, which is the same as shifting the 128-bit multiplication in clock_ticks_to_ns()
278 mulu64(&ns_low, &ns_high, clk->period, ticks); in clock_ticks_to_ns()
287 * @clk: the clock to query
298 * For some inputs the result could overflow a 64-bit value (because
300 * cases we truncate the result to a 64-bit value. This is on the
302 * a 32-bit or 64-bit guest register value, so wrapping either cannot
305 static inline uint64_t clock_ns_to_ticks(const Clock *clk, uint64_t ns) in clock_ns_to_ticks() argument
315 if (clk->period == 0) { in clock_ns_to_ticks()
319 divu128(&lo, &hi, clk->period); in clock_ns_to_ticks()
325 * @clk: a clock
329 static inline bool clock_is_enabled(const Clock *clk) in clock_is_enabled() argument
331 return clock_get(clk) != 0; in clock_is_enabled()
335 * clock_display_freq: return human-readable representation of clock frequency
336 * @clk: clock
338 * Return a string which has a human-readable representation of the
344 char *clock_display_freq(Clock *clk);
348 * @clk: clock
371 bool clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider);