This source file includes following definitions.
- pcic_isapnp_match
- pcic_isapnp_attach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39 #include <sys/device.h>
40 #include <sys/extent.h>
41 #include <sys/malloc.h>
42
43 #include <machine/bus.h>
44 #include <machine/intr.h>
45
46 #include <dev/isa/isareg.h>
47 #include <dev/isa/isavar.h>
48
49 #include <dev/isa/isapnpreg.h>
50
51 #include <dev/pcmcia/pcmciareg.h>
52 #include <dev/pcmcia/pcmciavar.h>
53 #include <dev/pcmcia/pcmciachip.h>
54
55 #include <dev/ic/i82365reg.h>
56 #include <dev/ic/i82365var.h>
57 #include <dev/isa/i82365_isavar.h>
58
59 #undef DPRINTF
60 #ifdef PCICISADEBUG
61 int pcicisapnp_debug = 0 ;
62 #define DPRINTF(arg) if (pcicisapnp_debug) printf arg;
63 #else
64 #define DPRINTF(arg)
65 #endif
66
67 int pcic_isapnp_match(struct device *, void *, void *);
68 void pcic_isapnp_attach(struct device *, struct device *, void *);
69
70 struct cfattach pcic_isapnp_ca = {
71 sizeof(struct pcic_softc), pcic_isapnp_match, pcic_isapnp_attach
72 };
73
74 static struct pcmcia_chip_functions pcic_isa_functions = {
75 pcic_chip_mem_alloc,
76 pcic_chip_mem_free,
77 pcic_chip_mem_map,
78 pcic_chip_mem_unmap,
79
80 pcic_chip_io_alloc,
81 pcic_chip_io_free,
82 pcic_chip_io_map,
83 pcic_chip_io_unmap,
84
85 pcic_isa_chip_intr_establish,
86 pcic_isa_chip_intr_disestablish,
87 pcic_isa_chip_intr_string,
88
89 pcic_chip_socket_enable,
90 pcic_chip_socket_disable,
91 };
92
93 int
94 pcic_isapnp_match(parent, match, aux)
95 struct device *parent;
96 void *match;
97 void *aux;
98 {
99 return (1);
100 }
101
102 void
103 pcic_isapnp_attach(parent, self, aux)
104 struct device *parent, *self;
105 void *aux;
106 {
107 struct pcic_softc *sc = (void *) self;
108 struct pcic_handle *h;
109 struct isa_attach_args *ipa = aux;
110 isa_chipset_tag_t ic = ipa->ia_ic;
111 bus_space_tag_t iot = ipa->ia_iot;
112 bus_space_tag_t memt = ipa->ia_memt;
113 bus_space_handle_t ioh;
114 bus_space_handle_t memh;
115 int tmp1, i;
116
117 printf("\n");
118
119 if (isapnp_config(iot, memt, ipa)) {
120 printf("%s: error in region allocation\n", sc->dev.dv_xname);
121 return;
122 }
123
124 printf("%s: %s %s", sc->dev.dv_xname, ipa->ipa_devident,
125 ipa->ipa_devclass);
126
127
128 if (ipa->ipa_nio < 1) {
129 printf("%s: failed to get one chunk of i/o space\n",
130 sc->dev.dv_xname);
131 return;
132 }
133
134
135 ioh = ipa->ipa_io[0].h;
136
137
138 bus_space_write_1(iot, ioh, PCIC_REG_INDEX, C0SA + PCIC_IDENT);
139 tmp1 = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
140 printf("(ident 0x%x", tmp1);
141 if (pcic_ident_ok(tmp1)) {
142 printf(" OK)");
143 } else {
144 printf(" Not OK)\n");
145 return;
146 }
147
148 if (bus_space_map(memt, ipa->ia_maddr, ipa->ia_msize, 0, &memh)) {
149 printf(": can't map mem space\n");
150 return;
151 }
152
153 sc->membase = ipa->ia_maddr;
154 sc->subregionmask = (1 << (ipa->ia_msize / PCIC_MEM_PAGESIZE)) - 1;
155
156 sc->intr_est = ic;
157 sc->pct = (pcmcia_chipset_tag_t) & pcic_isa_functions;
158
159 sc->iot = iot;
160 sc->ioh = ioh;
161 sc->memt = memt;
162 sc->memh = memh;
163
164 printf("\n");
165
166 pcic_attach(sc);
167 pcic_isa_bus_width_probe(sc, iot, ioh, ipa->ipa_io[0].base,
168 ipa->ipa_io[0].length);
169 pcic_attach_sockets(sc);
170
171
172
173
174
175
176
177 if (ipa->ipa_nirq > 0)
178 sc->irq = ipa->ipa_irq[0].num;
179 else
180 sc->irq = IRQUNK;
181
182 if (sc->irq == IRQUNK)
183 sc->irq = pcic_intr_find(sc, IST_EDGE);
184
185 if (sc->irq) {
186 sc->ih = isa_intr_establish(ic, sc->irq, IST_EDGE, IPL_TTY,
187 pcic_intr, sc, sc->dev.dv_xname);
188 if (!sc->ih)
189 sc->irq = 0;
190 }
191
192 if (sc->irq) {
193 printf("%s: irq %d, ", sc->dev.dv_xname, sc->irq);
194
195
196 for (i = 0; i < PCIC_NSLOTS; i++) {
197 h = &sc->handle[i];
198 if (h->flags & PCIC_FLAG_SOCKETP) {
199 pcic_write(h, PCIC_CSC_INTR,
200 (sc->irq << PCIC_CSC_INTR_IRQ_SHIFT) |
201 PCIC_CSC_INTR_CD_ENABLE);
202 powerhook_establish(pcic_power, h);
203 }
204 }
205 } else
206 printf("%s: no irq, ", sc->dev.dv_xname);
207
208 printf("polling enabled\n");
209 if (sc->poll_established == 0) {
210 timeout_set(&sc->poll_timeout, pcic_poll_intr, sc);
211 timeout_add(&sc->poll_timeout, hz / 2);
212 sc->poll_established = 1;
213 }
214 }