aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Harvey <tharvey@gateworks.com>2020-05-28 07:58:49 -0700
committerPetr Štetiar <ynezz@true.cz>2020-06-03 16:49:28 +0200
commit0cf101d6b39a10952420af0f300a0784190887ff (patch)
treea2a0386086923c2b05f75a994d23f19e5470ee4c
parent3fd8e86079b21459c744b61b466b12c69ed3ab24 (diff)
downloadupstream-0cf101d6b39a10952420af0f300a0784190887ff.tar.gz
upstream-0cf101d6b39a10952420af0f300a0784190887ff.tar.bz2
upstream-0cf101d6b39a10952420af0f300a0784190887ff.zip
octeontx: fix mcp251x can controller
Update the can-mcp251x-convert-to-half-duplex-SPI patch to fix reception Some SPI host controllers such as the Cavium Thunder TX do not support full-duplex SPI. Using half-duplex transfers allows the driver to work with those host controllers. This patch fixes the fact that mcp251x_hw_rx_frame was still relying on a full-duplex transfer where bits were being shifted on MOSI at the same time as MISO. After splitting the transaction into a spi_write_then_read() care must be taken to ignore the first byte. Signed-off-by: Tim Harvey <tharvey@gateworks.com>
-rw-r--r--target/linux/octeontx/patches-5.4/0003-can-mcp251x-convert-to-half-duplex-SPI.patch31
1 files changed, 24 insertions, 7 deletions
diff --git a/target/linux/octeontx/patches-5.4/0003-can-mcp251x-convert-to-half-duplex-SPI.patch b/target/linux/octeontx/patches-5.4/0003-can-mcp251x-convert-to-half-duplex-SPI.patch
index 6096fcf2be..54906b786e 100644
--- a/target/linux/octeontx/patches-5.4/0003-can-mcp251x-convert-to-half-duplex-SPI.patch
+++ b/target/linux/octeontx/patches-5.4/0003-can-mcp251x-convert-to-half-duplex-SPI.patch
@@ -1,20 +1,22 @@
-From 6edfb172ff1dd3cfc84c19790c245a4005474bb7 Mon Sep 17 00:00:00 2001
+From 097cc81ee5c15913ad330baffff2e3dea09bdad0 Mon Sep 17 00:00:00 2001
From: Tim Harvey <tharvey@gateworks.com>
-Date: Tue, 25 Feb 2020 12:01:36 -0800
-Subject: [PATCH 03/12] can: mcp251x: convert to half-duplex SPI
+Date: Thu, 30 Aug 2018 15:16:08 -0700
+Subject: [PATCH] can: mcp251x: convert driver to half-duplex SPI
-Some SPI host controllers such as the Cavium Thunder do not support
+Some SPI host controllers such as the Cavium Thunder TX do not support
full-duplex SPI. Using half-duplex transfers allows the driver to work
with those host controllers.
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
- drivers/net/can/spi/mcp251x.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
+ drivers/net/can/spi/mcp251x.c | 15 ++++++++-------
+ 1 file changed, 8 insertions(+), 7 deletions(-)
+diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
+index bb20a9b..dc0574a 100644
--- a/drivers/net/can/spi/mcp251x.c
+++ b/drivers/net/can/spi/mcp251x.c
-@@ -291,23 +291,23 @@ static u8 mcp251x_read_reg(struct spi_de
+@@ -291,23 +291,23 @@ static u8 mcp251x_read_reg(struct spi_device *spi, u8 reg)
priv->spi_tx_buf[0] = INSTRUCTION_READ;
priv->spi_tx_buf[1] = reg;
@@ -43,3 +45,18 @@ Signed-off-by: Tim Harvey <tharvey@gateworks.com>
}
static void mcp251x_write_reg(struct spi_device *spi, u8 reg, u8 val)
+@@ -398,8 +398,9 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
+ buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i);
+ } else {
+ priv->spi_tx_buf[RXBCTRL_OFF] = INSTRUCTION_READ_RXB(buf_idx);
+- mcp251x_spi_trans(spi, SPI_TRANSFER_BUF_LEN);
+- memcpy(buf, priv->spi_rx_buf, SPI_TRANSFER_BUF_LEN);
++ spi_write_then_read(spi, priv->spi_tx_buf, 1, priv->spi_rx_buf,
++ SPI_TRANSFER_BUF_LEN);
++ memcpy(buf + 1, priv->spi_rx_buf, SPI_TRANSFER_BUF_LEN - 1);
+ }
+ }
+
+--
+2.7.4
+