Skip to content

Commit

Permalink
spi/rockchip: Avoid accidentally turning off the clock
Browse files Browse the repository at this point in the history
If our client is requesting a clock that is above the maximum clock
then the following division will result in 0:
  rs->max_freq / rs->speed

We'll then program 0 into the SPI_BAUDR register.  The Rockchip TRM
says: "If the value is 0, the serial output clock (sclk_out) is
disabled."

It's much better to end up with the fastest possible clock rather than
a clock that is off, so enforce a minimum value.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Doug Anderson authored and Mark Brown committed Aug 29, 2014
1 parent 0ac7a49 commit 5d1d150
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/spi/spi-rockchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
}

/* div doesn't support odd number */
div = rs->max_freq / rs->speed;
div = max_t(u32, rs->max_freq / rs->speed, 1);
div = (div + 1) & 0xfffe;

spi_enable_chip(rs, 0);
Expand Down

0 comments on commit 5d1d150

Please sign in to comment.