]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
serial: sh: Use the clock framework to obtain clock config
authorMarek Vasut <marek.vasut@gmail.com>
Fri, 21 Jul 2017 21:19:18 +0000 (23:19 +0200)
committerNobuhiro Iwamatsu <iwamatsu@nigauri.org>
Wed, 2 Aug 2017 19:26:25 +0000 (04:26 +0900)
Since we now have clock driver on the RCar Gen3 , obtain the clock
configuration using the clock framework functions. In case this
fails, fall back to the original code for pulling the clock config
directly out of OF.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
drivers/serial/serial_sh.c

index 51f7fbcfb795ee502e8ca55e5e0c61cd7a9d3d58..087785f9a249ef7151456ae46b9d09d53db70d54 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <errno.h>
+#include <clk.h>
 #include <dm.h>
 #include <asm/io.h>
 #include <asm/processor.h>
@@ -214,15 +215,23 @@ static const struct udevice_id sh_serial_id[] ={
 static int sh_serial_ofdata_to_platdata(struct udevice *dev)
 {
        struct sh_serial_platdata *plat = dev_get_platdata(dev);
+       struct clk sh_serial_clk;
        fdt_addr_t addr;
+       int ret;
 
        addr = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), "reg");
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
        plat->base = addr;
-       plat->clk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
-                                  1);
+
+       ret = clk_get_by_name(dev, "fck", &sh_serial_clk);
+       if (!ret)
+               plat->clk = clk_get_rate(&sh_serial_clk);
+       else
+               plat->clk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+                                          "clock", 1);
+
        plat->type = dev_get_driver_data(dev);
        return 0;
 }