diff options
author | Aaron Durbin <adurbin@chromium.org> | 2017-03-31 14:46:26 -0500 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2017-04-05 16:10:14 +0200 |
commit | c5f10f9d857215319c015af3673fadfe1ff3de34 (patch) | |
tree | 6e3c13205e4fd50c63724c72459f28a28a6bfbd4 | |
parent | ba22e159bb21549ba92eb6e9d91eaa097a54985b (diff) |
soc/intel/common: allow lpss i2c time-based data hold time
When using rise_time_ns and fall_time_ns there's currently not
a way to specify a target data hold time. The internal 300ns
value is used. However, that isn't always sufficient depending on
bus topology. Therefore, provide the ability to specify data
hold time in ns from devicetree, defaulting to default value if
none are specified.
BUG=b:36469182
Change-Id: I86de095186ee396099709cc8a97240bd2f9722c9
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/19064
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Tested-by: build bot (Jenkins)
Reviewed-by: Furquan Shaikh <furquan@google.com>
-rw-r--r-- | src/soc/intel/common/lpss_i2c.c | 9 | ||||
-rw-r--r-- | src/soc/intel/common/lpss_i2c.h | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/soc/intel/common/lpss_i2c.c b/src/soc/intel/common/lpss_i2c.c index 8dfa3af365..19fda4c703 100644 --- a/src/soc/intel/common/lpss_i2c.c +++ b/src/soc/intel/common/lpss_i2c.c @@ -527,6 +527,7 @@ static int lpss_i2c_gen_config_rise_fall_time(struct lpss_i2c_regs *regs, const struct soc_clock *soc; int fall_cnt, rise_cnt, min_tlow_cnt, min_thigh_cnt, spk_cnt; int hcnt, lcnt, period_cnt, diff, tot; + int data_hold_time_ns; bus = get_bus_descriptor(speed); soc = get_soc_descriptor(ic_clk); @@ -591,7 +592,13 @@ static int lpss_i2c_gen_config_rise_fall_time(struct lpss_i2c_regs *regs, config->speed = speed; config->scl_lcnt = lcnt; config->scl_hcnt = hcnt; - config->sda_hold = counts_from_time(&soc->freq, DEFAULT_SDA_HOLD_TIME); + + /* Use internal default unless other value is specified. */ + data_hold_time_ns = DEFAULT_SDA_HOLD_TIME; + if (bcfg->data_hold_time_ns) + data_hold_time_ns = bcfg->data_hold_time_ns; + + config->sda_hold = counts_from_time(&soc->freq, data_hold_time_ns); printk(LPSS_DEBUG, "lpss_i2c: hcnt = %d lcnt = %d sda hold = %d\n", hcnt, lcnt, config->sda_hold); diff --git a/src/soc/intel/common/lpss_i2c.h b/src/soc/intel/common/lpss_i2c.h index dbfabf3631..b9517701f6 100644 --- a/src/soc/intel/common/lpss_i2c.h +++ b/src/soc/intel/common/lpss_i2c.h @@ -61,6 +61,7 @@ struct lpss_i2c_bus_config { * precedence. */ int rise_time_ns; int fall_time_ns; + int data_hold_time_ns; /* Specific bus speed configuration */ struct lpss_i2c_speed_config speed_config[LPSS_I2C_SPEED_CONFIG_COUNT]; }; |