[U-Boot] [PATCH 18/20] serial: uniphier: use clk for enable and get_rate

Masahiro Yamada yamada.masahiro at socionext.com
Fri Oct 13 10:22:07 UTC 2017


Get clock rate from the clock driver to drop U-Boot specific
property "clock-frequency".

Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
---

 drivers/serial/serial_uniphier.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index 68895bd..a9d8b5c 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -6,7 +6,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <common.h>
+#include <clk.h>
 #include <dm.h>
 #include <linux/io.h>
 #include <linux/serial_reg.h>
@@ -90,11 +90,12 @@ static int uniphier_serial_pending(struct udevice *dev, bool input)
 
 static int uniphier_serial_probe(struct udevice *dev)
 {
-	DECLARE_GLOBAL_DATA_PTR;
 	struct uniphier_serial_private_data *priv = dev_get_priv(dev);
 	struct uniphier_serial __iomem *port;
+	struct clk clk;
 	fdt_addr_t base;
 	u32 tmp;
+	int ret;
 
 	base = devfdt_get_addr(dev);
 	if (base == FDT_ADDR_T_NONE)
@@ -106,8 +107,15 @@ static int uniphier_serial_probe(struct udevice *dev)
 
 	priv->membase = port;
 
-	priv->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
-				       "clock-frequency", 0);
+	ret = clk_get_by_index(dev, 0, &clk);
+	if (ret)
+		return ret;
+
+	ret = clk_enable(&clk);
+	if (ret)
+		return ret;
+
+	priv->uartclk = clk_get_rate(&clk);
 
 	tmp = readl(&port->lcr_mcr);
 	tmp &= ~LCR_MASK;
-- 
2.7.4



More information about the U-Boot mailing list