diff mbox series

[v2,1/2] i2c: add PEC error event

Message ID 20200717090155.10383-2-rayagonda.kokatanur@broadcom.com
State Under Review
Delegated to: Wolfram Sang
Headers show
Series add PEC support on slave side | expand

Commit Message

Rayagonda Kokatanur July 17, 2020, 9:01 a.m. UTC
Add new event I2C_SLAVE_PEC_ERR to list of slave events.
This event will be used by slave bus driver to indicate
PEC error to slave client or backend driver.

Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
---
 include/linux/i2c.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Wolfram Sang July 23, 2020, 8:16 p.m. UTC | #1
On Fri, Jul 17, 2020 at 02:31:54PM +0530, Rayagonda Kokatanur wrote:
> Add new event I2C_SLAVE_PEC_ERR to list of slave events.
> This event will be used by slave bus driver to indicate
> PEC error to slave client or backend driver.
> 
> Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>

Definately needs documentation in Documentation/i2c/slave-interface.rst.

What is a backend supposed to do? Does 'value' have a meaning?

> ---
>  include/linux/i2c.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index b8b8963f8bb9..e04acd04eb48 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -370,6 +370,7 @@ enum i2c_slave_event {
>  	I2C_SLAVE_READ_PROCESSED,
>  	I2C_SLAVE_WRITE_RECEIVED,
>  	I2C_SLAVE_STOP,
> +	I2C_SLAVE_PEC_ERR,
>  };
>  
>  int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb);
> -- 
> 2.17.1
>
Rayagonda Kokatanur July 24, 2020, 9:22 a.m. UTC | #2
On Fri, Jul 24, 2020 at 1:46 AM Wolfram Sang <wsa@kernel.org> wrote:
>
> On Fri, Jul 17, 2020 at 02:31:54PM +0530, Rayagonda Kokatanur wrote:
> > Add new event I2C_SLAVE_PEC_ERR to list of slave events.
> > This event will be used by slave bus driver to indicate
> > PEC error to slave client or backend driver.
> >
> > Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
>
> Definately needs documentation in Documentation/i2c/slave-interface.rst.

Okay, I will update the doc.

>
> What is a backend supposed to do? Does 'value' have a meaning?

According to SMBUS spec, during slave receive transfer, it is
encouraged to issue NACK if the received PEC is not correct.
Also PEC errors discovered above the data link layer may also be
indicated with a NACK if the device is fast enough to discover and
indicate the error when the NACK is due.

If a device doesn't support issuing NACK and issuing NACK above the
data link layer is not possible because the device is not fast then in
that case we can send error code (I2C_SLAVE_PEC_ERR ) to the backend
driver. Backend drivers which support PEC should check for this error
code and take action such as discarding the data.

Best regards,
Rayagonda

>
> > ---
> >  include/linux/i2c.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> > index b8b8963f8bb9..e04acd04eb48 100644
> > --- a/include/linux/i2c.h
> > +++ b/include/linux/i2c.h
> > @@ -370,6 +370,7 @@ enum i2c_slave_event {
> >       I2C_SLAVE_READ_PROCESSED,
> >       I2C_SLAVE_WRITE_RECEIVED,
> >       I2C_SLAVE_STOP,
> > +     I2C_SLAVE_PEC_ERR,
> >  };
> >
> >  int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb);
> > --
> > 2.17.1
> >
diff mbox series

Patch

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index b8b8963f8bb9..e04acd04eb48 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -370,6 +370,7 @@  enum i2c_slave_event {
 	I2C_SLAVE_READ_PROCESSED,
 	I2C_SLAVE_WRITE_RECEIVED,
 	I2C_SLAVE_STOP,
+	I2C_SLAVE_PEC_ERR,
 };
 
 int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb);