All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] spi: stm32_qspi: flags management fixes
@ 2022-05-12  7:17 Patrice Chotard
  2022-05-12  7:17 ` [PATCH v1 1/2] spi: stm32_qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd() Patrice Chotard
  2022-05-12  7:17 ` [PATCH v1 2/2] spi: stm32_qspi: Remove SR_BUSY bit check before sending command Patrice Chotard
  0 siblings, 2 replies; 7+ messages in thread
From: Patrice Chotard @ 2022-05-12  7:17 UTC (permalink / raw)
  To: u-boot; +Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Jagan Teki

This series update flags management in the following cases:
  - Always check TCF flag in stm32_qspi_wait_cmd()
  - Don't check BUSY flag when sending new command

Patrice Chotard (2):
  spi: stm32_qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd()
  spi: stm32_qspi: Remove SR_BUSY bit check before sending command

 drivers/spi/stm32_qspi.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 1/2] spi: stm32_qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd()
  2022-05-12  7:17 [PATCH v1 0/2] spi: stm32_qspi: flags management fixes Patrice Chotard
@ 2022-05-12  7:17 ` Patrice Chotard
  2022-05-17  8:23   ` Patrick DELAUNAY
  2022-05-12  7:17 ` [PATCH v1 2/2] spi: stm32_qspi: Remove SR_BUSY bit check before sending command Patrice Chotard
  1 sibling, 1 reply; 7+ messages in thread
From: Patrice Chotard @ 2022-05-12  7:17 UTC (permalink / raw)
  To: u-boot; +Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Jagan Teki

Currently, SR_TCF flag is checked in case there is data, this criteria
is not correct.

SR_TCF flags is set when programmed number of bytes have been transferred
to the memory device ("bytes" comprised command and data send to the
SPI device).
So even if there is no data, we must check SR_TCF flag.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---

 drivers/spi/stm32_qspi.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
index 8f4aabc3d1..3c8faecb54 100644
--- a/drivers/spi/stm32_qspi.c
+++ b/drivers/spi/stm32_qspi.c
@@ -150,20 +150,19 @@ static int _stm32_qspi_wait_cmd(struct stm32_qspi_priv *priv,
 	u32 sr;
 	int ret = 0;
 
-	if (op->data.nbytes) {
-		ret = readl_poll_timeout(&priv->regs->sr, sr,
-					 sr & STM32_QSPI_SR_TCF,
-					 STM32_QSPI_CMD_TIMEOUT_US);
-		if (ret) {
-			log_err("cmd timeout (stat:%#x)\n", sr);
-		} else if (readl(&priv->regs->sr) & STM32_QSPI_SR_TEF) {
-			log_err("transfer error (stat:%#x)\n", sr);
-			ret = -EIO;
-		}
-		/* clear flags */
-		writel(STM32_QSPI_FCR_CTCF | STM32_QSPI_FCR_CTEF, &priv->regs->fcr);
+	ret = readl_poll_timeout(&priv->regs->sr, sr,
+				 sr & STM32_QSPI_SR_TCF,
+				 STM32_QSPI_CMD_TIMEOUT_US);
+	if (ret) {
+		log_err("cmd timeout (stat:%#x)\n", sr);
+	} else if (readl(&priv->regs->sr) & STM32_QSPI_SR_TEF) {
+		log_err("transfer error (stat:%#x)\n", sr);
+		ret = -EIO;
 	}
 
+	/* clear flags */
+	writel(STM32_QSPI_FCR_CTCF | STM32_QSPI_FCR_CTEF, &priv->regs->fcr);
+
 	if (!ret)
 		ret = _stm32_qspi_wait_for_not_busy(priv);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 2/2] spi: stm32_qspi: Remove SR_BUSY bit check before sending command
  2022-05-12  7:17 [PATCH v1 0/2] spi: stm32_qspi: flags management fixes Patrice Chotard
  2022-05-12  7:17 ` [PATCH v1 1/2] spi: stm32_qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd() Patrice Chotard
@ 2022-05-12  7:17 ` Patrice Chotard
  2022-05-17  8:24   ` Patrick DELAUNAY
  1 sibling, 1 reply; 7+ messages in thread
From: Patrice Chotard @ 2022-05-12  7:17 UTC (permalink / raw)
  To: u-boot; +Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Jagan Teki

Waiting for SR_BUSY bit when receiving a new command is not needed.
SR_BUSY bit is already managed in the previous command treatment.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>

---

 drivers/spi/stm32_qspi.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
index 3c8faecb54..ceba413727 100644
--- a/drivers/spi/stm32_qspi.c
+++ b/drivers/spi/stm32_qspi.c
@@ -255,10 +255,6 @@ static int stm32_qspi_exec_op(struct spi_slave *slave,
 		op->dummy.buswidth, op->data.buswidth,
 		op->addr.val, op->data.nbytes);
 
-	ret = _stm32_qspi_wait_for_not_busy(priv);
-	if (ret)
-		return ret;
-
 	addr_max = op->addr.val + op->data.nbytes + 1;
 
 	if (op->data.dir == SPI_MEM_DATA_IN && op->data.nbytes) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/2] spi: stm32_qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd()
  2022-05-12  7:17 ` [PATCH v1 1/2] spi: stm32_qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd() Patrice Chotard
@ 2022-05-17  8:23   ` Patrick DELAUNAY
  2022-05-20  7:21     ` [Uboot-stm32] " Patrick DELAUNAY
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick DELAUNAY @ 2022-05-17  8:23 UTC (permalink / raw)
  To: Patrice Chotard, u-boot; +Cc: U-Boot STM32, Jagan Teki

Hi Patrice,

On 5/12/22 09:17, Patrice Chotard wrote:
> Currently, SR_TCF flag is checked in case there is data, this criteria
> is not correct.
>
> SR_TCF flags is set when programmed number of bytes have been transferred
> to the memory device ("bytes" comprised command and data send to the
> SPI device).
> So even if there is no data, we must check SR_TCF flag.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   drivers/spi/stm32_qspi.c | 23 +++++++++++------------
>   1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
> index 8f4aabc3d1..3c8faecb54 100644
> --- a/drivers/spi/stm32_qspi.c
> +++ b/drivers/spi/stm32_qspi.c
> @@ -150,20 +150,19 @@ static int _stm32_qspi_wait_cmd(struct stm32_qspi_priv *priv,
>   	u32 sr;
>   	int ret = 0;
>   
> -	if (op->data.nbytes) {
> -		ret = readl_poll_timeout(&priv->regs->sr, sr,
> -					 sr & STM32_QSPI_SR_TCF,
> -					 STM32_QSPI_CMD_TIMEOUT_US);
> -		if (ret) {
> -			log_err("cmd timeout (stat:%#x)\n", sr);
> -		} else if (readl(&priv->regs->sr) & STM32_QSPI_SR_TEF) {
> -			log_err("transfer error (stat:%#x)\n", sr);
> -			ret = -EIO;
> -		}
> -		/* clear flags */
> -		writel(STM32_QSPI_FCR_CTCF | STM32_QSPI_FCR_CTEF, &priv->regs->fcr);
> +	ret = readl_poll_timeout(&priv->regs->sr, sr,
> +				 sr & STM32_QSPI_SR_TCF,
> +				 STM32_QSPI_CMD_TIMEOUT_US);
> +	if (ret) {
> +		log_err("cmd timeout (stat:%#x)\n", sr);
> +	} else if (readl(&priv->regs->sr) & STM32_QSPI_SR_TEF) {
> +		log_err("transfer error (stat:%#x)\n", sr);
> +		ret = -EIO;
>   	}
>   
> +	/* clear flags */
> +	writel(STM32_QSPI_FCR_CTCF | STM32_QSPI_FCR_CTEF, &priv->regs->fcr);
> +
>   	if (!ret)
>   		ret = _stm32_qspi_wait_for_not_busy(priv);
>   


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 2/2] spi: stm32_qspi: Remove SR_BUSY bit check before sending command
  2022-05-12  7:17 ` [PATCH v1 2/2] spi: stm32_qspi: Remove SR_BUSY bit check before sending command Patrice Chotard
@ 2022-05-17  8:24   ` Patrick DELAUNAY
  2022-05-20  7:22     ` Patrick DELAUNAY
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick DELAUNAY @ 2022-05-17  8:24 UTC (permalink / raw)
  To: Patrice Chotard, u-boot; +Cc: U-Boot STM32, Jagan Teki

Hi Patrice

On 5/12/22 09:17, Patrice Chotard wrote:
> Waiting for SR_BUSY bit when receiving a new command is not needed.
> SR_BUSY bit is already managed in the previous command treatment.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>
> ---
>
>   drivers/spi/stm32_qspi.c | 4 ----
>   1 file changed, 4 deletions(-)
>
> diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
> index 3c8faecb54..ceba413727 100644
> --- a/drivers/spi/stm32_qspi.c
> +++ b/drivers/spi/stm32_qspi.c
> @@ -255,10 +255,6 @@ static int stm32_qspi_exec_op(struct spi_slave *slave,
>   		op->dummy.buswidth, op->data.buswidth,
>   		op->addr.val, op->data.nbytes);
>   
> -	ret = _stm32_qspi_wait_for_not_busy(priv);
> -	if (ret)
> -		return ret;
> -
>   	addr_max = op->addr.val + op->data.nbytes + 1;
>   
>   	if (op->data.dir == SPI_MEM_DATA_IN && op->data.nbytes) {


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Uboot-stm32] [PATCH v1 1/2] spi: stm32_qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd()
  2022-05-17  8:23   ` Patrick DELAUNAY
@ 2022-05-20  7:21     ` Patrick DELAUNAY
  0 siblings, 0 replies; 7+ messages in thread
From: Patrick DELAUNAY @ 2022-05-20  7:21 UTC (permalink / raw)
  To: Patrice Chotard, u-boot; +Cc: U-Boot STM32, Jagan Teki

Hi,

On 5/17/22 10:23, Patrick DELAUNAY wrote:
> Hi Patrice,
>
> On 5/12/22 09:17, Patrice Chotard wrote:
>> Currently, SR_TCF flag is checked in case there is data, this criteria
>> is not correct.
>>
>> SR_TCF flags is set when programmed number of bytes have been 
>> transferred
>> to the memory device ("bytes" comprised command and data send to the
>> SPI device).
>> So even if there is no data, we must check SR_TCF flag.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>   drivers/spi/stm32_qspi.c | 23 +++++++++++------------
>>   1 file changed, 11 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
>> index 8f4aabc3d1..3c8faecb54 100644
>> --- a/drivers/spi/stm32_qspi.c
>> +++ b/drivers/spi/stm32_qspi.c
>> @@ -150,20 +150,19 @@ static int _stm32_qspi_wait_cmd(struct 
>> stm32_qspi_priv *priv,
>>       u32 sr;
>>       int ret = 0;
>>   -    if (op->data.nbytes) {
>> -        ret = readl_poll_timeout(&priv->regs->sr, sr,
>> -                     sr & STM32_QSPI_SR_TCF,
>> -                     STM32_QSPI_CMD_TIMEOUT_US);
>> -        if (ret) {
>> -            log_err("cmd timeout (stat:%#x)\n", sr);
>> -        } else if (readl(&priv->regs->sr) & STM32_QSPI_SR_TEF) {
>> -            log_err("transfer error (stat:%#x)\n", sr);
>> -            ret = -EIO;
>> -        }
>> -        /* clear flags */
>> -        writel(STM32_QSPI_FCR_CTCF | STM32_QSPI_FCR_CTEF, 
>> &priv->regs->fcr);
>> +    ret = readl_poll_timeout(&priv->regs->sr, sr,
>> +                 sr & STM32_QSPI_SR_TCF,
>> +                 STM32_QSPI_CMD_TIMEOUT_US);
>> +    if (ret) {
>> +        log_err("cmd timeout (stat:%#x)\n", sr);
>> +    } else if (readl(&priv->regs->sr) & STM32_QSPI_SR_TEF) {
>> +        log_err("transfer error (stat:%#x)\n", sr);
>> +        ret = -EIO;
>>       }
>>   +    /* clear flags */
>> +    writel(STM32_QSPI_FCR_CTCF | STM32_QSPI_FCR_CTEF, 
>> &priv->regs->fcr);
>> +
>>       if (!ret)
>>           ret = _stm32_qspi_wait_for_not_busy(priv);
>
>
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
>
> Thanks
> Patrick
>
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32@st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32



Applied to u-boot-stm/master, thanks!

Regards
Patrick


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 2/2] spi: stm32_qspi: Remove SR_BUSY bit check before sending command
  2022-05-17  8:24   ` Patrick DELAUNAY
@ 2022-05-20  7:22     ` Patrick DELAUNAY
  0 siblings, 0 replies; 7+ messages in thread
From: Patrick DELAUNAY @ 2022-05-20  7:22 UTC (permalink / raw)
  To: Patrice Chotard, u-boot; +Cc: U-Boot STM32, Jagan Teki

Hi,

On 5/17/22 10:24, Patrick DELAUNAY wrote:
> Hi Patrice
>
> On 5/12/22 09:17, Patrice Chotard wrote:
>> Waiting for SR_BUSY bit when receiving a new command is not needed.
>> SR_BUSY bit is already managed in the previous command treatment.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>>
>> ---
>>
>>   drivers/spi/stm32_qspi.c | 4 ----
>>   1 file changed, 4 deletions(-)
>>
>> diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
>> index 3c8faecb54..ceba413727 100644
>> --- a/drivers/spi/stm32_qspi.c
>> +++ b/drivers/spi/stm32_qspi.c
>> @@ -255,10 +255,6 @@ static int stm32_qspi_exec_op(struct spi_slave 
>> *slave,
>>           op->dummy.buswidth, op->data.buswidth,
>>           op->addr.val, op->data.nbytes);
>>   -    ret = _stm32_qspi_wait_for_not_busy(priv);
>> -    if (ret)
>> -        return ret;
>> -
>>       addr_max = op->addr.val + op->data.nbytes + 1;
>>         if (op->data.dir == SPI_MEM_DATA_IN && op->data.nbytes) {
>
>
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
>
> Thanks
> Patrick
>
>

Applied to u-boot-stm/master, thanks!

Regards
Patrick


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-20  7:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12  7:17 [PATCH v1 0/2] spi: stm32_qspi: flags management fixes Patrice Chotard
2022-05-12  7:17 ` [PATCH v1 1/2] spi: stm32_qspi: Always check SR_TCF flags in stm32_qspi_wait_cmd() Patrice Chotard
2022-05-17  8:23   ` Patrick DELAUNAY
2022-05-20  7:21     ` [Uboot-stm32] " Patrick DELAUNAY
2022-05-12  7:17 ` [PATCH v1 2/2] spi: stm32_qspi: Remove SR_BUSY bit check before sending command Patrice Chotard
2022-05-17  8:24   ` Patrick DELAUNAY
2022-05-20  7:22     ` Patrick DELAUNAY

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.