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>
This commit is contained in:
Aaron Durbin 2017-03-31 14:46:26 -05:00
parent ba22e159bb
commit c5f10f9d85
2 changed files with 9 additions and 1 deletions

View File

@ -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);

View File

@ -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];
};