aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/smiapp-pll.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-10-22 10:40:56 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-29 07:51:00 -0400
commit6ec84a28f5f40e3ebef5d8186c4b11b10aa295d7 (patch)
tree298d63522cd5b4db692f1b1e48691ed74d6f76d2 /drivers/media/i2c/smiapp-pll.c
parentf5984bbdf402b586581bc292a5449f17ce4b8209 (diff)
[media] smiapp-pll: Create a structure for OP and VT limits
OP and VT limits have identical fields, create a shared structure for both. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c/smiapp-pll.c')
-rw-r--r--drivers/media/i2c/smiapp-pll.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index d3243602c77a..cbef446180f8 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -122,7 +122,7 @@ static int __smiapp_pll_calculate(struct device *dev,
122 more_mul_max); 122 more_mul_max);
123 /* Don't go above the division capability of op sys clock divider. */ 123 /* Don't go above the division capability of op sys clock divider. */
124 more_mul_max = min(more_mul_max, 124 more_mul_max = min(more_mul_max,
125 limits->max_op_sys_clk_div * pll->pre_pll_clk_div 125 limits->op.max_sys_clk_div * pll->pre_pll_clk_div
126 / div); 126 / div);
127 dev_dbg(dev, "more_mul_max: max_op_sys_clk_div check: %d\n", 127 dev_dbg(dev, "more_mul_max: max_op_sys_clk_div check: %d\n",
128 more_mul_max); 128 more_mul_max);
@@ -152,7 +152,7 @@ static int __smiapp_pll_calculate(struct device *dev,
152 152
153 more_mul_factor = lcm(div, pll->pre_pll_clk_div) / div; 153 more_mul_factor = lcm(div, pll->pre_pll_clk_div) / div;
154 dev_dbg(dev, "more_mul_factor: %d\n", more_mul_factor); 154 dev_dbg(dev, "more_mul_factor: %d\n", more_mul_factor);
155 more_mul_factor = lcm(more_mul_factor, limits->min_op_sys_clk_div); 155 more_mul_factor = lcm(more_mul_factor, limits->op.min_sys_clk_div);
156 dev_dbg(dev, "more_mul_factor: min_op_sys_clk_div: %d\n", 156 dev_dbg(dev, "more_mul_factor: min_op_sys_clk_div: %d\n",
157 more_mul_factor); 157 more_mul_factor);
158 i = roundup(more_mul_min, more_mul_factor); 158 i = roundup(more_mul_min, more_mul_factor);
@@ -220,19 +220,19 @@ static int __smiapp_pll_calculate(struct device *dev,
220 dev_dbg(dev, "min_vt_div: %d\n", min_vt_div); 220 dev_dbg(dev, "min_vt_div: %d\n", min_vt_div);
221 min_vt_div = max(min_vt_div, 221 min_vt_div = max(min_vt_div,
222 DIV_ROUND_UP(pll->pll_op_clk_freq_hz, 222 DIV_ROUND_UP(pll->pll_op_clk_freq_hz,
223 limits->max_vt_pix_clk_freq_hz)); 223 limits->vt.max_pix_clk_freq_hz));
224 dev_dbg(dev, "min_vt_div: max_vt_pix_clk_freq_hz: %d\n", 224 dev_dbg(dev, "min_vt_div: max_vt_pix_clk_freq_hz: %d\n",
225 min_vt_div); 225 min_vt_div);
226 min_vt_div = max_t(uint32_t, min_vt_div, 226 min_vt_div = max_t(uint32_t, min_vt_div,
227 limits->min_vt_pix_clk_div 227 limits->vt.min_pix_clk_div
228 * limits->min_vt_sys_clk_div); 228 * limits->vt.min_sys_clk_div);
229 dev_dbg(dev, "min_vt_div: min_vt_clk_div: %d\n", min_vt_div); 229 dev_dbg(dev, "min_vt_div: min_vt_clk_div: %d\n", min_vt_div);
230 230
231 max_vt_div = limits->max_vt_sys_clk_div * limits->max_vt_pix_clk_div; 231 max_vt_div = limits->vt.max_sys_clk_div * limits->vt.max_pix_clk_div;
232 dev_dbg(dev, "max_vt_div: %d\n", max_vt_div); 232 dev_dbg(dev, "max_vt_div: %d\n", max_vt_div);
233 max_vt_div = min(max_vt_div, 233 max_vt_div = min(max_vt_div,
234 DIV_ROUND_UP(pll->pll_op_clk_freq_hz, 234 DIV_ROUND_UP(pll->pll_op_clk_freq_hz,
235 limits->min_vt_pix_clk_freq_hz)); 235 limits->vt.min_pix_clk_freq_hz));
236 dev_dbg(dev, "max_vt_div: min_vt_pix_clk_freq_hz: %d\n", 236 dev_dbg(dev, "max_vt_div: min_vt_pix_clk_freq_hz: %d\n",
237 max_vt_div); 237 max_vt_div);
238 238
@@ -240,28 +240,28 @@ static int __smiapp_pll_calculate(struct device *dev,
240 * Find limitsits for sys_clk_div. Not all values are possible 240 * Find limitsits for sys_clk_div. Not all values are possible
241 * with all values of pix_clk_div. 241 * with all values of pix_clk_div.
242 */ 242 */
243 min_sys_div = limits->min_vt_sys_clk_div; 243 min_sys_div = limits->vt.min_sys_clk_div;
244 dev_dbg(dev, "min_sys_div: %d\n", min_sys_div); 244 dev_dbg(dev, "min_sys_div: %d\n", min_sys_div);
245 min_sys_div = max(min_sys_div, 245 min_sys_div = max(min_sys_div,
246 DIV_ROUND_UP(min_vt_div, 246 DIV_ROUND_UP(min_vt_div,
247 limits->max_vt_pix_clk_div)); 247 limits->vt.max_pix_clk_div));
248 dev_dbg(dev, "min_sys_div: max_vt_pix_clk_div: %d\n", min_sys_div); 248 dev_dbg(dev, "min_sys_div: max_vt_pix_clk_div: %d\n", min_sys_div);
249 min_sys_div = max(min_sys_div, 249 min_sys_div = max(min_sys_div,
250 pll->pll_op_clk_freq_hz 250 pll->pll_op_clk_freq_hz
251 / limits->max_vt_sys_clk_freq_hz); 251 / limits->vt.max_sys_clk_freq_hz);
252 dev_dbg(dev, "min_sys_div: max_pll_op_clk_freq_hz: %d\n", min_sys_div); 252 dev_dbg(dev, "min_sys_div: max_pll_op_clk_freq_hz: %d\n", min_sys_div);
253 min_sys_div = clk_div_even_up(min_sys_div); 253 min_sys_div = clk_div_even_up(min_sys_div);
254 dev_dbg(dev, "min_sys_div: one or even: %d\n", min_sys_div); 254 dev_dbg(dev, "min_sys_div: one or even: %d\n", min_sys_div);
255 255
256 max_sys_div = limits->max_vt_sys_clk_div; 256 max_sys_div = limits->vt.max_sys_clk_div;
257 dev_dbg(dev, "max_sys_div: %d\n", max_sys_div); 257 dev_dbg(dev, "max_sys_div: %d\n", max_sys_div);
258 max_sys_div = min(max_sys_div, 258 max_sys_div = min(max_sys_div,
259 DIV_ROUND_UP(max_vt_div, 259 DIV_ROUND_UP(max_vt_div,
260 limits->min_vt_pix_clk_div)); 260 limits->vt.min_pix_clk_div));
261 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_div: %d\n", max_sys_div); 261 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_div: %d\n", max_sys_div);
262 max_sys_div = min(max_sys_div, 262 max_sys_div = min(max_sys_div,
263 DIV_ROUND_UP(pll->pll_op_clk_freq_hz, 263 DIV_ROUND_UP(pll->pll_op_clk_freq_hz,
264 limits->min_vt_pix_clk_freq_hz)); 264 limits->vt.min_pix_clk_freq_hz));
265 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_freq_hz: %d\n", max_sys_div); 265 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_freq_hz: %d\n", max_sys_div);
266 266
267 /* 267 /*
@@ -276,13 +276,13 @@ static int __smiapp_pll_calculate(struct device *dev,
276 sys_div += 2 - (sys_div & 1)) { 276 sys_div += 2 - (sys_div & 1)) {
277 uint16_t pix_div = DIV_ROUND_UP(vt_div, sys_div); 277 uint16_t pix_div = DIV_ROUND_UP(vt_div, sys_div);
278 278
279 if (pix_div < limits->min_vt_pix_clk_div 279 if (pix_div < limits->vt.min_pix_clk_div
280 || pix_div > limits->max_vt_pix_clk_div) { 280 || pix_div > limits->vt.max_pix_clk_div) {
281 dev_dbg(dev, 281 dev_dbg(dev,
282 "pix_div %d too small or too big (%d--%d)\n", 282 "pix_div %d too small or too big (%d--%d)\n",
283 pix_div, 283 pix_div,
284 limits->min_vt_pix_clk_div, 284 limits->vt.min_pix_clk_div,
285 limits->max_vt_pix_clk_div); 285 limits->vt.max_pix_clk_div);
286 continue; 286 continue;
287 } 287 }
288 288
@@ -327,36 +327,36 @@ static int __smiapp_pll_calculate(struct device *dev,
327 if (!rval) 327 if (!rval)
328 rval = bounds_check( 328 rval = bounds_check(
329 dev, pll->op_sys_clk_div, 329 dev, pll->op_sys_clk_div,
330 limits->min_op_sys_clk_div, limits->max_op_sys_clk_div, 330 limits->op.min_sys_clk_div, limits->op.max_sys_clk_div,
331 "op_sys_clk_div"); 331 "op_sys_clk_div");
332 if (!rval) 332 if (!rval)
333 rval = bounds_check( 333 rval = bounds_check(
334 dev, pll->op_pix_clk_div, 334 dev, pll->op_pix_clk_div,
335 limits->min_op_pix_clk_div, limits->max_op_pix_clk_div, 335 limits->op.min_pix_clk_div, limits->op.max_pix_clk_div,
336 "op_pix_clk_div"); 336 "op_pix_clk_div");
337 if (!rval) 337 if (!rval)
338 rval = bounds_check( 338 rval = bounds_check(
339 dev, pll->op_sys_clk_freq_hz, 339 dev, pll->op_sys_clk_freq_hz,
340 limits->min_op_sys_clk_freq_hz, 340 limits->op.min_sys_clk_freq_hz,
341 limits->max_op_sys_clk_freq_hz, 341 limits->op.max_sys_clk_freq_hz,
342 "op_sys_clk_freq_hz"); 342 "op_sys_clk_freq_hz");
343 if (!rval) 343 if (!rval)
344 rval = bounds_check( 344 rval = bounds_check(
345 dev, pll->op_pix_clk_freq_hz, 345 dev, pll->op_pix_clk_freq_hz,
346 limits->min_op_pix_clk_freq_hz, 346 limits->op.min_pix_clk_freq_hz,
347 limits->max_op_pix_clk_freq_hz, 347 limits->op.max_pix_clk_freq_hz,
348 "op_pix_clk_freq_hz"); 348 "op_pix_clk_freq_hz");
349 if (!rval) 349 if (!rval)
350 rval = bounds_check( 350 rval = bounds_check(
351 dev, pll->vt_sys_clk_freq_hz, 351 dev, pll->vt_sys_clk_freq_hz,
352 limits->min_vt_sys_clk_freq_hz, 352 limits->vt.min_sys_clk_freq_hz,
353 limits->max_vt_sys_clk_freq_hz, 353 limits->vt.max_sys_clk_freq_hz,
354 "vt_sys_clk_freq_hz"); 354 "vt_sys_clk_freq_hz");
355 if (!rval) 355 if (!rval)
356 rval = bounds_check( 356 rval = bounds_check(
357 dev, pll->vt_pix_clk_freq_hz, 357 dev, pll->vt_pix_clk_freq_hz,
358 limits->min_vt_pix_clk_freq_hz, 358 limits->vt.min_pix_clk_freq_hz,
359 limits->max_vt_pix_clk_freq_hz, 359 limits->vt.max_pix_clk_freq_hz,
360 "vt_pix_clk_freq_hz"); 360 "vt_pix_clk_freq_hz");
361 361
362 return rval; 362 return rval;