Message ID | 1426755714-28130-4-git-send-email-kernel@martin.sperl.org (mailing list archive) |
---|---|
State | Accepted |
Commit | 6935224da2482a261c786501fbccb1dc4a675225 |
Headers | show |
On 03/19/2015 03:01 AM, kernel@martin.sperl.org wrote: > diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c > @@ -201,6 +202,9 @@ static int bcm2835_spi_start_transfer( > cdiv = 0; /* 0 is the slowest we can go */ > } > > + if ((spi->mode & SPI_3WIRE) && (tfr->rx_buf)) > + cs |= BCM2835_SPI_CS_REN; > + I can see how that tells the HW which direction to transfer data in 3WIRE mode, but how does the HW know whether it's in 3WIRE mode or has separate RX/TX lines? -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> On 20.03.2015, at 06:12, Stephen Warren <swarren@wwwdotorg.org> wrote: > I can see how that tells the HW which direction to transfer data in > 3WIRE mode, but how does the HW know whether it's in 3WIRE mode or has > separate RX/TX lines? The HW assumes with this flag that MISO (=RX) sits on the same physical line as MOSI (=TX). This flag essentially just changes directions of the TX GPIO pin from out to in and samples the level on the TX pin. Without this patch what you would need to do to make such a device work is connecting RX with TX and that with the MIMO pin of the final device (maybe add a pullup). This flag is essentially just a shortcut. Note that the SPI-framework does the testing so that either RX or TX can be set in SPI-3WIRE mode (not both). Ciao, Martin -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Mar 19, 2015 at 09:01:53AM +0000, kernel@martin.sperl.org wrote: > From: Martin Sperl <kernel@martin.sperl.org> > > Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Applied, thanks.
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index e1dea40..51883f8 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -67,7 +67,8 @@ #define BCM2835_SPI_CS_CS_01 0x00000001 #define BCM2835_SPI_TIMEOUT_MS 30000 -#define BCM2835_SPI_MODE_BITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS) +#define BCM2835_SPI_MODE_BITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \ + | SPI_NO_CS | SPI_3WIRE) #define DRV_NAME "spi-bcm2835" @@ -201,6 +202,9 @@ static int bcm2835_spi_start_transfer( cdiv = 0; /* 0 is the slowest we can go */ } + if ((spi->mode & SPI_3WIRE) && (tfr->rx_buf)) + cs |= BCM2835_SPI_CS_REN; + if (spi->mode & SPI_CPOL) cs |= BCM2835_SPI_CS_CPOL; if (spi->mode & SPI_CPHA)