Skip to content

Commit dcb06c6

Browse files
Vishwaroop Abroonie
authored andcommitted
spi: tegra210-quad: Fix X1_X2_X4 encoding and support x4 transfers
This patch corrects the QSPI_COMMAND_X1_X2_X4 and QSPI_ADDRESS_X1_X2_X4 macros to properly encode the bus width for x1, x2, and x4 transfers. Although these macros were previously incorrect, they were not being used in the driver, so no functionality was affected. The patch updates tegra_qspi_cmd_config() and tegra_qspi_addr_config() function calls to use the actual bus width from the transfer, instead of hardcoding it to 0 (which implied x1 mode). This change enables proper support for x1, x2, and x4 data transfers by correctly configuring the interface width for commands and addresses. These modifications improve the QSPI driver's flexibility and prepare it for future use cases that may require different bus widths for commands and addresses. Fixes: 1b8342c ("spi: tegra210-quad: combined sequence mode") Signed-off-by: Vishwaroop A <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 8ffd015 commit dcb06c6

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/spi/spi-tegra210-quad.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
#define QSPI_COMMAND_VALUE_SET(X) (((x) & 0xFF) << 0)
135135

136136
#define QSPI_CMB_SEQ_CMD_CFG 0x1a0
137-
#define QSPI_COMMAND_X1_X2_X4(x) (((x) & 0x3) << 13)
137+
#define QSPI_COMMAND_X1_X2_X4(x) ((((x) >> 1) & 0x3) << 13)
138138
#define QSPI_COMMAND_X1_X2_X4_MASK (0x03 << 13)
139139
#define QSPI_COMMAND_SDR_DDR BIT(12)
140140
#define QSPI_COMMAND_SIZE_SET(x) (((x) & 0xFF) << 0)
@@ -147,7 +147,7 @@
147147
#define QSPI_ADDRESS_VALUE_SET(X) (((x) & 0xFFFF) << 0)
148148

149149
#define QSPI_CMB_SEQ_ADDR_CFG 0x1ac
150-
#define QSPI_ADDRESS_X1_X2_X4(x) (((x) & 0x3) << 13)
150+
#define QSPI_ADDRESS_X1_X2_X4(x) ((((x) >> 1) & 0x3) << 13)
151151
#define QSPI_ADDRESS_X1_X2_X4_MASK (0x03 << 13)
152152
#define QSPI_ADDRESS_SDR_DDR BIT(12)
153153
#define QSPI_ADDRESS_SIZE_SET(x) (((x) & 0xFF) << 0)
@@ -1036,10 +1036,6 @@ static u32 tegra_qspi_addr_config(bool is_ddr, u8 bus_width, u8 len)
10361036
{
10371037
u32 addr_config = 0;
10381038

1039-
/* Extract Address configuration and value */
1040-
is_ddr = 0; //Only SDR mode supported
1041-
bus_width = 0; //X1 mode
1042-
10431039
if (is_ddr)
10441040
addr_config |= QSPI_ADDRESS_SDR_DDR;
10451041
else
@@ -1079,13 +1075,13 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,
10791075
switch (transfer_phase) {
10801076
case CMD_TRANSFER:
10811077
/* X1 SDR mode */
1082-
cmd_config = tegra_qspi_cmd_config(false, 0,
1078+
cmd_config = tegra_qspi_cmd_config(false, xfer->tx_nbits,
10831079
xfer->len);
10841080
cmd_value = *((const u8 *)(xfer->tx_buf));
10851081
break;
10861082
case ADDR_TRANSFER:
10871083
/* X1 SDR mode */
1088-
addr_config = tegra_qspi_addr_config(false, 0,
1084+
addr_config = tegra_qspi_addr_config(false, xfer->tx_nbits,
10891085
xfer->len);
10901086
address_value = *((const u32 *)(xfer->tx_buf));
10911087
break;

0 commit comments

Comments
 (0)