[18/20] serial: uniphier: use clk for enable and get_rate

Message ID 1507890129-1543-19-git-send-email-yamada.masahiro@socionext.com
State New
Headers show
Series
  • ARM: uniphier: various refactoring for v2017.11-rc2
Related show

Commit Message

Masahiro Yamada Oct. 13, 2017, 10:22 a.m.
Get clock rate from the clock driver to drop U-Boot specific
property "clock-frequency".

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

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

Patch

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;