diff mbox series

[1/4] i3c: Drop support for I2C 10 bit addresing

Message ID 20190307095808.22540-2-pgaj@cadence.com (mailing list archive)
State Superseded
Headers show
Series Drop support for I2C 10 bit devices from I3C subsystem | expand

Commit Message

Przemysław Gaj March 7, 2019, 9:58 a.m. UTC
This patch dropps support for I2C devices with 10 bit addressing. When I2C
device with 10 bit address is defined in DT, I3C master registration fails.

Address space for I2C devices has been reduced and ->i2c_funcs() hook has been
removed.

Signed-off-by: Przemyslaw Gaj <pgaj@cadence.com>
---
 drivers/i3c/master.c       | 19 +++++++++++--------
 include/linux/i3c/master.h |  5 +----
 2 files changed, 12 insertions(+), 12 deletions(-)

Comments

Vitor Soares March 13, 2019, 7:30 p.m. UTC | #1
Hi Przemek,


On 07/03/19 09:58, Przemyslaw Gaj wrote:
> This patch dropps support for I2C devices with 10 bit addressing. When I2C
> device with 10 bit address is defined in DT, I3C master registration fails.
>
> Address space for I2C devices has been reduced and ->i2c_funcs() hook has been
> removed.
>
> Signed-off-by: Przemyslaw Gaj <pgaj@cadence.com>
> ---
>  drivers/i3c/master.c       | 19 +++++++++++--------
>  include/linux/i3c/master.h |  5 +----
>  2 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 2dc628d..5b3adb3 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -1962,6 +1962,16 @@ of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
>  	if (ret)
>  		return ret;
>  
> +	/*
> +	 * The I3C Specification does not clearly say I2C devices with 10-bit
> +	 * address are supported. These devices can't be passed properly through
> +	 * DEFSLVS command.
> +	 */
> +	if (boardinfo->base.flags & I2C_CLIENT_TEN) {
> +		dev_err(&master->dev, "I2C device with 10 bit address not supported.");
> +		return -ENOTSUPP;
> +	}
> +
>  	/* LVR is encoded in reg[2]. */
>  	boardinfo->lvr = reg[2];
>  
> @@ -2111,16 +2121,9 @@ static int i3c_master_i2c_adapter_xfer(struct i2c_adapter *adap,
>  	return ret ? ret : nxfers;
>  }
>  
> -static u32 i3c_master_i2c_functionalities(struct i2c_adapter *adap)
> -{
> -	struct i3c_master_controller *master = i2c_adapter_to_i3c_master(adap);
> -
> -	return master->ops->i2c_funcs(master);
> -}
> -
>  static const struct i2c_algorithm i3c_master_i2c_algo = {
>  	.master_xfer = i3c_master_i2c_adapter_xfer,
> -	.functionality = i3c_master_i2c_functionalities,
> +	.functionality = I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C,
>  };
>  
>  static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
> diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
> index f13fd8b..eca8337 100644
> --- a/include/linux/i3c/master.h
> +++ b/include/linux/i3c/master.h
> @@ -48,7 +48,7 @@ struct i3c_i2c_dev_desc {
>  #define I3C_LVR_I2C_INDEX(x)		((x) << 5)
>  #define I3C_LVR_I2C_FM_MODE		BIT(4)
>  
> -#define I2C_MAX_ADDR			GENMASK(9, 0)
> +#define I2C_MAX_ADDR			GENMASK(6, 0)
>  
>  /**
>   * struct i2c_dev_boardinfo - I2C device board information
> @@ -390,8 +390,6 @@ struct i3c_bus {
>   *	       and i2c_put_dma_safe_msg_buf() helpers provided by the I2C
>   *	       framework.
>   *	       This method is mandatory.
> - * @i2c_funcs: expose the supported I2C functionalities.
> - *	       This method is mandatory.
>   * @request_ibi: attach an IBI handler to an I3C device. This implies defining
>   *		 an IBI handler and the constraints of the IBI (maximum payload
>   *		 length and number of pre-allocated slots).
> @@ -437,7 +435,6 @@ struct i3c_master_controller_ops {
>  	void (*detach_i2c_dev)(struct i2c_dev_desc *dev);
>  	int (*i2c_xfers)(struct i2c_dev_desc *dev,
>  			 const struct i2c_msg *xfers, int nxfers);
> -	u32 (*i2c_funcs)(struct i3c_master_controller *master);
>  	int (*request_ibi)(struct i3c_dev_desc *dev,
>  			   const struct i3c_ibi_setup *req);
>  	void (*free_ibi)(struct i3c_dev_desc *dev);

Still need to remove ops->i2c_funcs from i3c_master_check_ops.

Best regards,
Vitor Soares
Przemysław Gaj March 14, 2019, 7:47 a.m. UTC | #2
Hi Vitor,

The 03/13/2019 19:30, vitor wrote:
> 
> 
> Hi Przemek,
> 
> 
> On 07/03/19 09:58, Przemyslaw Gaj wrote:
> > This patch dropps support for I2C devices with 10 bit addressing. When I2C
> > device with 10 bit address is defined in DT, I3C master registration fails.
> >
> > Address space for I2C devices has been reduced and ->i2c_funcs() hook has been
> > removed.
> >
> > Signed-off-by: Przemyslaw Gaj <pgaj@cadence.com>
> > ---
> >  drivers/i3c/master.c       | 19 +++++++++++--------
> >  include/linux/i3c/master.h |  5 +----
> >  2 files changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> > index 2dc628d..5b3adb3 100644
> > --- a/drivers/i3c/master.c
> > +++ b/drivers/i3c/master.c
> > @@ -1962,6 +1962,16 @@ of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
> >  	if (ret)
> >  		return ret;
> >  
> > +	/*
> > +	 * The I3C Specification does not clearly say I2C devices with 10-bit
> > +	 * address are supported. These devices can't be passed properly through
> > +	 * DEFSLVS command.
> > +	 */
> > +	if (boardinfo->base.flags & I2C_CLIENT_TEN) {
> > +		dev_err(&master->dev, "I2C device with 10 bit address not supported.");
> > +		return -ENOTSUPP;
> > +	}
> > +
> >  	/* LVR is encoded in reg[2]. */
> >  	boardinfo->lvr = reg[2];
> >  
> > @@ -2111,16 +2121,9 @@ static int i3c_master_i2c_adapter_xfer(struct i2c_adapter *adap,
> >  	return ret ? ret : nxfers;
> >  }
> >  
> > -static u32 i3c_master_i2c_functionalities(struct i2c_adapter *adap)
> > -{
> > -	struct i3c_master_controller *master = i2c_adapter_to_i3c_master(adap);
> > -
> > -	return master->ops->i2c_funcs(master);
> > -}
> > -
> >  static const struct i2c_algorithm i3c_master_i2c_algo = {
> >  	.master_xfer = i3c_master_i2c_adapter_xfer,
> > -	.functionality = i3c_master_i2c_functionalities,
> > +	.functionality = I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C,
> >  };
> >  
> >  static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
> > diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
> > index f13fd8b..eca8337 100644
> > --- a/include/linux/i3c/master.h
> > +++ b/include/linux/i3c/master.h
> > @@ -48,7 +48,7 @@ struct i3c_i2c_dev_desc {
> >  #define I3C_LVR_I2C_INDEX(x)		((x) << 5)
> >  #define I3C_LVR_I2C_FM_MODE		BIT(4)
> >  
> > -#define I2C_MAX_ADDR			GENMASK(9, 0)
> > +#define I2C_MAX_ADDR			GENMASK(6, 0)
> >  
> >  /**
> >   * struct i2c_dev_boardinfo - I2C device board information
> > @@ -390,8 +390,6 @@ struct i3c_bus {
> >   *	       and i2c_put_dma_safe_msg_buf() helpers provided by the I2C
> >   *	       framework.
> >   *	       This method is mandatory.
> > - * @i2c_funcs: expose the supported I2C functionalities.
> > - *	       This method is mandatory.
> >   * @request_ibi: attach an IBI handler to an I3C device. This implies defining
> >   *		 an IBI handler and the constraints of the IBI (maximum payload
> >   *		 length and number of pre-allocated slots).
> > @@ -437,7 +435,6 @@ struct i3c_master_controller_ops {
> >  	void (*detach_i2c_dev)(struct i2c_dev_desc *dev);
> >  	int (*i2c_xfers)(struct i2c_dev_desc *dev,
> >  			 const struct i2c_msg *xfers, int nxfers);
> > -	u32 (*i2c_funcs)(struct i3c_master_controller *master);
> >  	int (*request_ibi)(struct i3c_dev_desc *dev,
> >  			   const struct i3c_ibi_setup *req);
> >  	void (*free_ibi)(struct i3c_dev_desc *dev);
> 
> Still need to remove ops->i2c_funcs from i3c_master_check_ops.

I thought I did that. I need to check that patch carefully. I'm sure I compiled
that, now I'm wondering why it worked. Thank you!

> 
> Best regards, 
> Vitor Soares
diff mbox series

Patch

diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 2dc628d..5b3adb3 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -1962,6 +1962,16 @@  of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
 	if (ret)
 		return ret;
 
+	/*
+	 * The I3C Specification does not clearly say I2C devices with 10-bit
+	 * address are supported. These devices can't be passed properly through
+	 * DEFSLVS command.
+	 */
+	if (boardinfo->base.flags & I2C_CLIENT_TEN) {
+		dev_err(&master->dev, "I2C device with 10 bit address not supported.");
+		return -ENOTSUPP;
+	}
+
 	/* LVR is encoded in reg[2]. */
 	boardinfo->lvr = reg[2];
 
@@ -2111,16 +2121,9 @@  static int i3c_master_i2c_adapter_xfer(struct i2c_adapter *adap,
 	return ret ? ret : nxfers;
 }
 
-static u32 i3c_master_i2c_functionalities(struct i2c_adapter *adap)
-{
-	struct i3c_master_controller *master = i2c_adapter_to_i3c_master(adap);
-
-	return master->ops->i2c_funcs(master);
-}
-
 static const struct i2c_algorithm i3c_master_i2c_algo = {
 	.master_xfer = i3c_master_i2c_adapter_xfer,
-	.functionality = i3c_master_i2c_functionalities,
+	.functionality = I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C,
 };
 
 static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
index f13fd8b..eca8337 100644
--- a/include/linux/i3c/master.h
+++ b/include/linux/i3c/master.h
@@ -48,7 +48,7 @@  struct i3c_i2c_dev_desc {
 #define I3C_LVR_I2C_INDEX(x)		((x) << 5)
 #define I3C_LVR_I2C_FM_MODE		BIT(4)
 
-#define I2C_MAX_ADDR			GENMASK(9, 0)
+#define I2C_MAX_ADDR			GENMASK(6, 0)
 
 /**
  * struct i2c_dev_boardinfo - I2C device board information
@@ -390,8 +390,6 @@  struct i3c_bus {
  *	       and i2c_put_dma_safe_msg_buf() helpers provided by the I2C
  *	       framework.
  *	       This method is mandatory.
- * @i2c_funcs: expose the supported I2C functionalities.
- *	       This method is mandatory.
  * @request_ibi: attach an IBI handler to an I3C device. This implies defining
  *		 an IBI handler and the constraints of the IBI (maximum payload
  *		 length and number of pre-allocated slots).
@@ -437,7 +435,6 @@  struct i3c_master_controller_ops {
 	void (*detach_i2c_dev)(struct i2c_dev_desc *dev);
 	int (*i2c_xfers)(struct i2c_dev_desc *dev,
 			 const struct i2c_msg *xfers, int nxfers);
-	u32 (*i2c_funcs)(struct i3c_master_controller *master);
 	int (*request_ibi)(struct i3c_dev_desc *dev,
 			   const struct i3c_ibi_setup *req);
 	void (*free_ibi)(struct i3c_dev_desc *dev);