]> git.baikalelectronics.ru Git - kernel.git/commit
drm: rcar-du: lvds: Fix post-DLL divider calculation
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 12 Mar 2019 16:18:17 +0000 (18:18 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Thu, 28 Mar 2019 04:06:33 +0000 (06:06 +0200)
commit54495a5950740eec0cffa5db39e7742f163da1ba
tree7ff526645e2f0f7dfa9a8bb309c7f8eafa8a1e9c
parent383e7ac3b9596cec8a5bd6fb0b4e935224b6cf92
drm: rcar-du: lvds: Fix post-DLL divider calculation

The PLL parameters are computed by looping over the range of acceptable
M, N and E values, and selecting the combination that produces the
output frequency closest to the target. The internal frequency
constraints are taken into account by restricting the tested values for
the PLL parameters, reducing the search space. The target frequency,
however, is only taken into account when computing the post-PLL divider,
which can result in a 0 value for the divider when the PLL output
frequency being tested is lower than half of the target frequency.
Subsequent loops will produce a better set of PLL parameters, but for
some of the iterations this can result in a division by 0.

Fix it by clamping the divider value. We could instead restrict the E
values being tested in the inner loop, but that would require additional
calculation that would likely be less efficient as the E parameter can
only take three different values.

Fixes: c4d86ae5336c ("drm: rcar-du: lvds: D3/E3 support")
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
drivers/gpu/drm/rcar-du/rcar_lvds.c