summaryrefslogtreecommitdiffstats
path: root/drivers/serial/serial_imx.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-10-04 15:24:27 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-04 15:24:57 +0200
commit94de405d8f56aa66283d7497c707380762440601 (patch)
treeef6618eb4604ff3cbc69af90d9ec6feb4db5e771 /drivers/serial/serial_imx.c
parentddba7e606bc7a6b3715d6c123c0a9b708a6b8776 (diff)
parentd4edd480b2ab0754361b142e307796405310d34b (diff)
downloadbarebox-94de405d8f56aa66283d7497c707380762440601.tar.gz
Merge branch 'for-next/imx-clk'
Diffstat (limited to 'drivers/serial/serial_imx.c')
-rw-r--r--drivers/serial/serial_imx.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index 61ceb48..a711940 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -16,12 +16,13 @@
#include <common.h>
#include <mach/imx-regs.h>
-#include <mach/clock.h>
#include <driver.h>
#include <init.h>
#include <malloc.h>
#include <notifier.h>
#include <io.h>
+#include <linux/err.h>
+#include <linux/clk.h>
#define URXD0 0x0 /* Receiver Register */
#define URTX0 0x40 /* Transmitter Register */
@@ -170,16 +171,17 @@ struct imx_serial_priv {
int baudrate;
struct notifier_block notify;
void __iomem *regs;
+ struct clk *clk;
};
-static int imx_serial_reffreq(void __iomem *regs)
+static int imx_serial_reffreq(struct imx_serial_priv *priv)
{
ulong rfdiv;
- rfdiv = (readl(regs + UFCR) >> 7) & 7;
+ rfdiv = (readl(priv->regs + UFCR) >> 7) & 7;
rfdiv = rfdiv < 6 ? 6 - rfdiv : 7;
- return imx_get_uartclk() / rfdiv;
+ return clk_get_rate(priv->clk) / rfdiv;
}
/*
@@ -209,7 +211,7 @@ static int imx_serial_init_port(struct console_device *cdev)
writel(0xa81, regs + UFCR);
#ifdef ONEMS
- writel(imx_serial_reffreq(regs) / 1000, regs + ONEMS);
+ writel(imx_serial_reffreq(priv) / 1000, regs + ONEMS);
#endif
/* Enable FIFOs */
@@ -291,7 +293,7 @@ static int imx_serial_setbaudrate(struct console_device *cdev, int baudrate)
/* Set the numerator value minus one of the BRM ratio */
writel((baudrate / 100) - 1, regs + UBIR);
/* Set the denominator value minus one of the BRM ratio */
- writel((imx_serial_reffreq(regs) / 1600) - 1, regs + UBMR);
+ writel((imx_serial_reffreq(priv) / 1600) - 1, regs + UBMR);
writel(ucr1, regs + UCR1);
@@ -316,11 +318,18 @@ static int imx_serial_probe(struct device_d *dev)
struct console_device *cdev;
struct imx_serial_priv *priv;
uint32_t val;
+ int ret;
priv = xzalloc(sizeof(*priv));
cdev = &priv->cdev;
dev->priv = priv;
+ priv->clk = clk_get(dev, NULL);
+ if (IS_ERR(priv->clk)) {
+ ret = PTR_ERR(priv->clk);
+ goto err_free;
+ }
+
priv->regs = dev_request_mem_region(dev, 0);
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
@@ -343,6 +352,11 @@ static int imx_serial_probe(struct device_d *dev)
clock_register_client(&priv->notify);
return 0;
+
+err_free:
+ free(priv);
+
+ return ret;
}
static void imx_serial_remove(struct device_d *dev)