Re: [PATCH v4 1/4] i3c: Standardize defines for specification parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 22, 2025 at 09:07:43PM +0200, Wolfram Sang wrote:
> Align existing defines to follow the consistent pattern:
> I3C_BUS_<PARAM>_<MAX|MIN|TYP>_<UNIT>. Prepare the codebase for adding
> new parameters and help avoid duplication.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
> ---
> Changes since v3:
> * Reworded commit message
> * added version of spec and chapter number to the comment
>
> I added the chapter number to the main comment because it is applicable
> for all the values here and the next patch. I thought it doesn't make
> sense to repeat it all over for each value.

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

>
>  drivers/i3c/master.c               | 12 ++++++------
>  drivers/i3c/master/dw-i3c-master.c |  4 ++--
>  include/linux/i3c/master.h         |  9 +++++----
>  3 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index ffb734d378e2..6a2594dc29e6 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -728,12 +728,12 @@ static int i3c_bus_set_mode(struct i3c_bus *i3cbus, enum i3c_bus_mode mode,
>  	switch (i3cbus->mode) {
>  	case I3C_BUS_MODE_PURE:
>  		if (!i3cbus->scl_rate.i3c)
> -			i3cbus->scl_rate.i3c = I3C_BUS_TYP_I3C_SCL_RATE;
> +			i3cbus->scl_rate.i3c = I3C_BUS_I3C_SCL_TYP_RATE;
>  		break;
>  	case I3C_BUS_MODE_MIXED_FAST:
>  	case I3C_BUS_MODE_MIXED_LIMITED:
>  		if (!i3cbus->scl_rate.i3c)
> -			i3cbus->scl_rate.i3c = I3C_BUS_TYP_I3C_SCL_RATE;
> +			i3cbus->scl_rate.i3c = I3C_BUS_I3C_SCL_TYP_RATE;
>  		if (!i3cbus->scl_rate.i2c)
>  			i3cbus->scl_rate.i2c = max_i2c_scl_rate;
>  		break;
> @@ -755,8 +755,8 @@ static int i3c_bus_set_mode(struct i3c_bus *i3cbus, enum i3c_bus_mode mode,
>  	 * I3C/I2C frequency may have been overridden, check that user-provided
>  	 * values are not exceeding max possible frequency.
>  	 */
> -	if (i3cbus->scl_rate.i3c > I3C_BUS_MAX_I3C_SCL_RATE ||
> -	    i3cbus->scl_rate.i2c > I3C_BUS_I2C_FM_PLUS_SCL_RATE)
> +	if (i3cbus->scl_rate.i3c > I3C_BUS_I3C_SCL_MAX_RATE ||
> +	    i3cbus->scl_rate.i2c > I3C_BUS_I2C_FM_PLUS_SCL_MAX_RATE)
>  		return -EINVAL;
>
>  	return 0;
> @@ -2786,7 +2786,7 @@ int i3c_master_register(struct i3c_master_controller *master,
>  			const struct i3c_master_controller_ops *ops,
>  			bool secondary)
>  {
> -	unsigned long i2c_scl_rate = I3C_BUS_I2C_FM_PLUS_SCL_RATE;
> +	unsigned long i2c_scl_rate = I3C_BUS_I2C_FM_PLUS_SCL_MAX_RATE;
>  	struct i3c_bus *i3cbus = i3c_master_get_bus(master);
>  	enum i3c_bus_mode mode = I3C_BUS_MODE_PURE;
>  	struct i2c_dev_boardinfo *i2cbi;
> @@ -2845,7 +2845,7 @@ int i3c_master_register(struct i3c_master_controller *master,
>  		}
>
>  		if (i2cbi->lvr & I3C_LVR_I2C_FM_MODE)
> -			i2c_scl_rate = I3C_BUS_I2C_FM_SCL_RATE;
> +			i2c_scl_rate = I3C_BUS_I2C_FM_SCL_MAX_RATE;
>  	}
>
>  	ret = i3c_bus_set_mode(i3cbus, mode, i2c_scl_rate);
> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> index 91429d94a866..dc234efa046d 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -622,14 +622,14 @@ static int dw_i2c_clk_cfg(struct dw_i3c_master *master)
>  	core_period = DIV_ROUND_UP(1000000000, core_rate);
>
>  	lcnt = DIV_ROUND_UP(I3C_BUS_I2C_FMP_TLOW_MIN_NS, core_period);
> -	hcnt = DIV_ROUND_UP(core_rate, I3C_BUS_I2C_FM_PLUS_SCL_RATE) - lcnt;
> +	hcnt = DIV_ROUND_UP(core_rate, I3C_BUS_I2C_FM_PLUS_SCL_MAX_RATE) - lcnt;
>  	scl_timing = SCL_I2C_FMP_TIMING_HCNT(hcnt) |
>  		     SCL_I2C_FMP_TIMING_LCNT(lcnt);
>  	writel(scl_timing, master->regs + SCL_I2C_FMP_TIMING);
>  	master->i2c_fmp_timing = scl_timing;
>
>  	lcnt = DIV_ROUND_UP(I3C_BUS_I2C_FM_TLOW_MIN_NS, core_period);
> -	hcnt = DIV_ROUND_UP(core_rate, I3C_BUS_I2C_FM_SCL_RATE) - lcnt;
> +	hcnt = DIV_ROUND_UP(core_rate, I3C_BUS_I2C_FM_SCL_MAX_RATE) - lcnt;
>  	scl_timing = SCL_I2C_FM_TIMING_HCNT(hcnt) |
>  		     SCL_I2C_FM_TIMING_LCNT(lcnt);
>  	writel(scl_timing, master->regs + SCL_I2C_FM_TIMING);
> diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
> index c67922ece617..7dfcbe530515 100644
> --- a/include/linux/i3c/master.h
> +++ b/include/linux/i3c/master.h
> @@ -249,10 +249,11 @@ struct i3c_device {
>   */
>  #define I3C_BUS_MAX_DEVS		11
>
> -#define I3C_BUS_MAX_I3C_SCL_RATE	12900000
> -#define I3C_BUS_TYP_I3C_SCL_RATE	12500000
> -#define I3C_BUS_I2C_FM_PLUS_SCL_RATE	1000000
> -#define I3C_BUS_I2C_FM_SCL_RATE		400000
> +/* Taken from the I3C Spec V1.1.1, chapter 6.2. "Timing specification" */
> +#define I3C_BUS_I2C_FM_PLUS_SCL_MAX_RATE	1000000
> +#define I3C_BUS_I2C_FM_SCL_MAX_RATE		400000
> +#define I3C_BUS_I3C_SCL_MAX_RATE	12900000
> +#define I3C_BUS_I3C_SCL_TYP_RATE	12500000
>  #define I3C_BUS_TLOW_OD_MIN_NS		200
>
>  /**
> --
> 2.47.2
>




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux