usb: dwc3: Program GFLADJ
authorSean Anderson <sean.anderson@seco.com>
Sun, 27 Nov 2022 14:31:55 +0000 (15:31 +0100)
committerMarek Vasut <marex@denx.de>
Sun, 27 Nov 2022 14:34:56 +0000 (15:34 +0100)
commitc55ac51a550c8d2f8485abe94cb80c15b81d08fa
tree8706946987793b17b8cd92f73d08461be184dae9
parent6bae0eb5b8bd7f7f87c7bf106acea869da187b66
usb: dwc3: Program GFLADJ

GUCTL.REFCLKPER can only account for clock frequencies with integer
periods. To address this, program REFCLK_FLADJ with the relative error
caused by period truncation. The formula given in the register reference
has been rearranged to allow calculation based on rate (instead of
period), and to allow for fixed-point arithmetic.

Additionally, calculate a value for 240MHZDECR. This configures a
simulated 240Mhz clock using a counter with one fractional bit (PLS1).

This register is programmed only for versions >= 2.50a, since this is
the check also used by commit db2be4e9e30c ("usb: dwc3: Add frame length
adjustment quirk").

[ marek: Ported from Linux kernel commit
         596c87856e08d ("usb: dwc3: Program GFLADJ") ]

Reviewed-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: Marek Vasut <marex@denx.de> # Port from Linux
drivers/usb/dwc3/core.c
drivers/usb/dwc3/core.h