]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i2c: i2c-cdns: Use proper input frequency
authorTomasz Gorochowik <tgorochowik@antmicro.com>
Thu, 3 Jan 2019 12:36:33 +0000 (13:36 +0100)
committerHeiko Schocher <hs@denx.de>
Tue, 15 Jan 2019 08:04:49 +0000 (09:04 +0100)
This is needed to properly calculate i2c bus speed divisors.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
Signed-off-by: Wojciech Tatarski <wtatarski@antmicro.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/i2c/i2c-cdns.c

index 30be173343dd7ba03a8e7b4fe613eb0353888a60..f2c4b2073c48aa552c3679dd3902c20ca5ca7db7 100644 (file)
@@ -17,6 +17,7 @@
 #include <fdtdec.h>
 #include <mapmem.h>
 #include <wait_bit.h>
+#include <clk.h>
 
 /* i2c register set */
 struct cdns_i2c_regs {
@@ -415,6 +416,8 @@ static int cdns_i2c_ofdata_to_platdata(struct udevice *dev)
        struct i2c_cdns_bus *i2c_bus = dev_get_priv(dev);
        struct cdns_i2c_platform_data *pdata =
                (struct cdns_i2c_platform_data *)dev_get_driver_data(dev);
+       struct clk clk;
+       int ret;
 
        i2c_bus->regs = (struct cdns_i2c_regs *)devfdt_get_addr(dev);
        if (!i2c_bus->regs)
@@ -423,7 +426,11 @@ static int cdns_i2c_ofdata_to_platdata(struct udevice *dev)
        if (pdata)
                i2c_bus->quirks = pdata->quirks;
 
-       i2c_bus->input_freq = 100000000; /* TODO hardcode input freq for now */
+       ret = clk_get_by_index(dev, 0, &clk);
+       if (ret)
+               return ret;
+
+       i2c_bus->input_freq = clk_get_rate(&clk);
 
        return 0;
 }