Skip to content

Commit 35eba18

Browse files
wanahmadzainieWolfram Sang
authored andcommitted
i2c: designware: Calculate SCL timing parameter for High Speed Mode
Custom parameters for HCNT/LCNT are not available for OF based system. Thus, we will use existing SCL timing parameter calculation functions for High Speed Mode too. The value for the parameters tSYMBOL and tLOW is taken from DesignWare DW_apb_i2c Databook v2.01a, section 3.15.4.6. The calculation should assume higher bus load since it gives slower timing parameter. Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent 85f8fca commit 35eba18

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,22 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
129129
dev->master_cfg |= DW_IC_CON_SPEED_FAST;
130130
dev->hs_hcnt = 0;
131131
dev->hs_lcnt = 0;
132-
} else if (dev->hs_hcnt && dev->hs_lcnt) {
133-
dev_dbg(dev->dev, "High Speed Mode HCNT:LCNT = %d:%d\n",
134-
dev->hs_hcnt, dev->hs_lcnt);
132+
} else if (!dev->hs_hcnt || !dev->hs_lcnt) {
133+
ic_clk = i2c_dw_clk_rate(dev);
134+
dev->hs_hcnt =
135+
i2c_dw_scl_hcnt(ic_clk,
136+
160, /* tHIGH = 160 ns */
137+
sda_falling_time,
138+
0, /* DW default */
139+
0); /* No offset */
140+
dev->hs_lcnt =
141+
i2c_dw_scl_lcnt(ic_clk,
142+
320, /* tLOW = 320 ns */
143+
scl_falling_time,
144+
0); /* No offset */
135145
}
146+
dev_dbg(dev->dev, "High Speed Mode HCNT:LCNT = %d:%d\n",
147+
dev->hs_hcnt, dev->hs_lcnt);
136148
}
137149

138150
ret = i2c_dw_set_sda_hold(dev);

0 commit comments

Comments
 (0)