2024-02-01 04:47:58

by Aahil Awatramani

[permalink] [raw]
Subject: [PATCH 2/2] i2c: designware: allow fine tuning tuning waveform from device tree

The Synopsys i2c driver allows a user to override the parameters
controlling the waveform using ACPI; this is useful for fine tuning when
needed to make spec compliance. Extend this support to the device tree to
allow non-ACPI platforms the same capabilities.

Signed-off-by: Aahil Awatramani <[email protected]>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 855b698e99c0..09c464874fdb 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -132,6 +132,17 @@ static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev)
return 0;
}

+static void i2c_parse_cnt(struct device *dev, char *prop_name, u16 *cnt)
+{
+ u32 tmp_cnt;
+ int ret;
+
+ ret = device_property_read_u32(dev, prop_name, &tmp_cnt);
+ if (ret)
+ return;
+ *cnt = tmp_cnt;
+}
+
static int dw_i2c_of_configure(struct platform_device *pdev)
{
struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
@@ -146,6 +157,15 @@ static int dw_i2c_of_configure(struct platform_device *pdev)
break;
}

+ i2c_parse_cnt(&pdev->dev, "i2c-scl-ss-hcnt", &dev->ss_hcnt);
+ i2c_parse_cnt(&pdev->dev, "i2c-scl-ss-lcnt", &dev->ss_lcnt);
+ i2c_parse_cnt(&pdev->dev, "i2c-scl-fs-hcnt", &dev->fs_hcnt);
+ i2c_parse_cnt(&pdev->dev, "i2c-scl-fs-lcnt", &dev->fs_lcnt);
+ i2c_parse_cnt(&pdev->dev, "i2c-scl-fp-hcnt", &dev->fp_hcnt);
+ i2c_parse_cnt(&pdev->dev, "i2c-scl-fp-lcnt", &dev->fp_lcnt);
+ i2c_parse_cnt(&pdev->dev, "i2c-scl-hs-hcnt", &dev->hs_hcnt);
+ i2c_parse_cnt(&pdev->dev, "i2c-scl-hs-lcnt", &dev->hs_lcnt);
+
return 0;
}

--
2.43.0.429.g432eaa2c6b-goog



2024-02-01 07:35:49

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 2/2] i2c: designware: allow fine tuning tuning waveform from device tree

On 01/02/2024 05:46, Aahil Awatramani wrote:
>
> +static void i2c_parse_cnt(struct device *dev, char *prop_name, u16 *cnt)
> +{
> + u32 tmp_cnt;
> + int ret;
> +
> + ret = device_property_read_u32(dev, prop_name, &tmp_cnt);
> + if (ret)
> + return;
> + *cnt = tmp_cnt;
> +}
> +
> static int dw_i2c_of_configure(struct platform_device *pdev)
> {
> struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
> @@ -146,6 +157,15 @@ static int dw_i2c_of_configure(struct platform_device *pdev)
> break;
> }
>
> + i2c_parse_cnt(&pdev->dev, "i2c-scl-ss-hcnt", &dev->ss_hcnt);

Please post your DTS and post results of testing it against bindings.

Best regards,
Krzysztof