linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi/rockchip: Avoid accidentally turning off the clock
@ 2014-08-28 23:43 Doug Anderson
  2014-08-29 11:08 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Doug Anderson @ 2014-08-28 23:43 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 drivers/spi/spi-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 6321326..cd0e08b0 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -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);
-- 
2.1.0.rc2.206.gedb03e5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] spi/rockchip: Avoid accidentally turning off the clock
  2014-08-28 23:43 [PATCH] spi/rockchip: Avoid accidentally turning off the clock Doug Anderson
@ 2014-08-29 11:08 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-08-29 11:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Aug 28, 2014 at 04:43:48PM -0700, Doug Anderson wrote:
> 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

Applied, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140829/8107a85b/attachment.sig>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-29 11:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-28 23:43 [PATCH] spi/rockchip: Avoid accidentally turning off the clock Doug Anderson
2014-08-29 11:08 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).