* [RFC] cpm_uart: Add generic clock API support to set baudrates
@ 2008-07-24 12:05 Laurent Pinchart
2008-07-25 17:39 ` Kumar Gala
0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2008-07-24 12:05 UTC (permalink / raw)
To: linuxppc-dev list
[-- Attachment #1: Type: text/plain, Size: 2776 bytes --]
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.
This is required to support RS485 ports on a platform I'm working on (TBox
CPU32 - see http://www.cse-semaphore.com/products/t-box/t-box-ms.php).
---
drivers/serial/cpm_uart/cpm_uart.h | 1 +
drivers/serial/cpm_uart/cpm_uart_core.c | 26 +++++++++++++++++++-------
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index d0c55e2..2e64c03 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -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;
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index d3c19e5..438e460 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -44,6 +44,7 @@
#include <linux/fs_uart_pd.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
+#include <linux/clk.h>
#include <asm/io.h>
#include <asm/irq.h>
@@ -641,7 +642,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);
}
@@ -991,13 +995,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) {
--
1.5.0
--
Laurent Pinchart
CSE Semaphore Belgium
Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium
T +32 (2) 387 42 59
F +32 (2) 387 42 75
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC] cpm_uart: Add generic clock API support to set baudrates
2008-07-24 12:05 [RFC] cpm_uart: Add generic clock API support to set baudrates Laurent Pinchart
@ 2008-07-25 17:39 ` Kumar Gala
2008-07-28 8:42 ` Laurent Pinchart
0 siblings, 1 reply; 4+ messages in thread
From: Kumar Gala @ 2008-07-25 17:39 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: linuxppc-dev list
On Jul 24, 2008, at 7:05 AM, Laurent Pinchart wrote:
> 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.
>
> This is required to support RS485 ports on a platform I'm working on
> (TBox
> CPU32 - see http://www.cse-semaphore.com/products/t-box/t-box-ms.php).
>
> ---
> drivers/serial/cpm_uart/cpm_uart.h | 1 +
> drivers/serial/cpm_uart/cpm_uart_core.c | 26 ++++++++++++++++++
> +-------
> 2 files changed, 20 insertions(+), 7 deletions(-)
I'm having problems applying due to mailer formatting.
- k
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] cpm_uart: Add generic clock API support to set baudrates
2008-07-25 17:39 ` Kumar Gala
@ 2008-07-28 8:42 ` Laurent Pinchart
2008-07-28 12:48 ` Kumar Gala
0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2008-07-28 8:42 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev list
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>
---
drivers/serial/cpm_uart/cpm_uart.h | 1 +
drivers/serial/cpm_uart/cpm_uart_core.c | 26 +++++++++++++++++++-------
2 files changed, 20 insertions(+), 7 deletions(-)
On Friday 25 July 2008, Kumar Gala wrote:
> I'm having problems applying due to mailer formatting.
*sigh* I'll definitely have to fix GPG support in kmail. Sorry about the
annoyance.
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index d0c55e2..2e64c03 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -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;
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index d3c19e5..438e460 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -44,6 +44,7 @@
#include <linux/fs_uart_pd.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
+#include <linux/clk.h>
#include <asm/io.h>
#include <asm/irq.h>
@@ -641,7 +642,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);
}
@@ -991,13 +995,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) {
--
1.5.0
--
Laurent Pinchart
CSE Semaphore Belgium
Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium
T +32 (2) 387 42 59
F +32 (2) 387 42 75
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC] cpm_uart: Add generic clock API support to set baudrates
2008-07-28 8:42 ` Laurent Pinchart
@ 2008-07-28 12:48 ` Kumar Gala
0 siblings, 0 replies; 4+ messages in thread
From: Kumar Gala @ 2008-07-28 12:48 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: linuxppc-dev list
On Jul 28, 2008, at 3:42 AM, Laurent Pinchart wrote:
> 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>
> ---
> drivers/serial/cpm_uart/cpm_uart.h | 1 +
> drivers/serial/cpm_uart/cpm_uart_core.c | 26 ++++++++++++++++++
> +-------
> 2 files changed, 20 insertions(+), 7 deletions(-)
>
> On Friday 25 July 2008, Kumar Gala wrote:
>> I'm having problems applying due to mailer formatting.
>
> *sigh* I'll definitely have to fix GPG support in kmail. Sorry about
> the
> annoyance.
np.
applied.
- k
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-07-28 12:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-24 12:05 [RFC] cpm_uart: Add generic clock API support to set baudrates Laurent Pinchart
2008-07-25 17:39 ` Kumar Gala
2008-07-28 8:42 ` Laurent Pinchart
2008-07-28 12:48 ` Kumar Gala
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.