diff mbox series

i3c: master: svc: add NACK check after start byte sent

Message ID 20230517033030.3068085-3-xiaoning.wang@nxp.com (mailing list archive)
State Accepted
Headers show
Series i3c: master: svc: add NACK check after start byte sent | expand

Commit Message

Clark Wang May 17, 2023, 3:30 a.m. UTC
Add NACK check after start byte is sent.
It is possible to detect early that a device is not on the bus
and avoid invalid transmissions thereafter.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
 drivers/i3c/master/svc-i3c-master.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Miquel Raynal May 22, 2023, 8:33 a.m. UTC | #1
Hi Clark,

xiaoning.wang@nxp.com wrote on Wed, 17 May 2023 11:30:30 +0800:

> Add NACK check after start byte is sent.
> It is possible to detect early that a device is not on the bus
> and avoid invalid transmissions thereafter.
> 
> Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>

Nice addition.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

> ---
>  drivers/i3c/master/svc-i3c-master.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index 4edf33ed207d..0d63b732ef0c 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -92,6 +92,7 @@
>  #define SVC_I3C_MINTCLR      0x094
>  #define SVC_I3C_MINTMASKED   0x098
>  #define SVC_I3C_MERRWARN     0x09C
> +#define   SVC_I3C_MERRWARN_NACK BIT(2)
>  #define SVC_I3C_MDMACTRL     0x0A0
>  #define SVC_I3C_MDATACTRL    0x0AC
>  #define   SVC_I3C_MDATACTRL_FLUSHTB BIT(0)
> @@ -1014,6 +1015,11 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
>  	if (ret)
>  		goto emit_stop;
>  
> +	if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) {
> +		ret = -ENXIO;
> +		goto emit_stop;
> +	}
> +
>  	if (rnw)
>  		ret = svc_i3c_master_read(master, in, xfer_len);
>  	else


Thanks,
Miquèl
diff mbox series

Patch

diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 4edf33ed207d..0d63b732ef0c 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -92,6 +92,7 @@ 
 #define SVC_I3C_MINTCLR      0x094
 #define SVC_I3C_MINTMASKED   0x098
 #define SVC_I3C_MERRWARN     0x09C
+#define   SVC_I3C_MERRWARN_NACK BIT(2)
 #define SVC_I3C_MDMACTRL     0x0A0
 #define SVC_I3C_MDATACTRL    0x0AC
 #define   SVC_I3C_MDATACTRL_FLUSHTB BIT(0)
@@ -1014,6 +1015,11 @@  static int svc_i3c_master_xfer(struct svc_i3c_master *master,
 	if (ret)
 		goto emit_stop;
 
+	if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) {
+		ret = -ENXIO;
+		goto emit_stop;
+	}
+
 	if (rnw)
 		ret = svc_i3c_master_read(master, in, xfer_len);
 	else