This source file includes following definitions.
- aic_pcmcia_match
- aic_pcmcia_attach
- aic_pcmcia_detach
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 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/selinfo.h>
36 #include <sys/device.h>
37
38 #include <machine/cpu.h>
39 #include <machine/bus.h>
40 #include <machine/intr.h>
41
42 #include <scsi/scsi_all.h>
43 #include <scsi/scsiconf.h>
44
45 #include <dev/ic/aic6360var.h>
46
47 #include <dev/pcmcia/pcmciareg.h>
48 #include <dev/pcmcia/pcmciavar.h>
49 #include <dev/pcmcia/pcmciadevs.h>
50
51 int aic_pcmcia_match(struct device *, void *, void *);
52 void aic_pcmcia_attach(struct device *, struct device *, void *);
53 int aic_pcmcia_detach(struct device *, int);
54
55 struct aic_pcmcia_softc {
56 struct aic_softc sc_aic;
57
58
59 struct pcmcia_io_handle sc_pcioh;
60 int sc_io_window;
61 struct pcmcia_function *sc_pf;
62 void *sc_ih;
63 };
64
65 struct cfattach aic_pcmcia_ca = {
66 sizeof(struct aic_pcmcia_softc), aic_pcmcia_match, aic_pcmcia_attach,
67 aic_pcmcia_detach
68 };
69
70 struct aic_pcmcia_product {
71 u_int16_t app_vendor;
72 u_int16_t app_product;
73 int app_expfunc;
74 } aic_pcmcia_prod[] = {
75 { PCMCIA_VENDOR_ADAPTEC, PCMCIA_PRODUCT_ADAPTEC_APA1460_1,
76 0 },
77
78 { PCMCIA_VENDOR_ADAPTEC, PCMCIA_PRODUCT_ADAPTEC_APA1460_2,
79 0 },
80
81 { PCMCIA_VENDOR_NEWMEDIA, PCMCIA_PRODUCT_NEWMEDIA_BUSTOASTER,
82 0 }
83 };
84
85 int
86 aic_pcmcia_match(parent, match, aux)
87 struct device *parent;
88 void *match, *aux;
89 {
90 struct pcmcia_attach_args *pa = aux;
91 int i;
92
93 for (i = 0; i < sizeof(aic_pcmcia_prod)/sizeof(aic_pcmcia_prod[0]); i++)
94 if (pa->manufacturer == aic_pcmcia_prod[i].app_vendor &&
95 pa->product == aic_pcmcia_prod[i].app_product &&
96 pa->pf->number == aic_pcmcia_prod[i].app_expfunc)
97 return (1);
98 return (0);
99 }
100
101 void
102 aic_pcmcia_attach(parent, self, aux)
103 struct device *parent, *self;
104 void *aux;
105 {
106 struct aic_pcmcia_softc *psc = (void *)self;
107 struct aic_softc *sc = &psc->sc_aic;
108 struct pcmcia_attach_args *pa = aux;
109 struct pcmcia_config_entry *cfe;
110 struct pcmcia_function *pf = pa->pf;
111 const char *intrstr;
112
113 psc->sc_pf = pf;
114
115 for (cfe = SIMPLEQ_FIRST(&pf->cfe_head); cfe != NULL;
116 cfe = SIMPLEQ_NEXT(cfe, cfe_list)) {
117 if (cfe->num_memspace != 0 ||
118 cfe->num_iospace != 1)
119 continue;
120
121
122
123
124 if (pa->manufacturer == PCMCIA_VENDOR_NEWMEDIA &&
125 pa->product == PCMCIA_PRODUCT_NEWMEDIA_BUSTOASTER &&
126 cfe->iospace[0].start == 0)
127 continue;
128
129 if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
130 cfe->iospace[0].length, AIC_NPORTS, &psc->sc_pcioh) == 0)
131 break;
132 }
133
134 if (cfe == 0) {
135 printf(": can't alloc i/o space\n");
136 return;
137 }
138
139 sc->sc_iot = psc->sc_pcioh.iot;
140 sc->sc_ioh = psc->sc_pcioh.ioh;
141
142
143 pcmcia_function_init(pf, cfe);
144 if (pcmcia_function_enable(pf)) {
145 printf(": function enable failed\n");
146 return;
147 }
148
149
150 if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_AUTO, 0, psc->sc_pcioh.size,
151 &psc->sc_pcioh, &psc->sc_io_window)) {
152 printf(": can't map i/o space\n");
153 return;
154 }
155
156 printf(" port 0x%lx/%lu", psc->sc_pcioh.addr,
157 (u_long)psc->sc_pcioh.size);
158
159 if (!aic_find(sc->sc_iot, sc->sc_ioh)) {
160 printf(": unable to detect chip!\n");
161 return;
162 }
163
164
165 psc->sc_ih = pcmcia_intr_establish(pa->pf, IPL_BIO,
166 aicintr, sc, sc->sc_dev.dv_xname);
167 intrstr = pcmcia_intr_string(psc->sc_pf, psc->sc_ih);
168 printf("%s%s\n", *intrstr ? ", " : "", intrstr);
169 if (psc->sc_ih == NULL)
170 return;
171
172 aicattach(sc);
173
174 }
175
176 int
177 aic_pcmcia_detach(self, flags)
178 struct device *self;
179 int flags;
180 {
181 struct aic_pcmcia_softc *sc= (void *)self;
182 int error;
183
184 error = aic_detach(self, flags);
185 if (error)
186 return (error);
187
188
189 pcmcia_io_unmap(sc->sc_pf, sc->sc_io_window);
190 pcmcia_io_free(sc->sc_pf, &sc->sc_pcioh);
191
192 return (0);
193 }