Commit e752ec8e authored by Mark Brown's avatar Mark Brown

Merge series "spi: bcm2835/bcm2835aux: support effective_speed_hz" from Marc...

Merge series "spi: bcm2835/bcm2835aux: support effective_speed_hz" from Marc Kleine-Budde <mkl@pengutronix.de>:

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:

    5d7e2b5e spi: core: allow reporting the effectivly used speed_hz for a transfer

regards,
Marc

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
parents 499de01c 5e94c3cd
...@@ -1082,7 +1082,7 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr, ...@@ -1082,7 +1082,7 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr,
struct spi_transfer *tfr) struct spi_transfer *tfr)
{ {
struct bcm2835_spi *bs = spi_controller_get_devdata(ctlr); struct bcm2835_spi *bs = spi_controller_get_devdata(ctlr);
unsigned long spi_hz, clk_hz, cdiv, spi_used_hz; unsigned long spi_hz, clk_hz, cdiv;
unsigned long hz_per_byte, byte_limit; unsigned long hz_per_byte, byte_limit;
u32 cs = bs->prepare_cs[spi->chip_select]; u32 cs = bs->prepare_cs[spi->chip_select];
...@@ -1102,7 +1102,7 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr, ...@@ -1102,7 +1102,7 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr,
} else { } else {
cdiv = 0; /* 0 is the slowest we can go */ cdiv = 0; /* 0 is the slowest we can go */
} }
spi_used_hz = cdiv ? (clk_hz / cdiv) : (clk_hz / 65536); tfr->effective_speed_hz = cdiv ? (clk_hz / cdiv) : (clk_hz / 65536);
bcm2835_wr(bs, BCM2835_SPI_CLK, cdiv); bcm2835_wr(bs, BCM2835_SPI_CLK, cdiv);
/* handle all the 3-wire mode */ /* handle all the 3-wire mode */
...@@ -1122,7 +1122,7 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr, ...@@ -1122,7 +1122,7 @@ static int bcm2835_spi_transfer_one(struct spi_controller *ctlr,
* per 300,000 Hz of bus clock. * per 300,000 Hz of bus clock.
*/ */
hz_per_byte = polling_limit_us ? (9 * 1000000) / polling_limit_us : 0; hz_per_byte = polling_limit_us ? (9 * 1000000) / polling_limit_us : 0;
byte_limit = hz_per_byte ? spi_used_hz / hz_per_byte : 1; byte_limit = hz_per_byte ? tfr->effective_speed_hz / hz_per_byte : 1;
/* run in polling mode for short transfers */ /* run in polling mode for short transfers */
if (tfr->len < byte_limit) if (tfr->len < byte_limit)
......
...@@ -345,7 +345,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master, ...@@ -345,7 +345,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master,
struct spi_transfer *tfr) struct spi_transfer *tfr)
{ {
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_master_get_devdata(master);
unsigned long spi_hz, clk_hz, speed, spi_used_hz; unsigned long spi_hz, clk_hz, speed;
unsigned long hz_per_byte, byte_limit; unsigned long hz_per_byte, byte_limit;
/* calculate the registers to handle /* calculate the registers to handle
...@@ -374,7 +374,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master, ...@@ -374,7 +374,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master,
/* set the new speed */ /* set the new speed */
bs->cntl[0] |= speed << BCM2835_AUX_SPI_CNTL0_SPEED_SHIFT; bs->cntl[0] |= speed << BCM2835_AUX_SPI_CNTL0_SPEED_SHIFT;
spi_used_hz = clk_hz / (2 * (speed + 1)); tfr->effective_speed_hz = clk_hz / (2 * (speed + 1));
/* set transmit buffers and length */ /* set transmit buffers and length */
bs->tx_buf = tfr->tx_buf; bs->tx_buf = tfr->tx_buf;
...@@ -391,7 +391,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master, ...@@ -391,7 +391,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master,
* 30 µs per 300,000 Hz of bus clock. * 30 µs per 300,000 Hz of bus clock.
*/ */
hz_per_byte = polling_limit_us ? (9 * 1000000) / polling_limit_us : 0; hz_per_byte = polling_limit_us ? (9 * 1000000) / polling_limit_us : 0;
byte_limit = hz_per_byte ? spi_used_hz / hz_per_byte : 1; byte_limit = hz_per_byte ? tfr->effective_speed_hz / hz_per_byte : 1;
/* run in polling mode for short transfers */ /* run in polling mode for short transfers */
if (tfr->len < byte_limit) if (tfr->len < byte_limit)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment