Skip to content

Commit e752ec8

Browse files
committed
Merge series "spi: bcm2835/bcm2835aux: support effective_speed_hz" from Marc Kleine-Budde <[email protected]>:
Hello, I've picked up and forward ported Martin Sperl's patches which add support for effective_speed_hz to the SPI controllers found on all raspberry pi models. See the following patch, which adds this feature to the SPI core, for more information: 5d7e2b5 spi: core: allow reporting the effectivly used speed_hz for a transfer regards, Marc _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
2 parents 499de01 + 5e94c3c commit e752ec8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

drivers/spi/spi-bcm2835.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr,
10821082
struct spi_transfer *tfr)
10831083
{
10841084
struct bcm2835_spi *bs = spi_controller_get_devdata(ctlr);
1085-
unsigned long spi_hz, clk_hz, cdiv, spi_used_hz;
1085+
unsigned long spi_hz, clk_hz, cdiv;
10861086
unsigned long hz_per_byte, byte_limit;
10871087
u32 cs = bs->prepare_cs[spi->chip_select];
10881088

@@ -1102,7 +1102,7 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr,
11021102
} else {
11031103
cdiv = 0; /* 0 is the slowest we can go */
11041104
}
1105-
spi_used_hz = cdiv ? (clk_hz / cdiv) : (clk_hz / 65536);
1105+
tfr->effective_speed_hz = cdiv ? (clk_hz / cdiv) : (clk_hz / 65536);
11061106
bcm2835_wr(bs, BCM2835_SPI_CLK, cdiv);
11071107

11081108
/* handle all the 3-wire mode */
@@ -1122,7 +1122,7 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr,
11221122
* per 300,000 Hz of bus clock.
11231123
*/
11241124
hz_per_byte = polling_limit_us ? (9 * 1000000) / polling_limit_us : 0;
1125-
byte_limit = hz_per_byte ? spi_used_hz / hz_per_byte : 1;
1125+
byte_limit = hz_per_byte ? tfr->effective_speed_hz / hz_per_byte : 1;
11261126

11271127
/* run in polling mode for short transfers */
11281128
if (tfr->len < byte_limit)

drivers/spi/spi-bcm2835aux.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master,
345345
struct spi_transfer *tfr)
346346
{
347347
struct bcm2835aux_spi *bs = spi_master_get_devdata(master);
348-
unsigned long spi_hz, clk_hz, speed, spi_used_hz;
348+
unsigned long spi_hz, clk_hz, speed;
349349
unsigned long hz_per_byte, byte_limit;
350350

351351
/* calculate the registers to handle
@@ -374,7 +374,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master,
374374
/* set the new speed */
375375
bs->cntl[0] |= speed << BCM2835_AUX_SPI_CNTL0_SPEED_SHIFT;
376376

377-
spi_used_hz = clk_hz / (2 * (speed + 1));
377+
tfr->effective_speed_hz = clk_hz / (2 * (speed + 1));
378378

379379
/* set transmit buffers and length */
380380
bs->tx_buf = tfr->tx_buf;
@@ -391,7 +391,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master,
391391
* 30 µs per 300,000 Hz of bus clock.
392392
*/
393393
hz_per_byte = polling_limit_us ? (9 * 1000000) / polling_limit_us : 0;
394-
byte_limit = hz_per_byte ? spi_used_hz / hz_per_byte : 1;
394+
byte_limit = hz_per_byte ? tfr->effective_speed_hz / hz_per_byte : 1;
395395

396396
/* run in polling mode for short transfers */
397397
if (tfr->len < byte_limit)

0 commit comments

Comments
 (0)