jmide.c revision 1.1 1 1.1 bouyer /* $NetBSD: jmide.c,v 1.1 2007/05/15 17:53:45 bouyer Exp $ */
2 1.1 bouyer
3 1.1 bouyer /*
4 1.1 bouyer * Copyright (c) 2007 Manuel Bouyer.
5 1.1 bouyer *
6 1.1 bouyer * Redistribution and use in source and binary forms, with or without
7 1.1 bouyer * modification, are permitted provided that the following conditions
8 1.1 bouyer * are met:
9 1.1 bouyer * 1. Redistributions of source code must retain the above copyright
10 1.1 bouyer * notice, this list of conditions and the following disclaimer.
11 1.1 bouyer * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 bouyer * notice, this list of conditions and the following disclaimer in the
13 1.1 bouyer * documentation and/or other materials provided with the distribution.
14 1.1 bouyer * 3. All advertising materials mentioning features or use of this software
15 1.1 bouyer * must display the following acknowledgement:
16 1.1 bouyer * This product includes software developed by Manuel Bouyer.
17 1.1 bouyer * 4. The name of the author may not be used to endorse or promote products
18 1.1 bouyer * derived from this software without specific prior written permission.
19 1.1 bouyer *
20 1.1 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 bouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 bouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 bouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 bouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 bouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 bouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 bouyer */
31 1.1 bouyer
32 1.1 bouyer #include <sys/cdefs.h>
33 1.1 bouyer __KERNEL_RCSID(0, "$NetBSD: jmide.c,v 1.1 2007/05/15 17:53:45 bouyer Exp $");
34 1.1 bouyer
35 1.1 bouyer #include <sys/param.h>
36 1.1 bouyer #include <sys/systm.h>
37 1.1 bouyer #include <sys/malloc.h>
38 1.1 bouyer
39 1.1 bouyer #include <dev/pci/pcivar.h>
40 1.1 bouyer #include <dev/pci/pcidevs.h>
41 1.1 bouyer #include <dev/pci/pciidereg.h>
42 1.1 bouyer #include <dev/pci/pciidevar.h>
43 1.1 bouyer
44 1.1 bouyer #include <dev/pci/jmide_reg.h>
45 1.1 bouyer
46 1.1 bouyer #include <dev/ic/ahcisatavar.h>
47 1.1 bouyer
48 1.1 bouyer #include "jmide.h"
49 1.1 bouyer
50 1.1 bouyer static const struct jmide_product *jmide_lookup(pcireg_t);
51 1.1 bouyer
52 1.1 bouyer static int jmide_match(struct device *, struct cfdata *, void *);
53 1.1 bouyer static void jmide_attach(struct device *, struct device *, void *);
54 1.1 bouyer static int jmide_intr(void *);
55 1.1 bouyer
56 1.1 bouyer static void jmpata_chip_map(struct pciide_softc*, struct pci_attach_args*);
57 1.1 bouyer static void jmpata_setup_channel(struct ata_channel*);
58 1.1 bouyer
59 1.1 bouyer static int jmahci_print(void *, const char *);
60 1.1 bouyer
61 1.1 bouyer struct jmide_product {
62 1.1 bouyer u_int32_t jm_product;
63 1.1 bouyer int jm_npata;
64 1.1 bouyer int jm_nsata;
65 1.1 bouyer };
66 1.1 bouyer
67 1.1 bouyer static const struct jmide_product jm_products[] = {
68 1.1 bouyer { PCI_PRODUCT_JMICRON_JMB360,
69 1.1 bouyer 0,
70 1.1 bouyer 1
71 1.1 bouyer },
72 1.1 bouyer { PCI_PRODUCT_JMICRON_JMB361,
73 1.1 bouyer 1,
74 1.1 bouyer 1
75 1.1 bouyer },
76 1.1 bouyer { PCI_PRODUCT_JMICRON_JMB363,
77 1.1 bouyer 1,
78 1.1 bouyer 2
79 1.1 bouyer },
80 1.1 bouyer { PCI_PRODUCT_JMICRON_JMB365,
81 1.1 bouyer 2,
82 1.1 bouyer 1
83 1.1 bouyer },
84 1.1 bouyer { PCI_PRODUCT_JMICRON_JMB366,
85 1.1 bouyer 2,
86 1.1 bouyer 2
87 1.1 bouyer },
88 1.1 bouyer { PCI_PRODUCT_JMICRON_JMB368,
89 1.1 bouyer 1,
90 1.1 bouyer 0
91 1.1 bouyer },
92 1.1 bouyer { 0,
93 1.1 bouyer 0,
94 1.1 bouyer 0
95 1.1 bouyer }
96 1.1 bouyer };
97 1.1 bouyer
98 1.1 bouyer typedef enum {
99 1.1 bouyer TYPE_INVALID = 0,
100 1.1 bouyer TYPE_PATA,
101 1.1 bouyer TYPE_SATA,
102 1.1 bouyer TYPE_NONE
103 1.1 bouyer } jmchan_t;
104 1.1 bouyer
105 1.1 bouyer struct jmide_softc {
106 1.1 bouyer struct pciide_softc sc_pciide;
107 1.1 bouyer void *sc_ahci;
108 1.1 bouyer int sc_npata;
109 1.1 bouyer int sc_nsata;
110 1.1 bouyer jmchan_t sc_chan_type[PCIIDE_NUM_CHANNELS];
111 1.1 bouyer int sc_chan_swap;
112 1.1 bouyer };
113 1.1 bouyer
114 1.1 bouyer #define JM_NAME(sc) (sc->sc_pciide.sc_wdcdev.sc_atac.atac_dev.dv_xname)
115 1.1 bouyer
116 1.1 bouyer CFATTACH_DECL(jmide, sizeof(struct jmide_softc),
117 1.1 bouyer jmide_match, jmide_attach, NULL, NULL);
118 1.1 bouyer
119 1.1 bouyer static const struct jmide_product *
120 1.1 bouyer jmide_lookup(pcireg_t id) {
121 1.1 bouyer const struct jmide_product *jp;
122 1.1 bouyer
123 1.1 bouyer for (jp = jm_products; jp->jm_product != 0; jp++) {
124 1.1 bouyer if (jp->jm_product == PCI_PRODUCT(id))
125 1.1 bouyer return jp;
126 1.1 bouyer }
127 1.1 bouyer return NULL;
128 1.1 bouyer }
129 1.1 bouyer
130 1.1 bouyer static int
131 1.1 bouyer jmide_match(struct device *parent, struct cfdata *match,
132 1.1 bouyer void *aux)
133 1.1 bouyer {
134 1.1 bouyer struct pci_attach_args *pa = aux;
135 1.1 bouyer
136 1.1 bouyer if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_JMICRON) {
137 1.1 bouyer if (jmide_lookup(pa->pa_id))
138 1.1 bouyer return (4); /* highter than ahcisata */
139 1.1 bouyer }
140 1.1 bouyer return (0);
141 1.1 bouyer }
142 1.1 bouyer
143 1.1 bouyer static void
144 1.1 bouyer jmide_attach(struct device *parent, struct device *self, void *aux)
145 1.1 bouyer {
146 1.1 bouyer struct pci_attach_args *pa = aux;
147 1.1 bouyer struct jmide_softc *sc = (struct jmide_softc *)self;
148 1.1 bouyer const struct jmide_product *jp;
149 1.1 bouyer char devinfo[256];
150 1.1 bouyer const char *intrstr;
151 1.1 bouyer pci_intr_handle_t intrhandle;
152 1.1 bouyer u_int32_t pcictrl0 = pci_conf_read(pa->pa_pc, pa->pa_tag,
153 1.1 bouyer PCI_JM_CONTROL0);
154 1.1 bouyer u_int32_t pcictrl1 = pci_conf_read(pa->pa_pc, pa->pa_tag,
155 1.1 bouyer PCI_JM_CONTROL1);
156 1.1 bouyer struct pciide_product_desc *pp;
157 1.1 bouyer
158 1.1 bouyer jp = jmide_lookup(pa->pa_id);
159 1.1 bouyer if (jp == NULL) {
160 1.1 bouyer printf("jmide_attach: WTF?\n");
161 1.1 bouyer return;
162 1.1 bouyer }
163 1.1 bouyer sc->sc_npata = jp->jm_npata;
164 1.1 bouyer sc->sc_nsata = jp->jm_nsata;
165 1.1 bouyer
166 1.1 bouyer pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
167 1.1 bouyer aprint_naive(": JMICRON PATA/SATA disk controller\n");
168 1.1 bouyer aprint_normal(": %s\n", devinfo);
169 1.1 bouyer
170 1.1 bouyer aprint_normal("%s: ", JM_NAME(sc));
171 1.1 bouyer if (sc->sc_npata)
172 1.1 bouyer aprint_normal("%d PATA port%s", sc->sc_npata,
173 1.1 bouyer (sc->sc_npata > 1) ? "s" : "");
174 1.1 bouyer if (sc->sc_nsata)
175 1.1 bouyer aprint_normal("%s%d SATA port%s", sc->sc_npata ? ", " : "",
176 1.1 bouyer sc->sc_nsata, (sc->sc_nsata > 1) ? "s" : "");
177 1.1 bouyer aprint_normal("\n");
178 1.1 bouyer
179 1.1 bouyer if (pci_intr_map(pa, &intrhandle) != 0) {
180 1.1 bouyer aprint_error("%s: couldn't map interrupt\n", JM_NAME(sc));
181 1.1 bouyer return;
182 1.1 bouyer }
183 1.1 bouyer intrstr = pci_intr_string(pa->pa_pc, intrhandle);
184 1.1 bouyer sc->sc_pciide.sc_pci_ih = pci_intr_establish(pa->pa_pc, intrhandle,
185 1.1 bouyer IPL_BIO, jmide_intr, sc);
186 1.1 bouyer if (sc->sc_pciide.sc_pci_ih == NULL) {
187 1.1 bouyer aprint_error("%s: couldn't establish interrupt", JM_NAME(sc));
188 1.1 bouyer return;
189 1.1 bouyer }
190 1.1 bouyer aprint_normal("%s: interrupting at %s\n", JM_NAME(sc),
191 1.1 bouyer intrstr ? intrstr : "unknown interrupt");
192 1.1 bouyer
193 1.1 bouyer if (pcictrl0 & JM_CONTROL0_AHCI_EN) {
194 1.1 bouyer /*
195 1.1 bouyer * ahci controller enabled; disable sata on pciide and
196 1.1 bouyer * enable on ahci
197 1.1 bouyer */
198 1.1 bouyer pcictrl0 |= JM_CONTROL0_SATA0_AHCI | JM_CONTROL0_SATA1_AHCI;
199 1.1 bouyer pcictrl0 &= ~(JM_CONTROL0_SATA0_IDE | JM_CONTROL0_SATA1_IDE);
200 1.1 bouyer pci_conf_write(pa->pa_pc, pa->pa_tag,
201 1.1 bouyer PCI_JM_CONTROL0, pcictrl0);
202 1.1 bouyer /* attach ahci controller if on the right function */
203 1.1 bouyer if ((pa->pa_function == 0 &&
204 1.1 bouyer (pcictrl0 & JM_CONTROL0_AHCI_F1) == 0) ||
205 1.1 bouyer (pa->pa_function == 1 &&
206 1.1 bouyer (pcictrl0 & JM_CONTROL0_AHCI_F1) != 0)) {
207 1.1 bouyer sc->sc_ahci = config_found_ia(
208 1.1 bouyer &sc->sc_pciide.sc_wdcdev.sc_atac.atac_dev,
209 1.1 bouyer "jmide_hl", pa, jmahci_print);
210 1.1 bouyer }
211 1.1 bouyer }
212 1.1 bouyer sc->sc_chan_swap = ((pcictrl0 & JM_CONTROL0_PCIIDE_CS) != 0);
213 1.1 bouyer /* compute the type of internal primary channel */
214 1.1 bouyer if ((pcictrl0 & JM_CONTROL0_AHCI_EN) || sc->sc_nsata == 0) {
215 1.1 bouyer /* only a drive if second PATA enabled */
216 1.1 bouyer if (sc->sc_npata > 1 && (pcictrl1 & JM_CONTROL1_PATA1_PRI)
217 1.1 bouyer && (pcictrl1 & JM_CONTROL1_PATA1_EN))
218 1.1 bouyer sc->sc_chan_type[sc->sc_chan_swap ? 1 : 0] = TYPE_PATA;
219 1.1 bouyer else
220 1.1 bouyer sc->sc_chan_type[sc->sc_chan_swap ? 1 : 0] = TYPE_NONE;
221 1.1 bouyer } else {
222 1.1 bouyer /* always SATA here */
223 1.1 bouyer sc->sc_chan_type[sc->sc_chan_swap ? 1 : 0] = TYPE_SATA;
224 1.1 bouyer }
225 1.1 bouyer /* compute the type of internal secondary channel */
226 1.1 bouyer if (((pcictrl0 & JM_CONTROL0_AHCI_EN) &&
227 1.1 bouyer (pcictrl0 & JM_CONTROL0_PCIIDE0_MS)) || sc->sc_nsata == 0) {
228 1.1 bouyer /* only a drive if first PATA enabled */
229 1.1 bouyer if (sc->sc_npata > 0 && (pcictrl0 & JM_CONTROL0_PATA0_EN)
230 1.1 bouyer && (pcictrl0 &
231 1.1 bouyer (sc->sc_chan_swap ? JM_CONTROL0_PATA0_PRI: JM_CONTROL0_PATA0_SEC)))
232 1.1 bouyer sc->sc_chan_type[sc->sc_chan_swap ? 0 : 1] = TYPE_PATA;
233 1.1 bouyer else
234 1.1 bouyer sc->sc_chan_type[sc->sc_chan_swap ? 0 : 1] = TYPE_NONE;
235 1.1 bouyer } else {
236 1.1 bouyer if (sc->sc_nsata && (pcictrl0 & JM_CONTROL0_AHCI_EN) &&
237 1.1 bouyer (pcictrl0 & JM_CONTROL0_PCIIDE0_MS) == 0)
238 1.1 bouyer sc->sc_chan_type[sc->sc_chan_swap ? 0 : 1] = TYPE_SATA;
239 1.1 bouyer else
240 1.1 bouyer sc->sc_chan_type[sc->sc_chan_swap ? 0 : 1] = TYPE_NONE;
241 1.1 bouyer }
242 1.1 bouyer if (sc->sc_chan_type[0] == TYPE_NONE &&
243 1.1 bouyer sc->sc_chan_type[1] == TYPE_NONE)
244 1.1 bouyer return;
245 1.1 bouyer if (pa->pa_function == 0 && (pcictrl0 & JM_CONTROL0_PCIIDE_F1))
246 1.1 bouyer return;
247 1.1 bouyer if (pa->pa_function == 1 && (pcictrl0 & JM_CONTROL0_PCIIDE_F1) == 0)
248 1.1 bouyer return;
249 1.1 bouyer pp = malloc(sizeof(struct pciide_product_desc), M_DEVBUF, M_NOWAIT);
250 1.1 bouyer if (pp == NULL) {
251 1.1 bouyer aprint_error("%s: can't malloc sc_pp\n", JM_NAME(sc));
252 1.1 bouyer return;
253 1.1 bouyer }
254 1.1 bouyer aprint_normal("%s: PCI IDE interface used", JM_NAME(sc));
255 1.1 bouyer pp->ide_product = 0;
256 1.1 bouyer pp->ide_flags = 0;
257 1.1 bouyer pp->ide_name = NULL;
258 1.1 bouyer pp->chip_map = jmpata_chip_map;
259 1.1 bouyer pciide_common_attach(&sc->sc_pciide, pa, pp);
260 1.1 bouyer
261 1.1 bouyer }
262 1.1 bouyer
263 1.1 bouyer static int
264 1.1 bouyer jmide_intr(void *arg)
265 1.1 bouyer {
266 1.1 bouyer struct jmide_softc *sc = arg;
267 1.1 bouyer int ret = 0;
268 1.1 bouyer
269 1.1 bouyer #ifdef NJMAHCI
270 1.1 bouyer if (sc->sc_ahci)
271 1.1 bouyer ret |= ahci_intr(sc->sc_ahci);
272 1.1 bouyer #endif
273 1.1 bouyer if (sc->sc_npata)
274 1.1 bouyer ret |= pciide_pci_intr(&sc->sc_pciide);
275 1.1 bouyer return ret;
276 1.1 bouyer }
277 1.1 bouyer
278 1.1 bouyer static void
279 1.1 bouyer jmpata_chip_map(struct pciide_softc *sc, struct pci_attach_args *pa)
280 1.1 bouyer {
281 1.1 bouyer struct jmide_softc *jmidesc = (struct jmide_softc *)sc;
282 1.1 bouyer int channel;
283 1.1 bouyer pcireg_t interface;
284 1.1 bouyer bus_size_t cmdsize, ctlsize;
285 1.1 bouyer struct pciide_channel *cp;
286 1.1 bouyer
287 1.1 bouyer if (pciide_chipen(sc, pa) == 0)
288 1.1 bouyer return;
289 1.1 bouyer aprint_verbose("%s: bus-master DMA support present", JM_NAME(jmidesc));
290 1.1 bouyer pciide_mapreg_dma(sc, pa);
291 1.1 bouyer aprint_verbose("\n");
292 1.1 bouyer sc->sc_wdcdev.sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DATA32;
293 1.1 bouyer if (sc->sc_dma_ok) {
294 1.1 bouyer sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DMA | ATAC_CAP_UDMA;
295 1.1 bouyer sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
296 1.1 bouyer }
297 1.1 bouyer sc->sc_wdcdev.sc_atac.atac_pio_cap = 4;
298 1.1 bouyer sc->sc_wdcdev.sc_atac.atac_dma_cap = 2;
299 1.1 bouyer sc->sc_wdcdev.sc_atac.atac_set_modes = jmpata_setup_channel;
300 1.1 bouyer sc->sc_wdcdev.sc_atac.atac_channels = sc->wdc_chanarray;
301 1.1 bouyer sc->sc_wdcdev.sc_atac.atac_nchannels = PCIIDE_NUM_CHANNELS;
302 1.1 bouyer wdc_allocate_regs(&sc->sc_wdcdev);
303 1.1 bouyer /*
304 1.1 bouyer * can't rely on the PCI_CLASS_REG content if the chip was in raid
305 1.1 bouyer * mode. We have to fake interface
306 1.1 bouyer */
307 1.1 bouyer interface = PCIIDE_INTERFACE_PCI(0) | PCIIDE_INTERFACE_PCI(1);
308 1.1 bouyer for (channel = 0; channel < sc->sc_wdcdev.sc_atac.atac_nchannels;
309 1.1 bouyer channel++) {
310 1.1 bouyer cp = &sc->pciide_channels[channel];
311 1.1 bouyer if (pciide_chansetup(sc, channel, interface) == 0)
312 1.1 bouyer continue;
313 1.1 bouyer aprint_normal("%s: %s channel is ", JM_NAME(jmidesc),
314 1.1 bouyer PCIIDE_CHANNEL_NAME(channel));
315 1.1 bouyer switch(jmidesc->sc_chan_type[channel]) {
316 1.1 bouyer case TYPE_PATA:
317 1.1 bouyer aprint_normal("PATA");
318 1.1 bouyer break;
319 1.1 bouyer case TYPE_SATA:
320 1.1 bouyer aprint_normal("SATA");
321 1.1 bouyer break;
322 1.1 bouyer case TYPE_NONE:
323 1.1 bouyer aprint_normal("unused");
324 1.1 bouyer break;
325 1.1 bouyer default:
326 1.1 bouyer aprint_normal("impossible");
327 1.1 bouyer panic("jmide: wrong/uninitialised channel type");
328 1.1 bouyer }
329 1.1 bouyer aprint_normal("\n");
330 1.1 bouyer if (jmidesc->sc_chan_type[channel] == TYPE_NONE) {
331 1.1 bouyer cp->ata_channel.ch_flags |= ATACH_DISABLED;
332 1.1 bouyer continue;
333 1.1 bouyer }
334 1.1 bouyer pciide_mapchan(pa, cp, interface, &cmdsize, &ctlsize,
335 1.1 bouyer pciide_pci_intr);
336 1.1 bouyer }
337 1.1 bouyer }
338 1.1 bouyer
339 1.1 bouyer static void
340 1.1 bouyer jmpata_setup_channel(struct ata_channel *chp)
341 1.1 bouyer {
342 1.1 bouyer struct ata_drive_datas *drvp;
343 1.1 bouyer int drive, s;
344 1.1 bouyer u_int32_t idedma_ctl;
345 1.1 bouyer struct pciide_channel *cp = CHAN_TO_PCHAN(chp);
346 1.1 bouyer struct pciide_softc *sc = CHAN_TO_PCIIDE(chp);
347 1.1 bouyer struct jmide_softc *jmidesc = (struct jmide_softc *)sc;
348 1.1 bouyer int ide80p;
349 1.1 bouyer
350 1.1 bouyer /* setup DMA if needed */
351 1.1 bouyer pciide_channel_dma_setup(cp);
352 1.1 bouyer
353 1.1 bouyer idedma_ctl = 0;
354 1.1 bouyer
355 1.1 bouyer /* cable type detect */
356 1.1 bouyer ide80p = 1;
357 1.1 bouyer if (chp->ch_channel == (jmidesc->sc_chan_swap ? 1 : 0)) {
358 1.1 bouyer if (jmidesc->sc_chan_type[chp->ch_channel] == TYPE_PATA &&
359 1.1 bouyer (pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_JM_CONTROL1) &
360 1.1 bouyer JM_CONTROL1_PATA1_40P))
361 1.1 bouyer ide80p = 0;
362 1.1 bouyer } else {
363 1.1 bouyer if (jmidesc->sc_chan_type[chp->ch_channel] == TYPE_PATA &&
364 1.1 bouyer (pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_JM_CONTROL0) &
365 1.1 bouyer JM_CONTROL0_PATA0_40P))
366 1.1 bouyer ide80p = 0;
367 1.1 bouyer }
368 1.1 bouyer
369 1.1 bouyer for (drive = 0; drive < 2; drive++) {
370 1.1 bouyer drvp = &chp->ch_drive[drive];
371 1.1 bouyer /* If no drive, skip */
372 1.1 bouyer if ((drvp->drive_flags & DRIVE) == 0)
373 1.1 bouyer continue;
374 1.1 bouyer if (drvp->drive_flags & DRIVE_UDMA) {
375 1.1 bouyer /* use Ultra/DMA */
376 1.1 bouyer s = splbio();
377 1.1 bouyer drvp->drive_flags &= ~DRIVE_DMA;
378 1.1 bouyer if (drvp->UDMA_mode > 2 && ide80p == 0)
379 1.1 bouyer drvp->UDMA_mode = 2;
380 1.1 bouyer splx(s);
381 1.1 bouyer idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
382 1.1 bouyer } else if (drvp->drive_flags & DRIVE_DMA) {
383 1.1 bouyer idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
384 1.1 bouyer }
385 1.1 bouyer }
386 1.1 bouyer /* nothing to do to setup modes, the controller snoop SET_FEATURE cmd */
387 1.1 bouyer if (idedma_ctl != 0) {
388 1.1 bouyer /* Add software bits in status register */
389 1.1 bouyer bus_space_write_1(sc->sc_dma_iot, cp->dma_iohs[IDEDMA_CTL],
390 1.1 bouyer 0, idedma_ctl);
391 1.1 bouyer }
392 1.1 bouyer }
393 1.1 bouyer
394 1.1 bouyer static int
395 1.1 bouyer jmahci_print(void *aux, const char *pnp)
396 1.1 bouyer {
397 1.1 bouyer if (pnp)
398 1.1 bouyer aprint_normal("ahcisata at %s", pnp);
399 1.1 bouyer
400 1.1 bouyer return (UNCONF);
401 1.1 bouyer }
402 1.1 bouyer
403 1.1 bouyer
404 1.1 bouyer #ifdef NJMAHCI
405 1.1 bouyer static int jmahci_match(struct device *, struct cfdata *, void *);
406 1.1 bouyer static void jmahci_attach(struct device *, struct device *, void *);
407 1.1 bouyer
408 1.1 bouyer CFATTACH_DECL(jmahci, sizeof(struct ahci_softc),
409 1.1 bouyer jmahci_match, jmahci_attach, NULL, NULL);
410 1.1 bouyer
411 1.1 bouyer static int
412 1.1 bouyer jmahci_match(struct device *parent, struct cfdata *match, void *aux)
413 1.1 bouyer {
414 1.1 bouyer return 1;
415 1.1 bouyer }
416 1.1 bouyer
417 1.1 bouyer static void
418 1.1 bouyer jmahci_attach(struct device *parent, struct device *self, void *aux)
419 1.1 bouyer {
420 1.1 bouyer struct pci_attach_args *pa = aux;
421 1.1 bouyer struct ahci_softc *sc = (struct ahci_softc *)self;
422 1.1 bouyer bus_size_t size;
423 1.1 bouyer
424 1.1 bouyer if (pci_mapreg_map(pa, AHCI_PCI_ABAR,
425 1.1 bouyer PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
426 1.1 bouyer &sc->sc_ahcit, &sc->sc_ahcih, NULL, &size) != 0) {
427 1.1 bouyer aprint_error("%s: can't map ahci registers\n", AHCINAME(sc));
428 1.1 bouyer return;
429 1.1 bouyer }
430 1.1 bouyer aprint_naive(": AHCI disk controller\n");
431 1.1 bouyer aprint_normal("\n");
432 1.1 bouyer
433 1.1 bouyer sc->sc_dmat = pa->pa_dmat;
434 1.1 bouyer ahci_attach(sc);
435 1.1 bouyer }
436 1.1 bouyer #endif
437