Home | History | Annotate | Line # | Download | only in pcmcia
aic_pcmcia.c revision 1.1.2.6
      1 #include <sys/param.h>
      2 #include <sys/systm.h>
      3 #include <sys/select.h>
      4 #include <sys/device.h>
      5 
      6 #include <machine/cpu.h>
      7 #include <machine/bus.h>
      8 #include <machine/intr.h>
      9 
     10 #include <dev/pcmcia/pcmciareg.h>
     11 #include <dev/pcmcia/pcmciavar.h>
     12 
     13 #define PCMCIA_MANUFACTURER_ADAPTEC	0x12F
     14 #define PCMCIA_PRODUCT_ADAPTEC_APA1460	0x1
     15 
     16 struct aic_pcmcia_softc {
     17     struct device sc_dev;
     18 
     19     struct pcmcia_io_handle sc_pcioh;
     20 #define	sc_iot	sc_pcioh.iot
     21 #define	sc_ioh	sc_pcioh.ioh
     22     struct pcmcia_function *sc_pf;
     23 };
     24 
     25 #ifdef __BROKEN_INDIRECT_CONFIG
     26 int aic_pcmcia_match __P((struct device *, void *, void *));
     27 #else
     28 int aic_pcmcia_match __P((struct device *, struct cfdata *, void *));
     29 #endif
     30 void aic_pcmcia_attach __P((struct device *, struct device *, void *));
     31 
     32 struct cfattach aic_pcmcia_ca = {
     33     sizeof(struct aic_pcmcia_softc), aic_pcmcia_match, aic_pcmcia_attach
     34 };
     35 
     36 struct cfdriver aicx_cd = {
     37 	NULL, "aicx", DV_DULL
     38 };
     39 
     40 int
     41 aic_pcmcia_match(parent, match, aux)
     42      struct device *parent;
     43 #ifdef __BROKEN_INDIRECT_CONFIG
     44      void *match;
     45 #else
     46      struct cfdata *cf;
     47 #endif
     48      void *aux;
     49 {
     50     struct pcmcia_attach_args *pa = (struct pcmcia_attach_args *) aux;
     51 
     52     if ((pa->manufacturer == PCMCIA_MANUFACTURER_ADAPTEC) &&
     53 	(pa->product == PCMCIA_PRODUCT_ADAPTEC_APA1460) &&
     54 	(pa->pf->number == 0))
     55 	return(1);
     56 
     57     return(0);
     58 }
     59 
     60 void
     61 aic_pcmcia_attach(parent, self, aux)
     62      struct device *parent, *self;
     63      void *aux;
     64 {
     65     struct aic_pcmcia_softc *sc = (void *) self;
     66     struct pcmcia_attach_args *pa = aux;
     67     struct pcmcia_config_entry *cfe;
     68     struct pcmcia_function *pf = pa->pf;
     69 
     70     sc->sc_pf = pf;
     71     cfe = pf->cfe_head.sqh_first;
     72 
     73     /* Enable the card. */
     74     pcmcia_function_init(pf, cfe);
     75     if (pcmcia_function_enable(pf)) {
     76 	printf(": function enable failed\n");
     77 	return;
     78     }
     79 
     80     if (cfe->num_memspace != 0) {
     81 	printf(": unexpected number of memory spaces %d should be 0\n",
     82 	       cfe->num_memspace);
     83 	return;
     84     }
     85 
     86     if (cfe->num_iospace != 1) {
     87 	printf(": unexpected number of I/O spaces %d should be 1\n",
     88 	       cfe->num_iospace);
     89 	return;
     90     }
     91 
     92     printf(": APA-1460 SCSI Host Adapter (not really attached)\n");
     93 
     94     return;
     95 }
     96