OSDN Git Service

soc/fsl/qe: round brg_freq to 1kHz granularity
authorValentin Longchamp <valentin.longchamp@keymile.com>
Fri, 17 Feb 2017 10:29:45 +0000 (11:29 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 24 Mar 2018 10:00:19 +0000 (11:00 +0100)
commit949b9dc1818a100941ed63c5147059a5f64c7987
treec2222f2d038257a58579aadb0757276427adab1e
parentb0d0441f2a6ae3dc20ee4a6871d48178c17911a7
soc/fsl/qe: round brg_freq to 1kHz granularity

[ Upstream commit 2ccf80b7566cc035d903dd0ac5d7ebd25c2c1060 ]

Because of integer computation rounding in u-boot (that sets the QE
brg-frequency DTS prop), the clk value is 99999999 Hz even though it is
100 MHz.

When setting brg clks that are exact divisors of 100 MHz, this small
differnce plays a role and can result in lower clks to be output (for
instance 20 MHz - divide by 5 - results in 16.666 MHz - divide by 6).

This patch fixes that by "forcing" the brg_clk to the nearest kHz when
the difference is below 2 integer rounding errors (i.e. 4).

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Scott Wood <oss@buserror.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/soc/fsl/qe/qe.c