Skip to content

Commit 0a09088

Browse files
committed
i2c: designware: Look for *CNT values in DT
The i2c-designware driver supports reading precise timing values from ACPI, but the Device Tree support relies on a combination of standard rise and fall times and hard-coded minimum timings. The result of this is that it is difficult to get optimum timings, particularly given that the values are bus speed-specific and only one set can be stored in DT at a time. Add support for initialisation from DT that is similar to that for ACPI. Signed-off-by: Phil Elwell <[email protected]>
1 parent da5fd98 commit 0a09088

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,18 @@ static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
132132
return 0;
133133
}
134134

135+
static void dw_i2c_read_of_cnt(struct device_node *np, const char *name, u16 *pval)
136+
{
137+
u32 val;
138+
139+
if (!of_property_read_u32(np, name, &val))
140+
*pval = (u16)val;
141+
}
142+
135143
static int dw_i2c_of_configure(struct platform_device *pdev)
136144
{
137145
struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
146+
struct device_node *np = pdev->dev.of_node;
138147

139148
switch (dev->flags & MODEL_MASK) {
140149
case MODEL_MSCC_OCELOT:
@@ -146,6 +155,15 @@ static int dw_i2c_of_configure(struct platform_device *pdev)
146155
break;
147156
}
148157

158+
dw_i2c_read_of_cnt(np, "snps,ss_hcnt", &dev->ss_hcnt);
159+
dw_i2c_read_of_cnt(np, "snps,ss_lcnt", &dev->ss_lcnt);
160+
dw_i2c_read_of_cnt(np, "snps,fs_hcnt", &dev->fs_hcnt);
161+
dw_i2c_read_of_cnt(np, "snps,fs_lcnt", &dev->fs_lcnt);
162+
dw_i2c_read_of_cnt(np, "snps,fp_hcnt", &dev->fp_hcnt);
163+
dw_i2c_read_of_cnt(np, "snps,fp_lcnt", &dev->fp_lcnt);
164+
dw_i2c_read_of_cnt(np, "snps,hs_hcnt", &dev->hs_hcnt);
165+
dw_i2c_read_of_cnt(np, "snps,hs_lcnt", &dev->hs_lcnt);
166+
149167
return 0;
150168
}
151169

0 commit comments

Comments
 (0)