| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $Id: rmixl_com.c,v 1.1.2.3 2009/09/15 02:33:39 cliff Exp $ */ | | 1 | /* $Id: rmixl_com.c,v 1.1.2.4 2009/09/15 10:32:41 cliff Exp $ */ |
2 | /*- | | 2 | /*- |
3 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | | 3 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. |
4 | * Copyright (c) 2006 Garrett D'Amore. | | 4 | * Copyright (c) 2006 Garrett D'Amore. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Portions of this code were written by Garrett D'Amore for the | | 7 | * Portions of this code were written by Garrett D'Amore for the |
8 | * Champaign-Urbana Community Wireless Network Project. | | 8 | * Champaign-Urbana Community Wireless Network Project. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or | | 10 | * Redistribution and use in source and binary forms, with or |
11 | * without modification, are permitted provided that the following | | 11 | * without modification, are permitted provided that the following |
12 | * conditions are met: | | 12 | * conditions are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -91,27 +91,27 @@ | | | @@ -91,27 +91,27 @@ |
91 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 91 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
92 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 92 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
93 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 93 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
94 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 94 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
95 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 95 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
96 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 96 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
97 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 97 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
98 | * SUCH DAMAGE. | | 98 | * SUCH DAMAGE. |
99 | * | | 99 | * |
100 | * @(#)com.c 7.5 (Berkeley) 5/16/91 | | 100 | * @(#)com.c 7.5 (Berkeley) 5/16/91 |
101 | */ | | 101 | */ |
102 | | | 102 | |
103 | #include <sys/cdefs.h> | | 103 | #include <sys/cdefs.h> |
104 | __KERNEL_RCSID(0, "$NetBSD: rmixl_com.c,v 1.1.2.3 2009/09/15 02:33:39 cliff Exp $"); | | 104 | __KERNEL_RCSID(0, "$NetBSD: rmixl_com.c,v 1.1.2.4 2009/09/15 10:32:41 cliff Exp $"); |
105 | | | 105 | |
106 | #include <sys/param.h> | | 106 | #include <sys/param.h> |
107 | #include <sys/systm.h> | | 107 | #include <sys/systm.h> |
108 | #include <sys/device.h> | | 108 | #include <sys/device.h> |
109 | #include <sys/kernel.h> | | 109 | #include <sys/kernel.h> |
110 | #include <sys/termios.h> | | 110 | #include <sys/termios.h> |
111 | #include <sys/ttydefaults.h> | | 111 | #include <sys/ttydefaults.h> |
112 | #include <sys/types.h> | | 112 | #include <sys/types.h> |
113 | | | 113 | |
114 | #include <machine/bus.h> | | 114 | #include <machine/bus.h> |
115 | | | 115 | |
116 | #include <dev/cons.h> | | 116 | #include <dev/cons.h> |
117 | #include <dev/ic/comreg.h> | | 117 | #include <dev/ic/comreg.h> |
| @@ -208,61 +208,64 @@ rmixl_com_match(device_t parent, cfdata_ | | | @@ -208,61 +208,64 @@ rmixl_com_match(device_t parent, cfdata_ |
208 | struct com_regs regs; | | 208 | struct com_regs regs; |
209 | int rv; | | 209 | int rv; |
210 | | | 210 | |
211 | bst = obio->obio_eb_bst; /* com is always big endian */ | | 211 | bst = obio->obio_eb_bst; /* com is always big endian */ |
212 | addr = obio->obio_addr; | | 212 | addr = obio->obio_addr; |
213 | size = obio->obio_size; | | 213 | size = obio->obio_size; |
214 | | | 214 | |
215 | if (com_is_console(bst, addr, ®s.cr_ioh)) | | 215 | if (com_is_console(bst, addr, ®s.cr_ioh)) |
216 | return 1; | | 216 | return 1; |
217 | | | 217 | |
218 | if (bus_space_map(bst, addr, size, 0, ®s.cr_ioh)) | | 218 | if (bus_space_map(bst, addr, size, 0, ®s.cr_ioh)) |
219 | return 0; /* FAIL */ | | 219 | return 0; /* FAIL */ |
220 | | | 220 | |
| | | 221 | memset(®s, 0, sizeof(regs)); |
221 | regs.cr_iot = bst; | | 222 | regs.cr_iot = bst; |
222 | regs.cr_iobase = addr; | | 223 | regs.cr_iobase = addr; |
223 | regs.cr_nports = size; | | 224 | regs.cr_nports = size; |
224 | rmixl_com_initmap(®s); | | 225 | rmixl_com_initmap(®s); |
225 | | | 226 | |
226 | rv = com_probe_subr(®s); | | 227 | rv = com_probe_subr(®s); |
227 | | | 228 | |
228 | bus_space_unmap(bst, regs.cr_ioh, size); | | 229 | bus_space_unmap(bst, regs.cr_ioh, size); |
229 | | | 230 | |
230 | return rv; | | 231 | return rv; |
231 | } | | 232 | } |
232 | | | 233 | |
233 | void | | 234 | void |
234 | rmixl_com_attach(device_t parent, device_t self, void *aux) | | 235 | rmixl_com_attach(device_t parent, device_t self, void *aux) |
235 | { | | 236 | { |
236 | struct rmixl_com_softc *rsc = device_private(self); | | 237 | struct rmixl_com_softc *rsc = device_private(self); |
237 | struct com_softc *sc = &rsc->sc_com; | | 238 | struct com_softc *sc = &rsc->sc_com; |
238 | struct obio_attach_args *obio = aux; | | 239 | struct obio_attach_args *obio = aux; |
239 | bus_space_tag_t bst; | | 240 | bus_space_tag_t bst; |
240 | bus_space_handle_t ioh; | | 241 | bus_space_handle_t ioh; |
241 | bus_addr_t addr; | | 242 | bus_addr_t addr; |
242 | bus_size_t size; | | 243 | bus_size_t size; |
243 | | | 244 | |
| | | 245 | sc->sc_dev = self; |
244 | sc->sc_frequency = -1; /* XXX */ | | 246 | sc->sc_frequency = -1; /* XXX */ |
245 | | | 247 | |
246 | bst = obio->obio_eb_bst; | | 248 | bst = obio->obio_eb_bst; |
247 | addr = obio->obio_addr; | | 249 | addr = obio->obio_addr; |
248 | size = obio->obio_size; | | 250 | size = obio->obio_size; |
249 | | | 251 | |
250 | if (!com_is_console(bst, addr, &ioh) | | 252 | if (!com_is_console(bst, addr, &ioh) |
251 | && bus_space_map(bst, addr, size, 0, &ioh) != 0) { | | 253 | && bus_space_map(bst, addr, size, 0, &ioh) != 0) { |
252 | aprint_error(": can't map registers\n"); | | 254 | aprint_error(": can't map registers\n"); |
253 | return; | | 255 | return; |
254 | } | | 256 | } |
255 | | | 257 | |
| | | 258 | memset(&sc->sc_regs, 0, sizeof(sc->sc_regs)); |
256 | COM_INIT_REGS(sc->sc_regs, bst, ioh, addr); | | 259 | COM_INIT_REGS(sc->sc_regs, bst, ioh, addr); |
257 | sc->sc_regs.cr_nports = size; | | 260 | sc->sc_regs.cr_nports = size; |
258 | rmixl_com_initmap(&sc->sc_regs); | | 261 | rmixl_com_initmap(&sc->sc_regs); |
259 | | | 262 | |
260 | com_attach_subr(sc); | | 263 | com_attach_subr(sc); |
261 | | | 264 | |
262 | #ifdef NOTYET | | 265 | #ifdef NOTYET |
263 | rmixl_intr_establish(obio->obio_intr, comintr, sc); | | 266 | rmixl_intr_establish(obio->obio_intr, comintr, sc); |
264 | #endif | | 267 | #endif |
265 | } | | 268 | } |
266 | | | 269 | |
267 | void | | 270 | void |
268 | rmixl_com_initmap(struct com_regs *regsp) | | 271 | rmixl_com_initmap(struct com_regs *regsp) |
| @@ -276,24 +279,24 @@ rmixl_com_initmap(struct com_regs *regsp | | | @@ -276,24 +279,24 @@ rmixl_com_initmap(struct com_regs *regsp |
276 | sz = sizeof(regsp->cr_map) / sizeof(regsp->cr_map[0]); | | 279 | sz = sizeof(regsp->cr_map) / sizeof(regsp->cr_map[0]); |
277 | for (i = 0; i < 16; i++) | | 280 | for (i = 0; i < 16; i++) |
278 | regsp->cr_map[i] = com_std_map[i] * 4; | | 281 | regsp->cr_map[i] = com_std_map[i] * 4; |
279 | } | | 282 | } |
280 | | | 283 | |
281 | void | | 284 | void |
282 | rmixl_com_cnattach(bus_addr_t addr, int speed, int freq, | | 285 | rmixl_com_cnattach(bus_addr_t addr, int speed, int freq, |
283 | int type, tcflag_t mode) | | 286 | int type, tcflag_t mode) |
284 | { | | 287 | { |
285 | bus_space_tag_t bst; | | 288 | bus_space_tag_t bst; |
286 | bus_size_t sz; | | 289 | bus_size_t sz; |
287 | struct com_regs regs; | | 290 | struct com_regs regs; |
288 | | | 291 | |
289 | bst = (bus_space_tag_t)&rmixl_configuration.rc_el_memt; | | 292 | bst = (bus_space_tag_t)&rmixl_configuration.rc_eb_memt; |
290 | sz = COM_NPORTS * sizeof(uint32_t); /* span of UART regs in bytes */ | | 293 | sz = COM_NPORTS * sizeof(uint32_t); /* span of UART regs in bytes */ |
291 | | | 294 | |
292 | memset(®s, 0, sizeof(regs)); | | 295 | memset(®s, 0, sizeof(regs)); |
293 | rmixl_com_initmap(®s); | | 296 | rmixl_com_initmap(®s); |
294 | regs.cr_iot = bst; | | 297 | regs.cr_iot = bst; |
295 | regs.cr_iobase = addr; | | 298 | regs.cr_iobase = addr; |
296 | regs.cr_nports = sz; | | 299 | regs.cr_nports = sz; |
297 | | | 300 | |
298 | comcnattach1(®s, speed, freq, type, mode); | | 301 | comcnattach1(®s, speed, freq, type, mode); |
299 | } | | 302 | } |