Skip to content

Commit

Permalink
spi: xilinx_spi: Modify transfer logic for quad mode
Browse files Browse the repository at this point in the history
Modify the transfer logic to get it working for both single
and quad modes. The controller expects 4 dummy bytes for
quad read and also expects the txfifo filled with full command
and required args before starting the transfer. This fixes
an issue in reading from device using quad read command.

Signed-off-by: Siva Durga Prasad Paladugu <[email protected]>
Signed-off-by: Michal Simek <[email protected]>
Signed-off-by: Ashok Reddy Soma <[email protected]>
State: pending
  • Loading branch information
Siva Durga Prasad Paladugu authored and Michal Simek committed Jan 29, 2020
1 parent 095d3c3 commit 0a14024
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions drivers/spi/xilinx_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ DECLARE_GLOBAL_DATA_PTR;

#define XILSPI_MAX_XFER_BITS 8
#define XILSPI_SPICR_DFLT_ON (SPICR_MANUAL_SS | SPICR_MASTER_MODE | \
SPICR_SPE)
SPICR_SPE | SPICR_MASTER_INHIBIT)
#define XILSPI_SPICR_DFLT_OFF (SPICR_MASTER_INHIBIT | SPICR_MANUAL_SS)

#ifndef CONFIG_XILINX_SPI_IDLE_VAL
Expand All @@ -84,6 +84,9 @@ DECLARE_GLOBAL_DATA_PTR;

#define XILINX_SPI_QUAD_MODE 2

#define XILINX_SPI_QUAD_EXTRA_DUMMY 3
#define SPI_QUAD_OUT_FAST_READ 0x6B

/* xilinx spi register set */
struct xilinx_spi_regs {
u32 __space0__[7];
Expand Down Expand Up @@ -155,7 +158,10 @@ static void spi_cs_deactivate(struct udevice *dev)
struct udevice *bus = dev_get_parent(dev);
struct xilinx_spi_priv *priv = dev_get_priv(bus);
struct xilinx_spi_regs *regs = priv->regs;
u32 reg;

reg = readl(&regs->spicr) | SPICR_RXFIFO_RESEST | SPICR_TXFIFO_RESEST;
writel(reg, &regs->spicr);
writel(SPISSR_OFF, &regs->spissr);
}

Expand Down Expand Up @@ -286,8 +292,18 @@ static int xilinx_spi_xfer(struct udevice *dev, unsigned int bitlen,
goto done;
}

if (flags & SPI_XFER_BEGIN)
if (flags & SPI_XFER_BEGIN) {
spi_cs_activate(dev, slave_plat->cs);
/* FIX ME Temporary hack to fix Quad read
* check if the command is Quad out fast read
* and increase dummy bytes by 3 so a total of 4
* (3 here + 1 from framework)
*/
if (*txp == SPI_QUAD_OUT_FAST_READ) {
txbytes += XILINX_SPI_QUAD_EXTRA_DUMMY;
rxbytes += XILINX_SPI_QUAD_EXTRA_DUMMY;
}
}

/*
* This is the work around for the startup block issue in
Expand Down

0 comments on commit 0a14024

Please sign in to comment.