Home | History | Annotate | Line # | Download | only in pcmcia
pcmcom.c revision 1.1
      1  1.1  thorpej /*	$NetBSD: pcmcom.c,v 1.1 1998/10/10 21:27:21 thorpej Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej /*-
      4  1.1  thorpej  * Copyright (c) 1998 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.1  thorpej 
     53  1.1  thorpej #include <sys/param.h>
     54  1.1  thorpej #include <sys/systm.h>
     55  1.1  thorpej #include <sys/device.h>
     56  1.1  thorpej #include <sys/termios.h>
     57  1.1  thorpej #include <sys/malloc.h>
     58  1.1  thorpej 
     59  1.1  thorpej #include <machine/bus.h>
     60  1.1  thorpej #include <machine/intr.h>
     61  1.1  thorpej 
     62  1.1  thorpej #include <dev/ic/comreg.h>
     63  1.1  thorpej #include <dev/ic/comvar.h>
     64  1.1  thorpej 
     65  1.1  thorpej #include <dev/pcmcia/pcmciavar.h>
     66  1.1  thorpej #include <dev/pcmcia/pcmciareg.h>
     67  1.1  thorpej #include <dev/pcmcia/pcmciadevs.h>
     68  1.1  thorpej 
     69  1.1  thorpej #include "com.h"
     70  1.1  thorpej #include "pcmcom.h"
     71  1.1  thorpej 
     72  1.1  thorpej #include "locators.h"
     73  1.1  thorpej 
     74  1.1  thorpej struct pcmcom_slave_info {
     75  1.1  thorpej 	struct pcmcia_io_handle psi_pcioh;	/* PCMCIA i/o space info */
     76  1.1  thorpej 	int psi_io_window;			/* our i/o window */
     77  1.1  thorpej 	struct device *psi_child;		/* child's device */
     78  1.1  thorpej };
     79  1.1  thorpej 
     80  1.1  thorpej struct pcmcom_softc {
     81  1.1  thorpej 	struct device sc_dev;			/* generic device glue */
     82  1.1  thorpej 
     83  1.1  thorpej 	struct pcmcia_function *sc_pf;		/* our PCMCIA function */
     84  1.1  thorpej 	void *sc_ih;				/* interrupt handle */
     85  1.1  thorpej 	int sc_enabled_count;			/* enabled count */
     86  1.1  thorpej 
     87  1.1  thorpej 	struct pcmcom_slave_info *sc_slaves;	/* slave info */
     88  1.1  thorpej 	int sc_nslaves;				/* slave count */
     89  1.1  thorpej };
     90  1.1  thorpej 
     91  1.1  thorpej struct pcmcom_attach_args {
     92  1.1  thorpej 	bus_space_tag_t pca_iot;		/* I/O tag */
     93  1.1  thorpej 	bus_space_handle_t pca_ioh;		/* I/O handle */
     94  1.1  thorpej 	int pca_slave;				/* slave # */
     95  1.1  thorpej };
     96  1.1  thorpej 
     97  1.1  thorpej int	pcmcom_match __P((struct device *, struct cfdata *, void *));
     98  1.1  thorpej void	pcmcom_attach __P((struct device *, struct device *, void *));
     99  1.1  thorpej 
    100  1.1  thorpej struct cfattach pcmcom_ca = {
    101  1.1  thorpej 	sizeof(struct pcmcom_softc), pcmcom_match, pcmcom_attach
    102  1.1  thorpej };
    103  1.1  thorpej 
    104  1.1  thorpej struct pcmcom_product {
    105  1.1  thorpej 	u_int32_t	pp_vendor;		/* PCMCIA vendor ID */
    106  1.1  thorpej 	u_int32_t	pp_product;		/* PCMCIA product ID */
    107  1.1  thorpej 	int		pp_expfunc;		/* expected function number */
    108  1.1  thorpej 	int		pp_nslaves;		/* number of slaves */
    109  1.1  thorpej 	const char	*pp_name;		/* device name */
    110  1.1  thorpej } pcmcom_products[] = {
    111  1.1  thorpej 	{ PCMCIA_VENDOR_SOCKET,		PCMCIA_PRODUCT_SOCKET_DUAL_RS232,
    112  1.1  thorpej 	  0,				2,
    113  1.1  thorpej 	  PCMCIA_STR_SOCKET_DUAL_RS232 },
    114  1.1  thorpej 
    115  1.1  thorpej 	{ 0,				0,
    116  1.1  thorpej 	  0,				0,
    117  1.1  thorpej 	  NULL },
    118  1.1  thorpej };
    119  1.1  thorpej 
    120  1.1  thorpej int	pcmcom_print __P((void *, const char *));
    121  1.1  thorpej int	pcmcom_submatch __P((struct device *, struct cfdata *, void *));
    122  1.1  thorpej 
    123  1.1  thorpej int	pcmcom_check_cfe __P((struct pcmcom_softc *,
    124  1.1  thorpej 	    struct pcmcia_config_entry *));
    125  1.1  thorpej void	pcmcom_attach_slave __P((struct pcmcom_softc *, int));
    126  1.1  thorpej 
    127  1.1  thorpej int	pcmcom_enable __P((struct pcmcom_softc *));
    128  1.1  thorpej void	pcmcom_disable __P((struct pcmcom_softc *));
    129  1.1  thorpej 
    130  1.1  thorpej int	pcmcom_intr __P((void *));
    131  1.1  thorpej 
    132  1.1  thorpej struct pcmcom_product *pcmcom_lookup __P((struct pcmcia_attach_args *));
    133  1.1  thorpej 
    134  1.1  thorpej struct pcmcom_product *
    135  1.1  thorpej pcmcom_lookup(pa)
    136  1.1  thorpej 	struct pcmcia_attach_args *pa;
    137  1.1  thorpej {
    138  1.1  thorpej 	struct pcmcom_product *pp;
    139  1.1  thorpej 
    140  1.1  thorpej 	for (pp = pcmcom_products; pp->pp_name != NULL; pp++)
    141  1.1  thorpej 		if (pa->manufacturer == pp->pp_vendor &&
    142  1.1  thorpej 		    pa->product == pp->pp_product &&
    143  1.1  thorpej 		    pa->pf->number == pp->pp_expfunc)
    144  1.1  thorpej 			return (pp);
    145  1.1  thorpej 
    146  1.1  thorpej 	return (NULL);
    147  1.1  thorpej }
    148  1.1  thorpej 
    149  1.1  thorpej int
    150  1.1  thorpej pcmcom_match(parent, cf, aux)
    151  1.1  thorpej 	struct device *parent;
    152  1.1  thorpej 	struct cfdata *cf;
    153  1.1  thorpej 	void *aux;
    154  1.1  thorpej {
    155  1.1  thorpej 	struct pcmcia_attach_args *pa = aux;
    156  1.1  thorpej 
    157  1.1  thorpej 	if (pcmcom_lookup(pa) != NULL)
    158  1.1  thorpej 		return (10);	/* beat com_pcmcia */
    159  1.1  thorpej 	return (0);
    160  1.1  thorpej }
    161  1.1  thorpej 
    162  1.1  thorpej void
    163  1.1  thorpej pcmcom_attach(parent, self, aux)
    164  1.1  thorpej 	struct device *parent, *self;
    165  1.1  thorpej 	void *aux;
    166  1.1  thorpej {
    167  1.1  thorpej 	struct pcmcom_softc *sc = (struct pcmcom_softc *)self;
    168  1.1  thorpej 	struct pcmcia_attach_args *pa = aux;
    169  1.1  thorpej 	struct pcmcia_config_entry *cfe;
    170  1.1  thorpej 	struct pcmcom_product *pp;
    171  1.1  thorpej 	size_t size;
    172  1.1  thorpej 	int i;
    173  1.1  thorpej 
    174  1.1  thorpej 	sc->sc_pf = pa->pf;
    175  1.1  thorpej 
    176  1.1  thorpej 	pp = pcmcom_lookup(pa);
    177  1.1  thorpej 	if (pp == NULL) {
    178  1.1  thorpej 		printf("\n");
    179  1.1  thorpej 		panic("pcmcom_attach: impossible");
    180  1.1  thorpej 	}
    181  1.1  thorpej 
    182  1.1  thorpej 	printf(": %s\n", pp->pp_name);
    183  1.1  thorpej 
    184  1.1  thorpej 	/* Allocate the slave info. */
    185  1.1  thorpej 	sc->sc_nslaves = pp->pp_nslaves;
    186  1.1  thorpej 	size = sizeof(struct pcmcom_slave_info) * sc->sc_nslaves;
    187  1.1  thorpej 	sc->sc_slaves = malloc(size, M_DEVBUF, M_NOWAIT);
    188  1.1  thorpej 	if (sc->sc_slaves == NULL) {
    189  1.1  thorpej 		printf("%s: unable to allocate slave info\n",
    190  1.1  thorpej 		    sc->sc_dev.dv_xname);
    191  1.1  thorpej 		return;
    192  1.1  thorpej 	}
    193  1.1  thorpej 	memset(sc->sc_slaves, 0, size);
    194  1.1  thorpej 
    195  1.1  thorpej 	/*
    196  1.1  thorpej 	 * The address decoders on these cards are stupid.  They decode
    197  1.1  thorpej 	 * (usually) 10 bits of address, so you need to allocate the
    198  1.1  thorpej 	 * regions they request in order for the card to differentiate
    199  1.1  thorpej 	 * between serial ports.
    200  1.1  thorpej 	 */
    201  1.1  thorpej 	for (cfe = pa->pf->cfe_head.sqh_first; cfe != NULL;
    202  1.1  thorpej 	     cfe = cfe->cfe_list.sqe_next) {
    203  1.1  thorpej 		if (pcmcom_check_cfe(sc, cfe)) {
    204  1.1  thorpej 			/* Found one! */
    205  1.1  thorpej 			break;
    206  1.1  thorpej 		}
    207  1.1  thorpej 	}
    208  1.1  thorpej 	if (cfe == NULL) {
    209  1.1  thorpej 		printf("%s: unable to find a suitable config table entry\n",
    210  1.1  thorpej 		    sc->sc_dev.dv_xname);
    211  1.1  thorpej 		return;
    212  1.1  thorpej 	}
    213  1.1  thorpej 
    214  1.1  thorpej 	/* Enable the card. */
    215  1.1  thorpej 	pcmcia_function_init(pa->pf, cfe);
    216  1.1  thorpej 	if (pcmcia_function_enable(sc->sc_pf)) {
    217  1.1  thorpej 		printf("%s: function enable failed\n", sc->sc_dev.dv_xname);
    218  1.1  thorpej 		return;
    219  1.1  thorpej 	};
    220  1.1  thorpej 
    221  1.1  thorpej 	sc->sc_enabled_count = 1;
    222  1.1  thorpej 
    223  1.1  thorpej 	/* Attach the children. */
    224  1.1  thorpej 	for (i = 0; i < sc->sc_nslaves; i++)
    225  1.1  thorpej 		pcmcom_attach_slave(sc, i);
    226  1.1  thorpej 
    227  1.1  thorpej 	sc->sc_enabled_count = 0;
    228  1.1  thorpej 	pcmcia_function_disable(sc->sc_pf);
    229  1.1  thorpej }
    230  1.1  thorpej 
    231  1.1  thorpej int
    232  1.1  thorpej pcmcom_check_cfe(sc, cfe)
    233  1.1  thorpej 	struct pcmcom_softc *sc;
    234  1.1  thorpej 	struct pcmcia_config_entry *cfe;
    235  1.1  thorpej {
    236  1.1  thorpej 	struct pcmcom_slave_info *psi;
    237  1.1  thorpej 	int slave;
    238  1.1  thorpej 
    239  1.1  thorpej 	/* We need to have the same number of I/O spaces as we do slaves. */
    240  1.1  thorpej 	if (cfe->num_iospace != sc->sc_nslaves)
    241  1.1  thorpej 		return (0);
    242  1.1  thorpej 
    243  1.1  thorpej 	for (slave = 0; slave < sc->sc_nslaves; slave++) {
    244  1.1  thorpej 		psi = &sc->sc_slaves[slave];
    245  1.1  thorpej 		if (pcmcia_io_alloc(sc->sc_pf,
    246  1.1  thorpej 		    cfe->iospace[slave].start,
    247  1.1  thorpej 		    cfe->iospace[slave].length,
    248  1.1  thorpej 		    cfe->iospace[slave].length,
    249  1.1  thorpej 		    &psi->psi_pcioh))
    250  1.1  thorpej 			goto release;
    251  1.1  thorpej 	}
    252  1.1  thorpej 
    253  1.1  thorpej 	/* If we got here, we were able to allocate space for all slaves! */
    254  1.1  thorpej 	return (1);
    255  1.1  thorpej 
    256  1.1  thorpej  release:
    257  1.1  thorpej 	/* Release the i/o spaces we've allocated. */
    258  1.1  thorpej 	for (slave--; slave >= 0; slave--) {
    259  1.1  thorpej 		psi = &sc->sc_slaves[slave];
    260  1.1  thorpej 		pcmcia_io_free(sc->sc_pf, &psi->psi_pcioh);
    261  1.1  thorpej 	}
    262  1.1  thorpej 	return (0);
    263  1.1  thorpej }
    264  1.1  thorpej 
    265  1.1  thorpej void
    266  1.1  thorpej pcmcom_attach_slave(sc, slave)
    267  1.1  thorpej 	struct pcmcom_softc *sc;
    268  1.1  thorpej 	int slave;
    269  1.1  thorpej {
    270  1.1  thorpej 	struct pcmcom_slave_info *psi = &sc->sc_slaves[slave];
    271  1.1  thorpej 	struct pcmcom_attach_args pca;
    272  1.1  thorpej 
    273  1.1  thorpej 	printf("%s: slave %d", sc->sc_dev.dv_xname, slave);
    274  1.1  thorpej 
    275  1.1  thorpej 	if (pcmcia_io_map(sc->sc_pf, PCMCIA_WIDTH_IO8, 0, psi->psi_pcioh.size,
    276  1.1  thorpej 	    &psi->psi_pcioh, &psi->psi_io_window)) {
    277  1.1  thorpej 		printf(": can't map i/o space\n");
    278  1.1  thorpej 		return;
    279  1.1  thorpej 	}
    280  1.1  thorpej 
    281  1.1  thorpej 	printf("\n");
    282  1.1  thorpej 
    283  1.1  thorpej 	pca.pca_iot = psi->psi_pcioh.iot;
    284  1.1  thorpej 	pca.pca_ioh = psi->psi_pcioh.ioh;
    285  1.1  thorpej 	pca.pca_slave = slave;
    286  1.1  thorpej 
    287  1.1  thorpej 	psi->psi_child = config_found_sm(&sc->sc_dev, &pca, pcmcom_print,
    288  1.1  thorpej 	    pcmcom_submatch);
    289  1.1  thorpej }
    290  1.1  thorpej 
    291  1.1  thorpej int
    292  1.1  thorpej pcmcom_print(aux, pnp)
    293  1.1  thorpej 	void *aux;
    294  1.1  thorpej 	const char *pnp;
    295  1.1  thorpej {
    296  1.1  thorpej 	struct pcmcom_attach_args *pca = aux;
    297  1.1  thorpej 
    298  1.1  thorpej 	/* only com's can attach to pcmcom's; easy... */
    299  1.1  thorpej 	if (pnp)
    300  1.1  thorpej 		printf("com at %s", pnp);
    301  1.1  thorpej 
    302  1.1  thorpej 	printf(" slave %d", pca->pca_slave);
    303  1.1  thorpej 
    304  1.1  thorpej 	return (UNCONF);
    305  1.1  thorpej }
    306  1.1  thorpej 
    307  1.1  thorpej int
    308  1.1  thorpej pcmcom_submatch(parent, cf, aux)
    309  1.1  thorpej 	struct device *parent;
    310  1.1  thorpej 	struct cfdata *cf;
    311  1.1  thorpej 	void *aux;
    312  1.1  thorpej {
    313  1.1  thorpej 	struct pcmcom_attach_args *pca = aux;
    314  1.1  thorpej 
    315  1.1  thorpej 	if (cf->cf_loc[PCMCOMCF_SLAVE] != pca->pca_slave &&
    316  1.1  thorpej 	    cf->cf_loc[PCMCOMCF_SLAVE] != PCMCOMCF_SLAVE_DEFAULT)
    317  1.1  thorpej 		return (0);
    318  1.1  thorpej 
    319  1.1  thorpej 	return ((*cf->cf_attach->ca_match)(parent, cf, aux));
    320  1.1  thorpej }
    321  1.1  thorpej 
    322  1.1  thorpej int
    323  1.1  thorpej pcmcom_intr(arg)
    324  1.1  thorpej 	void *arg;
    325  1.1  thorpej {
    326  1.1  thorpej #if NCOM > 0
    327  1.1  thorpej 	struct pcmcom_softc *sc = arg;
    328  1.1  thorpej 	int i, rval = 0;
    329  1.1  thorpej 
    330  1.1  thorpej 	if (sc->sc_enabled_count == 0)
    331  1.1  thorpej 		return (0);
    332  1.1  thorpej 
    333  1.1  thorpej 	for (i = 0; i < sc->sc_nslaves; i++) {
    334  1.1  thorpej 		if (sc->sc_slaves[i].psi_child != NULL)
    335  1.1  thorpej 			rval |= comintr(sc->sc_slaves[i].psi_child);
    336  1.1  thorpej 	}
    337  1.1  thorpej 
    338  1.1  thorpej 	return (rval);
    339  1.1  thorpej #else
    340  1.1  thorpej 	return (0);
    341  1.1  thorpej #endif /* NCOM > 0 */
    342  1.1  thorpej }
    343  1.1  thorpej 
    344  1.1  thorpej int
    345  1.1  thorpej pcmcom_enable(sc)
    346  1.1  thorpej 	struct pcmcom_softc *sc;
    347  1.1  thorpej {
    348  1.1  thorpej 
    349  1.1  thorpej 	sc->sc_enabled_count++;
    350  1.1  thorpej 	if (sc->sc_enabled_count > 1)
    351  1.1  thorpej 		return (0);
    352  1.1  thorpej 
    353  1.1  thorpej 	/* Establish the interrupt. */
    354  1.1  thorpej 	sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_SERIAL,
    355  1.1  thorpej 	    pcmcom_intr, sc);
    356  1.1  thorpej 	if (sc->sc_ih == NULL) {
    357  1.1  thorpej 		printf("%s: couldn't establish interrupt\n",
    358  1.1  thorpej 		    sc->sc_dev.dv_xname);
    359  1.1  thorpej 		return (1);
    360  1.1  thorpej 	}
    361  1.1  thorpej 
    362  1.1  thorpej 	return (pcmcia_function_enable(sc->sc_pf));
    363  1.1  thorpej }
    364  1.1  thorpej 
    365  1.1  thorpej void
    366  1.1  thorpej pcmcom_disable(sc)
    367  1.1  thorpej 	struct pcmcom_softc *sc;
    368  1.1  thorpej {
    369  1.1  thorpej 
    370  1.1  thorpej 	sc->sc_enabled_count--;
    371  1.1  thorpej 	if (sc->sc_enabled_count != 0)
    372  1.1  thorpej 		return;
    373  1.1  thorpej 
    374  1.1  thorpej 	pcmcia_function_disable(sc->sc_pf);
    375  1.1  thorpej 	pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
    376  1.1  thorpej }
    377  1.1  thorpej 
    378  1.1  thorpej /****** Here begins the com attachment code. ******/
    379  1.1  thorpej 
    380  1.1  thorpej #if NCOM_PCMCOM > 0
    381  1.1  thorpej int	com_pcmcom_match __P((struct device *, struct cfdata *, void *));
    382  1.1  thorpej void	com_pcmcom_attach __P((struct device *, struct device *, void *));
    383  1.1  thorpej 
    384  1.1  thorpej /* No pcmcom-specific goo in the softc; it's all in the parent. */
    385  1.1  thorpej struct cfattach com_pcmcom_ca = {
    386  1.1  thorpej 	sizeof(struct com_softc), com_pcmcom_match, com_pcmcom_attach
    387  1.1  thorpej };
    388  1.1  thorpej 
    389  1.1  thorpej int	com_pcmcom_enable __P((struct com_softc *));
    390  1.1  thorpej void	com_pcmcom_disable __P((struct com_softc *));
    391  1.1  thorpej 
    392  1.1  thorpej int
    393  1.1  thorpej com_pcmcom_match(parent, cf, aux)
    394  1.1  thorpej 	struct device *parent;
    395  1.1  thorpej 	struct cfdata *cf;
    396  1.1  thorpej 	void *aux;
    397  1.1  thorpej {
    398  1.1  thorpej 
    399  1.1  thorpej 	/* Device is always present. */
    400  1.1  thorpej 	return (1);
    401  1.1  thorpej }
    402  1.1  thorpej 
    403  1.1  thorpej void
    404  1.1  thorpej com_pcmcom_attach(parent, self, aux)
    405  1.1  thorpej 	struct device *parent, *self;
    406  1.1  thorpej 	void *aux;
    407  1.1  thorpej {
    408  1.1  thorpej 	struct com_softc *sc = (struct com_softc *)self;
    409  1.1  thorpej 	struct pcmcom_attach_args *pca = aux;
    410  1.1  thorpej 
    411  1.1  thorpej 	sc->sc_iot = pca->pca_iot;
    412  1.1  thorpej 	sc->sc_ioh = pca->pca_ioh;
    413  1.1  thorpej 
    414  1.1  thorpej 	sc->enabled = 1;
    415  1.1  thorpej 
    416  1.1  thorpej 	sc->sc_iobase = -1;
    417  1.1  thorpej 	sc->sc_frequency = COM_FREQ;
    418  1.1  thorpej 
    419  1.1  thorpej 	sc->enable = com_pcmcom_enable;
    420  1.1  thorpej 	sc->disable = com_pcmcom_disable;
    421  1.1  thorpej 
    422  1.1  thorpej 	com_attach_subr(sc);
    423  1.1  thorpej 
    424  1.1  thorpej 	sc->enabled = 0;
    425  1.1  thorpej }
    426  1.1  thorpej 
    427  1.1  thorpej int
    428  1.1  thorpej com_pcmcom_enable(sc)
    429  1.1  thorpej 	struct com_softc *sc;
    430  1.1  thorpej {
    431  1.1  thorpej 
    432  1.1  thorpej 	return (pcmcom_enable((struct pcmcom_softc *)sc->sc_dev.dv_parent));
    433  1.1  thorpej }
    434  1.1  thorpej 
    435  1.1  thorpej void
    436  1.1  thorpej com_pcmcom_disable(sc)
    437  1.1  thorpej 	struct com_softc *sc;
    438  1.1  thorpej {
    439  1.1  thorpej 
    440  1.1  thorpej 	pcmcom_disable((struct pcmcom_softc *)sc->sc_dev.dv_parent);
    441  1.1  thorpej }
    442  1.1  thorpej #endif /* NCOM_PCMCOM > 0 */
    443