Skip to contentSkip to conversation

Drop support for I2C 10 bit devices from I3C subsystem

PATCH In review Przemyslaw Gaj 3 participants 8 messages Mar 7, 2019 – Mar 14, 2019

Subsystems (4)
lore
Share & tools
lore

Przemyslaw Gaj

author maintainer
#0 lore raw

cover Drop support for I2C 10 bit devices from I3C subsystem

I3C MIPI spec does not clearly say that I2C 10bit devices are supported. Additionally, it isn't possible to pass 10 bit device properly through DEFSLVS command and reserve address for such device on secondary master side.

Przemyslaw Gaj (4):
i3c: Drop support for I2C 10 bit addresing
i3c: master: cdns: Drop support for I2C 10 bit addresing in Cadence
I3C master
i3c: master: dw-i3c-master: Remove i2c_funcs hook implementation
dt-bindings: i3c: Document dropped support for I2C 10 bit devices

 Documentation/devicetree/bindings/i3c/i3c.txt |  4 +++-
 drivers/i3c/master.c                          | 19 +++++++++++--------
 drivers/i3c/master/dw-i3c-master.c            |  6 ------
 drivers/i3c/master/i3c-master-cdns.c          | 10 +---------
 include/linux/i3c/master.h                    |  5 +----
 5 files changed, 16 insertions(+), 28 deletions(-)
Signature · 7 lines
2.8.3


_______________________________________________
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
author maintainer
#1 lore raw

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

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.

---
 drivers/i3c/master.c       | 19 +++++++++++--------
 include/linux/i3c/master.h |  5 +----
 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/i3c/master.c +11 -8
index 2dc628d..5b3adb3 100644
@@ -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)
include/linux/i3c/master.h +1 -4
index f13fd8b..eca8337 100644
@@ -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);
Signature · 7 lines
2.8.3


_______________________________________________
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#2 lore raw

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

Hi Przemek,

Quoted 74 lines · Przemyslaw Gaj

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.

---
 drivers/i3c/master.c       | 19 +++++++++++--------
 include/linux/i3c/master.h |  5 +----
 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/i3c/master.c +11 -8
index 2dc628d..5b3adb3 100644
@@ -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)
include/linux/i3c/master.h +1 -3
index f13fd8b..eca8337 100644
@@ -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).

include/linux/i3c/master.h struct i3c_master_controller_ops { · line 440

Quoted 7 lines
include/linux/i3c/master.h +0 -1
@@ -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

_______________________________________________
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

author maintainer
#3 lore raw

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

Hi Vitor,

Quoted 81 lines · vitor

Hi Przemek,

Quoted 75 lines · Przemyslaw Gaj

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.

---
 drivers/i3c/master.c       | 19 +++++++++++--------
 include/linux/i3c/master.h |  5 +----
 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/i3c/master.c +11 -8
index 2dc628d..5b3adb3 100644
@@ -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)
include/linux/i3c/master.h +1 -3
index f13fd8b..eca8337 100644
@@ -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);
Quoted 8 lines

include/linux/i3c/master.h struct i3c_master_controller_ops { · line 440

Quoted 6 lines
include/linux/i3c/master.h +0 -1
 	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!

Quoted 3 lines

Best regards,
Vitor Soares

Signature · 7 lines
-- 
Przemyslaw Gaj

_______________________________________________
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
author maintainer
#4 lore raw

PATCH 2/4 i3c: master: cdns: Drop support for I2C 10 bit addresing in Cadence I3C master

In reply to Przemyslaw Gaj

Because this patch series dropped support for 10 bit I2C devices, support is also dropped in Cadence I3C master driver.

---
 drivers/i3c/master/i3c-master-cdns.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/i3c/master/i3c-master-cdns.c +1 -9
index 8889a4f..237f24a 100644
@@ -864,11 +864,6 @@ static int cdns_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
 	return ret;
 }
 
-static u32 cdns_i3c_master_i2c_funcs(struct i3c_master_controller *m)
-{
-	return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR;
-}
-
 struct cdns_i3c_i2c_dev_data {
 	u16 id;
 	s16 ibi;
@@ -1010,9 +1005,7 @@ static int cdns_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev)
 	master->free_rr_slots &= ~BIT(slot);
 	i2c_dev_set_master_data(dev, data);
 
-	writel(prepare_rr0_dev_address(dev->boardinfo->base.addr) |
-	       (dev->boardinfo->base.flags & I2C_CLIENT_TEN ?
-		DEV_ID_RR0_LVR_EXT_ADDR : 0),
+	writel(prepare_rr0_dev_address(dev->boardinfo->base.addr),
 	       master->regs + DEV_ID_RR0(data->id));
 	writel(dev->boardinfo->lvr, master->regs + DEV_ID_RR2(data->id));
 	writel(readl(master->regs + DEVS_CTRL) |
@@ -1518,7 +1511,6 @@ static const struct i3c_master_controller_ops cdns_i3c_master_ops = {
 	.send_ccc_cmd = cdns_i3c_master_send_ccc_cmd,
 	.priv_xfers = cdns_i3c_master_priv_xfers,
 	.i2c_xfers = cdns_i3c_master_i2c_xfers,
-	.i2c_funcs = cdns_i3c_master_i2c_funcs,
 	.enable_ibi = cdns_i3c_master_enable_ibi,
 	.disable_ibi = cdns_i3c_master_disable_ibi,
 	.request_ibi = cdns_i3c_master_request_ibi,
Signature · 7 lines
2.8.3


_______________________________________________
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
author maintainer
#5 lore raw

PATCH 3/4 i3c: master: dw-i3c-master: Remove i2c_funcs hook implementation

In reply to Przemyslaw Gaj

Because this patch series dropped support for 10 bit I2C devices, i2c_funcs() hook has been removed. I removed hook implementation from Synopsys DesignWare I3C master driver.

---
 drivers/i3c/master/dw-i3c-master.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/i3c/master/dw-i3c-master.c +0 -6
index bb03079..9934a12 100644
@@ -1069,11 +1069,6 @@ static void dw_i3c_master_detach_i2c_dev(struct i2c_dev_desc *dev)
 	kfree(data);
 }
 
-static u32 dw_i3c_master_i2c_funcs(struct i3c_master_controller *m)
-{
-	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
-}
-
 static irqreturn_t dw_i3c_master_irq_handler(int irq, void *dev_id)
 {
 	struct dw_i3c_master *master = dev_id;
@@ -1108,7 +1103,6 @@ static const struct i3c_master_controller_ops dw_mipi_i3c_ops = {
 	.attach_i2c_dev = dw_i3c_master_attach_i2c_dev,
 	.detach_i2c_dev = dw_i3c_master_detach_i2c_dev,
 	.i2c_xfers = dw_i3c_master_i2c_xfers,
-	.i2c_funcs = dw_i3c_master_i2c_funcs,
 };
 
 static int dw_i3c_probe(struct platform_device *pdev)
Signature · 7 lines
2.8.3


_______________________________________________
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
author maintainer
#6 lore raw

PATCH 4/4 dt-bindings: i3c: Document dropped support for I2C 10 bit devices

In reply to Przemyslaw Gaj

Because this patch series dropped support for 10 bit I2C devices, I'm documenting this.

---
 Documentation/devicetree/bindings/i3c/i3c.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/i3c/i3c.txt +3 -1
index ab729a0..4ffe059 100644
@@ -39,7 +39,9 @@ valid here, but several new properties have been added.
 New constraint on existing properties:
 --------------------------------------
 - reg: contains 3 cells
-  + first cell : still encoding the I2C address
+  + first cell : still encoding the I2C address. 10 bit addressing is not
+    supported. Devices with 10 bit address can't be properly passed through
+    DEFSLVS command.
 
   + second cell: shall be 0
 
Signature · 7 lines
2.8.3


_______________________________________________
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#7 lore raw
In reply to Przemyslaw Gaj

Hi Przemek,

Missing v2 in the subject prefix, and there's no changelog in the cover letter/patches.

Quoted 10 lines · On Thu, 7 Mar 2019 09:58:04 +0000 Przemyslaw Gaj <[email protected]> wrote:

I3C MIPI spec does not clearly say that I2C 10bit devices are supported. Additionally, it isn't possible to pass 10 bit device properly through DEFSLVS command and reserve address for such device on secondary master side.

Przemyslaw Gaj (4):
i3c: Drop support for I2C 10 bit addresing
i3c: master: cdns: Drop support for I2C 10 bit addresing in Cadence
I3C master
i3c: master: dw-i3c-master: Remove i2c_funcs hook implementation
dt-bindings: i3c: Document dropped support for I2C 10 bit devices

Looks like this series is still not bisectable. Please make sure things compile/work correctly after each of your change.

Regards,

Boris

Quoted 8 lines
 Documentation/devicetree/bindings/i3c/i3c.txt |  4 +++-
 drivers/i3c/master.c                          | 19 +++++++++++--------
 drivers/i3c/master/dw-i3c-master.c            |  6 ------
 drivers/i3c/master/i3c-master-cdns.c          | 10 +---------
 include/linux/i3c/master.h                    |  5 +----
 5 files changed, 16 insertions(+), 28 deletions(-)

_______________________________________________
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c