1 /* $NetBSD: acemidi.c,v 1.7 2002/10/02 16:52:23 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 2001 Ben Harris
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: acemidi.c,v 1.7 2002/10/02 16:52:23 thorpej Exp $");
32
33 #include <sys/param.h>
34
35 #include <sys/device.h>
36 #include <sys/systm.h>
37
38 #include <machine/bus.h>
39
40 #include <dev/podulebus/podulebus.h>
41 #include <dev/podulebus/podules.h>
42 #include <dev/podulebus/acemidireg.h>
43
44 #include <sys/termios.h>
45 #include <dev/ic/comvar.h>
46 #include <dev/ic/comreg.h>
47
48 struct acemidi_softc {
49 struct device sc_dev;
50 };
51
52 struct com_acemidi_softc {
53 struct com_softc sc_com;
54 struct evcnt sc_intrcnt;
55 };
56
57 static int acemidi_match(struct device *, struct cfdata *, void *);
58 static void acemidi_attach(struct device *, struct device *, void *);
59 static int com_acemidi_match(struct device *, struct cfdata *, void *);
60 static void com_acemidi_attach(struct device *, struct device *, void *);
61
62 CFATTACH_DECL(acemidi, sizeof(struct acemidi_softc),
63 acemidi_match, acemidi_attach, NULL, NULL);
64
65 CFATTACH_DECL(com_acemidi, sizeof(struct com_acemidi_softc),
66 com_acemidi_match, com_acemidi_attach, NULL, NULL);
67
68 static int
69 acemidi_match(struct device *parent, struct cfdata *cf, void *aux)
70 {
71 struct podulebus_attach_args *pa = aux;
72
73 if (pa->pa_product == PODULE_MIDICONNECT)
74 return 1;
75 return 0;
76 }
77
78 static void
79 acemidi_attach(struct device *parent, struct device *self, void *aux)
80 {
81 /* struct acemidi_softc *sc = (void *)self; */
82 /* struct podulebus_attach_args *pa = aux; */
83
84 printf("\n");
85 config_found_sm(self, aux, NULL, NULL);
86 }
87
88 static int
89 com_acemidi_match(struct device *parent, struct cfdata *cf, void *aux)
90 {
91
92 return 1;
93 }
94
95 static void
96 com_acemidi_attach(struct device *parent, struct device *self, void *aux)
97 {
98 struct com_acemidi_softc *sc = (void *)self;
99 struct com_softc *csc = &sc->sc_com;
100 struct podulebus_attach_args *pa = aux;
101
102 csc->sc_iobase = pa->pa_fast_base + ACEMIDI_16550_BASE;
103 csc->sc_iot = pa->pa_fast_t;
104 bus_space_map(csc->sc_iot, csc->sc_iobase, COM_NPORTS, 0,
105 &csc->sc_ioh);
106 csc->sc_frequency = ACEMIDI_16550_FREQ;
107
108 com_attach_subr(csc);
109
110 evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
111 self->dv_xname, "intr");
112 podulebus_irq_establish(pa->pa_ih, IPL_SERIAL, comintr, sc,
113 &sc->sc_intrcnt);
114 }
115
116 /*
117 * Stray IRQ bug:
118 *
119 * Occasionally, when receiving, we get a stray IRQ. Sometimes, the interrupt
120 * bit on the unixbp reads as clear. In any case, comintr() gets an IIR
121 * of 0xc1 (no interrupts pending).
122 *
123 * The behaviour can be observed with a logic probe:
124 *
125 * Channel 1 to PIRQ* (pin 19 on IC3 on A540 backplane)
126 * Channel 2 to INTR on 16550
127 * trigger on ch1 low, ch2 falling
128 * 2 us/div
129 *
130 * This catches cases where the 16550 de-asserts the interrupt before
131 * irq_handler is entered and disables the interrupt at unixbp (by calling
132 * splhigh()).
133 *
134 * This gets us 5us pulses on INTR and PIRQ*. Now to work out why.
135 *
136 * Connecting channel 3 to the CS2* pin on the 16550 shows it high throughout,
137 * so the interrupt isn't being cleared by the host. MR, similarly, is low
138 * throughout, so it's not being cleared by a reset.
139 */
Cache object: 88d12e86dcb241ee383bf331cd16c466
|