mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-28 01:28:59 +00:00
58 lines
1.9 KiB
Diff
58 lines
1.9 KiB
Diff
|
From 0a09088e24c013ef608b1bb79501ef890cefc767 Mon Sep 17 00:00:00 2001
|
||
|
From: Phil Elwell <phil@raspberrypi.com>
|
||
|
Date: Tue, 19 Dec 2023 11:16:25 +0000
|
||
|
Subject: [PATCH] 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 <phil@raspberrypi.com>
|
||
|
---
|
||
|
drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++++++++++
|
||
|
1 file changed, 18 insertions(+)
|
||
|
|
||
|
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
|
||
|
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
|
||
|
@@ -132,9 +132,18 @@ static int mscc_twi_set_sda_hold_time(st
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
+static void dw_i2c_read_of_cnt(struct device_node *np, const char *name, u16 *pval)
|
||
|
+{
|
||
|
+ u32 val;
|
||
|
+
|
||
|
+ if (!of_property_read_u32(np, name, &val))
|
||
|
+ *pval = (u16)val;
|
||
|
+}
|
||
|
+
|
||
|
static int dw_i2c_of_configure(struct platform_device *pdev)
|
||
|
{
|
||
|
struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
|
||
|
+ struct device_node *np = pdev->dev.of_node;
|
||
|
|
||
|
switch (dev->flags & MODEL_MASK) {
|
||
|
case MODEL_MSCC_OCELOT:
|
||
|
@@ -146,6 +155,15 @@ static int dw_i2c_of_configure(struct pl
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
+ dw_i2c_read_of_cnt(np, "snps,ss_hcnt", &dev->ss_hcnt);
|
||
|
+ dw_i2c_read_of_cnt(np, "snps,ss_lcnt", &dev->ss_lcnt);
|
||
|
+ dw_i2c_read_of_cnt(np, "snps,fs_hcnt", &dev->fs_hcnt);
|
||
|
+ dw_i2c_read_of_cnt(np, "snps,fs_lcnt", &dev->fs_lcnt);
|
||
|
+ dw_i2c_read_of_cnt(np, "snps,fp_hcnt", &dev->fp_hcnt);
|
||
|
+ dw_i2c_read_of_cnt(np, "snps,fp_lcnt", &dev->fp_lcnt);
|
||
|
+ dw_i2c_read_of_cnt(np, "snps,hs_hcnt", &dev->hs_hcnt);
|
||
|
+ dw_i2c_read_of_cnt(np, "snps,hs_lcnt", &dev->hs_lcnt);
|
||
|
+
|
||
|
return 0;
|
||
|
}
|
||
|
|