From: Frank Li <Frank.li@nxp.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-i3c@lists.infradead.org
Subject: Re: [PATCH v4 1/4] i3c: Standardize defines for specification parameters
Date: Wed, 23 Jul 2025 11:30:29 -0400 [thread overview]
Message-ID: <aIEAFUYaZQmZlFRI@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250722190749.6264-2-wsa+renesas@sang-engineering.com>
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@sang-engineering.com>
> ---
> 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@nxp.com>
>
> 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
>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next prev parent reply other threads:[~2025-07-23 15:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 19:07 [PATCH v4 0/4] i3c: add support for the Renesas controller Wolfram Sang
2025-07-22 19:07 ` [PATCH v4 1/4] i3c: Standardize defines for specification parameters Wolfram Sang
2025-07-23 15:30 ` Frank Li [this message]
2025-07-22 19:07 ` [PATCH v4 2/4] i3c: Add more parameters for controllers to the header Wolfram Sang
2025-07-23 15:32 ` Frank Li
2025-07-23 17:50 ` Wolfram Sang
2025-07-24 9:09 ` Wolfram Sang
2025-07-22 19:07 ` [PATCH v4 3/4] dt-bindings: i3c: Add Renesas I3C controller Wolfram Sang
2025-07-22 19:07 ` [PATCH v4 4/4] i3c: master: Add basic driver for the " Wolfram Sang
2025-07-23 15:33 ` Frank Li
2025-07-23 9:35 ` [PATCH v4 0/4] i3c: add support for the Renesas controller Tommaso Merciai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aIEAFUYaZQmZlFRI@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox