serial: a37xx: Fix parent clock rate value and divider calculation
authorPali Rohár <pali@kernel.org>
Tue, 25 May 2021 17:42:38 +0000 (19:42 +0200)
committerStefan Roese <sr@denx.de>
Thu, 8 Jul 2021 14:40:52 +0000 (16:40 +0200)
commit139d081384c2f613ac74b372cb7afe2386d556e4
tree1697676be5ad01f701dd3b7921bf073c3103a367
parentfd075f77ca56ffb07e0b1979f0cb47fc8831600f
serial: a37xx: Fix parent clock rate value and divider calculation

UART parent clock is by default the platform's xtal clock, which is
25 MHz.

The value defined in the driver, though, is 25.8048 MHz. This is a hack
for the suboptimal divisor calculation
  Divisor = UART clock / (16 * baudrate)
which does not use rounding division, resulting in a suboptimal value
for divisor if the correct parent clock rate was used.

Change the code for divisor calculation to round to closest value, i.e.
  Divisor = Round(UART clock / (16 * baudrate))
and change the parent clock rate value to that returned by
get_ref_clk().

This makes A3720 UART stable at standard UART baudrates between 1800 and
230400.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
drivers/serial/serial_mvebu_a3700.c