Annotation of sys/arch/sparc/dev/com_obio.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: com_obio.c,v 1.1 2005/07/17 12:22:42 miod Exp $ */
2:
3: /*
4: * Copyright (c) 2005, Miodrag Vallat.
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: * 1. Redistributions of source code must retain the above copyright
10: * notice, this list of conditions and the following disclaimer.
11: * 2. Redistributions in binary form must reproduce the above copyright
12: * notice, this list of conditions and the following disclaimer in the
13: * documentation and/or other materials provided with the distribution.
14: *
15: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25: * POSSIBILITY OF SUCH DAMAGE.
26: */
27:
28: /*
29: * Driver for the built-in modem on Tadpole SPARCbooks, which provides a
30: * 16C450-compatible interface. Later models apparently are 16550A-compatible
31: * (i.e. with a 16 byte FIFO).
32: */
33:
34: #include <sys/types.h>
35: #include <sys/param.h>
36: #include <sys/systm.h>
37: #include <sys/device.h>
38: #include <sys/tty.h>
39:
40: #include <machine/bus.h>
41: #include <sparc/sparc/auxioreg.h>
42:
43: #include <dev/ic/comreg.h>
44: #include <dev/ic/comvar.h>
45:
46: int com_obio_match(struct device *, void *, void *);
47: void com_obio_attach(struct device *, struct device *, void *);
48:
49: struct com_obio_softc {
50: struct com_softc sc_com;
51: struct intrhand sc_ih;
52: struct rom_reg sc_reg;
53: int sc_pwr;
54: };
55:
56: struct cfattach com_obio_ca = {
57: sizeof(struct com_obio_softc), com_obio_match, com_obio_attach
58: };
59:
60: void com_obio_disable(struct com_softc *);
61: int com_obio_enable(struct com_softc *);
62:
63: int
64: com_obio_match(struct device *parent, void *match, void *aux)
65: {
66: struct confargs *ca = aux;
67:
68: return (strcmp("modem", ca->ca_ra.ra_name) == 0);
69: }
70:
71: void
72: com_obio_attach(struct device *parent, struct device *self, void *aux)
73: {
74: struct confargs *ca = aux;
75: struct com_softc *sc = (void *)self;
76: struct com_obio_softc *osc = (void *)sc;
77:
78: /* build a bus tag */
79: osc->sc_reg = ca->ca_ra.ra_reg[0];
80:
81: #if 0 /* not necessary as we don't compile com console support */
82: sc->sc_iobase = -1;
83: #endif
84: sc->sc_iot = &osc->sc_reg;
85:
86: if (ca->ca_ra.ra_nreg == 0 || bus_space_map(sc->sc_iot, 0,
87: ca->ca_ra.ra_len, 0, &sc->sc_ioh) != 0) {
88: printf(": can't map modem registers\n");
89: return;
90: }
91:
92: osc->sc_ih.ih_fun = comintr;
93: osc->sc_ih.ih_arg = sc;
94: intr_establish(ca->ca_ra.ra_intr[0].int_pri, &osc->sc_ih, -1,
95: self->dv_xname);
96: printf(" pri %d", ca->ca_ra.ra_intr[0].int_pri);
97:
98: sc->disable = com_obio_disable;
99: sc->enable = com_obio_enable;
100: osc->sc_pwr = getpropint(ca->ca_ra.ra_node, "pwr-on-auxio", 0);
101: com_obio_enable(sc);
102: sc->enabled = 1;
103:
104: sc->sc_frequency = COM_FREQ;
105: com_attach_subr(sc);
106: }
107:
108: void
109: com_obio_disable(struct com_softc *sc)
110: {
111: struct com_obio_softc *osc = (void *)sc;
112:
113: if (osc->sc_pwr) {
114: sb_auxregbisc(0, 0, AUXIO_MODEM | AUXIO_MODEM_RESET);
115: }
116: }
117:
118: int
119: com_obio_enable(struct com_softc *sc)
120: {
121: struct com_obio_softc *osc = (void *)sc;
122:
123: if (osc->sc_pwr) {
124: /* enable and reset modem for 20 usec */
125: sb_auxregbisc(0, AUXIO_MODEM, AUXIO_MODEM_RESET);
126: delay(20);
127: /* end reset (active low) */
128: sb_auxregbisc(0, AUXIO_MODEM_RESET, 0);
129: /* give the device some time to settle */
130: delay(100);
131: }
132: return (0);
133: }
CVSweb