@@ -11,6 +11,7 @@
#include <linux/iopoll.h>
#include <linux/sizes.h>
#include <linux/types.h>
+#include <clk.h>
#include <dm.h>
#include <i2c.h>
#include <fdtdec.h>
@@ -61,8 +62,6 @@ struct uniphier_fi2c_regs {
#define I2C_BRST_RSCLO (1 << 0) /* release SCL low fixing */
};
-#define FIOCLK 50000000
-
struct uniphier_fi2c_priv {
struct udevice *dev;
struct uniphier_fi2c_regs __iomem *regs; /* register base */
@@ -93,6 +92,8 @@ static int uniphier_fi2c_probe(struct udevice *dev)
{
fdt_addr_t addr;
struct uniphier_fi2c_priv *priv = dev_get_priv(dev);
+ struct clk clk;
+ int ret;
addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
@@ -102,7 +103,19 @@ static int uniphier_fi2c_probe(struct udevice *dev)
if (!priv->regs)
return -ENOMEM;
- priv->fioclk = FIOCLK;
+ ret = clk_get_by_index(dev, 0, &clk);
+ if (ret < 0) {
+ dev_err(dev, "failed to get clock\n");
+ return ret;
+ }
+
+ ret = clk_enable(&clk);
+ if (ret) {
+ dev_err(dev, "failed to enable clock\n");
+ return ret;
+ }
+
+ priv->fioclk = clk_get_rate(&clk);
priv->dev = dev;
Get clock rate from the clock driver instead of hard-coding it. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> --- drivers/i2c/i2c-uniphier-f.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)