diff options
Diffstat (limited to 'drivers/serial/suncore.c')
-rw-r--r-- | drivers/serial/suncore.c | 123 |
1 files changed, 46 insertions, 77 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 | ||
27 | EXPORT_SYMBOL(sunserial_current_minor); | 28 | EXPORT_SYMBOL(sunserial_current_minor); |
28 | 29 | ||
29 | void | 30 | int sunserial_console_match(struct console *con, struct device_node *dp, |
30 | sunserial_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 | 52 | EXPORT_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)) { | 54 | void |
106 | memset(buf, 0, sizeof(buf)); | 55 | sunserial_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 | ||
114 | no_options: | ||
115 | cflag = CREAD | HUPCL | CLOCAL; | 84 | cflag = CREAD | HUPCL | CLOCAL; |
116 | 85 | ||
117 | s = mode; | 86 | s = mode; |