summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom <support@vamrs.com>2021-01-07 22:25:24 +0300
committerFu Wei <fu.wei@linaro.org>2021-04-19 21:31:18 +0300
commitfa93bc89e51017a8dcd5f30fee4d7ecb9f00e43a (patch)
tree292f93ac17b61a11f4615682ed0605f90d777979
parentb13f90700b72d4fbdceea046d3b50780f2e7a8ce (diff)
downloadlinux-fa93bc89e51017a8dcd5f30fee4d7ecb9f00e43a.tar.xz
drivers/i2c: Improve Synopsys DesignWare I2C adapter driver for StarFive VIC7100
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 0dfeb2d11603..420a3d41526b 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -40,6 +40,21 @@ static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
return clk_get_rate(dev->clk)/1000;
}
+#ifdef CONFIG_SOC_STARFIVE_VIC7100
+static u32 starfive_i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
+{
+ u32 val;
+
+ if(!device_property_read_u32(dev->dev, "clocks", &val)) {
+ dev_info(dev->dev, "Using 'clocks' : %u / 1000", val);
+ return (val / 1000);
+ } else {
+ dev_info(dev->dev, "Using the static setting value: 49500");
+ return 49500;
+ }
+}
+#endif
+
#ifdef CONFIG_ACPI
static const struct acpi_device_id dw_i2c_acpi_match[] = {
{ "INT33C2", 0 },
@@ -276,6 +291,18 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
if (!dev->sda_hold_time && t->sda_hold_ns)
dev->sda_hold_time =
div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000);
+#ifdef CONFIG_SOC_STARFIVE_VIC7100
+ } else {
+ u64 clk_khz;
+
+ dev->get_clk_rate_khz = starfive_i2c_dw_get_clk_rate_khz;
+ clk_khz = dev->get_clk_rate_khz(dev);
+
+ if (!dev->sda_hold_time && t->sda_hold_ns)
+ dev->sda_hold_time =
+ div_u64(clk_khz * t->sda_hold_ns + 500000,
+ 1000000);
+#endif
}
adap = &dev->adapter;