Lines Matching refs:req
33 static void sun4i_get_pll1_factors(struct factors_request *req) in sun4i_get_pll1_factors() argument
38 div = req->rate / 6000000; in sun4i_get_pll1_factors()
39 req->rate = 6000000 * div; in sun4i_get_pll1_factors()
42 req->m = 0; in sun4i_get_pll1_factors()
45 if (req->rate >= 768000000 || req->rate == 42000000 || in sun4i_get_pll1_factors()
46 req->rate == 54000000) in sun4i_get_pll1_factors()
47 req->k = 1; in sun4i_get_pll1_factors()
49 req->k = 0; in sun4i_get_pll1_factors()
53 req->p = 3; in sun4i_get_pll1_factors()
57 req->p = 2; in sun4i_get_pll1_factors()
62 req->p = 1; in sun4i_get_pll1_factors()
66 req->p = 0; in sun4i_get_pll1_factors()
69 div <<= req->p; in sun4i_get_pll1_factors()
70 div /= (req->k + 1); in sun4i_get_pll1_factors()
71 req->n = div / 4; in sun4i_get_pll1_factors()
80 static void sun6i_a31_get_pll1_factors(struct factors_request *req) in sun6i_a31_get_pll1_factors() argument
86 u32 freq_mhz = req->rate / 1000000; in sun6i_a31_get_pll1_factors()
87 u32 parent_freq_mhz = req->parent_rate / 1000000; in sun6i_a31_get_pll1_factors()
101 req->rate = freq_mhz * 1000000; in sun6i_a31_get_pll1_factors()
105 req->k = 3; in sun6i_a31_get_pll1_factors()
108 req->k = 2; in sun6i_a31_get_pll1_factors()
111 req->k = 1; in sun6i_a31_get_pll1_factors()
114 req->k = 0; in sun6i_a31_get_pll1_factors()
125 req->m = 2; in sun6i_a31_get_pll1_factors()
131 req->m = 3; in sun6i_a31_get_pll1_factors()
134 req->m = 1; in sun6i_a31_get_pll1_factors()
137 req->n = freq_mhz * (req->m + 1) / ((req->k + 1) * parent_freq_mhz) in sun6i_a31_get_pll1_factors()
144 if ((req->n + 1) > 31 && (req->m + 1) > 1) { in sun6i_a31_get_pll1_factors()
145 req->n = (req->n + 1) / 2 - 1; in sun6i_a31_get_pll1_factors()
146 req->m = (req->m + 1) / 2 - 1; in sun6i_a31_get_pll1_factors()
157 static void sun8i_a23_get_pll1_factors(struct factors_request *req) in sun8i_a23_get_pll1_factors() argument
162 div = req->rate / 6000000; in sun8i_a23_get_pll1_factors()
163 req->rate = 6000000 * div; in sun8i_a23_get_pll1_factors()
166 req->m = 0; in sun8i_a23_get_pll1_factors()
169 if (req->rate >= 768000000 || req->rate == 42000000 || in sun8i_a23_get_pll1_factors()
170 req->rate == 54000000) in sun8i_a23_get_pll1_factors()
171 req->k = 1; in sun8i_a23_get_pll1_factors()
173 req->k = 0; in sun8i_a23_get_pll1_factors()
177 req->p = 2; in sun8i_a23_get_pll1_factors()
182 req->p = 1; in sun8i_a23_get_pll1_factors()
186 req->p = 0; in sun8i_a23_get_pll1_factors()
189 div <<= req->p; in sun8i_a23_get_pll1_factors()
190 div /= (req->k + 1); in sun8i_a23_get_pll1_factors()
191 req->n = div / 4 - 1; in sun8i_a23_get_pll1_factors()
201 static void sun4i_get_pll5_factors(struct factors_request *req) in sun4i_get_pll5_factors() argument
206 div = req->rate / req->parent_rate; in sun4i_get_pll5_factors()
207 req->rate = req->parent_rate * div; in sun4i_get_pll5_factors()
210 req->k = 0; in sun4i_get_pll5_factors()
212 req->k = 1; in sun4i_get_pll5_factors()
214 req->k = 2; in sun4i_get_pll5_factors()
216 req->k = 3; in sun4i_get_pll5_factors()
218 req->n = DIV_ROUND_UP(div, (req->k + 1)); in sun4i_get_pll5_factors()
228 static void sun6i_a31_get_pll6_factors(struct factors_request *req) in sun6i_a31_get_pll6_factors() argument
233 div = req->rate / req->parent_rate; in sun6i_a31_get_pll6_factors()
234 req->rate = req->parent_rate * div; in sun6i_a31_get_pll6_factors()
236 req->k = div / 32; in sun6i_a31_get_pll6_factors()
237 if (req->k > 3) in sun6i_a31_get_pll6_factors()
238 req->k = 3; in sun6i_a31_get_pll6_factors()
240 req->n = DIV_ROUND_UP(div, (req->k + 1)) - 1; in sun6i_a31_get_pll6_factors()
249 static void sun5i_a13_get_ahb_factors(struct factors_request *req) in sun5i_a13_get_ahb_factors() argument
254 if (req->parent_rate < req->rate) in sun5i_a13_get_ahb_factors()
255 req->rate = req->parent_rate; in sun5i_a13_get_ahb_factors()
261 if (req->rate < 8000) in sun5i_a13_get_ahb_factors()
262 req->rate = 8000; in sun5i_a13_get_ahb_factors()
263 if (req->rate > 300000000) in sun5i_a13_get_ahb_factors()
264 req->rate = 300000000; in sun5i_a13_get_ahb_factors()
266 div = order_base_2(DIV_ROUND_UP(req->parent_rate, req->rate)); in sun5i_a13_get_ahb_factors()
272 req->rate = req->parent_rate >> div; in sun5i_a13_get_ahb_factors()
274 req->p = div; in sun5i_a13_get_ahb_factors()
288 static void sun6i_get_ahb1_factors(struct factors_request *req) in sun6i_get_ahb1_factors() argument
296 if (req->parent_rate && req->rate > req->parent_rate) in sun6i_get_ahb1_factors()
297 req->rate = req->parent_rate; in sun6i_get_ahb1_factors()
299 div = DIV_ROUND_UP(req->parent_rate, req->rate); in sun6i_get_ahb1_factors()
302 if (req->parent_index == SUN6I_AHB1_PARENT_PLL6) { in sun6i_get_ahb1_factors()
318 req->rate = (req->parent_rate / calcm) >> calcp; in sun6i_get_ahb1_factors()
319 req->p = calcp; in sun6i_get_ahb1_factors()
320 req->m = calcm - 1; in sun6i_get_ahb1_factors()
327 static void sun6i_ahb1_recalc(struct factors_request *req) in sun6i_ahb1_recalc() argument
329 req->rate = req->parent_rate; in sun6i_ahb1_recalc()
332 if (req->parent_index == SUN6I_AHB1_PARENT_PLL6) in sun6i_ahb1_recalc()
333 req->rate /= req->m + 1; in sun6i_ahb1_recalc()
336 req->rate >>= req->p; in sun6i_ahb1_recalc()
345 static void sun4i_get_apb1_factors(struct factors_request *req) in sun4i_get_apb1_factors() argument
350 if (req->parent_rate < req->rate) in sun4i_get_apb1_factors()
351 req->rate = req->parent_rate; in sun4i_get_apb1_factors()
353 div = DIV_ROUND_UP(req->parent_rate, req->rate); in sun4i_get_apb1_factors()
370 req->rate = (req->parent_rate >> calcp) / (calcm + 1); in sun4i_get_apb1_factors()
371 req->m = calcm; in sun4i_get_apb1_factors()
372 req->p = calcp; in sun4i_get_apb1_factors()
384 static void sun7i_a20_get_out_factors(struct factors_request *req) in sun7i_a20_get_out_factors() argument
390 if (req->rate > req->parent_rate) in sun7i_a20_get_out_factors()
391 req->rate = req->parent_rate; in sun7i_a20_get_out_factors()
393 div = DIV_ROUND_UP(req->parent_rate, req->rate); in sun7i_a20_get_out_factors()
406 req->rate = (req->parent_rate >> calcp) / calcm; in sun7i_a20_get_out_factors()
407 req->m = calcm - 1; in sun7i_a20_get_out_factors()
408 req->p = calcp; in sun7i_a20_get_out_factors()
1125 static void sun6i_display_factors(struct factors_request *req) in sun6i_display_factors() argument
1129 if (req->rate > req->parent_rate) in sun6i_display_factors()
1130 req->rate = req->parent_rate; in sun6i_display_factors()
1132 m = DIV_ROUND_UP(req->parent_rate, req->rate); in sun6i_display_factors()
1134 req->rate = req->parent_rate / m; in sun6i_display_factors()
1135 req->m = m - 1; in sun6i_display_factors()