Lines Matching +full:duty +full:- +full:cycle
1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
12 * The duty cycle may also be set for the LR clock variant. The duty cycle
15 * hi = [0 - val]
19 #include <linux/clk-provider.h>
22 #include "clk-regmap.h"
23 #include "sclk-div.h"
28 return (struct meson_sclk_div_data *)clk->data; in meson_sclk_div_data()
33 return (1 << sclk->div.width) - 1; in sclk_div_maxval()
84 if (abs(rate - now) < abs(rate - best)) { in sclk_div_bestdiv()
106 div = sclk_div_bestdiv(hw, req->rate, &req->best_parent_rate, sclk); in sclk_div_determine_rate()
107 req->rate = DIV_ROUND_UP_ULL((u64)req->best_parent_rate, div); in sclk_div_determine_rate()
115 unsigned int hi = DIV_ROUND_CLOSEST(sclk->cached_div * in sclk_apply_ratio()
116 sclk->cached_duty.num, in sclk_apply_ratio()
117 sclk->cached_duty.den); in sclk_apply_ratio()
120 hi -= 1; in sclk_apply_ratio()
122 meson_parm_write(clk->map, &sclk->hi, hi); in sclk_apply_ratio()
126 struct clk_duty *duty) in sclk_div_set_duty_cycle() argument
131 if (MESON_PARM_APPLICABLE(&sclk->hi)) { in sclk_div_set_duty_cycle()
132 memcpy(&sclk->cached_duty, duty, sizeof(*duty)); in sclk_div_set_duty_cycle()
140 struct clk_duty *duty) in sclk_div_get_duty_cycle() argument
146 if (!MESON_PARM_APPLICABLE(&sclk->hi)) { in sclk_div_get_duty_cycle()
147 duty->num = 1; in sclk_div_get_duty_cycle()
148 duty->den = 2; in sclk_div_get_duty_cycle()
152 hi = meson_parm_read(clk->map, &sclk->hi); in sclk_div_get_duty_cycle()
153 duty->num = hi + 1; in sclk_div_get_duty_cycle()
154 duty->den = sclk->cached_div; in sclk_div_get_duty_cycle()
161 if (MESON_PARM_APPLICABLE(&sclk->hi)) in sclk_apply_divider()
164 meson_parm_write(clk->map, &sclk->div, sclk->cached_div - 1); in sclk_apply_divider()
174 sclk->cached_div = sclk_div_getdiv(hw, rate, prate, maxdiv); in sclk_div_set_rate()
188 return DIV_ROUND_UP_ULL((u64)prate, sclk->cached_div); in sclk_div_recalc_rate()
206 meson_parm_write(clk->map, &sclk->div, 0); in sclk_div_disable()
214 if (meson_parm_read(clk->map, &sclk->div)) in sclk_div_is_enabled()
226 val = meson_parm_read(clk->map, &sclk->div); in sclk_div_init()
230 sclk->cached_div = sclk_div_maxdiv(sclk); in sclk_div_init()
232 sclk->cached_div = val + 1; in sclk_div_init()
234 sclk_div_get_duty_cycle(hw, &sclk->cached_duty); in sclk_div_init()