浏览代码

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>
Martin Sperl 10 年之前
父节点
当前提交
210b49231a
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      drivers/spi/spi-bcm2835.c

+ 3 - 2
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) {
 	if (spi_hz >= clk_hz / 2) {
 		cdiv = 2; /* clk_hz/2 is the fastest we can go */
 		cdiv = 2; /* clk_hz/2 is the fastest we can go */
 	} else if (spi_hz) {
 	} 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)
 		if (cdiv >= 65536)
 			cdiv = 0; /* 0 is the slowest we can go */
 			cdiv = 0; /* 0 is the slowest we can go */