From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vignesh R Date: Wed, 12 Oct 2016 09:46:20 +0530 Subject: [U-Boot] [PATCH 2/2] spi: ti_qspi: Fix baudrate divider calculation In-Reply-To: <20161012041620.25077-1-vigneshr@ti.com> References: <20161012041620.25077-1-vigneshr@ti.com> Message-ID: <20161012041620.25077-2-vigneshr@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Fix the divider calculation logic to choose a value so that the resulting baudrate is either equal to or closest possible baudrate less than the requested value. Signed-off-by: Vignesh R --- drivers/spi/ti_qspi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c index 52520dff6325..d97e2479d1b3 100644 --- a/drivers/spi/ti_qspi.c +++ b/drivers/spi/ti_qspi.c @@ -16,6 +16,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -118,7 +119,7 @@ static void ti_spi_set_speed(struct ti_qspi_priv *priv, uint hz) if (!hz) clk_div = 0; else - clk_div = (priv->fclk / hz) - 1; + clk_div = DIV_ROUND_UP(priv->fclk, hz) - 1; debug("ti_spi_set_speed: hz: %d, clock divider %d\n", hz, clk_div); -- 2.10.1