Skip to content

Commit 86bdd8e

Browse files
andy-shevAndi Shyti
authored andcommitted
i2c: designware: Remove 'cond' from i2c_dw_scl_hcnt()
The 'cond' parameter is not being used (always default, hence drop it and hence make it consistent with i2c_dw_scl_lcnt(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent dd05a76 commit 86bdd8e

3 files changed

Lines changed: 16 additions & 42 deletions

File tree

drivers/i2c/busses/i2c-designware-common.c

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -407,47 +407,26 @@ static u32 i2c_dw_read_scl_reg(struct dw_i2c_dev *dev, u32 reg)
407407
}
408408

409409
u32 i2c_dw_scl_hcnt(struct dw_i2c_dev *dev, unsigned int reg, u32 ic_clk,
410-
u32 tSYMBOL, u32 tf, int cond, int offset)
410+
u32 tSYMBOL, u32 tf, int offset)
411411
{
412412
if (!ic_clk)
413413
return i2c_dw_read_scl_reg(dev, reg);
414414

415415
/*
416-
* DesignWare I2C core doesn't seem to have solid strategy to meet
417-
* the tHD;STA timing spec. Configuring _HCNT based on tHIGH spec
418-
* will result in violation of the tHD;STA spec.
416+
* Conditional expression:
417+
*
418+
* IC_[FS]S_SCL_HCNT + 3 >= IC_CLK * (tHD;STA + tf)
419+
*
420+
* This is just experimental rule; the tHD;STA period turned
421+
* out to be proportinal to (_HCNT + 3). With this setting,
422+
* we could meet both tHIGH and tHD;STA timing specs.
423+
*
424+
* If unsure, you'd better to take this alternative.
425+
*
426+
* The reason why we need to take into account "tf" here,
427+
* is the same as described in i2c_dw_scl_lcnt().
419428
*/
420-
if (cond)
421-
/*
422-
* Conditional expression:
423-
*
424-
* IC_[FS]S_SCL_HCNT + (1+4+3) >= IC_CLK * tHIGH
425-
*
426-
* This is based on the DW manuals, and represents an ideal
427-
* configuration. The resulting I2C bus speed will be
428-
* faster than any of the others.
429-
*
430-
* If your hardware is free from tHD;STA issue, try this one.
431-
*/
432-
return DIV_ROUND_CLOSEST_ULL((u64)ic_clk * tSYMBOL, MICRO) -
433-
8 + offset;
434-
else
435-
/*
436-
* Conditional expression:
437-
*
438-
* IC_[FS]S_SCL_HCNT + 3 >= IC_CLK * (tHD;STA + tf)
439-
*
440-
* This is just experimental rule; the tHD;STA period turned
441-
* out to be proportinal to (_HCNT + 3). With this setting,
442-
* we could meet both tHIGH and tHD;STA timing specs.
443-
*
444-
* If unsure, you'd better to take this alternative.
445-
*
446-
* The reason why we need to take into account "tf" here,
447-
* is the same as described in i2c_dw_scl_lcnt().
448-
*/
449-
return DIV_ROUND_CLOSEST_ULL((u64)ic_clk * (tSYMBOL + tf), MICRO) -
450-
3 + offset;
429+
return DIV_ROUND_CLOSEST_ULL((u64)ic_clk * (tSYMBOL + tf), MICRO) - 3 + offset;
451430
}
452431

453432
u32 i2c_dw_scl_lcnt(struct dw_i2c_dev *dev, unsigned int reg, u32 ic_clk,
@@ -467,8 +446,7 @@ u32 i2c_dw_scl_lcnt(struct dw_i2c_dev *dev, unsigned int reg, u32 ic_clk,
467446
* account the fall time of SCL signal (tf). Default tf value
468447
* should be 0.3 us, for safety.
469448
*/
470-
return DIV_ROUND_CLOSEST_ULL((u64)ic_clk * (tLOW + tf), MICRO) -
471-
1 + offset;
449+
return DIV_ROUND_CLOSEST_ULL((u64)ic_clk * (tLOW + tf), MICRO) - 1 + offset;
472450
}
473451

474452
int i2c_dw_set_sda_hold(struct dw_i2c_dev *dev)

drivers/i2c/busses/i2c-designware-core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ struct i2c_dw_semaphore_callbacks {
329329

330330
int i2c_dw_init_regmap(struct dw_i2c_dev *dev);
331331
u32 i2c_dw_scl_hcnt(struct dw_i2c_dev *dev, unsigned int reg, u32 ic_clk,
332-
u32 tSYMBOL, u32 tf, int cond, int offset);
332+
u32 tSYMBOL, u32 tf, int offset);
333333
u32 i2c_dw_scl_lcnt(struct dw_i2c_dev *dev, unsigned int reg, u32 ic_clk,
334334
u32 tLOW, u32 tf, int offset);
335335
int i2c_dw_set_sda_hold(struct dw_i2c_dev *dev);

drivers/i2c/busses/i2c-designware-master.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
7171
ic_clk,
7272
4000, /* tHD;STA = tHIGH = 4.0 us */
7373
sda_falling_time,
74-
0, /* 0: DW default, 1: Ideal */
7574
0); /* No offset */
7675
dev->ss_lcnt =
7776
i2c_dw_scl_lcnt(dev,
@@ -105,7 +104,6 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
105104
ic_clk,
106105
260, /* tHIGH = 260 ns */
107106
sda_falling_time,
108-
0, /* DW default */
109107
0); /* No offset */
110108
dev->fs_lcnt =
111109
i2c_dw_scl_lcnt(dev,
@@ -129,7 +127,6 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
129127
ic_clk,
130128
600, /* tHD;STA = tHIGH = 0.6 us */
131129
sda_falling_time,
132-
0, /* 0: DW default, 1: Ideal */
133130
0); /* No offset */
134131
dev->fs_lcnt =
135132
i2c_dw_scl_lcnt(dev,
@@ -161,7 +158,6 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
161158
ic_clk,
162159
160, /* tHIGH = 160 ns */
163160
sda_falling_time,
164-
0, /* DW default */
165161
0); /* No offset */
166162
dev->hs_lcnt =
167163
i2c_dw_scl_lcnt(dev,

0 commit comments

Comments
 (0)