MTD: mxs_nand: Fix BCH read timeout error on boards requiring ECC
[platform/kernel/u-boot.git] / drivers / i2c / i2c-cdns.c
index 8265ce3..4330d28 100644 (file)
@@ -1,11 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2015 Moritz Fischer <moritz.fischer@ettus.com>
  * IP from Cadence (ID T-CS-PE-0007-100, Version R1p10f2)
  *
  * This file is based on: drivers/i2c/zynq_i2c.c,
  * with added driver-model support and code cleanup.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -18,8 +17,7 @@
 #include <fdtdec.h>
 #include <mapmem.h>
 #include <wait_bit.h>
-
-DECLARE_GLOBAL_DATA_PTR;
+#include <clk.h>
 
 /* i2c register set */
 struct cdns_i2c_regs {
@@ -418,15 +416,21 @@ 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);
+       i2c_bus->regs = (struct cdns_i2c_regs *)dev_read_addr(dev);
        if (!i2c_bus->regs)
                return -ENOMEM;
 
        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;
 }