Skip to content

Commit c283fcd

Browse files
Vishwaroop Abroonie
authored andcommitted
spi: tegra210-quad: Update dummy sequence configuration
Adding support for the dummy sequence configuration. The dummy sequence introduces a delay between the command and the data phases of a transfer. This delay, measured in clock cycles, allows the slave device to prepare for data transmission, ensuring data integrity and proper synchronization. Signed-off-by: Vishwaroop A <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent d8966b6 commit c283fcd

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

drivers/spi/spi-tegra210-quad.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/spi/spi.h>
2323
#include <linux/acpi.h>
2424
#include <linux/property.h>
25+
#include <linux/sizes.h>
2526

2627
#define QSPI_COMMAND1 0x000
2728
#define QSPI_BIT_LENGTH(x) (((x) & 0x1f) << 0)
@@ -156,10 +157,14 @@
156157
#define DATA_DIR_RX BIT(1)
157158

158159
#define QSPI_DMA_TIMEOUT (msecs_to_jiffies(1000))
159-
#define DEFAULT_QSPI_DMA_BUF_LEN (64 * 1024)
160-
#define CMD_TRANSFER 0
161-
#define ADDR_TRANSFER 1
162-
#define DATA_TRANSFER 2
160+
#define DEFAULT_QSPI_DMA_BUF_LEN SZ_64K
161+
162+
enum tegra_qspi_transfer_type {
163+
CMD_TRANSFER = 0,
164+
ADDR_TRANSFER = 1,
165+
DUMMY_TRANSFER = 2,
166+
DATA_TRANSFER = 3
167+
};
163168

164169
struct tegra_qspi_soc_data {
165170
bool has_dma;
@@ -1085,6 +1090,13 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,
10851090
xfer->len);
10861091
address_value = *((const u32 *)(xfer->tx_buf));
10871092
break;
1093+
case DUMMY_TRANSFER:
1094+
if (xfer->dummy_data) {
1095+
tqspi->dummy_cycles = xfer->len * 8 / xfer->tx_nbits;
1096+
break;
1097+
}
1098+
transfer_phase++;
1099+
fallthrough;
10881100
case DATA_TRANSFER:
10891101
/* Program Command, Address value in register */
10901102
tegra_qspi_writel(tqspi, cmd_value, QSPI_CMB_SEQ_CMD);
@@ -1292,7 +1304,9 @@ static bool tegra_qspi_validate_cmb_seq(struct tegra_qspi *tqspi,
12921304
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
12931305
transfer_count++;
12941306
}
1295-
if (!tqspi->soc_data->cmb_xfer_capable || transfer_count != 3)
1307+
if (!tqspi->soc_data->cmb_xfer_capable)
1308+
return false;
1309+
if (transfer_count > 4 || transfer_count < 3)
12961310
return false;
12971311
xfer = list_first_entry(&msg->transfers, typeof(*xfer),
12981312
transfer_list);
@@ -1302,6 +1316,13 @@ static bool tegra_qspi_validate_cmb_seq(struct tegra_qspi *tqspi,
13021316
if (xfer->len > 4 || xfer->len < 3)
13031317
return false;
13041318
xfer = list_next_entry(xfer, transfer_list);
1319+
if (transfer_count == 4) {
1320+
if (xfer->dummy_data != 1)
1321+
return false;
1322+
if ((xfer->len * 8 / xfer->tx_nbits) > QSPI_DUMMY_CYCLES_MAX)
1323+
return false;
1324+
xfer = list_next_entry(xfer, transfer_list);
1325+
}
13051326
if (!tqspi->soc_data->has_dma && xfer->len > (QSPI_FIFO_DEPTH << 2))
13061327
return false;
13071328

0 commit comments

Comments
 (0)