2 * Copyright (c) 1998 - 2008 Søren Schmidt <sos@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/kernel.h>
34 #include <sys/module.h>
38 #include <sys/malloc.h>
40 #include <sys/taskqueue.h>
42 #include <machine/stdarg.h>
43 #include <machine/resource.h>
44 #include <machine/bus.h>
46 #include <dev/pci/pcivar.h>
47 #include <dev/pci/pcireg.h>
48 #include <dev/ata/ata-all.h>
49 #include <dev/ata/ata-pci.h>
53 static MALLOC_DEFINE(M_ATAPCI, "ata_pci", "ATA driver PCI");
56 #define IOMASK 0xfffffffc
58 /* local prototypes */
59 static int ata_generic_chipinit(device_t dev);
60 static void ata_generic_setmode(device_t dev, int mode);
63 * generic PCI ATA device probe
66 ata_pci_probe(device_t dev)
68 struct ata_pci_controller *ctlr = device_get_softc(dev);
71 /* is this a storage class device ? */
72 if (pci_get_class(dev) != PCIC_STORAGE)
75 /* is this an IDE/ATA type device ? */
76 if (pci_get_subclass(dev) != PCIS_STORAGE_IDE)
79 sprintf(buffer, "%s ATA controller", ata_pcivendor2str(dev));
80 device_set_desc_copy(dev, buffer);
81 ctlr->chipinit = ata_generic_chipinit;
83 /* we are a low priority handler */
84 return (BUS_PROBE_GENERIC);
88 ata_pci_attach(device_t dev)
90 struct ata_pci_controller *ctlr = device_get_softc(dev);
95 /* do chipset specific setups only needed once */
96 ctlr->legacy = ata_legacy(dev);
97 if (ctlr->legacy || pci_read_config(dev, PCIR_BAR(2), 4) & IOMASK)
101 ctlr->ichannels = -1;
102 ctlr->ch_attach = ata_pci_ch_attach;
103 ctlr->ch_detach = ata_pci_ch_detach;
106 /* if needed try to enable busmastering */
107 cmd = pci_read_config(dev, PCIR_COMMAND, 2);
108 if (!(cmd & PCIM_CMD_BUSMASTEREN)) {
109 pci_write_config(dev, PCIR_COMMAND, cmd | PCIM_CMD_BUSMASTEREN, 2);
110 cmd = pci_read_config(dev, PCIR_COMMAND, 2);
113 /* if busmastering mode "stuck" use it */
114 if ((cmd & PCIM_CMD_BUSMASTEREN) == PCIM_CMD_BUSMASTEREN) {
115 ctlr->r_type1 = SYS_RES_IOPORT;
116 ctlr->r_rid1 = ATA_BMADDR_RID;
117 ctlr->r_res1 = bus_alloc_resource_any(dev, ctlr->r_type1, &ctlr->r_rid1,
121 if (ctlr->chipinit(dev))
124 /* attach all channels on this controller */
125 for (unit = 0; unit < ctlr->channels; unit++) {
126 if ((ctlr->ichannels & (1 << unit)) == 0)
128 child = device_add_child(dev, "ata",
129 ((unit == 0 || unit == 1) && ctlr->legacy) ?
130 unit : devclass_find_free_unit(ata_devclass, 2));
132 device_printf(dev, "failed to add ata child device\n");
134 device_set_ivars(child, (void *)(intptr_t)unit);
136 bus_generic_attach(dev);
141 ata_pci_detach(device_t dev)
143 struct ata_pci_controller *ctlr = device_get_softc(dev);
147 /* detach & delete all children */
148 if (!device_get_children(dev, &children, &nchildren)) {
149 for (i = 0; i < nchildren; i++)
150 device_delete_child(dev, children[i]);
151 free(children, M_TEMP);
155 bus_teardown_intr(dev, ctlr->r_irq, ctlr->handle);
156 bus_release_resource(dev, SYS_RES_IRQ, ctlr->r_irq_rid, ctlr->r_irq);
157 if (ctlr->r_irq_rid != ATA_IRQ_RID)
158 pci_release_msi(dev);
161 bus_release_resource(dev, ctlr->r_type2, ctlr->r_rid2, ctlr->r_res2);
163 bus_release_resource(dev, ctlr->r_type1, ctlr->r_rid1, ctlr->r_res1);
169 ata_pci_suspend(device_t dev)
171 struct ata_pci_controller *ctlr = device_get_softc(dev);
174 bus_generic_suspend(dev);
176 error = ctlr->suspend(dev);
181 ata_pci_resume(device_t dev)
183 struct ata_pci_controller *ctlr = device_get_softc(dev);
187 error = ctlr->resume(dev);
188 bus_generic_resume(dev);
193 ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
194 u_long start, u_long end, u_long count, u_int flags)
196 struct ata_pci_controller *controller = device_get_softc(dev);
197 int unit = ((struct ata_channel *)device_get_softc(child))->unit;
198 struct resource *res = NULL;
201 if (type == SYS_RES_IOPORT) {
204 if (controller->legacy) {
205 start = (unit ? ATA_SECONDARY : ATA_PRIMARY);
207 end = start + count - 1;
209 myrid = PCIR_BAR(0) + (unit << 3);
210 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev,
211 SYS_RES_IOPORT, &myrid,
212 start, end, count, flags);
215 case ATA_CTLADDR_RID:
216 if (controller->legacy) {
217 start = (unit ? ATA_SECONDARY : ATA_PRIMARY) + ATA_CTLOFFSET;
218 count = ATA_CTLIOSIZE;
219 end = start + count - 1;
221 myrid = PCIR_BAR(1) + (unit << 3);
222 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev,
223 SYS_RES_IOPORT, &myrid,
224 start, end, count, flags);
228 if (type == SYS_RES_IRQ && *rid == ATA_IRQ_RID) {
229 if (controller->legacy) {
230 int irq = (unit == 0 ? 14 : 15);
232 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
233 SYS_RES_IRQ, rid, irq, irq, 1, flags);
236 res = controller->r_irq;
242 ata_pci_release_resource(device_t dev, device_t child, int type, int rid,
245 struct ata_pci_controller *controller = device_get_softc(dev);
246 int unit = ((struct ata_channel *)device_get_softc(child))->unit;
248 if (type == SYS_RES_IOPORT) {
251 return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev,
253 PCIR_BAR(0) + (unit << 3), r);
256 case ATA_CTLADDR_RID:
257 return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev,
259 PCIR_BAR(1) + (unit << 3), r);
265 if (type == SYS_RES_IRQ) {
266 if (rid != ATA_IRQ_RID)
269 if (controller->legacy) {
270 return BUS_RELEASE_RESOURCE(device_get_parent(dev), child,
271 SYS_RES_IRQ, rid, r);
280 ata_pci_setup_intr(device_t dev, device_t child, struct resource *irq,
281 int flags, driver_filter_t *filter, driver_intr_t *function,
282 void *argument, void **cookiep)
284 struct ata_pci_controller *controller = device_get_softc(dev);
286 if (controller->legacy) {
287 return BUS_SETUP_INTR(device_get_parent(dev), child, irq,
288 flags, filter, function, argument, cookiep);
291 struct ata_pci_controller *controller = device_get_softc(dev);
292 int unit = ((struct ata_channel *)device_get_softc(child))->unit;
294 if (filter != NULL) {
295 printf("ata-pci.c: we cannot use a filter here\n");
298 controller->interrupt[unit].function = function;
299 controller->interrupt[unit].argument = argument;
300 *cookiep = controller;
306 ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq,
309 struct ata_pci_controller *controller = device_get_softc(dev);
311 if (controller->legacy) {
312 return BUS_TEARDOWN_INTR(device_get_parent(dev), child, irq, cookie);
315 struct ata_pci_controller *controller = device_get_softc(dev);
316 int unit = ((struct ata_channel *)device_get_softc(child))->unit;
318 controller->interrupt[unit].function = NULL;
319 controller->interrupt[unit].argument = NULL;
325 ata_generic_setmode(device_t dev, int mode)
327 struct ata_device *atadev = device_get_softc(dev);
329 mode = ata_limit_mode(dev, mode, ATA_UDMA2);
330 mode = ata_check_80pin(dev, mode);
331 if (!ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode))
336 ata_generic_chipinit(device_t dev)
338 struct ata_pci_controller *ctlr = device_get_softc(dev);
340 if (ata_setup_interrupt(dev, ata_generic_intr))
342 ctlr->setmode = ata_generic_setmode;
347 ata_pci_ch_attach(device_t dev)
349 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
350 struct ata_channel *ch = device_get_softc(dev);
351 struct resource *io = NULL, *ctlio = NULL;
354 rid = ATA_IOADDR_RID;
355 if (!(io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE)))
358 rid = ATA_CTLADDR_RID;
359 if (!(ctlio = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,RF_ACTIVE))){
360 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io);
364 ata_pci_dmainit(dev);
366 for (i = ATA_DATA; i <= ATA_COMMAND; i ++) {
367 ch->r_io[i].res = io;
368 ch->r_io[i].offset = i;
370 ch->r_io[ATA_CONTROL].res = ctlio;
371 ch->r_io[ATA_CONTROL].offset = ctlr->legacy ? 0 : 2;
372 ch->r_io[ATA_IDX_ADDR].res = io;
373 ata_default_registers(dev);
375 for (i = ATA_BMCMD_PORT; i <= ATA_BMDTP_PORT; i++) {
376 ch->r_io[i].res = ctlr->r_res1;
377 ch->r_io[i].offset = (i - ATA_BMCMD_PORT) + (ch->unit*ATA_BMIOSIZE);
386 ata_pci_ch_detach(device_t dev)
388 struct ata_channel *ch = device_get_softc(dev);
390 ata_pci_dmafini(dev);
392 bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID,
393 ch->r_io[ATA_CONTROL].res);
394 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID,
395 ch->r_io[ATA_IDX_ADDR].res);
401 ata_pci_status(device_t dev)
403 struct ata_pci_controller *controller =
404 device_get_softc(device_get_parent(dev));
405 struct ata_channel *ch = device_get_softc(dev);
407 if ((dumping || !controller->legacy) &&
408 ((ch->flags & ATA_ALWAYS_DMASTAT) ||
409 (ch->dma.flags & ATA_DMA_ACTIVE))) {
410 int bmstat = ATA_IDX_INB(ch, ATA_BMSTAT_PORT) & ATA_BMSTAT_MASK;
412 if ((bmstat & (ATA_BMSTAT_ACTIVE | ATA_BMSTAT_INTERRUPT)) !=
413 ATA_BMSTAT_INTERRUPT)
415 ATA_IDX_OUTB(ch, ATA_BMSTAT_PORT, bmstat & ~ATA_BMSTAT_ERROR);
418 if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY) {
420 if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY)
427 ata_pci_hw(device_t dev)
429 struct ata_channel *ch = device_get_softc(dev);
432 ch->hw.status = ata_pci_status;
436 ata_pci_dmastart(struct ata_request *request)
438 struct ata_channel *ch = device_get_softc(request->parent);
440 ATA_DEBUG_RQ(request, "dmastart");
442 ATA_IDX_OUTB(ch, ATA_BMSTAT_PORT, (ATA_IDX_INB(ch, ATA_BMSTAT_PORT) |
443 (ATA_BMSTAT_INTERRUPT | ATA_BMSTAT_ERROR)));
444 ATA_IDX_OUTL(ch, ATA_BMDTP_PORT, request->dma->sg_bus);
445 ch->dma.flags |= ATA_DMA_ACTIVE;
446 ATA_IDX_OUTB(ch, ATA_BMCMD_PORT,
447 (ATA_IDX_INB(ch, ATA_BMCMD_PORT) & ~ATA_BMCMD_WRITE_READ) |
448 ((request->flags & ATA_R_READ) ? ATA_BMCMD_WRITE_READ : 0)|
449 ATA_BMCMD_START_STOP);
454 ata_pci_dmastop(struct ata_request *request)
456 struct ata_channel *ch = device_get_softc(request->parent);
459 ATA_DEBUG_RQ(request, "dmastop");
461 ATA_IDX_OUTB(ch, ATA_BMCMD_PORT,
462 ATA_IDX_INB(ch, ATA_BMCMD_PORT) & ~ATA_BMCMD_START_STOP);
463 ch->dma.flags &= ~ATA_DMA_ACTIVE;
464 error = ATA_IDX_INB(ch, ATA_BMSTAT_PORT) & ATA_BMSTAT_MASK;
465 ATA_IDX_OUTB(ch, ATA_BMSTAT_PORT, ATA_BMSTAT_INTERRUPT | ATA_BMSTAT_ERROR);
470 ata_pci_dmareset(device_t dev)
472 struct ata_channel *ch = device_get_softc(dev);
473 struct ata_request *request;
475 ATA_IDX_OUTB(ch, ATA_BMCMD_PORT,
476 ATA_IDX_INB(ch, ATA_BMCMD_PORT) & ~ATA_BMCMD_START_STOP);
477 ch->dma.flags &= ~ATA_DMA_ACTIVE;
478 ATA_IDX_OUTB(ch, ATA_BMSTAT_PORT, ATA_BMSTAT_INTERRUPT | ATA_BMSTAT_ERROR);
479 if ((request = ch->running)) {
480 device_printf(request->dev, "DMA reset calling unload\n");
481 ch->dma.unload(request);
486 ata_pci_dmainit(device_t dev)
488 struct ata_channel *ch = device_get_softc(dev);
491 ch->dma.start = ata_pci_dmastart;
492 ch->dma.stop = ata_pci_dmastop;
493 ch->dma.reset = ata_pci_dmareset;
497 ata_pci_dmafini(device_t dev)
503 static device_method_t ata_pci_methods[] = {
504 /* device interface */
505 DEVMETHOD(device_probe, ata_pci_probe),
506 DEVMETHOD(device_attach, ata_pci_attach),
507 DEVMETHOD(device_detach, ata_pci_detach),
508 DEVMETHOD(device_suspend, ata_pci_suspend),
509 DEVMETHOD(device_resume, ata_pci_resume),
510 DEVMETHOD(device_shutdown, bus_generic_shutdown),
513 DEVMETHOD(bus_alloc_resource, ata_pci_alloc_resource),
514 DEVMETHOD(bus_release_resource, ata_pci_release_resource),
515 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
516 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
517 DEVMETHOD(bus_setup_intr, ata_pci_setup_intr),
518 DEVMETHOD(bus_teardown_intr, ata_pci_teardown_intr),
523 devclass_t ata_pci_devclass;
525 static driver_t ata_pci_driver = {
528 sizeof(struct ata_pci_controller),
531 DRIVER_MODULE(atapci, pci, ata_pci_driver, ata_pci_devclass, 0, 0);
532 MODULE_VERSION(atapci, 1);
533 MODULE_DEPEND(atapci, ata, 1, 1, 1);
536 ata_pcichannel_probe(device_t dev)
540 sprintf(buffer, "ATA channel %d", (int)(intptr_t)device_get_ivars(dev));
541 device_set_desc_copy(dev, buffer);
543 return ata_probe(dev);
547 ata_pcichannel_attach(device_t dev)
549 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
550 struct ata_channel *ch = device_get_softc(dev);
557 ch->unit = (intptr_t)device_get_ivars(dev);
559 resource_int_value(device_get_name(dev),
560 device_get_unit(dev), "pm_level", &ch->pm_level);
562 if ((error = ctlr->ch_attach(dev)))
565 return ata_attach(dev);
569 ata_pcichannel_detach(device_t dev)
571 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
572 struct ata_channel *ch = device_get_softc(dev);
579 if ((error = ata_detach(dev)))
583 return (ctlr->ch_detach(dev));
588 ata_pcichannel_suspend(device_t dev)
590 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
591 struct ata_channel *ch = device_get_softc(dev);
597 if ((error = ata_suspend(dev)))
600 if (ctlr->ch_suspend != NULL && (error = ctlr->ch_suspend(dev)))
607 ata_pcichannel_resume(device_t dev)
609 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
610 struct ata_channel *ch = device_get_softc(dev);
616 if (ctlr->ch_resume != NULL && (error = ctlr->ch_resume(dev)))
619 return ata_resume(dev);
624 ata_pcichannel_locking(device_t dev, int mode)
626 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
627 struct ata_channel *ch = device_get_softc(dev);
630 return ctlr->locking(dev, mode);
636 ata_pcichannel_reset(device_t dev)
638 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
639 struct ata_channel *ch = device_get_softc(dev);
641 /* if DMA engine present reset it */
645 /* reset the controller HW */
649 ata_generic_reset(dev);
653 ata_pcichannel_setmode(device_t parent, device_t dev)
655 struct ata_pci_controller *ctlr = device_get_softc(GRANDPARENT(dev));
656 struct ata_device *atadev = device_get_softc(dev);
657 int mode = atadev->mode;
659 ctlr->setmode(dev, ATA_PIO_MAX);
661 ctlr->setmode(dev, mode);
664 static device_method_t ata_pcichannel_methods[] = {
665 /* device interface */
666 DEVMETHOD(device_probe, ata_pcichannel_probe),
667 DEVMETHOD(device_attach, ata_pcichannel_attach),
668 DEVMETHOD(device_detach, ata_pcichannel_detach),
669 DEVMETHOD(device_shutdown, bus_generic_shutdown),
670 DEVMETHOD(device_suspend, ata_pcichannel_suspend),
671 DEVMETHOD(device_resume, ata_pcichannel_resume),
674 DEVMETHOD(ata_setmode, ata_pcichannel_setmode),
675 DEVMETHOD(ata_locking, ata_pcichannel_locking),
676 DEVMETHOD(ata_reset, ata_pcichannel_reset),
681 driver_t ata_pcichannel_driver = {
683 ata_pcichannel_methods,
684 sizeof(struct ata_channel),
687 DRIVER_MODULE(ata, atapci, ata_pcichannel_driver, ata_devclass, 0, 0);
691 * misc support fucntions
694 ata_legacy(device_t dev)
696 return (((pci_read_config(dev, PCIR_PROGIF, 1)&PCIP_STORAGE_IDE_MASTERDEV)&&
697 ((pci_read_config(dev, PCIR_PROGIF, 1) &
698 (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC)) !=
699 (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC))) ||
700 (!pci_read_config(dev, PCIR_BAR(0), 4) &&
701 !pci_read_config(dev, PCIR_BAR(1), 4) &&
702 !pci_read_config(dev, PCIR_BAR(2), 4) &&
703 !pci_read_config(dev, PCIR_BAR(3), 4) &&
704 !pci_read_config(dev, PCIR_BAR(5), 4)));
708 ata_generic_intr(void *data)
710 struct ata_pci_controller *ctlr = data;
711 struct ata_channel *ch;
714 for (unit = 0; unit < ctlr->channels; unit++) {
715 if ((ch = ctlr->interrupt[unit].argument))
716 ctlr->interrupt[unit].function(ch);
721 ata_setup_interrupt(device_t dev, void *intr_func)
723 struct ata_pci_controller *ctlr = device_get_softc(dev);
727 if (resource_int_value(device_get_name(dev),
728 device_get_unit(dev), "msi", &i) == 0 && i != 0)
730 if (msi && pci_msi_count(dev) > 0 && pci_alloc_msi(dev, &msi) == 0) {
731 ctlr->r_irq_rid = 0x1;
733 ctlr->r_irq_rid = ATA_IRQ_RID;
735 if (!(ctlr->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
736 &ctlr->r_irq_rid, RF_SHAREABLE | RF_ACTIVE))) {
737 device_printf(dev, "unable to map interrupt\n");
740 if ((bus_setup_intr(dev, ctlr->r_irq, ATA_INTR_FLAGS, NULL,
741 intr_func, ctlr, &ctlr->handle))) {
742 /* SOS XXX release r_irq */
743 device_printf(dev, "unable to setup interrupt\n");
751 ata_set_desc(device_t dev)
753 struct ata_pci_controller *ctlr = device_get_softc(dev);
756 sprintf(buffer, "%s %s %s controller",
757 ata_pcivendor2str(dev), ctlr->chip->text,
758 ata_mode2str(ctlr->chip->max_dma));
759 device_set_desc_copy(dev, buffer);
763 ata_match_chip(device_t dev, struct ata_chip_id *index)
768 devid = pci_get_devid(dev);
769 revid = pci_get_revid(dev);
770 while (index->chipid != 0) {
771 if (devid == index->chipid && revid >= index->chiprev)
779 ata_find_chip(device_t dev, struct ata_chip_id *index, int slot)
781 struct ata_chip_id *idx;
786 if (device_get_children(device_get_parent(dev), &children, &nchildren))
789 for (i = 0; i < nchildren; i++) {
790 s = pci_get_slot(children[i]);
791 if ((slot >= 0 && s == slot) || (slot < 0 && s <= -slot)) {
792 idx = ata_match_chip(children[i], index);
794 free(children, M_TEMP);
799 free(children, M_TEMP);
804 ata_print_cable(device_t dev, u_int8_t *who)
807 "DMA limited to UDMA33, %s found non-ATA66 cable\n", who);
811 ata_check_80pin(device_t dev, int mode)
813 struct ata_device *atadev = device_get_softc(dev);
815 if (!ata_dma_check_80pin) {
817 device_printf(dev, "Skipping 80pin cable check\n");
821 if (mode > ATA_UDMA2 && !(atadev->param.hwres & ATA_CABLE_ID)) {
822 ata_print_cable(dev, "device");
829 ata_pcivendor2str(device_t dev)
831 switch (pci_get_vendor(dev)) {
832 case ATA_ACARD_ID: return "Acard";
833 case ATA_ACER_LABS_ID: return "AcerLabs";
834 case ATA_AMD_ID: return "AMD";
835 case ATA_ADAPTEC_ID: return "Adaptec";
836 case ATA_ATI_ID: return "ATI";
837 case ATA_CYRIX_ID: return "Cyrix";
838 case ATA_CYPRESS_ID: return "Cypress";
839 case ATA_HIGHPOINT_ID: return "HighPoint";
840 case ATA_INTEL_ID: return "Intel";
841 case ATA_ITE_ID: return "ITE";
842 case ATA_JMICRON_ID: return "JMicron";
843 case ATA_MARVELL_ID: return "Marvell";
844 case ATA_NATIONAL_ID: return "National";
845 case ATA_NETCELL_ID: return "Netcell";
846 case ATA_NVIDIA_ID: return "nVidia";
847 case ATA_PROMISE_ID: return "Promise";
848 case ATA_SERVERWORKS_ID: return "ServerWorks";
849 case ATA_SILICON_IMAGE_ID: return "SiI";
850 case ATA_SIS_ID: return "SiS";
851 case ATA_VIA_ID: return "VIA";
852 case ATA_CENATEK_ID: return "Cenatek";
853 case ATA_MICRON_ID: return "Micron";
854 default: return "Generic";
859 ata_mode2idx(int mode)
861 if ((mode & ATA_DMA_MASK) == ATA_UDMA0)
862 return (mode & ATA_MODE_MASK) + 8;
863 if ((mode & ATA_DMA_MASK) == ATA_WDMA0)
864 return (mode & ATA_MODE_MASK) + 5;
865 return (mode & ATA_MODE_MASK) - ATA_PIO0;