Skip to content

Commit 9c0609d

Browse files
Wolfram Sangalexandrebelloni
authored andcommitted
i3c: Standardize defines for specification parameters
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 <[email protected]> Tested-by: Tommaso Merciai <[email protected]> Reviewed-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 5523a46 commit 9c0609d

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

drivers/i3c/master.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -727,12 +727,12 @@ static int i3c_bus_set_mode(struct i3c_bus *i3cbus, enum i3c_bus_mode mode,
727727
switch (i3cbus->mode) {
728728
case I3C_BUS_MODE_PURE:
729729
if (!i3cbus->scl_rate.i3c)
730-
i3cbus->scl_rate.i3c = I3C_BUS_TYP_I3C_SCL_RATE;
730+
i3cbus->scl_rate.i3c = I3C_BUS_I3C_SCL_TYP_RATE;
731731
break;
732732
case I3C_BUS_MODE_MIXED_FAST:
733733
case I3C_BUS_MODE_MIXED_LIMITED:
734734
if (!i3cbus->scl_rate.i3c)
735-
i3cbus->scl_rate.i3c = I3C_BUS_TYP_I3C_SCL_RATE;
735+
i3cbus->scl_rate.i3c = I3C_BUS_I3C_SCL_TYP_RATE;
736736
if (!i3cbus->scl_rate.i2c)
737737
i3cbus->scl_rate.i2c = max_i2c_scl_rate;
738738
break;
@@ -754,8 +754,8 @@ static int i3c_bus_set_mode(struct i3c_bus *i3cbus, enum i3c_bus_mode mode,
754754
* I3C/I2C frequency may have been overridden, check that user-provided
755755
* values are not exceeding max possible frequency.
756756
*/
757-
if (i3cbus->scl_rate.i3c > I3C_BUS_MAX_I3C_SCL_RATE ||
758-
i3cbus->scl_rate.i2c > I3C_BUS_I2C_FM_PLUS_SCL_RATE)
757+
if (i3cbus->scl_rate.i3c > I3C_BUS_I3C_SCL_MAX_RATE ||
758+
i3cbus->scl_rate.i2c > I3C_BUS_I2C_FM_PLUS_SCL_MAX_RATE)
759759
return -EINVAL;
760760

761761
return 0;
@@ -2787,7 +2787,7 @@ int i3c_master_register(struct i3c_master_controller *master,
27872787
const struct i3c_master_controller_ops *ops,
27882788
bool secondary)
27892789
{
2790-
unsigned long i2c_scl_rate = I3C_BUS_I2C_FM_PLUS_SCL_RATE;
2790+
unsigned long i2c_scl_rate = I3C_BUS_I2C_FM_PLUS_SCL_MAX_RATE;
27912791
struct i3c_bus *i3cbus = i3c_master_get_bus(master);
27922792
enum i3c_bus_mode mode = I3C_BUS_MODE_PURE;
27932793
struct i2c_dev_boardinfo *i2cbi;
@@ -2846,7 +2846,7 @@ int i3c_master_register(struct i3c_master_controller *master,
28462846
}
28472847

28482848
if (i2cbi->lvr & I3C_LVR_I2C_FM_MODE)
2849-
i2c_scl_rate = I3C_BUS_I2C_FM_SCL_RATE;
2849+
i2c_scl_rate = I3C_BUS_I2C_FM_SCL_MAX_RATE;
28502850
}
28512851

28522852
ret = i3c_bus_set_mode(i3cbus, mode, i2c_scl_rate);

drivers/i3c/master/dw-i3c-master.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,14 +605,14 @@ static int dw_i2c_clk_cfg(struct dw_i3c_master *master)
605605
core_period = DIV_ROUND_UP(1000000000, core_rate);
606606

607607
lcnt = DIV_ROUND_UP(I3C_BUS_I2C_FMP_TLOW_MIN_NS, core_period);
608-
hcnt = DIV_ROUND_UP(core_rate, I3C_BUS_I2C_FM_PLUS_SCL_RATE) - lcnt;
608+
hcnt = DIV_ROUND_UP(core_rate, I3C_BUS_I2C_FM_PLUS_SCL_MAX_RATE) - lcnt;
609609
scl_timing = SCL_I2C_FMP_TIMING_HCNT(hcnt) |
610610
SCL_I2C_FMP_TIMING_LCNT(lcnt);
611611
writel(scl_timing, master->regs + SCL_I2C_FMP_TIMING);
612612
master->i2c_fmp_timing = scl_timing;
613613

614614
lcnt = DIV_ROUND_UP(I3C_BUS_I2C_FM_TLOW_MIN_NS, core_period);
615-
hcnt = DIV_ROUND_UP(core_rate, I3C_BUS_I2C_FM_SCL_RATE) - lcnt;
615+
hcnt = DIV_ROUND_UP(core_rate, I3C_BUS_I2C_FM_SCL_MAX_RATE) - lcnt;
616616
scl_timing = SCL_I2C_FM_TIMING_HCNT(hcnt) |
617617
SCL_I2C_FM_TIMING_LCNT(lcnt);
618618
writel(scl_timing, master->regs + SCL_I2C_FM_TIMING);

include/linux/i3c/master.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,11 @@ struct i3c_device {
249249
*/
250250
#define I3C_BUS_MAX_DEVS 11
251251

252-
#define I3C_BUS_MAX_I3C_SCL_RATE 12900000
253-
#define I3C_BUS_TYP_I3C_SCL_RATE 12500000
254-
#define I3C_BUS_I2C_FM_PLUS_SCL_RATE 1000000
255-
#define I3C_BUS_I2C_FM_SCL_RATE 400000
252+
/* Taken from the I3C Spec V1.1.1, chapter 6.2. "Timing specification" */
253+
#define I3C_BUS_I2C_FM_PLUS_SCL_MAX_RATE 1000000
254+
#define I3C_BUS_I2C_FM_SCL_MAX_RATE 400000
255+
#define I3C_BUS_I3C_SCL_MAX_RATE 12900000
256+
#define I3C_BUS_I3C_SCL_TYP_RATE 12500000
256257
#define I3C_BUS_TLOW_OD_MIN_NS 200
257258

258259
/**

0 commit comments

Comments
 (0)