aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/sh-sci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial/sh-sci.c')
-rw-r--r--drivers/serial/sh-sci.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index ac658a7a27be..3b9d2d83b590 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -79,7 +79,7 @@ struct sci_port {
79 struct timer_list break_timer; 79 struct timer_list break_timer;
80 int break_flag; 80 int break_flag;
81 81
82#ifdef CONFIG_SUPERH 82#ifdef CONFIG_HAVE_CLK
83 /* Port clock */ 83 /* Port clock */
84 struct clk *clk; 84 struct clk *clk;
85#endif 85#endif
@@ -832,7 +832,7 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
832 return IRQ_HANDLED; 832 return IRQ_HANDLED;
833} 833}
834 834
835#ifdef CONFIG_CPU_FREQ 835#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_HAVE_CLK)
836/* 836/*
837 * Here we define a transistion notifier so that we can update all of our 837 * Here we define a transistion notifier so that we can update all of our
838 * ports' baud rate when the peripheral clock changes. 838 * ports' baud rate when the peripheral clock changes.
@@ -861,7 +861,7 @@ static int sci_notifier(struct notifier_block *self,
861 * Clean this up later.. 861 * Clean this up later..
862 */ 862 */
863 clk = clk_get(NULL, "module_clk"); 863 clk = clk_get(NULL, "module_clk");
864 port->uartclk = clk_get_rate(clk) * 16; 864 port->uartclk = clk_get_rate(clk);
865 clk_put(clk); 865 clk_put(clk);
866 } 866 }
867 867
@@ -874,7 +874,7 @@ static int sci_notifier(struct notifier_block *self,
874} 874}
875 875
876static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 }; 876static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 };
877#endif /* CONFIG_CPU_FREQ */ 877#endif /* CONFIG_CPU_FREQ && CONFIG_HAVE_CLK */
878 878
879static int sci_request_irq(struct sci_port *port) 879static int sci_request_irq(struct sci_port *port)
880{ 880{
@@ -1009,7 +1009,7 @@ static int sci_startup(struct uart_port *port)
1009 if (s->enable) 1009 if (s->enable)
1010 s->enable(port); 1010 s->enable(port);
1011 1011
1012#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 1012#ifdef CONFIG_HAVE_CLK
1013 s->clk = clk_get(NULL, "module_clk"); 1013 s->clk = clk_get(NULL, "module_clk");
1014#endif 1014#endif
1015 1015
@@ -1031,7 +1031,7 @@ static void sci_shutdown(struct uart_port *port)
1031 if (s->disable) 1031 if (s->disable)
1032 s->disable(port); 1032 s->disable(port);
1033 1033
1034#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 1034#ifdef CONFIG_HAVE_CLK
1035 clk_put(s->clk); 1035 clk_put(s->clk);
1036 s->clk = NULL; 1036 s->clk = NULL;
1037#endif 1037#endif
@@ -1042,24 +1042,11 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1042{ 1042{
1043 struct sci_port *s = &sci_ports[port->line]; 1043 struct sci_port *s = &sci_ports[port->line];
1044 unsigned int status, baud, smr_val; 1044 unsigned int status, baud, smr_val;
1045 int t; 1045 int t = -1;
1046 1046
1047 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 1047 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
1048 1048 if (likely(baud))
1049 switch (baud) { 1049 t = SCBRR_VALUE(baud, port->uartclk);
1050 case 0:
1051 t = -1;
1052 break;
1053 default:
1054 {
1055#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
1056 t = SCBRR_VALUE(baud, clk_get_rate(s->clk));
1057#else
1058 t = SCBRR_VALUE(baud);
1059#endif
1060 break;
1061 }
1062 }
1063 1050
1064 do { 1051 do {
1065 status = sci_in(port, SCxSR); 1052 status = sci_in(port, SCxSR);
@@ -1212,17 +1199,17 @@ static void __init sci_init_ports(void)
1212 sci_ports[i].disable = h8300_sci_disable; 1199 sci_ports[i].disable = h8300_sci_disable;
1213#endif 1200#endif
1214 sci_ports[i].port.uartclk = CONFIG_CPU_CLOCK; 1201 sci_ports[i].port.uartclk = CONFIG_CPU_CLOCK;
1215#elif defined(CONFIG_SUPERH64) 1202#elif defined(CONFIG_HAVE_CLK)
1216 sci_ports[i].port.uartclk = current_cpu_data.module_clock * 16;
1217#else
1218 /* 1203 /*
1219 * XXX: We should use a proper SCI/SCIF clock 1204 * XXX: We should use a proper SCI/SCIF clock
1220 */ 1205 */
1221 { 1206 {
1222 struct clk *clk = clk_get(NULL, "module_clk"); 1207 struct clk *clk = clk_get(NULL, "module_clk");
1223 sci_ports[i].port.uartclk = clk_get_rate(clk) * 16; 1208 sci_ports[i].port.uartclk = clk_get_rate(clk);
1224 clk_put(clk); 1209 clk_put(clk);
1225 } 1210 }
1211#else
1212#error "Need a valid uartclk"
1226#endif 1213#endif
1227 1214
1228 sci_ports[i].break_timer.data = (unsigned long)&sci_ports[i]; 1215 sci_ports[i].break_timer.data = (unsigned long)&sci_ports[i];
@@ -1290,7 +1277,7 @@ static int __init serial_console_setup(struct console *co, char *options)
1290 1277
1291 port->type = serial_console_port->type; 1278 port->type = serial_console_port->type;
1292 1279
1293#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 1280#ifdef CONFIG_HAVE_CLK
1294 if (!serial_console_port->clk) 1281 if (!serial_console_port->clk)
1295 serial_console_port->clk = clk_get(NULL, "module_clk"); 1282 serial_console_port->clk = clk_get(NULL, "module_clk");
1296#endif 1283#endif
@@ -1494,7 +1481,7 @@ static int __devinit sci_probe(struct platform_device *dev)
1494 kgdb_putchar = kgdb_sci_putchar; 1481 kgdb_putchar = kgdb_sci_putchar;
1495#endif 1482#endif
1496 1483
1497#ifdef CONFIG_CPU_FREQ 1484#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_HAVE_CLK)
1498 cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER); 1485 cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER);
1499 dev_info(&dev->dev, "CPU frequency notifier registered\n"); 1486 dev_info(&dev->dev, "CPU frequency notifier registered\n");
1500#endif 1487#endif