All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] serial: sh: Use the clock framework to obtain clock config
@ 2017-07-21 21:19 Marek Vasut
  2017-08-02 23:15 ` Nobuhiro Iwamatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2017-07-21 21:19 UTC (permalink / raw)
  To: u-boot

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>
---
 drivers/serial/serial_sh.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
index 51f7fbcfb7..087785f9a2 100644
--- a/drivers/serial/serial_sh.c
+++ b/drivers/serial/serial_sh.c
@@ -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;
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] serial: sh: Use the clock framework to obtain clock config
  2017-07-21 21:19 [U-Boot] [PATCH] serial: sh: Use the clock framework to obtain clock config Marek Vasut
@ 2017-08-02 23:15 ` Nobuhiro Iwamatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Nobuhiro Iwamatsu @ 2017-08-02 23:15 UTC (permalink / raw)
  To: u-boot

Applied, thanks!

2017-07-22 6:19 GMT+09:00 Marek Vasut <marek.vasut@gmail.com>:
> 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>
> ---
>  drivers/serial/serial_sh.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
> index 51f7fbcfb7..087785f9a2 100644
> --- a/drivers/serial/serial_sh.c
> +++ b/drivers/serial/serial_sh.c
> @@ -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;
>  }
> --
> 2.11.0
>



-- 
Nobuhiro Iwamatsu
   iwamatsu at {nigauri.org / debian.org}
   GPG ID: 40AD1FA6

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-02 23:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-21 21:19 [U-Boot] [PATCH] serial: sh: Use the clock framework to obtain clock config Marek Vasut
2017-08-02 23:15 ` Nobuhiro Iwamatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.