Lines Matching full:clk

23 void clock_setup_canonical_path(Clock *clk)  in clock_setup_canonical_path()  argument
25 g_free(clk->canonical_path); in clock_setup_canonical_path()
26 clk->canonical_path = object_get_canonical_path(OBJECT(clk)); in clock_setup_canonical_path()
32 Clock *clk; in clock_new() local
38 clk = CLOCK(obj); in clock_new()
39 clock_setup_canonical_path(clk); in clock_new()
41 return clk; in clock_new()
44 void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque, in clock_set_callback() argument
47 clk->callback = cb; in clock_set_callback()
48 clk->callback_opaque = opaque; in clock_set_callback()
49 clk->callback_events = events; in clock_set_callback()
52 void clock_clear_callback(Clock *clk) in clock_clear_callback() argument
54 clock_set_callback(clk, NULL, NULL, 0); in clock_clear_callback()
57 bool clock_set(Clock *clk, uint64_t period) in clock_set() argument
59 if (clk->period == period) { in clock_set()
62 trace_clock_set(CLOCK_PATH(clk), CLOCK_PERIOD_TO_HZ(clk->period), in clock_set()
64 clk->period = period; in clock_set()
69 static uint64_t clock_get_child_period(Clock *clk) in clock_get_child_period() argument
75 return muldiv64(clk->period, clk->multiplier, clk->divider); in clock_get_child_period()
78 static void clock_call_callback(Clock *clk, ClockEvent event) in clock_call_callback() argument
84 if (clk->callback && (clk->callback_events & event)) { in clock_call_callback()
85 clk->callback(clk->callback_opaque, event); in clock_call_callback()
89 static void clock_propagate_period(Clock *clk, bool call_callbacks) in clock_propagate_period() argument
92 uint64_t child_period = clock_get_child_period(clk); in clock_propagate_period()
94 QLIST_FOREACH(child, &clk->children, sibling) { in clock_propagate_period()
100 trace_clock_update(CLOCK_PATH(child), CLOCK_PATH(clk), in clock_propagate_period()
111 void clock_propagate(Clock *clk) in clock_propagate() argument
113 trace_clock_propagate(CLOCK_PATH(clk)); in clock_propagate()
114 clock_propagate_period(clk, true); in clock_propagate()
117 void clock_set_source(Clock *clk, Clock *src) in clock_set_source() argument
120 assert(!clk->source); in clock_set_source()
122 trace_clock_set_source(CLOCK_PATH(clk), CLOCK_PATH(src)); in clock_set_source()
124 clk->period = clock_get_child_period(src); in clock_set_source()
125 QLIST_INSERT_HEAD(&src->children, clk, sibling); in clock_set_source()
126 clk->source = src; in clock_set_source()
127 clock_propagate_period(clk, false); in clock_set_source()
130 static void clock_disconnect(Clock *clk) in clock_disconnect() argument
132 if (clk->source == NULL) { in clock_disconnect()
136 trace_clock_disconnect(CLOCK_PATH(clk)); in clock_disconnect()
138 clk->source = NULL; in clock_disconnect()
139 QLIST_REMOVE(clk, sibling); in clock_disconnect()
142 char *clock_display_freq(Clock *clk) in clock_display_freq() argument
144 return freq_to_str(clock_get_hz(clk)); in clock_display_freq()
147 bool clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider) in clock_set_mul_div() argument
151 if (clk->multiplier == multiplier && clk->divider == divider) { in clock_set_mul_div()
155 trace_clock_set_mul_div(CLOCK_PATH(clk), clk->multiplier, multiplier, in clock_set_mul_div()
156 clk->divider, divider); in clock_set_mul_div()
157 clk->multiplier = multiplier; in clock_set_mul_div()
158 clk->divider = divider; in clock_set_mul_div()
166 Clock *clk = CLOCK(obj); in clock_period_prop_get() local
167 uint64_t period = clock_get(clk); in clock_period_prop_get()
174 Clock *clk = CLOCK(obj); in clock_initfn() local
176 clk->multiplier = 1; in clock_initfn()
177 clk->divider = 1; in clock_initfn()
179 QLIST_INIT(&clk->children); in clock_initfn()
189 Clock *clk = CLOCK(obj); in clock_finalizefn() local
193 QLIST_FOREACH_SAFE(child, &clk->children, sibling, next) { in clock_finalizefn()
198 clock_disconnect(clk); in clock_finalizefn()
200 g_free(clk->canonical_path); in clock_finalizefn()