diff options
author | Simon Glass <sjg@chromium.org> | 2020-01-23 11:48:15 -0700 |
---|---|---|
committer | Heiko Schocher <hs@denx.de> | 2020-01-27 07:22:01 +0100 |
commit | 96fe11c3dace9038e2df0e7c4625d1c3e330425f (patch) | |
tree | 031e52df4c897ca563ccf299ba16b2eaa7fe53bd /drivers/i2c/designware_i2c.c | |
parent | e71b6f6622d6a3380d866943799f36e473a3cd9b (diff) | |
download | u-boot-96fe11c3dace9038e2df0e7c4625d1c3e330425f.zip u-boot-96fe11c3dace9038e2df0e7c4625d1c3e330425f.tar.gz u-boot-96fe11c3dace9038e2df0e7c4625d1c3e330425f.tar.bz2 |
i2c: designware_i2c: Add spike supression
Some versions of this peripheral include a spike-suppression phase of the
bus. Add support for this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c/designware_i2c.c')
-rw-r--r-- | drivers/i2c/designware_i2c.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index 0069602..4aee25c 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -220,6 +220,7 @@ static unsigned int __dw_i2c_set_bus_speed(struct dw_i2c *priv, enum i2c_speed_mode i2c_spd; unsigned int cntl; unsigned int ena; + int spk_cnt; int ret; if (priv) @@ -241,6 +242,13 @@ static unsigned int __dw_i2c_set_bus_speed(struct dw_i2c *priv, cntl = (readl(&i2c_base->ic_con) & (~IC_CON_SPD_MSK)); + /* Get the proper spike-suppression count based on target speed */ + if (!priv || !priv->has_spk_cnt) + spk_cnt = 0; + else if (i2c_spd >= IC_SPEED_MODE_HIGH) + spk_cnt = readl(&i2c_base->hs_spklen); + else + spk_cnt = readl(&i2c_base->fs_spklen); if (scl_sda_cfg) { config.sda_hold = scl_sda_cfg->sda_hold; if (i2c_spd == IC_SPEED_MODE_STANDARD) { @@ -251,7 +259,7 @@ static unsigned int __dw_i2c_set_bus_speed(struct dw_i2c *priv, config.scl_lcnt = scl_sda_cfg->fs_lcnt; } } else { - ret = dw_i2c_calc_timing(priv, i2c_spd, bus_clk, 0, + ret = dw_i2c_calc_timing(priv, i2c_spd, bus_clk, spk_cnt, &config); if (ret) return log_msg_ret("gen_confg", ret); |