aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2009-01-21 10:14:14 -0500
committerPaul Mundt <lethal@linux-sh.org>2009-05-08 10:09:20 -0400
commit7ed7e0711b3ff85b3e15591081b42f2af96d584b (patch)
treee1b7c7cf83d2d84481354b72d5775508f7483bba /drivers/serial
parent0ee70712922c15252183db8b50a7e369c96017c0 (diff)
sh-sci: replace sci_init_ports()
Replace sci_init_ports() with sci_init_single(). Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/sh-sci.c107
1 files changed, 50 insertions, 57 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index e9b350c58ba8..039c700ce1ec 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -1036,46 +1036,64 @@ static struct uart_ops sci_uart_ops = {
1036#endif 1036#endif
1037}; 1037};
1038 1038
1039static void __init sci_init_ports(void) 1039static int __devinit sci_init_single(struct sci_port *sci_port,
1040 unsigned int index,
1041 struct plat_sci_port *p)
1040{ 1042{
1041 static int first = 1; 1043 sci_port->port.ops = &sci_uart_ops;
1042 int i; 1044 sci_port->port.iotype = UPIO_MEM;
1043 1045 sci_port->port.line = index;
1044 if (!first) 1046 sci_port->port.fifosize = 1;
1045 return;
1046
1047 first = 0;
1048
1049 for (i = 0; i < SCI_NPORTS; i++) {
1050 sci_ports[i].port.ops = &sci_uart_ops;
1051 sci_ports[i].port.iotype = UPIO_MEM;
1052 sci_ports[i].port.line = i;
1053 sci_ports[i].port.fifosize = 1;
1054 1047
1055#if defined(__H8300H__) || defined(__H8300S__) 1048#if defined(__H8300H__) || defined(__H8300S__)
1056#ifdef __H8300S__ 1049#ifdef __H8300S__
1057 sci_ports[i].enable = h8300_sci_enable; 1050 sci_port->enable = h8300_sci_enable;
1058 sci_ports[i].disable = h8300_sci_disable; 1051 sci_port->disable = h8300_sci_disable;
1059#endif 1052#endif
1060 sci_ports[i].port.uartclk = CONFIG_CPU_CLOCK; 1053 sci_port->port.uartclk = CONFIG_CPU_CLOCK;
1061#elif defined(CONFIG_HAVE_CLK) 1054#elif defined(CONFIG_HAVE_CLK)
1062 /* 1055 /*
1063 * XXX: We should use a proper SCI/SCIF clock 1056 * XXX: We should use a proper SCI/SCIF clock
1064 */ 1057 */
1065 { 1058 {
1066 struct clk *clk = clk_get(NULL, "module_clk"); 1059 struct clk *clk = clk_get(NULL, "module_clk");
1067 sci_ports[i].port.uartclk = clk_get_rate(clk); 1060 sci_port->port.uartclk = clk_get_rate(clk);
1068 clk_put(clk); 1061 clk_put(clk);
1069 } 1062 }
1070#else 1063#else
1071#error "Need a valid uartclk" 1064#error "Need a valid uartclk"
1072#endif 1065#endif
1073 1066
1074 sci_ports[i].break_timer.data = (unsigned long)&sci_ports[i]; 1067 sci_port->break_timer.data = (unsigned long)sci_port;
1075 sci_ports[i].break_timer.function = sci_break_timer; 1068 sci_port->break_timer.function = sci_break_timer;
1069 init_timer(&sci_port->break_timer);
1070
1071 sci_port->port.mapbase = p->mapbase;
1076 1072
1077 init_timer(&sci_ports[i].break_timer); 1073 if (p->mapbase && !p->membase) {
1074 if (p->flags & UPF_IOREMAP) {
1075 p->membase = ioremap_nocache(p->mapbase, 0x40);
1076 if (IS_ERR(p->membase))
1077 return PTR_ERR(p->membase);
1078 } else {
1079 /*
1080 * For the simple (and majority of) cases
1081 * where we don't need to do any remapping,
1082 * just cast the cookie directly.
1083 */
1084 p->membase = (void __iomem *)p->mapbase;
1085 }
1078 } 1086 }
1087
1088 sci_port->port.membase = p->membase;
1089
1090 sci_port->port.irq = p->irqs[SCIx_TXI_IRQ];
1091 sci_port->port.flags = p->flags;
1092 sci_port->type = sci_port->port.type = p->type;
1093
1094 memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs));
1095
1096 return 0;
1079} 1097}
1080 1098
1081#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE 1099#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
@@ -1174,7 +1192,6 @@ static struct console serial_console = {
1174 1192
1175static int __init sci_console_init(void) 1193static int __init sci_console_init(void)
1176{ 1194{
1177 sci_init_ports();
1178 register_console(&serial_console); 1195 register_console(&serial_console);
1179 return 0; 1196 return 0;
1180} 1197}
@@ -1240,32 +1257,10 @@ static int __devinit sci_probe_single(struct platform_device *dev,
1240 return 0; 1257 return 0;
1241 } 1258 }
1242 1259
1243 sciport->port.mapbase = p->mapbase; 1260 sciport->port.dev = &dev->dev;
1244 1261 ret = sci_init_single(sciport, index, p);
1245 if (p->mapbase && !p->membase) { 1262 if (ret)
1246 if (p->flags & UPF_IOREMAP) { 1263 return ret;
1247 p->membase = ioremap_nocache(p->mapbase, 0x40);
1248 if (IS_ERR(p->membase))
1249 return PTR_ERR(p->membase);
1250 } else {
1251 /*
1252 * For the simple (and majority of) cases
1253 * where we don't need to do any remapping,
1254 * just cast the cookie directly.
1255 */
1256 p->membase = (void __iomem *)p->mapbase;
1257 }
1258 }
1259
1260 sciport->port.membase = p->membase;
1261
1262 sciport->port.irq = p->irqs[SCIx_TXI_IRQ];
1263 sciport->port.flags = p->flags;
1264 sciport->port.dev = &dev->dev;
1265
1266 sciport->type = sciport->port.type = p->type;
1267
1268 memcpy(&sciport->irqs, &p->irqs, sizeof(p->irqs));
1269 1264
1270 ret = uart_add_one_port(&sci_uart_driver, &sciport->port); 1265 ret = uart_add_one_port(&sci_uart_driver, &sciport->port);
1271 1266
@@ -1380,8 +1375,6 @@ static int __init sci_init(void)
1380 1375
1381 printk(banner); 1376 printk(banner);
1382 1377
1383 sci_init_ports();
1384
1385 ret = uart_register_driver(&sci_uart_driver); 1378 ret = uart_register_driver(&sci_uart_driver);
1386 if (likely(ret == 0)) { 1379 if (likely(ret == 0)) {
1387 ret = platform_driver_register(&sci_driver); 1380 ret = platform_driver_register(&sci_driver);