Lines Matching full:sclk
23 #include "sclk-div.h"
31 static int sclk_div_maxval(struct meson_sclk_div_data *sclk) in sclk_div_maxval() argument
33 return (1 << sclk->div.width) - 1; in sclk_div_maxval()
36 static int sclk_div_maxdiv(struct meson_sclk_div_data *sclk) in sclk_div_maxdiv() argument
38 return sclk_div_maxval(sclk) + 1; in sclk_div_maxdiv()
51 struct meson_sclk_div_data *sclk) in sclk_div_bestdiv() argument
61 maxdiv = sclk_div_maxdiv(sclk); in sclk_div_bestdiv()
92 bestdiv = sclk_div_maxdiv(sclk); in sclk_div_bestdiv()
103 struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk); in sclk_div_round_rate() local
106 div = sclk_div_bestdiv(hw, rate, prate, sclk); in sclk_div_round_rate()
112 struct meson_sclk_div_data *sclk) in sclk_apply_ratio() argument
114 unsigned int hi = DIV_ROUND_CLOSEST(sclk->cached_div * in sclk_apply_ratio()
115 sclk->cached_duty.num, in sclk_apply_ratio()
116 sclk->cached_duty.den); in sclk_apply_ratio()
121 meson_parm_write(clk->map, &sclk->hi, hi); in sclk_apply_ratio()
128 struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk); in sclk_div_set_duty_cycle() local
130 if (MESON_PARM_APPLICABLE(&sclk->hi)) { in sclk_div_set_duty_cycle()
131 memcpy(&sclk->cached_duty, duty, sizeof(*duty)); in sclk_div_set_duty_cycle()
132 sclk_apply_ratio(clk, sclk); in sclk_div_set_duty_cycle()
142 struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk); in sclk_div_get_duty_cycle() local
145 if (!MESON_PARM_APPLICABLE(&sclk->hi)) { in sclk_div_get_duty_cycle()
151 hi = meson_parm_read(clk->map, &sclk->hi); in sclk_div_get_duty_cycle()
153 duty->den = sclk->cached_div; in sclk_div_get_duty_cycle()
158 struct meson_sclk_div_data *sclk) in sclk_apply_divider() argument
160 if (MESON_PARM_APPLICABLE(&sclk->hi)) in sclk_apply_divider()
161 sclk_apply_ratio(clk, sclk); in sclk_apply_divider()
163 meson_parm_write(clk->map, &sclk->div, sclk->cached_div - 1); in sclk_apply_divider()
170 struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk); in sclk_div_set_rate() local
171 unsigned long maxdiv = sclk_div_maxdiv(sclk); in sclk_div_set_rate()
173 sclk->cached_div = sclk_div_getdiv(hw, rate, prate, maxdiv); in sclk_div_set_rate()
176 sclk_apply_divider(clk, sclk); in sclk_div_set_rate()
185 struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk); in sclk_div_recalc_rate() local
187 return DIV_ROUND_UP_ULL((u64)prate, sclk->cached_div); in sclk_div_recalc_rate()
193 struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk); in sclk_div_enable() local
195 sclk_apply_divider(clk, sclk); in sclk_div_enable()
203 struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk); in sclk_div_disable() local
205 meson_parm_write(clk->map, &sclk->div, 0); in sclk_div_disable()
211 struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk); in sclk_div_is_enabled() local
213 if (meson_parm_read(clk->map, &sclk->div)) in sclk_div_is_enabled()
222 struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk); in sclk_div_init() local
225 val = meson_parm_read(clk->map, &sclk->div); in sclk_div_init()
229 sclk->cached_div = sclk_div_maxdiv(sclk); in sclk_div_init()
231 sclk->cached_div = val + 1; in sclk_div_init()
233 sclk_div_get_duty_cycle(hw, &sclk->cached_duty); in sclk_div_init()