Deleted Added
full compact
uart_cpu_sparc64.c (137826) uart_cpu_sparc64.c (138157)
1/*
2 * Copyright (c) 2003, 2004 Marcel Moolenaar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2003, 2004 Marcel Moolenaar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_cpu_sparc64.c 137826 2004-11-17 20:01:43Z marius $");
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_cpu_sparc64.c 138157 2004-11-28 16:00:36Z marius $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32
33#include <machine/bus.h>
34#include <machine/bus_private.h>
35
36#include <dev/ofw/openfirm.h>
37#include <machine/ofw_machdep.h>
38
39#include <dev/uart/uart.h>
40#include <dev/uart/uart_cpu.h>
41
42bus_space_tag_t uart_bus_space_io;
43bus_space_tag_t uart_bus_space_mem;
44
45static struct bus_space_tag bst_store[3];
46
29
30#include <sys/param.h>
31#include <sys/systm.h>
32
33#include <machine/bus.h>
34#include <machine/bus_private.h>
35
36#include <dev/ofw/openfirm.h>
37#include <machine/ofw_machdep.h>
38
39#include <dev/uart/uart.h>
40#include <dev/uart/uart_cpu.h>
41
42bus_space_tag_t uart_bus_space_io;
43bus_space_tag_t uart_bus_space_mem;
44
45static struct bus_space_tag bst_store[3];
46
47/*
48 * Determine which channel of a SCC a device referenced by an alias is.
49 * The information present in the OF device tree only allows to do this
50 * for "ttyX" aliases. If a device is a channel of a SCC its property
51 * in the /aliases node looks like one of these:
52 * ttya: '/central/fhc/zs@0,902000:a'
53 * ttyc: '/pci@1f,0/pci@1,1/ebus@1/se@14,400000:a'
54 */
47static int
48uart_cpu_channel(char *dev)
49{
50 char alias[64];
51 phandle_t aliases;
52 int len;
53
54 strcpy(alias, dev);

--- 9 unchanged lines hidden (view full) ---

64int
65uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
66{
67
68 return ((b1->bsh == b2->bsh) ? 1 : 0);
69}
70
71/*
55static int
56uart_cpu_channel(char *dev)
57{
58 char alias[64];
59 phandle_t aliases;
60 int len;
61
62 strcpy(alias, dev);

--- 9 unchanged lines hidden (view full) ---

72int
73uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
74{
75
76 return ((b1->bsh == b2->bsh) ? 1 : 0);
77}
78
79/*
72 * Get the address of the UART that is selected as the console, if the
73 * console is an UART of course. Note that we enforce that both stdin and
74 * stdout are selected.
80 * Get the package handle of the UART that is selected as the console, if
81 * the console is an UART of course. Note that we enforce that both stdin
82 * and stdout are selected.
75 * Note that the currently active console (i.e. /chosen/stdout and
76 * /chosen/stdin) may not be the same as the device selected in the
77 * environment (ie /options/output-device and /options/input-device) because
78 * keyboard and screen were selected but the keyboard was unplugged or the
79 * user has changed the environment. In the latter case I would assume that
80 * the user expects that FreeBSD uses the new console setting.
81 * For weirder configurations, use ofw_console(4).
82 */

--- 27 unchanged lines hidden (view full) ---

110 if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1)
111 return (-1);
112 if (strcmp(buf, "serial") != 0)
113 return (-1);
114 return (input);
115}
116
117/*
83 * Note that the currently active console (i.e. /chosen/stdout and
84 * /chosen/stdin) may not be the same as the device selected in the
85 * environment (ie /options/output-device and /options/input-device) because
86 * keyboard and screen were selected but the keyboard was unplugged or the
87 * user has changed the environment. In the latter case I would assume that
88 * the user expects that FreeBSD uses the new console setting.
89 * For weirder configurations, use ofw_console(4).
90 */

--- 27 unchanged lines hidden (view full) ---

118 if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1)
119 return (-1);
120 if (strcmp(buf, "serial") != 0)
121 return (-1);
122 return (input);
123}
124
125/*
118 * Get the address of the UART that's selected as the debug port. Since
119 * there's no place for this in the OF, we use the kernel environment
126 * Get the package handle of the UART that's selected as the debug port.
127 * Since there's no place for this in the OF, we use the kernel environment
120 * variable "hw.uart.dbgport". Note however that the variable is not a
121 * list of attributes. It's single device name or alias, as known by
122 * the OF.
123 */
124static phandle_t
125uart_cpu_getdev_dbgport(phandle_t options, char *dev, size_t devsz)
126{
127 char buf[32];

--- 5 unchanged lines hidden (view full) ---

133 return (-1);
134 if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1)
135 return (-1);
136 if (strcmp(buf, "serial") != 0)
137 return (-1);
138 return (input);
139}
140
128 * variable "hw.uart.dbgport". Note however that the variable is not a
129 * list of attributes. It's single device name or alias, as known by
130 * the OF.
131 */
132static phandle_t
133uart_cpu_getdev_dbgport(phandle_t options, char *dev, size_t devsz)
134{
135 char buf[32];

--- 5 unchanged lines hidden (view full) ---

141 return (-1);
142 if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1)
143 return (-1);
144 if (strcmp(buf, "serial") != 0)
145 return (-1);
146 return (input);
147}
148
149/*
150 * Get the package handle of the device that is selected as the keyboard
151 * port.
152 * XXX this also matches PS/2 keyboard controllers and most likely also
153 * USB keyboards.
154 */
141static phandle_t
142uart_cpu_getdev_keyboard(phandle_t root, char *dev, size_t devsz)
143{
144 char buf[32];
145 phandle_t child, node;
146
147 child = OF_child(root);
148 while (child != 0 && child != -1) {

--- 45 unchanged lines hidden (view full) ---

194 if (OF_getprop(input, "name", buf, sizeof(buf)) == -1)
195 return (ENXIO);
196 if (OF_getprop(input, "compatible", compat, sizeof(compat)) == -1)
197 compat[0] = '\0';
198 di->bas.regshft = 0;
199 di->bas.rclk = 0;
200 if (!strcmp(buf, "se")) {
201 di->ops = uart_sab82532_ops;
155static phandle_t
156uart_cpu_getdev_keyboard(phandle_t root, char *dev, size_t devsz)
157{
158 char buf[32];
159 phandle_t child, node;
160
161 child = OF_child(root);
162 while (child != 0 && child != -1) {

--- 45 unchanged lines hidden (view full) ---

208 if (OF_getprop(input, "name", buf, sizeof(buf)) == -1)
209 return (ENXIO);
210 if (OF_getprop(input, "compatible", compat, sizeof(compat)) == -1)
211 compat[0] = '\0';
212 di->bas.regshft = 0;
213 di->bas.rclk = 0;
214 if (!strcmp(buf, "se")) {
215 di->ops = uart_sab82532_ops;
202 di->bas.chan = uart_cpu_channel(dev);
216 /* SAB82532 are only known to be used for TTYs. */
217 if ((di->bas.chan = uart_cpu_channel(dev)) == 0)
218 return (ENXIO);
203 addr += 64 * (di->bas.chan - 1);
204 } else if (!strcmp(buf, "zs")) {
205 di->ops = uart_z8530_ops;
219 addr += 64 * (di->bas.chan - 1);
220 } else if (!strcmp(buf, "zs")) {
221 di->ops = uart_z8530_ops;
206 di->bas.chan = uart_cpu_channel(dev);
222 if ((di->bas.chan = uart_cpu_channel(dev)) == 0) {
223 /*
224 * There's no way to determine from OF which
225 * channel has the keyboard. Should always be
226 * on channel 1 however.
227 */
228 if (devtype == UART_DEV_KEYBOARD)
229 di->bas.chan = 1;
230 else
231 return (ENXIO);
232 }
207 di->bas.regshft = 1;
208 addr += 4 - 4 * (di->bas.chan - 1);
209 } else if (!strcmp(buf, "su") || !strcmp(buf, "su_pnp") ||
210 !strcmp(compat, "su") || !strcmp(compat, "su16550")) {
211 di->ops = uart_ns8250_ops;
212 di->bas.chan = 0;
213 } else
214 return (ENXIO);

--- 26 unchanged lines hidden ---
233 di->bas.regshft = 1;
234 addr += 4 - 4 * (di->bas.chan - 1);
235 } else if (!strcmp(buf, "su") || !strcmp(buf, "su_pnp") ||
236 !strcmp(compat, "su") || !strcmp(compat, "su16550")) {
237 di->ops = uart_ns8250_ops;
238 di->bas.chan = 0;
239 } else
240 return (ENXIO);

--- 26 unchanged lines hidden ---