summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMartin Sperl <kernel@martin.sperl.org>2015-03-19 09:01:52 +0000
committerpopcornmix <popcornmix@gmail.com>2015-05-18 14:12:23 +0100
commit290acb5cf812124bea0686f1b6832fead641c511 (patch)
tree3f58cc754e14cb35b2b83528b606cb3e5128f84c /drivers
parentec9ba6fa160bce5005881e7bda743892cb838fae (diff)
downloadlinux-290acb5cf812124bea0686f1b6832fead641c511.tar.gz
spi: bcm2835: clock divider can be a multiple of 2
The official documentation is wrong in this respect. Has been tested empirically for dividers 2-1024 Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/spi-bcm2835.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index 960dcce607c2..8de1925fe554 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -153,8 +153,9 @@ static int bcm2835_spi_start_transfer(struct spi_device *spi,
if (spi_hz >= clk_hz / 2) {
cdiv = 2; /* clk_hz/2 is the fastest we can go */
} else if (spi_hz) {
- /* CDIV must be a power of two */
- cdiv = roundup_pow_of_two(DIV_ROUND_UP(clk_hz, spi_hz));
+ /* CDIV must be a multiple of two */
+ cdiv = DIV_ROUND_UP(clk_hz, spi_hz);
+ cdiv += (cdiv % 2);
if (cdiv >= 65536)
cdiv = 0; /* 0 is the slowest we can go */