Skip to content

Commit

Permalink
spi: spi-cadence-quadspi: Search for rxlow at incrementing TX values
Browse files Browse the repository at this point in the history
commit 44a68f7b5931677bd0a99cf7d6683ce7ca05331f from
git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git

Sometimes TX = 16 might fall outside the range of valid TX values. In
that case, the tuning algorithm would be unable to find rxlow or rxhigh,
and give up. If TX = 16 is on the border of the valid range, then on
some runs it would succeed and on some others it would fail.

So if rxlow is not found at the initial TX value of 16, do not give up.
Instead, increment the TX and look for it again. This process is
repeated until the TX crosses a threshold, after which an error is
returned. A similar process is followed for the upper TX boundary as
well.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
  • Loading branch information
Pratyush Yadav authored and xulinsun committed Dec 1, 2020
1 parent 27a627c commit 3f00e5f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions drivers/spi/spi-cadence-quadspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ struct cqspi_driver_platdata {
#define CQSPI_PHY_HIGH_RX_BOUND 25
#define CQSPI_PHY_LOW_TX_BOUND 32
#define CQSPI_PHY_HIGH_TX_BOUND 48
#define CQSPI_PHY_TX_LOOKUP_LOW_BOUND 24
#define CQSPI_PHY_TX_LOOKUP_HIGH_BOUND 38

#define CQSPI_PHY_DEFAULT_TEMP 45
#define CQSPI_PHY_MIN_TEMP -45
Expand Down Expand Up @@ -575,15 +577,19 @@ static int cqspi_phy_calibrate(struct cqspi_flash_pdata *f_pdata,

/* Look for RX boundaries at TX = 16. */
rxlow.tx = 16;
rxhigh.tx = 16;

rxlow.read_delay = CQSPI_PHY_INIT_RD;
ret = cqspi_find_rx_low(f_pdata, mem, &rxlow);
do {
dev_dbg(dev, "Searching for rxlow on TX = %d\n", rxlow.tx);
rxlow.read_delay = CQSPI_PHY_INIT_RD;
ret = cqspi_find_rx_low(f_pdata, mem, &rxlow);
} while (ret && ++rxlow.tx <= CQSPI_PHY_TX_LOOKUP_LOW_BOUND);

if (ret)
goto out;
dev_dbg(dev, "rxlow: RX: %d TX: %d RD: %d\n", rxlow.rx, rxlow.tx,
rxlow.read_delay);

rxhigh.tx = rxlow.tx;
rxhigh.read_delay = rxlow.read_delay;
cqspi_find_rx_high(f_pdata, mem, &rxhigh);
if (ret)
Expand All @@ -601,9 +607,14 @@ static int cqspi_phy_calibrate(struct cqspi_flash_pdata *f_pdata,

/* Look for RX boundaries at TX = 48. */
temp.tx = 48;
temp.read_delay = CQSPI_PHY_INIT_RD;

ret = cqspi_find_rx_low(f_pdata, mem, &temp);
do {
dev_dbg(dev, "Searching for rxlow on TX = %d\n",
temp.tx);
temp.read_delay = CQSPI_PHY_INIT_RD;
ret = cqspi_find_rx_low(f_pdata, mem, &temp);
} while (ret && --temp.tx >= CQSPI_PHY_TX_LOOKUP_HIGH_BOUND);

if (ret)
goto out;
dev_dbg(dev, "rxlow: RX: %d TX: %d RD: %d\n", temp.rx, temp.tx,
Expand Down

0 comments on commit 3f00e5f

Please sign in to comment.