]> git.dujemihanovic.xyz Git - u-boot.git/commit
spi: sunxi: fix CDR2 calculation
authorMichael Walle <mwalle@kernel.org>
Thu, 18 Jul 2024 20:42:52 +0000 (22:42 +0200)
committerAndre Przywara <andre.przywara@arm.com>
Tue, 6 Aug 2024 10:20:10 +0000 (11:20 +0100)
commit6aadcb814d1e2203b0b953dda8d5fbdc7b3a9bf0
tree36bb9078d8d3022eae129e20305e080fa637b636
parent895d051702790311a98244e26c757c12771022e2
spi: sunxi: fix CDR2 calculation

The CDR2 divider calculation always yield a frequency greater than the
requested one. Use DIV_ROUND_UP() to keep the frequency equal or below
the requested one. This way, we can also drop the "if div > 0" check
because we know for a fact that div cannot be zero.

FWIW, this aligns the CDR2 calculation with the linux driver.

Suggested-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
drivers/spi/spi-sunxi.c