]> www.infradead.org Git - users/dwmw2/linux.git/commit
drm/bridge: tc358768: Cleanup PLL calculations
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Wed, 6 Sep 2023 06:50:52 +0000 (09:50 +0300)
committerRobert Foss <rfoss@kernel.org>
Wed, 20 Sep 2023 11:48:39 +0000 (13:48 +0200)
commit1e08e78871df0fe615c1d90614529181a554da16
treee6acc6ba3f9afcef8584f52fe8dc68edaeff384f
parent66962d5c3c51377b9b90cae35b7e038950438e02
drm/bridge: tc358768: Cleanup PLL calculations

As is quite common, some of TC358768's PLL register fields are to be
programmed with (value - 1). Specifically, the FBD and PRD, multiplier
and divider, are such fields.

However, what the driver currently does is that it considers that the
formula used for PLL rate calculation is:

RefClk * [(FBD + 1)/ (PRD + 1)] * [1 / (2^FRS)]

where FBD and PRD are values directly from the registers, while a more
sensible way to look at it is:

RefClk * FBD / PRD * (1 / (2^FRS))

and when the FBD and PRD values are written to the registers, they will
be subtracted by one.

Change the driver accordingly, as it simplifies the PLL code.

Reviewed-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Tested-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Robert Foss <rfoss@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230906-tc358768-v4-5-31725f008a50@ideasonboard.com
drivers/gpu/drm/bridge/tc358768.c