[PATCH] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()

2018-04-10 Thread sxauwsk
In case of xspi work in busy condition, may send bytes failed.
Add one bytes delay

Signed-off-by: sxauwsk 
Signed-off-by: guojian 
Signed-off-by: wangshikai 
---
 drivers/spi/spi-cadence.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 5c9516a..66ae055 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -313,6 +313,12 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)
 
while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) &&
   (xspi->tx_bytes > 0)) {
+
+   /* When xspi in busy condition, bytes may send failed,
+* caused communication failure so add one byte delay
+*/
+   usleep_range(10, 20);
+
if (xspi->txbuf)
cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
else
-- 
1.7.9.5




[PATCH] [PATCH v1] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()

2018-04-16 Thread sxauwsk
In case of xspi work in busy condition, may send bytes failed.
once something wrong, spi controller did't work any more

My test found this situation appear in both of read/write process.
so when TX FIFO is full, add one byte delay before send data;

Signed-off-by: sxauwsk 
Signed-off-by: guojian 
Signed-off-by: wangshikai 
---
 drivers/spi/spi-cadence.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 66ae055..9694042 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -315,9 +315,11 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)
   (xspi->tx_bytes > 0)) {
 
/* When xspi in busy condition, bytes may send failed,
-* caused communication failure so add one byte delay
+* then spi control did't work thoroughly, add one byte delay
 */
-   usleep_range(10, 20);
+   if (cdns_spi_read(xspi, CDNS_SPI_ISR_OFFSET) &
+   CDNS_SPI_IXR_TXFULL_MASK)
+   usleep_range(10, 20);
 
if (xspi->txbuf)
cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
-- 
1.7.9.5




[PATCH] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()

2018-04-16 Thread sxauwsk
In case of xspi work in busy condition, may send bytes failed then caused
communication failure. once something wrong, spi controller did't work any more.

My test found this situation appear in both of read/write operation.
so when TX FIFO is full, add one byte delay before send data.

Signed-off-by: sxauwsk 
---
 drivers/spi/spi-cadence.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 5c9516a..9694042 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -313,6 +313,14 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)

while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) &&
   (xspi->tx_bytes > 0)) {
+
+   /* When xspi in busy condition, bytes may send failed,
+* then spi control did't work thoroughly, add one byte delay
+*/
+   if (cdns_spi_read(xspi, CDNS_SPI_ISR_OFFSET) &
+   CDNS_SPI_IXR_TXFULL_MASK)
+   usleep_range(10, 20);
+
if (xspi->txbuf)
cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
else
--
1.7.9.5




[PATCH] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()

2018-04-17 Thread sxauwsk
In case of xspi work in busy condition, may send bytes failed.
once something wrong, spi controller did't work any more

My test found this situation appear in both of read/write process.
so when TX FIFO is full, add one byte delay before send data;

Signed-off-by: sxauwsk 
---
 drivers/spi/spi-cadence.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 5c9516a..4a00163 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -313,6 +313,14 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)

while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) &&
   (xspi->tx_bytes > 0)) {
+
+   /* When xspi in busy condition, bytes may send failed,
+* then spi control did't work thoroughly, add one byte delay
+*/
+   if (cdns_spi_read(xspi, CDNS_SPI_ISR) &
+   CDNS_SPI_IXR_TXFULL)
+   usleep_range(10, 20);
+
if (xspi->txbuf)
cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
else
--
1.7.9.5



[PATCH] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()

2018-04-10 Thread sxauwsk
In case of xspi work in busy condition, may send bytes failed.
Add one bytes delay

Signed-off-by: sxauwsk <sxau...@163.com>
Signed-off-by: guojian <guoj...@innoinstrument.net>
Signed-off-by: wangshikai <wangshi...@inno-instrument.cn>
---
 drivers/spi/spi-cadence.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 5c9516a..66ae055 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -313,6 +313,12 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)
 
while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) &&
   (xspi->tx_bytes > 0)) {
+
+   /* When xspi in busy condition, bytes may send failed,
+* caused communication failure so add one byte delay
+*/
+   usleep_range(10, 20);
+
if (xspi->txbuf)
cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
else
-- 
1.7.9.5




[PATCH] [PATCH v1] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()

2018-04-16 Thread sxauwsk
In case of xspi work in busy condition, may send bytes failed.
once something wrong, spi controller did't work any more

My test found this situation appear in both of read/write process.
so when TX FIFO is full, add one byte delay before send data;

Signed-off-by: sxauwsk <sxau...@163.com>
Signed-off-by: guojian <guoj...@innoinstrument.net>
Signed-off-by: wangshikai <wangshi...@inno-instrument.cn>
---
 drivers/spi/spi-cadence.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 66ae055..9694042 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -315,9 +315,11 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)
   (xspi->tx_bytes > 0)) {
 
/* When xspi in busy condition, bytes may send failed,
-* caused communication failure so add one byte delay
+* then spi control did't work thoroughly, add one byte delay
 */
-   usleep_range(10, 20);
+   if (cdns_spi_read(xspi, CDNS_SPI_ISR_OFFSET) &
+   CDNS_SPI_IXR_TXFULL_MASK)
+   usleep_range(10, 20);
 
if (xspi->txbuf)
cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
-- 
1.7.9.5




[PATCH] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()

2018-04-16 Thread sxauwsk
In case of xspi work in busy condition, may send bytes failed then caused
communication failure. once something wrong, spi controller did't work any more.

My test found this situation appear in both of read/write operation.
so when TX FIFO is full, add one byte delay before send data.

Signed-off-by: sxauwsk <sxau...@163.com>
---
 drivers/spi/spi-cadence.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 5c9516a..9694042 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -313,6 +313,14 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)

while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) &&
   (xspi->tx_bytes > 0)) {
+
+   /* When xspi in busy condition, bytes may send failed,
+* then spi control did't work thoroughly, add one byte delay
+*/
+   if (cdns_spi_read(xspi, CDNS_SPI_ISR_OFFSET) &
+   CDNS_SPI_IXR_TXFULL_MASK)
+   usleep_range(10, 20);
+
if (xspi->txbuf)
cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
else
--
1.7.9.5




[PATCH] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()

2018-04-17 Thread sxauwsk
In case of xspi work in busy condition, may send bytes failed.
once something wrong, spi controller did't work any more

My test found this situation appear in both of read/write process.
so when TX FIFO is full, add one byte delay before send data;

Signed-off-by: sxauwsk <sxau...@163.com>
---
 drivers/spi/spi-cadence.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index 5c9516a..4a00163 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -313,6 +313,14 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi)

while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) &&
   (xspi->tx_bytes > 0)) {
+
+   /* When xspi in busy condition, bytes may send failed,
+* then spi control did't work thoroughly, add one byte delay
+*/
+   if (cdns_spi_read(xspi, CDNS_SPI_ISR) &
+   CDNS_SPI_IXR_TXFULL)
+   usleep_range(10, 20);
+
if (xspi->txbuf)
cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
else
--
1.7.9.5



[PATCH] i2c: cadence: try reset when master receive error interrupts

2019-01-30 Thread sxauwsk
When the adapter receive error interrupts, such as NACK, arbitration lost,
cdns_i2c_master_xfer return to the caller directly instead of resuming 
the adapter which resulted in the adapter being out of control.

So when driver detect err_status then try to repair and fix it.

Signed-off-by: sxauwsk 
---
 drivers/i2c/busses/i2c-cadence.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index b13605718291..e10048d7524a 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -548,10 +548,6 @@ static int cdns_i2c_process_msg(struct cdns_i2c *id, 
struct i2c_msg *msg,
cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK,
  CDNS_I2C_IDR_OFFSET);
 
-   /* If it is bus arbitration error, try again */
-   if (id->err_status & CDNS_I2C_IXR_ARB_LOST)
-   return -EAGAIN;
-
return 0;
 }
 
@@ -617,13 +613,19 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, 
struct i2c_msg *msgs,
id->bus_hold_flag = 0;
 
ret = cdns_i2c_process_msg(id, msgs, adap);
-   if (ret)
+   if (!ret)
goto out;
 
/* Report the other error interrupts to application */
if (id->err_status) {
cdns_i2c_master_reset(adap);
 
+   /* If it is bus arbitration error, try again */
+   if (id->err_status & CDNS_I2C_IXR_ARB_LOST) {
+   ret = -EAGAIN;
+   goto out;
+   }
+
if (id->err_status & CDNS_I2C_IXR_NACK) {
ret = -ENXIO;
goto out;
-- 
2.19.2




[PATCH] i2c: cadence: try reset when master receive arbitration lost

2019-02-18 Thread sxauwsk
When the adapter receive arbitration lost error interrupts,
cdns_i2c_master_xfer return to the caller directly instead of resetting
the adapter which resulted in the adapter being out of control.

So when driver detect err_status such as arbitration lost,
then try to repair and fix it.

Signed-off-by: sxauwsk 
Signed-off-by: Shubhrajyoti Datta 
---
 drivers/i2c/busses/i2c-cadence.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index b13605718291..595b0d56ff1a 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -548,10 +548,6 @@ static int cdns_i2c_process_msg(struct cdns_i2c *id, 
struct i2c_msg *msg,
cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK,
  CDNS_I2C_IDR_OFFSET);
 
-   /* If it is bus arbitration error, try again */
-   if (id->err_status & CDNS_I2C_IXR_ARB_LOST)
-   return -EAGAIN;
-
return 0;
 }
 
@@ -624,6 +620,12 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, 
struct i2c_msg *msgs,
if (id->err_status) {
cdns_i2c_master_reset(adap);
 
+   /* If it is bus arbitration error, try again */
+   if (id->err_status & CDNS_I2C_IXR_ARB_LOST) {
+   ret = -EAGAIN;
+   goto out;
+   }
+
if (id->err_status & CDNS_I2C_IXR_NACK) {
ret = -ENXIO;
goto out;
-- 
2.19.2