aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-20 20:35:25 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-20 20:35:25 -0400
commitc2e68052429fdf87702fccd272951282bef1c60a (patch)
treeb9f3bf3918526af068ed264190a85fb18dd3d8b0 /drivers/serial
parentd6f410bdbcb435c744c4f8259d6659ae2c6e447a (diff)
parent1256efd5519a8eca2dfa6039ce5cf58f44d1626d (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
* 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6: [SPARC64]: fix section mismatch warning in mdesc.c [SPARC64]: fix section mismatch warning in pci_sunv4 [SPARC64]: Stop using drivers/char/rtc.c [SPARC64]: Convert parport to of_platform_driver. [SPARC]: Implement fb_is_primary_device(). [SPARC64]: Fix virq decomposition. [SPARC64]: Use KERN_ERR in IRQ manipulation error printks. [SPARC64]: Do not flood log with failed DS messages. [SPARC64]: Add proper multicast support to VNET driver. [SPARC64]: Handle multiple domain-services-port nodes properly. [SPARC64]: Improve VIO device naming further. [SPARC]: Make sure dev_archdata is filled in for all devices. [SPARC]: Define minimal struct dev_archdata, similarly to sparc64. [SPARC]: Fix serial console device detection.
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/suncore.c123
-rw-r--r--drivers/serial/suncore.h2
-rw-r--r--drivers/serial/sunhv.c13
-rw-r--r--drivers/serial/sunsab.c22
-rw-r--r--drivers/serial/sunsu.c23
-rw-r--r--drivers/serial/sunzilog.c24
6 files changed, 65 insertions, 142 deletions
diff --git a/drivers/serial/suncore.c b/drivers/serial/suncore.c
index b45ba5392dd3..70a09a3d5af0 100644
--- a/drivers/serial/suncore.c
+++ b/drivers/serial/suncore.c
@@ -16,9 +16,10 @@
16#include <linux/tty.h> 16#include <linux/tty.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/serial_core.h>
19#include <linux/init.h> 20#include <linux/init.h>
20 21
21#include <asm/oplib.h> 22#include <asm/prom.h>
22 23
23#include "suncore.h" 24#include "suncore.h"
24 25
@@ -26,92 +27,60 @@ int sunserial_current_minor = 64;
26 27
27EXPORT_SYMBOL(sunserial_current_minor); 28EXPORT_SYMBOL(sunserial_current_minor);
28 29
29void 30int sunserial_console_match(struct console *con, struct device_node *dp,
30sunserial_console_termios(struct console *con) 31 struct uart_driver *drv, int line)
31{ 32{
32 char mode[16], buf[16], *s; 33 int off;
33 char mode_prop[] = "ttyX-mode";
34 char cd_prop[] = "ttyX-ignore-cd";
35 char dtr_prop[] = "ttyX-rts-dtr-off";
36 char *ssp_console_modes_prop = "ssp-console-modes";
37 int baud, bits, stop, cflag;
38 char parity;
39 int carrier = 0;
40 int rtsdtr = 1;
41 int topnd, nd;
42
43 if (!serial_console)
44 return;
45
46 switch (serial_console) {
47 case PROMDEV_OTTYA:
48 mode_prop[3] = 'a';
49 cd_prop[3] = 'a';
50 dtr_prop[3] = 'a';
51 break;
52
53 case PROMDEV_OTTYB:
54 mode_prop[3] = 'b';
55 cd_prop[3] = 'b';
56 dtr_prop[3] = 'b';
57 break;
58
59 case PROMDEV_ORSC:
60
61 nd = prom_pathtoinode("rsc");
62 if (!nd) {
63 strcpy(mode, "115200,8,n,1,-");
64 goto no_options;
65 }
66 34
67 if (!prom_node_has_property(nd, ssp_console_modes_prop)) { 35 if (!con || of_console_device != dp)
68 strcpy(mode, "115200,8,n,1,-"); 36 return 0;
69 goto no_options;
70 }
71 37
72 memset(mode, 0, sizeof(mode)); 38 off = 0;
73 prom_getstring(nd, ssp_console_modes_prop, mode, sizeof(mode)); 39 if (of_console_options &&
74 goto no_options; 40 *of_console_options == 'b')
41 off = 1;
75 42
76 default: 43 if ((line & 1) != off)
77 strcpy(mode, "9600,8,n,1,-"); 44 return 0;
78 goto no_options;
79 }
80 45
81 topnd = prom_getchild(prom_root_node); 46 con->index = line;
82 nd = prom_searchsiblings(topnd, "options"); 47 drv->cons = con;
83 if (!nd) { 48 add_preferred_console(con->name, line, NULL);
84 strcpy(mode, "9600,8,n,1,-");
85 goto no_options;
86 }
87
88 if (!prom_node_has_property(nd, mode_prop)) {
89 strcpy(mode, "9600,8,n,1,-");
90 goto no_options;
91 }
92 49
93 memset(mode, 0, sizeof(mode)); 50 return 1;
94 prom_getstring(nd, mode_prop, mode, sizeof(mode)); 51}
95 52EXPORT_SYMBOL(sunserial_console_match);
96 if (prom_node_has_property(nd, cd_prop)) {
97 memset(buf, 0, sizeof(buf));
98 prom_getstring(nd, cd_prop, buf, sizeof(buf));
99 if (!strcmp(buf, "false"))
100 carrier = 1;
101
102 /* XXX: this is unused below. */
103 }
104 53
105 if (prom_node_has_property(nd, dtr_prop)) { 54void
106 memset(buf, 0, sizeof(buf)); 55sunserial_console_termios(struct console *con)
107 prom_getstring(nd, dtr_prop, buf, sizeof(buf)); 56{
108 if (!strcmp(buf, "false")) 57 struct device_node *dp;
109 rtsdtr = 0; 58 const char *od, *mode, *s;
59 char mode_prop[] = "ttyX-mode";
60 int baud, bits, stop, cflag;
61 char parity;
110 62
111 /* XXX: this is unused below. */ 63 dp = of_find_node_by_path("/options");
64 od = of_get_property(dp, "output-device", NULL);
65 if (!strcmp(od, "rsc")) {
66 mode = of_get_property(of_console_device,
67 "ssp-console-modes", NULL);
68 if (!mode)
69 mode = "115200,8,n,1,-";
70 } else {
71 char c;
72
73 c = 'a';
74 if (of_console_options)
75 c = *of_console_options;
76
77 mode_prop[3] = c;
78
79 mode = of_get_property(dp, mode_prop, NULL);
80 if (!mode)
81 mode = "9600,8,n,1,-";
112 } 82 }
113 83
114no_options:
115 cflag = CREAD | HUPCL | CLOCAL; 84 cflag = CREAD | HUPCL | CLOCAL;
116 85
117 s = mode; 86 s = mode;
diff --git a/drivers/serial/suncore.h b/drivers/serial/suncore.h
index 513916a8ce37..829d7d65d6db 100644
--- a/drivers/serial/suncore.h
+++ b/drivers/serial/suncore.h
@@ -24,6 +24,8 @@ extern int suncore_mouse_baud_detection(unsigned char, int);
24 24
25extern int sunserial_current_minor; 25extern int sunserial_current_minor;
26 26
27extern int sunserial_console_match(struct console *, struct device_node *,
28 struct uart_driver *, int);
27extern void sunserial_console_termios(struct console *); 29extern void sunserial_console_termios(struct console *);
28 30
29#endif /* !(_SERIAL_SUN_H) */ 31#endif /* !(_SERIAL_SUN_H) */
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c
index d82be42ff29a..8ff900b09811 100644
--- a/drivers/serial/sunhv.c
+++ b/drivers/serial/sunhv.c
@@ -520,16 +520,6 @@ static struct console sunhv_console = {
520 .data = &sunhv_reg, 520 .data = &sunhv_reg,
521}; 521};
522 522
523static inline struct console *SUNHV_CONSOLE(void)
524{
525 if (con_is_present())
526 return NULL;
527
528 sunhv_console.index = 0;
529
530 return &sunhv_console;
531}
532
533static int __devinit hv_probe(struct of_device *op, const struct of_device_id *match) 523static int __devinit hv_probe(struct of_device *op, const struct of_device_id *match)
534{ 524{
535 struct uart_port *port; 525 struct uart_port *port;
@@ -582,7 +572,8 @@ static int __devinit hv_probe(struct of_device *op, const struct of_device_id *m
582 sunhv_reg.tty_driver->name_base = sunhv_reg.minor - 64; 572 sunhv_reg.tty_driver->name_base = sunhv_reg.minor - 64;
583 sunserial_current_minor += 1; 573 sunserial_current_minor += 1;
584 574
585 sunhv_reg.cons = SUNHV_CONSOLE(); 575 sunserial_console_match(&sunhv_console, op->node,
576 &sunhv_reg, port->line);
586 577
587 err = uart_add_one_port(&sunhv_reg, port); 578 err = uart_add_one_port(&sunhv_reg, port);
588 if (err) 579 if (err)
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index 8a0f9e4408d4..bca57bb94939 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -968,22 +968,6 @@ static struct console sunsab_console = {
968 968
969static inline struct console *SUNSAB_CONSOLE(void) 969static inline struct console *SUNSAB_CONSOLE(void)
970{ 970{
971 int i;
972
973 if (con_is_present())
974 return NULL;
975
976 for (i = 0; i < num_channels; i++) {
977 int this_minor = sunsab_reg.minor + i;
978
979 if ((this_minor - 64) == (serial_console - 1))
980 break;
981 }
982 if (i == num_channels)
983 return NULL;
984
985 sunsab_console.index = i;
986
987 return &sunsab_console; 971 return &sunsab_console;
988} 972}
989#else 973#else
@@ -1080,7 +1064,12 @@ static int __devinit sab_probe(struct of_device *op, const struct of_device_id *
1080 return err; 1064 return err;
1081 } 1065 }
1082 1066
1067 sunserial_console_match(SUNSAB_CONSOLE(), op->node,
1068 &sunsab_reg, up[0].port.line);
1083 uart_add_one_port(&sunsab_reg, &up[0].port); 1069 uart_add_one_port(&sunsab_reg, &up[0].port);
1070
1071 sunserial_console_match(SUNSAB_CONSOLE(), op->node,
1072 &sunsab_reg, up[1].port.line);
1084 uart_add_one_port(&sunsab_reg, &up[1].port); 1073 uart_add_one_port(&sunsab_reg, &up[1].port);
1085 1074
1086 dev_set_drvdata(&op->dev, &up[0]); 1075 dev_set_drvdata(&op->dev, &up[0]);
@@ -1164,7 +1153,6 @@ static int __init sunsab_init(void)
1164 } 1153 }
1165 1154
1166 sunsab_reg.tty_driver->name_base = sunsab_reg.minor - 64; 1155 sunsab_reg.tty_driver->name_base = sunsab_reg.minor - 64;
1167 sunsab_reg.cons = SUNSAB_CONSOLE();
1168 sunserial_current_minor += num_channels; 1156 sunserial_current_minor += num_channels;
1169 } 1157 }
1170 1158
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 26d720baf88c..79b13685bdfa 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1371,28 +1371,12 @@ static struct console sunsu_console = {
1371 * Register console. 1371 * Register console.
1372 */ 1372 */
1373 1373
1374static inline struct console *SUNSU_CONSOLE(int num_uart) 1374static inline struct console *SUNSU_CONSOLE(void)
1375{ 1375{
1376 int i;
1377
1378 if (con_is_present())
1379 return NULL;
1380
1381 for (i = 0; i < num_uart; i++) {
1382 int this_minor = sunsu_reg.minor + i;
1383
1384 if ((this_minor - 64) == (serial_console - 1))
1385 break;
1386 }
1387 if (i == num_uart)
1388 return NULL;
1389
1390 sunsu_console.index = i;
1391
1392 return &sunsu_console; 1376 return &sunsu_console;
1393} 1377}
1394#else 1378#else
1395#define SUNSU_CONSOLE(num_uart) (NULL) 1379#define SUNSU_CONSOLE() (NULL)
1396#define sunsu_serial_console_init() do { } while (0) 1380#define sunsu_serial_console_init() do { } while (0)
1397#endif 1381#endif
1398 1382
@@ -1482,6 +1466,8 @@ static int __devinit su_probe(struct of_device *op, const struct of_device_id *m
1482 1466
1483 up->port.ops = &sunsu_pops; 1467 up->port.ops = &sunsu_pops;
1484 1468
1469 sunserial_console_match(SUNSU_CONSOLE(), dp,
1470 &sunsu_reg, up->port.line);
1485 err = uart_add_one_port(&sunsu_reg, &up->port); 1471 err = uart_add_one_port(&sunsu_reg, &up->port);
1486 if (err) 1472 if (err)
1487 goto out_unmap; 1473 goto out_unmap;
@@ -1572,7 +1558,6 @@ static int __init sunsu_init(void)
1572 return err; 1558 return err;
1573 sunsu_reg.tty_driver->name_base = sunsu_reg.minor - 64; 1559 sunsu_reg.tty_driver->name_base = sunsu_reg.minor - 64;
1574 sunserial_current_minor += num_uart; 1560 sunserial_current_minor += num_uart;
1575 sunsu_reg.cons = SUNSU_CONSOLE(num_uart);
1576 } 1561 }
1577 1562
1578 err = of_register_driver(&su_driver, &of_bus_type); 1563 err = of_register_driver(&su_driver, &of_bus_type);
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 0a3e10a4a35d..1d262c0c613f 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1226,23 +1226,6 @@ static struct console sunzilog_console_ops = {
1226 1226
1227static inline struct console *SUNZILOG_CONSOLE(void) 1227static inline struct console *SUNZILOG_CONSOLE(void)
1228{ 1228{
1229 int i;
1230
1231 if (con_is_present())
1232 return NULL;
1233
1234 for (i = 0; i < NUM_CHANNELS; i++) {
1235 int this_minor = sunzilog_reg.minor + i;
1236
1237 if ((this_minor - 64) == (serial_console - 1))
1238 break;
1239 }
1240 if (i == NUM_CHANNELS)
1241 return NULL;
1242
1243 sunzilog_console_ops.index = i;
1244 sunzilog_port_table[i].flags |= SUNZILOG_FLAG_IS_CONS;
1245
1246 return &sunzilog_console_ops; 1229 return &sunzilog_console_ops;
1247} 1230}
1248 1231
@@ -1428,12 +1411,18 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m
1428 sunzilog_init_hw(&up[1]); 1411 sunzilog_init_hw(&up[1]);
1429 1412
1430 if (!keyboard_mouse) { 1413 if (!keyboard_mouse) {
1414 if (sunserial_console_match(SUNZILOG_CONSOLE(), op->node,
1415 &sunzilog_reg, up[0].port.line))
1416 up->flags |= SUNZILOG_FLAG_IS_CONS;
1431 err = uart_add_one_port(&sunzilog_reg, &up[0].port); 1417 err = uart_add_one_port(&sunzilog_reg, &up[0].port);
1432 if (err) { 1418 if (err) {
1433 of_iounmap(&op->resource[0], 1419 of_iounmap(&op->resource[0],
1434 rp, sizeof(struct zilog_layout)); 1420 rp, sizeof(struct zilog_layout));
1435 return err; 1421 return err;
1436 } 1422 }
1423 if (sunserial_console_match(SUNZILOG_CONSOLE(), op->node,
1424 &sunzilog_reg, up[1].port.line))
1425 up->flags |= SUNZILOG_FLAG_IS_CONS;
1437 err = uart_add_one_port(&sunzilog_reg, &up[1].port); 1426 err = uart_add_one_port(&sunzilog_reg, &up[1].port);
1438 if (err) { 1427 if (err) {
1439 uart_remove_one_port(&sunzilog_reg, &up[0].port); 1428 uart_remove_one_port(&sunzilog_reg, &up[0].port);
@@ -1531,7 +1520,6 @@ static int __init sunzilog_init(void)
1531 goto out_free_tables; 1520 goto out_free_tables;
1532 1521
1533 sunzilog_reg.tty_driver->name_base = sunzilog_reg.minor - 64; 1522 sunzilog_reg.tty_driver->name_base = sunzilog_reg.minor - 64;
1534 sunzilog_reg.cons = SUNZILOG_CONSOLE();
1535 1523
1536 sunserial_current_minor += uart_count; 1524 sunserial_current_minor += uart_count;
1537 } 1525 }