Skip to contentSkip to conversation

SCI(F) clock source select

RFC In review Yoshinori Sato 2 participants 2 messages Aug 12, 2008 – Aug 13, 2008 SuperH

lore
Share & tools
lore

Yoshinori Sato

author maintainer
#0 lore raw

RFC 1/1 SCI(F) clock source select

SCI(F) clock source (Internal/External) selection is hard coding now. And depend on CPU type.

But I think it's setting depend on target.

I hope add clock selection in platform_data.

Any comments?

drivers/serial/sh-sci.c +15 -2
index 3df2aae..6c0ceff 100644
@@ -82,6 +82,8 @@ struct sci_port {
 	/* Port clock */
 	struct clk		*clk;
 #endif
+	/* clock source */
+	int			clock_source;
 };
 
 #ifdef CONFIG_SH_KGDB
@@ -1040,7 +1042,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 			    struct ktermios *old)
 {
 	struct sci_port *s = &sci_ports[port->line];
-	unsigned int status, baud, smr_val;
+	unsigned int status, baud, smr_val, scscr_val;
 	int t;
 
 	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
@@ -1099,7 +1101,16 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 	if (likely(s->init_pins))
 		s->init_pins(port, termios->c_cflag);
 
-	sci_out(port, SCSCR, SCSCR_INIT(port));
+	scscr_val = SCSCR_INIT(port);
+	switch (s->clock_source) {
+	case SCIx_CLOCK_INT:
+		scscr_val &= ~0x02;
+		break;
+	case SCIx_CLOCK_EXT:
+		scscr_val |= 0x02;
+		break;
+	}
+	sci_out(port, SCSCR, scscr_val);
 
 	if ((termios->c_cflag & CREAD) != 0)
               sci_start_rx(port,0);
@@ -1468,6 +1479,8 @@ static int __devinit sci_probe(struct platform_device *dev)
 
 		sciport->type		= sciport->port.type = p->type;
 
+		sciport->clock_source	= p->clock;
+
 		memcpy(&sciport->irqs, &p->irqs, sizeof(p->irqs));
 
 		uart_add_one_port(&sci_uart_driver, &sciport->port);
include/linux/serial_sci.h +7 -0
index 893cc53..8f08db1 100644
@@ -16,6 +16,12 @@ enum {
 	SCIx_NR_IRQS,
 };
 
+/* clock source type */
+enum {
+	SCIx_CLOCK_INT,
+	SCIx_CLOCK_EXT,
+};
+
 /*
  * Platform device specific platform_data struct
  */
@@ -25,6 +31,7 @@ struct plat_sci_port {
 	unsigned int	irqs[SCIx_NR_IRQS];	/* ERI, RXI, TXI, BRI */
 	unsigned int	type;			/* SCI / SCIF / IRDA */
 	upf_t		flags;			/* UPF_* flags */
+	int		clock;			/* clock source */
 };
 
 int early_sci_setup(struct uart_port *port);
Signature · 2 lines
Yoshinori Sato
<[email protected]>
#1 lore raw
Quoted 14 lines · Yoshinori Sato

SCI(F) clock source (Internal/External) selection is hard coding now. And depend on CPU type.

But I think it's setting depend on target.

I hope add clock selection in platform_data.

Any comments?

drivers/serial/sh-sci.c +0 -0
index 3df2aae..6c0ceff 100644

drivers/serial/sh-sci.c struct sci_port { · line 88

Quoted 7 lines
drivers/serial/sh-sci.c +2 -0
@@ -82,6 +82,8 @@ struct sci_port {
 	/* Port clock */
 	struct clk		*clk;
 #endif
+	/* clock source */
+	int			clock_source;
 };
 

We should probably just add an additional flags field to the port type and platform data and allow internal/external selection based off of that. Then we can default to the current behaviour, and allow the platforms that want different behaviour to specifically set a bit.

It's certainly heading in the right direction, though.