aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2009-01-21 10:14:06 -0500
committerPaul Mundt <lethal@linux-sh.org>2009-05-08 10:01:12 -0400
commitdc8e6f5bfcd6a307a8196d3e41fd9798be5a1c76 (patch)
tree4dd52f5208c652a99324755baf8e8ea2b8710a50 /drivers/serial
parent9080b72819650c3a757d173a19bc930d603b79d6 (diff)
sh-sci: rework serial console support
Rework sh-sci serial console code. 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.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 5f37f7d3166..d2cd1a400c1 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -91,10 +91,6 @@ struct sh_sci_priv {
91#endif 91#endif
92}; 92};
93 93
94#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
95static struct sci_port *serial_console_port;
96#endif
97
98/* Function prototypes */ 94/* Function prototypes */
99static void sci_stop_tx(struct uart_port *port); 95static void sci_stop_tx(struct uart_port *port);
100 96
@@ -1083,6 +1079,18 @@ static void __init sci_init_ports(void)
1083} 1079}
1084 1080
1085#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE 1081#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
1082static struct tty_driver *serial_console_device(struct console *co, int *index)
1083{
1084 struct uart_driver *p = &sci_uart_driver;
1085 *index = co->index;
1086 return p->tty_driver;
1087}
1088
1089static void serial_console_putchar(struct uart_port *port, int ch)
1090{
1091 sci_poll_put_char(port, ch);
1092}
1093
1086/* 1094/*
1087 * Print a string to the serial port trying not to disturb 1095 * Print a string to the serial port trying not to disturb
1088 * any possible real use of the port... 1096 * any possible real use of the port...
@@ -1090,16 +1098,10 @@ static void __init sci_init_ports(void)
1090static void serial_console_write(struct console *co, const char *s, 1098static void serial_console_write(struct console *co, const char *s,
1091 unsigned count) 1099 unsigned count)
1092{ 1100{
1093 struct uart_port *port = &serial_console_port->port; 1101 struct uart_port *port = co->data;
1094 unsigned short bits; 1102 unsigned short bits;
1095 int i;
1096 1103
1097 for (i = 0; i < count; i++) { 1104 uart_console_write(co->data, s, count, serial_console_putchar);
1098 if (*s == 10)
1099 sci_poll_put_char(port, '\r');
1100
1101 sci_poll_put_char(port, *s++);
1102 }
1103 1105
1104 /* wait until fifo is empty and last bit has been transmitted */ 1106 /* wait until fifo is empty and last bit has been transmitted */
1105 bits = SCxSR_TDxE(port) | SCxSR_TEND(port); 1107 bits = SCxSR_TDxE(port) | SCxSR_TEND(port);
@@ -1109,6 +1111,7 @@ static void serial_console_write(struct console *co, const char *s,
1109 1111
1110static int __init serial_console_setup(struct console *co, char *options) 1112static int __init serial_console_setup(struct console *co, char *options)
1111{ 1113{
1114 struct sci_port *sci_port;
1112 struct uart_port *port; 1115 struct uart_port *port;
1113 int baud = 115200; 1116 int baud = 115200;
1114 int bits = 8; 1117 int bits = 8;
@@ -1124,8 +1127,9 @@ static int __init serial_console_setup(struct console *co, char *options)
1124 if (co->index >= SCI_NPORTS) 1127 if (co->index >= SCI_NPORTS)
1125 co->index = 0; 1128 co->index = 0;
1126 1129
1127 serial_console_port = &sci_ports[co->index]; 1130 sci_port = &sci_ports[co->index];
1128 port = &serial_console_port->port; 1131 port = &sci_port->port;
1132 co->data = port;
1129 1133
1130 /* 1134 /*
1131 * Also need to check port->type, we don't actually have any 1135 * Also need to check port->type, we don't actually have any
@@ -1135,21 +1139,17 @@ static int __init serial_console_setup(struct console *co, char *options)
1135 */ 1139 */
1136 if (!port->type) 1140 if (!port->type)
1137 return -ENODEV; 1141 return -ENODEV;
1138 if (!port->membase || !port->mapbase)
1139 return -ENODEV;
1140
1141 port->type = serial_console_port->type;
1142 1142
1143#ifdef CONFIG_HAVE_CLK 1143#ifdef CONFIG_HAVE_CLK
1144 if (!serial_console_port->clk) 1144 if (!sci_port->clk)
1145 serial_console_port->clk = clk_get(NULL, "module_clk"); 1145 sci_port->clk = clk_get(NULL, "module_clk");
1146#endif 1146#endif
1147 1147
1148 if (port->flags & UPF_IOREMAP) 1148 if (port->flags & UPF_IOREMAP)
1149 sci_config_port(port, 0); 1149 sci_config_port(port, 0);
1150 1150
1151 if (serial_console_port->enable) 1151 if (sci_port->enable)
1152 serial_console_port->enable(port); 1152 sci_port->enable(port);
1153 1153
1154 if (options) 1154 if (options)
1155 uart_parse_options(options, &baud, &parity, &bits, &flow); 1155 uart_parse_options(options, &baud, &parity, &bits, &flow);
@@ -1165,12 +1165,11 @@ static int __init serial_console_setup(struct console *co, char *options)
1165 1165
1166static struct console serial_console = { 1166static struct console serial_console = {
1167 .name = "ttySC", 1167 .name = "ttySC",
1168 .device = uart_console_device, 1168 .device = serial_console_device,
1169 .write = serial_console_write, 1169 .write = serial_console_write,
1170 .setup = serial_console_setup, 1170 .setup = serial_console_setup,
1171 .flags = CON_PRINTBUFFER, 1171 .flags = CON_PRINTBUFFER,
1172 .index = -1, 1172 .index = -1,
1173 .data = &sci_uart_driver,
1174}; 1173};
1175 1174
1176static int __init sci_console_init(void) 1175static int __init sci_console_init(void)