From c5f10f9d857215319c015af3673fadfe1ff3de34 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Fri, 31 Mar 2017 14:46:26 -0500 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/19064 Reviewed-by: Duncan Laurie Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- src/soc/intel/common/lpss_i2c.c | 9 ++++++++- src/soc/intel/common/lpss_i2c.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) 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]; };