bcm27xx: update 6.1 patches to latest version
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-6.1 / 950-1226-i2c-designware-Look-for-CNT-values-in-DT.patch
1 From 0a09088e24c013ef608b1bb79501ef890cefc767 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Tue, 19 Dec 2023 11:16:25 +0000
4 Subject: [PATCH] i2c: designware: Look for *CNT values in DT
5
6 The i2c-designware driver supports reading precise timing values from
7 ACPI, but the Device Tree support relies on a combination of standard
8 rise and fall times and hard-coded minimum timings. The result of this
9 is that it is difficult to get optimum timings, particularly given that
10 the values are bus speed-specific and only one set can be stored in
11 DT at a time.
12
13 Add support for initialisation from DT that is similar to that for
14 ACPI.
15
16 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
17 ---
18 drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++++++++++
19 1 file changed, 18 insertions(+)
20
21 --- a/drivers/i2c/busses/i2c-designware-platdrv.c
22 +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
23 @@ -132,9 +132,18 @@ static int mscc_twi_set_sda_hold_time(st
24 return 0;
25 }
26
27 +static void dw_i2c_read_of_cnt(struct device_node *np, const char *name, u16 *pval)
28 +{
29 + u32 val;
30 +
31 + if (!of_property_read_u32(np, name, &val))
32 + *pval = (u16)val;
33 +}
34 +
35 static int dw_i2c_of_configure(struct platform_device *pdev)
36 {
37 struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
38 + struct device_node *np = pdev->dev.of_node;
39
40 switch (dev->flags & MODEL_MASK) {
41 case MODEL_MSCC_OCELOT:
42 @@ -146,6 +155,15 @@ static int dw_i2c_of_configure(struct pl
43 break;
44 }
45
46 + dw_i2c_read_of_cnt(np, "snps,ss_hcnt", &dev->ss_hcnt);
47 + dw_i2c_read_of_cnt(np, "snps,ss_lcnt", &dev->ss_lcnt);
48 + dw_i2c_read_of_cnt(np, "snps,fs_hcnt", &dev->fs_hcnt);
49 + dw_i2c_read_of_cnt(np, "snps,fs_lcnt", &dev->fs_lcnt);
50 + dw_i2c_read_of_cnt(np, "snps,fp_hcnt", &dev->fp_hcnt);
51 + dw_i2c_read_of_cnt(np, "snps,fp_lcnt", &dev->fp_lcnt);
52 + dw_i2c_read_of_cnt(np, "snps,hs_hcnt", &dev->hs_hcnt);
53 + dw_i2c_read_of_cnt(np, "snps,hs_lcnt", &dev->hs_lcnt);
54 +
55 return 0;
56 }
57