pcmcom.c revision 1.17 1 1.17 mycroft /* $NetBSD: pcmcom.c,v 1.17 2004/08/10 18:39:08 mycroft Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*-
4 1.17 mycroft * Copyright (c) 1998, 2000, 2004 The NetBSD Foundation, Inc.
5 1.1 thorpej * All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.1 thorpej * by RedBack Networks, Inc.
9 1.1 thorpej *
10 1.1 thorpej * Redistribution and use in source and binary forms, with or without
11 1.1 thorpej * modification, are permitted provided that the following conditions
12 1.1 thorpej * are met:
13 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.1 thorpej * notice, this list of conditions and the following disclaimer.
15 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.1 thorpej * documentation and/or other materials provided with the distribution.
18 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.1 thorpej * must display the following acknowledgement:
20 1.1 thorpej * This product includes software developed by the NetBSD
21 1.1 thorpej * Foundation, Inc. and its contributors.
22 1.1 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 thorpej * contributors may be used to endorse or promote products derived
24 1.1 thorpej * from this software without specific prior written permission.
25 1.1 thorpej *
26 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE.
37 1.1 thorpej */
38 1.1 thorpej
39 1.1 thorpej /*
40 1.1 thorpej * Device driver for multi-port PCMCIA serial cards, written by
41 1.1 thorpej * Jason R. Thorpe for RedBack Networks, Inc.
42 1.1 thorpej *
43 1.1 thorpej * Most of these cards are simply multiple UARTs sharing a single interrupt
44 1.1 thorpej * line, and rely on the fact that PCMCIA level-triggered interrupts can
45 1.1 thorpej * be shared. There are no special interrupt registers on them, as there
46 1.1 thorpej * are on most ISA multi-port serial cards.
47 1.1 thorpej *
48 1.1 thorpej * If there are other cards that have interrupt registers, they should not
49 1.1 thorpej * be glued into this driver. Rather, separate drivers should be written
50 1.1 thorpej * for those devices, as we have in the ISA multi-port serial card case.
51 1.1 thorpej */
52 1.7 lukem
53 1.7 lukem #include <sys/cdefs.h>
54 1.17 mycroft __KERNEL_RCSID(0, "$NetBSD: pcmcom.c,v 1.17 2004/08/10 18:39:08 mycroft Exp $");
55 1.1 thorpej
56 1.1 thorpej #include <sys/param.h>
57 1.1 thorpej #include <sys/systm.h>
58 1.1 thorpej #include <sys/device.h>
59 1.1 thorpej #include <sys/termios.h>
60 1.1 thorpej #include <sys/malloc.h>
61 1.1 thorpej
62 1.1 thorpej #include <machine/bus.h>
63 1.1 thorpej #include <machine/intr.h>
64 1.1 thorpej
65 1.1 thorpej #include <dev/ic/comreg.h>
66 1.1 thorpej #include <dev/ic/comvar.h>
67 1.1 thorpej
68 1.1 thorpej #include <dev/pcmcia/pcmciavar.h>
69 1.1 thorpej #include <dev/pcmcia/pcmciareg.h>
70 1.1 thorpej #include <dev/pcmcia/pcmciadevs.h>
71 1.1 thorpej
72 1.1 thorpej #include "com.h"
73 1.1 thorpej #include "pcmcom.h"
74 1.1 thorpej
75 1.1 thorpej #include "locators.h"
76 1.1 thorpej
77 1.1 thorpej struct pcmcom_slave_info {
78 1.1 thorpej struct pcmcia_io_handle psi_pcioh; /* PCMCIA i/o space info */
79 1.1 thorpej int psi_io_window; /* our i/o window */
80 1.1 thorpej struct device *psi_child; /* child's device */
81 1.1 thorpej };
82 1.1 thorpej
83 1.1 thorpej struct pcmcom_softc {
84 1.1 thorpej struct device sc_dev; /* generic device glue */
85 1.1 thorpej
86 1.1 thorpej struct pcmcia_function *sc_pf; /* our PCMCIA function */
87 1.1 thorpej void *sc_ih; /* interrupt handle */
88 1.1 thorpej int sc_enabled_count; /* enabled count */
89 1.1 thorpej
90 1.1 thorpej struct pcmcom_slave_info *sc_slaves; /* slave info */
91 1.1 thorpej int sc_nslaves; /* slave count */
92 1.1 thorpej };
93 1.1 thorpej
94 1.1 thorpej struct pcmcom_attach_args {
95 1.1 thorpej bus_space_tag_t pca_iot; /* I/O tag */
96 1.1 thorpej bus_space_handle_t pca_ioh; /* I/O handle */
97 1.1 thorpej int pca_slave; /* slave # */
98 1.1 thorpej };
99 1.1 thorpej
100 1.1 thorpej int pcmcom_match __P((struct device *, struct cfdata *, void *));
101 1.1 thorpej void pcmcom_attach __P((struct device *, struct device *, void *));
102 1.3 thorpej int pcmcom_detach __P((struct device *, int));
103 1.3 thorpej int pcmcom_activate __P((struct device *, enum devact));
104 1.1 thorpej
105 1.12 thorpej CFATTACH_DECL(pcmcom, sizeof(struct pcmcom_softc),
106 1.13 thorpej pcmcom_match, pcmcom_attach, pcmcom_detach, pcmcom_activate);
107 1.1 thorpej
108 1.5 cgd const struct pcmcom_product {
109 1.5 cgd struct pcmcia_product pp_product;
110 1.1 thorpej int pp_nslaves; /* number of slaves */
111 1.1 thorpej } pcmcom_products[] = {
112 1.17 mycroft { { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_DUAL_RS232,
113 1.17 mycroft PCMCIA_CIS_INVALID },
114 1.5 cgd 2 },
115 1.1 thorpej };
116 1.17 mycroft const size_t pcmcom_nproducts =
117 1.17 mycroft sizeof(pcmcom_products) / sizeof(pcmcom_products[0]);
118 1.1 thorpej
119 1.1 thorpej int pcmcom_print __P((void *, const char *));
120 1.1 thorpej int pcmcom_submatch __P((struct device *, struct cfdata *, void *));
121 1.1 thorpej
122 1.1 thorpej int pcmcom_check_cfe __P((struct pcmcom_softc *,
123 1.1 thorpej struct pcmcia_config_entry *));
124 1.1 thorpej void pcmcom_attach_slave __P((struct pcmcom_softc *, int));
125 1.1 thorpej
126 1.1 thorpej int pcmcom_enable __P((struct pcmcom_softc *));
127 1.1 thorpej void pcmcom_disable __P((struct pcmcom_softc *));
128 1.1 thorpej
129 1.1 thorpej int pcmcom_intr __P((void *));
130 1.1 thorpej
131 1.1 thorpej int
132 1.1 thorpej pcmcom_match(parent, cf, aux)
133 1.1 thorpej struct device *parent;
134 1.1 thorpej struct cfdata *cf;
135 1.1 thorpej void *aux;
136 1.1 thorpej {
137 1.1 thorpej struct pcmcia_attach_args *pa = aux;
138 1.1 thorpej
139 1.17 mycroft if (pcmcia_product_lookup(pa, pcmcom_products, pcmcom_nproducts,
140 1.17 mycroft sizeof(pcmcom_products[0]), NULL))
141 1.17 mycroft return (2); /* beat com_pcmcia */
142 1.1 thorpej return (0);
143 1.1 thorpej }
144 1.1 thorpej
145 1.1 thorpej void
146 1.1 thorpej pcmcom_attach(parent, self, aux)
147 1.1 thorpej struct device *parent, *self;
148 1.1 thorpej void *aux;
149 1.1 thorpej {
150 1.1 thorpej struct pcmcom_softc *sc = (struct pcmcom_softc *)self;
151 1.1 thorpej struct pcmcia_attach_args *pa = aux;
152 1.1 thorpej struct pcmcia_config_entry *cfe;
153 1.5 cgd const struct pcmcom_product *pp;
154 1.1 thorpej size_t size;
155 1.1 thorpej int i;
156 1.1 thorpej
157 1.17 mycroft printf("\n");
158 1.1 thorpej sc->sc_pf = pa->pf;
159 1.1 thorpej
160 1.17 mycroft pp = pcmcia_product_lookup(pa, pcmcom_products, pcmcom_nproducts,
161 1.17 mycroft sizeof(pcmcom_products[0]), NULL);
162 1.17 mycroft if (!pp) {
163 1.1 thorpej printf("\n");
164 1.1 thorpej panic("pcmcom_attach: impossible");
165 1.1 thorpej }
166 1.1 thorpej
167 1.1 thorpej /* Allocate the slave info. */
168 1.1 thorpej sc->sc_nslaves = pp->pp_nslaves;
169 1.1 thorpej size = sizeof(struct pcmcom_slave_info) * sc->sc_nslaves;
170 1.8 tsutsui sc->sc_slaves = malloc(size, M_DEVBUF, M_NOWAIT|M_ZERO);
171 1.1 thorpej if (sc->sc_slaves == NULL) {
172 1.1 thorpej printf("%s: unable to allocate slave info\n",
173 1.1 thorpej sc->sc_dev.dv_xname);
174 1.1 thorpej return;
175 1.1 thorpej }
176 1.1 thorpej
177 1.1 thorpej /*
178 1.1 thorpej * The address decoders on these cards are stupid. They decode
179 1.1 thorpej * (usually) 10 bits of address, so you need to allocate the
180 1.1 thorpej * regions they request in order for the card to differentiate
181 1.1 thorpej * between serial ports.
182 1.1 thorpej */
183 1.9 lukem SIMPLEQ_FOREACH(cfe, &pa->pf->cfe_head, cfe_list) {
184 1.1 thorpej if (pcmcom_check_cfe(sc, cfe)) {
185 1.1 thorpej /* Found one! */
186 1.1 thorpej break;
187 1.1 thorpej }
188 1.1 thorpej }
189 1.1 thorpej if (cfe == NULL) {
190 1.1 thorpej printf("%s: unable to find a suitable config table entry\n",
191 1.1 thorpej sc->sc_dev.dv_xname);
192 1.1 thorpej return;
193 1.1 thorpej }
194 1.1 thorpej
195 1.1 thorpej /* Enable the card. */
196 1.1 thorpej pcmcia_function_init(pa->pf, cfe);
197 1.1 thorpej if (pcmcia_function_enable(sc->sc_pf)) {
198 1.1 thorpej printf("%s: function enable failed\n", sc->sc_dev.dv_xname);
199 1.1 thorpej return;
200 1.2 thorpej }
201 1.1 thorpej
202 1.1 thorpej sc->sc_enabled_count = 1;
203 1.1 thorpej
204 1.1 thorpej /* Attach the children. */
205 1.1 thorpej for (i = 0; i < sc->sc_nslaves; i++)
206 1.1 thorpej pcmcom_attach_slave(sc, i);
207 1.1 thorpej
208 1.1 thorpej sc->sc_enabled_count = 0;
209 1.1 thorpej pcmcia_function_disable(sc->sc_pf);
210 1.1 thorpej }
211 1.1 thorpej
212 1.1 thorpej int
213 1.1 thorpej pcmcom_check_cfe(sc, cfe)
214 1.1 thorpej struct pcmcom_softc *sc;
215 1.1 thorpej struct pcmcia_config_entry *cfe;
216 1.1 thorpej {
217 1.1 thorpej struct pcmcom_slave_info *psi;
218 1.1 thorpej int slave;
219 1.1 thorpej
220 1.1 thorpej /* We need to have the same number of I/O spaces as we do slaves. */
221 1.1 thorpej if (cfe->num_iospace != sc->sc_nslaves)
222 1.1 thorpej return (0);
223 1.1 thorpej
224 1.1 thorpej for (slave = 0; slave < sc->sc_nslaves; slave++) {
225 1.1 thorpej psi = &sc->sc_slaves[slave];
226 1.1 thorpej if (pcmcia_io_alloc(sc->sc_pf,
227 1.1 thorpej cfe->iospace[slave].start,
228 1.1 thorpej cfe->iospace[slave].length,
229 1.1 thorpej cfe->iospace[slave].length,
230 1.1 thorpej &psi->psi_pcioh))
231 1.1 thorpej goto release;
232 1.1 thorpej }
233 1.1 thorpej
234 1.1 thorpej /* If we got here, we were able to allocate space for all slaves! */
235 1.1 thorpej return (1);
236 1.1 thorpej
237 1.1 thorpej release:
238 1.1 thorpej /* Release the i/o spaces we've allocated. */
239 1.1 thorpej for (slave--; slave >= 0; slave--) {
240 1.1 thorpej psi = &sc->sc_slaves[slave];
241 1.1 thorpej pcmcia_io_free(sc->sc_pf, &psi->psi_pcioh);
242 1.1 thorpej }
243 1.1 thorpej return (0);
244 1.1 thorpej }
245 1.1 thorpej
246 1.1 thorpej void
247 1.1 thorpej pcmcom_attach_slave(sc, slave)
248 1.1 thorpej struct pcmcom_softc *sc;
249 1.1 thorpej int slave;
250 1.1 thorpej {
251 1.1 thorpej struct pcmcom_slave_info *psi = &sc->sc_slaves[slave];
252 1.1 thorpej struct pcmcom_attach_args pca;
253 1.1 thorpej
254 1.1 thorpej printf("%s: slave %d", sc->sc_dev.dv_xname, slave);
255 1.1 thorpej
256 1.15 mycroft if (pcmcia_io_map(sc->sc_pf, PCMCIA_WIDTH_IO8, &psi->psi_pcioh,
257 1.15 mycroft &psi->psi_io_window)) {
258 1.1 thorpej printf(": can't map i/o space\n");
259 1.1 thorpej return;
260 1.1 thorpej }
261 1.1 thorpej
262 1.1 thorpej printf("\n");
263 1.1 thorpej
264 1.1 thorpej pca.pca_iot = psi->psi_pcioh.iot;
265 1.1 thorpej pca.pca_ioh = psi->psi_pcioh.ioh;
266 1.1 thorpej pca.pca_slave = slave;
267 1.1 thorpej
268 1.1 thorpej psi->psi_child = config_found_sm(&sc->sc_dev, &pca, pcmcom_print,
269 1.1 thorpej pcmcom_submatch);
270 1.1 thorpej }
271 1.1 thorpej
272 1.1 thorpej int
273 1.3 thorpej pcmcom_detach(self, flags)
274 1.3 thorpej struct device *self;
275 1.3 thorpej int flags;
276 1.3 thorpej {
277 1.3 thorpej struct pcmcom_softc *sc = (struct pcmcom_softc *)self;
278 1.3 thorpej struct pcmcom_slave_info *psi;
279 1.3 thorpej int slave, error;
280 1.3 thorpej
281 1.4 thorpej for (slave = sc->sc_nslaves - 1; slave >= 0; slave--) {
282 1.3 thorpej psi = &sc->sc_slaves[slave];
283 1.3 thorpej if (psi->psi_child == NULL)
284 1.3 thorpej continue;
285 1.3 thorpej
286 1.3 thorpej /* Detach the child. */
287 1.6 itojun if ((error = config_detach(psi->psi_child, flags)) != 0)
288 1.3 thorpej return (error);
289 1.3 thorpej psi->psi_child = NULL;
290 1.3 thorpej
291 1.3 thorpej /* Unmap the i/o window. */
292 1.3 thorpej pcmcia_io_unmap(sc->sc_pf, psi->psi_io_window);
293 1.3 thorpej
294 1.3 thorpej /* Free the i/o space. */
295 1.3 thorpej pcmcia_io_free(sc->sc_pf, &psi->psi_pcioh);
296 1.3 thorpej }
297 1.3 thorpej return (0);
298 1.3 thorpej }
299 1.3 thorpej
300 1.3 thorpej int
301 1.3 thorpej pcmcom_activate(self, act)
302 1.3 thorpej struct device *self;
303 1.3 thorpej enum devact act;
304 1.3 thorpej {
305 1.3 thorpej struct pcmcom_softc *sc = (struct pcmcom_softc *)self;
306 1.3 thorpej struct pcmcom_slave_info *psi;
307 1.3 thorpej int slave, error = 0, s;
308 1.3 thorpej
309 1.3 thorpej s = splserial();
310 1.3 thorpej switch (act) {
311 1.3 thorpej case DVACT_ACTIVATE:
312 1.3 thorpej error = EOPNOTSUPP;
313 1.3 thorpej break;
314 1.3 thorpej
315 1.3 thorpej case DVACT_DEACTIVATE:
316 1.4 thorpej for (slave = sc->sc_nslaves - 1; slave >= 0; slave--) {
317 1.3 thorpej psi = &sc->sc_slaves[slave];
318 1.3 thorpej if (psi->psi_child == NULL)
319 1.3 thorpej continue;
320 1.3 thorpej
321 1.3 thorpej /*
322 1.3 thorpej * Deactivate the child. Doing so will cause our
323 1.3 thorpej * own enabled count to drop to 0, once all children
324 1.3 thorpej * are deactivated.
325 1.3 thorpej */
326 1.3 thorpej if ((error = config_deactivate(psi->psi_child)) != 0)
327 1.3 thorpej break;
328 1.3 thorpej }
329 1.3 thorpej break;
330 1.3 thorpej }
331 1.3 thorpej splx(s);
332 1.3 thorpej return (error);
333 1.3 thorpej }
334 1.3 thorpej
335 1.3 thorpej int
336 1.1 thorpej pcmcom_print(aux, pnp)
337 1.1 thorpej void *aux;
338 1.1 thorpej const char *pnp;
339 1.1 thorpej {
340 1.1 thorpej struct pcmcom_attach_args *pca = aux;
341 1.1 thorpej
342 1.1 thorpej /* only com's can attach to pcmcom's; easy... */
343 1.1 thorpej if (pnp)
344 1.14 thorpej aprint_normal("com at %s", pnp);
345 1.1 thorpej
346 1.14 thorpej aprint_normal(" slave %d", pca->pca_slave);
347 1.1 thorpej
348 1.1 thorpej return (UNCONF);
349 1.1 thorpej }
350 1.1 thorpej
351 1.1 thorpej int
352 1.1 thorpej pcmcom_submatch(parent, cf, aux)
353 1.1 thorpej struct device *parent;
354 1.1 thorpej struct cfdata *cf;
355 1.1 thorpej void *aux;
356 1.1 thorpej {
357 1.1 thorpej struct pcmcom_attach_args *pca = aux;
358 1.1 thorpej
359 1.1 thorpej if (cf->cf_loc[PCMCOMCF_SLAVE] != pca->pca_slave &&
360 1.1 thorpej cf->cf_loc[PCMCOMCF_SLAVE] != PCMCOMCF_SLAVE_DEFAULT)
361 1.1 thorpej return (0);
362 1.1 thorpej
363 1.10 thorpej return (config_match(parent, cf, aux));
364 1.1 thorpej }
365 1.1 thorpej
366 1.1 thorpej int
367 1.1 thorpej pcmcom_intr(arg)
368 1.1 thorpej void *arg;
369 1.1 thorpej {
370 1.1 thorpej #if NCOM > 0
371 1.1 thorpej struct pcmcom_softc *sc = arg;
372 1.1 thorpej int i, rval = 0;
373 1.1 thorpej
374 1.1 thorpej if (sc->sc_enabled_count == 0)
375 1.1 thorpej return (0);
376 1.1 thorpej
377 1.1 thorpej for (i = 0; i < sc->sc_nslaves; i++) {
378 1.1 thorpej if (sc->sc_slaves[i].psi_child != NULL)
379 1.1 thorpej rval |= comintr(sc->sc_slaves[i].psi_child);
380 1.1 thorpej }
381 1.1 thorpej
382 1.1 thorpej return (rval);
383 1.1 thorpej #else
384 1.1 thorpej return (0);
385 1.1 thorpej #endif /* NCOM > 0 */
386 1.1 thorpej }
387 1.1 thorpej
388 1.1 thorpej int
389 1.1 thorpej pcmcom_enable(sc)
390 1.1 thorpej struct pcmcom_softc *sc;
391 1.1 thorpej {
392 1.16 mycroft int error;
393 1.1 thorpej
394 1.16 mycroft if (sc->sc_enabled_count++ != 0)
395 1.1 thorpej return (0);
396 1.1 thorpej
397 1.1 thorpej /* Establish the interrupt. */
398 1.1 thorpej sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_SERIAL,
399 1.1 thorpej pcmcom_intr, sc);
400 1.1 thorpej if (sc->sc_ih == NULL) {
401 1.1 thorpej printf("%s: couldn't establish interrupt\n",
402 1.1 thorpej sc->sc_dev.dv_xname);
403 1.1 thorpej return (1);
404 1.1 thorpej }
405 1.1 thorpej
406 1.16 mycroft error = pcmcia_function_enable(sc->sc_pf);
407 1.16 mycroft if (error)
408 1.16 mycroft pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
409 1.16 mycroft
410 1.16 mycroft return (error);
411 1.1 thorpej }
412 1.1 thorpej
413 1.1 thorpej void
414 1.1 thorpej pcmcom_disable(sc)
415 1.1 thorpej struct pcmcom_softc *sc;
416 1.1 thorpej {
417 1.1 thorpej
418 1.16 mycroft if (--sc->sc_enabled_count != 0)
419 1.1 thorpej return;
420 1.1 thorpej
421 1.1 thorpej pcmcia_function_disable(sc->sc_pf);
422 1.1 thorpej pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
423 1.1 thorpej }
424 1.1 thorpej
425 1.1 thorpej /****** Here begins the com attachment code. ******/
426 1.1 thorpej
427 1.1 thorpej #if NCOM_PCMCOM > 0
428 1.1 thorpej int com_pcmcom_match __P((struct device *, struct cfdata *, void *));
429 1.1 thorpej void com_pcmcom_attach __P((struct device *, struct device *, void *));
430 1.1 thorpej
431 1.1 thorpej /* No pcmcom-specific goo in the softc; it's all in the parent. */
432 1.12 thorpej CFATTACH_DECL(com_pcmcom, sizeof(struct com_softc),
433 1.13 thorpej com_pcmcom_match, com_pcmcom_attach, com_detach, com_activate);
434 1.1 thorpej
435 1.1 thorpej int com_pcmcom_enable __P((struct com_softc *));
436 1.1 thorpej void com_pcmcom_disable __P((struct com_softc *));
437 1.1 thorpej
438 1.1 thorpej int
439 1.1 thorpej com_pcmcom_match(parent, cf, aux)
440 1.1 thorpej struct device *parent;
441 1.1 thorpej struct cfdata *cf;
442 1.1 thorpej void *aux;
443 1.1 thorpej {
444 1.1 thorpej
445 1.1 thorpej /* Device is always present. */
446 1.1 thorpej return (1);
447 1.1 thorpej }
448 1.1 thorpej
449 1.1 thorpej void
450 1.1 thorpej com_pcmcom_attach(parent, self, aux)
451 1.1 thorpej struct device *parent, *self;
452 1.1 thorpej void *aux;
453 1.1 thorpej {
454 1.1 thorpej struct com_softc *sc = (struct com_softc *)self;
455 1.1 thorpej struct pcmcom_attach_args *pca = aux;
456 1.1 thorpej
457 1.1 thorpej sc->sc_iot = pca->pca_iot;
458 1.1 thorpej sc->sc_ioh = pca->pca_ioh;
459 1.1 thorpej
460 1.1 thorpej sc->enabled = 1;
461 1.1 thorpej
462 1.1 thorpej sc->sc_iobase = -1;
463 1.1 thorpej sc->sc_frequency = COM_FREQ;
464 1.1 thorpej
465 1.1 thorpej sc->enable = com_pcmcom_enable;
466 1.1 thorpej sc->disable = com_pcmcom_disable;
467 1.1 thorpej
468 1.1 thorpej com_attach_subr(sc);
469 1.1 thorpej
470 1.1 thorpej sc->enabled = 0;
471 1.1 thorpej }
472 1.1 thorpej
473 1.1 thorpej int
474 1.1 thorpej com_pcmcom_enable(sc)
475 1.1 thorpej struct com_softc *sc;
476 1.1 thorpej {
477 1.1 thorpej
478 1.1 thorpej return (pcmcom_enable((struct pcmcom_softc *)sc->sc_dev.dv_parent));
479 1.1 thorpej }
480 1.1 thorpej
481 1.1 thorpej void
482 1.1 thorpej com_pcmcom_disable(sc)
483 1.1 thorpej struct com_softc *sc;
484 1.1 thorpej {
485 1.1 thorpej
486 1.1 thorpej pcmcom_disable((struct pcmcom_softc *)sc->sc_dev.dv_parent);
487 1.1 thorpej }
488 1.1 thorpej #endif /* NCOM_PCMCOM > 0 */
489