[PATCH 12/17] serial: stm: Use clk support
Sascha Hauer
s.hauer at pengutronix.de
Thu Jun 20 02:54:16 EDT 2013
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/serial/stm-serial.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/stm-serial.c b/drivers/serial/stm-serial.c
index a1bb733..0d7484f 100644
--- a/drivers/serial/stm-serial.c
+++ b/drivers/serial/stm-serial.c
@@ -29,6 +29,8 @@
#include <gpio.h>
#include <io.h>
#include <malloc.h>
+#include <linux/clk.h>
+#include <linux/err.h>
#include <mach/imx-regs.h>
#include <mach/clock.h>
@@ -56,6 +58,7 @@ struct stm_priv {
int baudrate;
struct notifier_block notify;
void __iomem *base;
+ struct clk *clk;
};
static void stm_serial_putc(struct console_device *cdev, char c)
@@ -107,7 +110,7 @@ static int stm_serial_setbaudrate(struct console_device *cdev, int new_baudrate)
writel(0, priv->base + UARTDBGCR);
/* Calculate and set baudrate */
- quot = (imx_get_xclk() * 4) / new_baudrate;
+ quot = (clk_get_rate(priv->clk) * 4) / new_baudrate;
writel(quot & 0x3f, priv->base + UARTDBGFBRD);
writel(quot >> 6, priv->base + UARTDBGIBRD);
@@ -160,6 +163,9 @@ static int stm_serial_probe(struct device_d *dev)
dev->priv = priv;
priv->base = dev_request_mem_region(dev, 0);
+ priv->clk = clk_get(dev, NULL);
+ if (IS_ERR(priv->clk))
+ return PTR_ERR(priv->clk);
stm_serial_init_port(priv);
stm_serial_setbaudrate(cdev, CONFIG_BAUDRATE);
--
1.8.3.1
More information about the barebox
mailing list