]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
cpm_uart: Add generic clock API support to set baudrates
authorLaurent Pinchart <laurentp@cse-semaphore.com>
Mon, 28 Jul 2008 08:42:16 +0000 (10:42 +0200)
committerKumar Gala <galak@kernel.crashing.org>
Mon, 28 Jul 2008 13:47:32 +0000 (08:47 -0500)
This patch introduces baudrate setting support via the generic clock API.
When present the optional device tree clock property is used instead of
fsl-cpm-brg. Platforms can then define complex clock schemes, to output
the serial clock on an external pin for instance.

Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/platforms/Kconfig
drivers/serial/cpm_uart/cpm_uart.h
drivers/serial/cpm_uart/cpm_uart_core.c

index 18a71839dc9e297acb40f62f57901065f23a9f3d..4c900efa164e43fcd4331bddc81b925e35ad77c8 100644 (file)
@@ -283,6 +283,7 @@ config FSL_ULI1575
 
 config CPM
        bool
+       select PPC_CLOCK
 
 config OF_RTC
        bool
index 5999ef5ac78e2ff00f32ad76e8db6b5ec3c60d2c..7274b527a3c1737a248cdafb77edb0fd17c14bb9 100644 (file)
@@ -77,6 +77,7 @@ struct uart_cpm_port {
        unsigned char           *rx_buf;
        u32                     flags;
        void                    (*set_lineif)(struct uart_cpm_port *);
+       struct clk              *clk;
        u8                      brg;
        uint                     dp_addr;
        void                    *mem_addr;
index 5e0c17f71653529587b58c0d9c5567c104fde53a..25efca5a7a1ffe423b0757f2a89f660390537e20 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/of_platform.h>
 #include <linux/gpio.h>
 #include <linux/of_gpio.h>
+#include <linux/clk.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -596,7 +597,10 @@ static void cpm_uart_set_termios(struct uart_port *port,
                out_be16(&sccp->scc_psmr, (sbits << 12) | scval);
        }
 
-       cpm_set_brg(pinfo->brg - 1, baud);
+       if (pinfo->clk)
+               clk_set_rate(pinfo->clk, baud);
+       else
+               cpm_set_brg(pinfo->brg - 1, baud);
        spin_unlock_irqrestore(&port->lock, flags);
 }
 
@@ -1023,13 +1027,21 @@ static int cpm_uart_init_port(struct device_node *np,
        int ret;
        int i;
 
-       data = of_get_property(np, "fsl,cpm-brg", &len);
-       if (!data || len != 4) {
-               printk(KERN_ERR "CPM UART %s has no/invalid "
-                               "fsl,cpm-brg property.\n", np->name);
-               return -EINVAL;
+       data = of_get_property(np, "clock", NULL);
+       if (data) {
+               struct clk *clk = clk_get(NULL, (const char*)data);
+               if (!IS_ERR(clk))
+                       pinfo->clk = clk;
+       }
+       if (!pinfo->clk) {
+               data = of_get_property(np, "fsl,cpm-brg", &len);
+               if (!data || len != 4) {
+                       printk(KERN_ERR "CPM UART %s has no/invalid "
+                                       "fsl,cpm-brg property.\n", np->name);
+                       return -EINVAL;
+               }
+               pinfo->brg = *data;
        }
-       pinfo->brg = *data;
 
        data = of_get_property(np, "fsl,cpm-command", &len);
        if (!data || len != 4) {