diff mbox series

[V5,1/2] i3c: master: support to adjust first broadcast address speed

Message ID 20240910051626.4052552-1-carlos.song@nxp.com (mailing list archive)
State Accepted
Headers show
Series [V5,1/2] i3c: master: support to adjust first broadcast address speed | expand

Commit Message

Carlos Song Sept. 10, 2024, 5:16 a.m. UTC
From: Carlos Song <carlos.song@nxp.com>

According to I3C spec 6.2 Timing Specification, the Open Drain High Period
of SCL Clock timing for first broadcast address should be adjusted to 200ns
at least. I3C device working as i2c device will see the broadcast to close
its Spike Filter then change to work at I3C mode. After that I3C open drain
SCL high level should be adjusted back.

Signed-off-by: Carlos Song <carlos.song@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---
Change for V5:
- No change. Resend this patch to list after subscribe to mail list.
Change for V4:
- No change. Send this patch with svc-i3c-master.c fix patch.
Change for V3:
- Modify comments from Miquel's suggestion
Change for V2:
- Fix set_speed description from Frank's comment
---
 drivers/i3c/master.c       | 12 ++++++++++++
 include/linux/i3c/master.h | 16 ++++++++++++++++
 2 files changed, 28 insertions(+)

Comments

Frank Li Sept. 16, 2024, 3:13 p.m. UTC | #1
On Tue, Sep 10, 2024 at 01:16:25PM +0800, carlos.song@nxp.com wrote:
> From: Carlos Song <carlos.song@nxp.com>
>
> According to I3C spec 6.2 Timing Specification, the Open Drain High Period
> of SCL Clock timing for first broadcast address should be adjusted to 200ns
> at least. I3C device working as i2c device will see the broadcast to close
> its Spike Filter then change to work at I3C mode. After that I3C open drain
> SCL high level should be adjusted back.
>
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---

Alex:
	I saw v6.11 tag, These two patches is critical for imx93-9x9-evk
boards. without these two patch, all i3c devices can't be proble. I am
sure if there still have chance to get merged for 6.12.

Frank


> Change for V5:
> - No change. Resend this patch to list after subscribe to mail list.
> Change for V4:
> - No change. Send this patch with svc-i3c-master.c fix patch.
> Change for V3:
> - Modify comments from Miquel's suggestion
> Change for V2:
> - Fix set_speed description from Frank's comment
> ---
>  drivers/i3c/master.c       | 12 ++++++++++++
>  include/linux/i3c/master.h | 16 ++++++++++++++++
>  2 files changed, 28 insertions(+)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 7028f03c2c42..6f3eb710a75d 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -1868,6 +1868,12 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
>  		goto err_bus_cleanup;
>  	}
>
> +	if (master->ops->set_speed) {
> +		ret = master->ops->set_speed(master, I3C_OPEN_DRAIN_SLOW_SPEED);
> +		if (ret)
> +			goto err_bus_cleanup;
> +	}
> +
>  	/*
>  	 * Reset all dynamic address that may have been assigned before
>  	 * (assigned by the bootloader for example).
> @@ -1876,6 +1882,12 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
>  	if (ret && ret != I3C_ERROR_M2)
>  		goto err_bus_cleanup;
>
> +	if (master->ops->set_speed) {
> +		master->ops->set_speed(master, I3C_OPEN_DRAIN_NORMAL_SPEED);
> +		if (ret)
> +			goto err_bus_cleanup;
> +	}
> +
>  	/* Disable all slave events before starting DAA. */
>  	ret = i3c_master_disec_locked(master, I3C_BROADCAST_ADDR,
>  				      I3C_CCC_EVENT_SIR | I3C_CCC_EVENT_MR |
> diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
> index 074f632868d9..2a1ed05d5782 100644
> --- a/include/linux/i3c/master.h
> +++ b/include/linux/i3c/master.h
> @@ -277,6 +277,20 @@ enum i3c_bus_mode {
>  	I3C_BUS_MODE_MIXED_SLOW,
>  };
>
> +/**
> + * enum i3c_open_drain_speed - I3C open-drain speed
> + * @I3C_OPEN_DRAIN_SLOW_SPEED: Slow open-drain speed for sending the first
> + *				broadcast address. The first broadcast address at this speed
> + *				will be visible to all devices on the I3C bus. I3C devices
> + *				working in I2C mode will turn off their spike filter when
> + *				switching into I3C mode.
> + * @I3C_OPEN_DRAIN_NORMAL_SPEED: Normal open-drain speed in I3C bus mode.
> + */
> +enum i3c_open_drain_speed {
> +	I3C_OPEN_DRAIN_SLOW_SPEED,
> +	I3C_OPEN_DRAIN_NORMAL_SPEED,
> +};
> +
>  /**
>   * enum i3c_addr_slot_status - I3C address slot status
>   * @I3C_ADDR_SLOT_FREE: address is free
> @@ -436,6 +450,7 @@ struct i3c_bus {
>   *		      NULL.
>   * @enable_hotjoin: enable hot join event detect.
>   * @disable_hotjoin: disable hot join event detect.
> + * @set_speed: adjust I3C open drain mode timing.
>   */
>  struct i3c_master_controller_ops {
>  	int (*bus_init)(struct i3c_master_controller *master);
> @@ -464,6 +479,7 @@ struct i3c_master_controller_ops {
>  				 struct i3c_ibi_slot *slot);
>  	int (*enable_hotjoin)(struct i3c_master_controller *master);
>  	int (*disable_hotjoin)(struct i3c_master_controller *master);
> +	int (*set_speed)(struct i3c_master_controller *master, enum i3c_open_drain_speed speed);
>  };
>
>  /**
> --
> 2.34.1
>
Frank Li Sept. 16, 2024, 3:22 p.m. UTC | #2
On Mon, Sep 16, 2024 at 11:13:08AM -0400, Frank Li wrote:
> On Tue, Sep 10, 2024 at 01:16:25PM +0800, carlos.song@nxp.com wrote:
> > From: Carlos Song <carlos.song@nxp.com>
> >
> > According to I3C spec 6.2 Timing Specification, the Open Drain High Period
> > of SCL Clock timing for first broadcast address should be adjusted to 200ns
> > at least. I3C device working as i2c device will see the broadcast to close
> > its Spike Filter then change to work at I3C mode. After that I3C open drain
> > SCL high level should be adjusted back.
> >
> > Signed-off-by: Carlos Song <carlos.song@nxp.com>
> > Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > Reviewed-by: Frank Li <Frank.Li@nxp.com>
> > ---
>
> Alex:
> 	I saw v6.11 tag, These two patches is critical for imx93-9x9-evk
> boards. without these two patch, all i3c devices can't be proble. I am
> sure if there still have chance to get merged for 6.12.

Sorry, miss 'not'
'I am not sure if there still have chance to get merged for 6.12.'

>
> Frank
>
>
> > Change for V5:
> > - No change. Resend this patch to list after subscribe to mail list.
> > Change for V4:
> > - No change. Send this patch with svc-i3c-master.c fix patch.
> > Change for V3:
> > - Modify comments from Miquel's suggestion
> > Change for V2:
> > - Fix set_speed description from Frank's comment
> > ---
> >  drivers/i3c/master.c       | 12 ++++++++++++
> >  include/linux/i3c/master.h | 16 ++++++++++++++++
> >  2 files changed, 28 insertions(+)
> >
> > diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> > index 7028f03c2c42..6f3eb710a75d 100644
> > --- a/drivers/i3c/master.c
> > +++ b/drivers/i3c/master.c
> > @@ -1868,6 +1868,12 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
> >  		goto err_bus_cleanup;
> >  	}
> >
> > +	if (master->ops->set_speed) {
> > +		ret = master->ops->set_speed(master, I3C_OPEN_DRAIN_SLOW_SPEED);
> > +		if (ret)
> > +			goto err_bus_cleanup;
> > +	}
> > +
> >  	/*
> >  	 * Reset all dynamic address that may have been assigned before
> >  	 * (assigned by the bootloader for example).
> > @@ -1876,6 +1882,12 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
> >  	if (ret && ret != I3C_ERROR_M2)
> >  		goto err_bus_cleanup;
> >
> > +	if (master->ops->set_speed) {
> > +		master->ops->set_speed(master, I3C_OPEN_DRAIN_NORMAL_SPEED);
> > +		if (ret)
> > +			goto err_bus_cleanup;
> > +	}
> > +
> >  	/* Disable all slave events before starting DAA. */
> >  	ret = i3c_master_disec_locked(master, I3C_BROADCAST_ADDR,
> >  				      I3C_CCC_EVENT_SIR | I3C_CCC_EVENT_MR |
> > diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
> > index 074f632868d9..2a1ed05d5782 100644
> > --- a/include/linux/i3c/master.h
> > +++ b/include/linux/i3c/master.h
> > @@ -277,6 +277,20 @@ enum i3c_bus_mode {
> >  	I3C_BUS_MODE_MIXED_SLOW,
> >  };
> >
> > +/**
> > + * enum i3c_open_drain_speed - I3C open-drain speed
> > + * @I3C_OPEN_DRAIN_SLOW_SPEED: Slow open-drain speed for sending the first
> > + *				broadcast address. The first broadcast address at this speed
> > + *				will be visible to all devices on the I3C bus. I3C devices
> > + *				working in I2C mode will turn off their spike filter when
> > + *				switching into I3C mode.
> > + * @I3C_OPEN_DRAIN_NORMAL_SPEED: Normal open-drain speed in I3C bus mode.
> > + */
> > +enum i3c_open_drain_speed {
> > +	I3C_OPEN_DRAIN_SLOW_SPEED,
> > +	I3C_OPEN_DRAIN_NORMAL_SPEED,
> > +};
> > +
> >  /**
> >   * enum i3c_addr_slot_status - I3C address slot status
> >   * @I3C_ADDR_SLOT_FREE: address is free
> > @@ -436,6 +450,7 @@ struct i3c_bus {
> >   *		      NULL.
> >   * @enable_hotjoin: enable hot join event detect.
> >   * @disable_hotjoin: disable hot join event detect.
> > + * @set_speed: adjust I3C open drain mode timing.
> >   */
> >  struct i3c_master_controller_ops {
> >  	int (*bus_init)(struct i3c_master_controller *master);
> > @@ -464,6 +479,7 @@ struct i3c_master_controller_ops {
> >  				 struct i3c_ibi_slot *slot);
> >  	int (*enable_hotjoin)(struct i3c_master_controller *master);
> >  	int (*disable_hotjoin)(struct i3c_master_controller *master);
> > +	int (*set_speed)(struct i3c_master_controller *master, enum i3c_open_drain_speed speed);
> >  };
> >
> >  /**
> > --
> > 2.34.1
> >
Alexandre Belloni Sept. 17, 2024, 2:58 p.m. UTC | #3
On Tue, 10 Sep 2024 13:16:25 +0800, carlos.song@nxp.com wrote:
> According to I3C spec 6.2 Timing Specification, the Open Drain High Period
> of SCL Clock timing for first broadcast address should be adjusted to 200ns
> at least. I3C device working as i2c device will see the broadcast to close
> its Spike Filter then change to work at I3C mode. After that I3C open drain
> SCL high level should be adjusted back.
> 
> 
> [...]

Applied, thanks!

[1/2] i3c: master: support to adjust first broadcast address speed
      https://git.kernel.org/abelloni/c/aef79e189ba2
[2/2] i3c: master: svc: use slow speed for first broadcast address
      https://git.kernel.org/abelloni/c/20ade67bb164

Best regards,
diff mbox series

Patch

diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 7028f03c2c42..6f3eb710a75d 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -1868,6 +1868,12 @@  static int i3c_master_bus_init(struct i3c_master_controller *master)
 		goto err_bus_cleanup;
 	}
 
+	if (master->ops->set_speed) {
+		ret = master->ops->set_speed(master, I3C_OPEN_DRAIN_SLOW_SPEED);
+		if (ret)
+			goto err_bus_cleanup;
+	}
+
 	/*
 	 * Reset all dynamic address that may have been assigned before
 	 * (assigned by the bootloader for example).
@@ -1876,6 +1882,12 @@  static int i3c_master_bus_init(struct i3c_master_controller *master)
 	if (ret && ret != I3C_ERROR_M2)
 		goto err_bus_cleanup;
 
+	if (master->ops->set_speed) {
+		master->ops->set_speed(master, I3C_OPEN_DRAIN_NORMAL_SPEED);
+		if (ret)
+			goto err_bus_cleanup;
+	}
+
 	/* Disable all slave events before starting DAA. */
 	ret = i3c_master_disec_locked(master, I3C_BROADCAST_ADDR,
 				      I3C_CCC_EVENT_SIR | I3C_CCC_EVENT_MR |
diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
index 074f632868d9..2a1ed05d5782 100644
--- a/include/linux/i3c/master.h
+++ b/include/linux/i3c/master.h
@@ -277,6 +277,20 @@  enum i3c_bus_mode {
 	I3C_BUS_MODE_MIXED_SLOW,
 };
 
+/**
+ * enum i3c_open_drain_speed - I3C open-drain speed
+ * @I3C_OPEN_DRAIN_SLOW_SPEED: Slow open-drain speed for sending the first
+ *				broadcast address. The first broadcast address at this speed
+ *				will be visible to all devices on the I3C bus. I3C devices
+ *				working in I2C mode will turn off their spike filter when
+ *				switching into I3C mode.
+ * @I3C_OPEN_DRAIN_NORMAL_SPEED: Normal open-drain speed in I3C bus mode.
+ */
+enum i3c_open_drain_speed {
+	I3C_OPEN_DRAIN_SLOW_SPEED,
+	I3C_OPEN_DRAIN_NORMAL_SPEED,
+};
+
 /**
  * enum i3c_addr_slot_status - I3C address slot status
  * @I3C_ADDR_SLOT_FREE: address is free
@@ -436,6 +450,7 @@  struct i3c_bus {
  *		      NULL.
  * @enable_hotjoin: enable hot join event detect.
  * @disable_hotjoin: disable hot join event detect.
+ * @set_speed: adjust I3C open drain mode timing.
  */
 struct i3c_master_controller_ops {
 	int (*bus_init)(struct i3c_master_controller *master);
@@ -464,6 +479,7 @@  struct i3c_master_controller_ops {
 				 struct i3c_ibi_slot *slot);
 	int (*enable_hotjoin)(struct i3c_master_controller *master);
 	int (*disable_hotjoin)(struct i3c_master_controller *master);
+	int (*set_speed)(struct i3c_master_controller *master, enum i3c_open_drain_speed speed);
 };
 
 /**