summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTianfei Zhang <tianfei.zhang@intel.com>2019-11-14 17:02:54 +0800
committerFerruh Yigit <ferruh.yigit@intel.com>2019-11-20 17:36:05 +0100
commitec2613b746d42d2911dfdc3f7ff5bd0b79a01211 (patch)
treeb8a01a7e5b2dd09e6a58529529559c77fd6dcd63 /drivers
parente1defba4cf6689eadc78693a8253d0c8a8d56c00 (diff)
downloaddpdk-ec2613b746d42d2911dfdc3f7ff5bd0b79a01211.zip
dpdk-ec2613b746d42d2911dfdc3f7ff5bd0b79a01211.tar.gz
dpdk-ec2613b746d42d2911dfdc3f7ff5bd0b79a01211.tar.xz
raw/ifpga/base: align send buffer for SPI
The length of send buffer of SPI bus should be 4bytes align. Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com> Signed-off-by: Andy Pei <andy.pei@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/raw/ifpga/base/opae_spi_transaction.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/drivers/raw/ifpga/base/opae_spi_transaction.c b/drivers/raw/ifpga/base/opae_spi_transaction.c
index 17ec3c1..06ca625 100644
--- a/drivers/raw/ifpga/base/opae_spi_transaction.c
+++ b/drivers/raw/ifpga/base/opae_spi_transaction.c
@@ -109,6 +109,34 @@ done:
return ret;
}
+static void phy_tx_pad(unsigned char *phy_buf, unsigned int phy_buf_len,
+ unsigned int *aligned_len)
+{
+ unsigned char *p = &phy_buf[phy_buf_len - 1], *dst_p;
+
+ *aligned_len = IFPGA_ALIGN(phy_buf_len, 4);
+
+ if (*aligned_len == phy_buf_len)
+ return;
+
+ dst_p = &phy_buf[*aligned_len - 1];
+
+ /* move EOP and bytes after EOP to the end of aligned size */
+ while (p > phy_buf) {
+ *dst_p = *p;
+
+ if (*p == SPI_PACKET_EOP)
+ break;
+
+ p--;
+ dst_p--;
+ }
+
+ /* fill the hole with PHY_IDLE */
+ while (p < dst_p)
+ *p++ = SPI_BYTE_IDLE;
+}
+
static int byte_to_core_convert(struct spi_transaction_dev *dev,
unsigned int send_len, unsigned char *send_data,
unsigned int resp_len, unsigned char *resp_data,
@@ -149,15 +177,19 @@ static int byte_to_core_convert(struct spi_transaction_dev *dev,
}
}
- print_buffer("before spi:", send_packet, p-send_packet);
+ tx_len = p - send_packet;
+
+ print_buffer("before spi:", send_packet, tx_len);
- reorder_phy_data(32, send_packet, p - send_packet);
+ phy_tx_pad(send_packet, tx_len, &tx_len);
+ print_buffer("after pad:", send_packet, tx_len);
- print_buffer("after order to spi:", send_packet, p-send_packet);
+ reorder_phy_data(32, send_packet, tx_len);
+
+ print_buffer("after order to spi:", send_packet, tx_len);
/* call spi */
tx_buffer = send_packet;
- tx_len = p - send_packet;
rx_buffer = resp_packet;
rx_len = resp_max_len;
spi_flags = SPI_NOT_FOUND;