Lines Matching refs:dev

62 ata_pci_probe(device_t dev)  in ata_pci_probe()  argument
64 struct ata_pci_controller *ctlr = device_get_softc(dev); in ata_pci_probe()
68 if (pci_get_class(dev) != PCIC_STORAGE) in ata_pci_probe()
72 if (pci_get_subclass(dev) != PCIS_STORAGE_IDE) in ata_pci_probe()
75 sprintf(buffer, "%s ATA controller", ata_pcivendor2str(dev)); in ata_pci_probe()
76 device_set_desc_copy(dev, buffer); in ata_pci_probe()
84 ata_pci_attach(device_t dev) in ata_pci_attach() argument
86 struct ata_pci_controller *ctlr = device_get_softc(dev); in ata_pci_attach()
92 ctlr->legacy = ata_legacy(dev); in ata_pci_attach()
93 if (ctlr->legacy || pci_read_config(dev, PCIR_BAR(2), 4) & IOMASK) in ata_pci_attach()
100 ctlr->dev = dev; in ata_pci_attach()
103 pci_enable_busmaster(dev); in ata_pci_attach()
104 cmd = pci_read_config(dev, PCIR_COMMAND, 2); in ata_pci_attach()
110 ctlr->r_res1 = bus_alloc_resource_any(dev, ctlr->r_type1, &ctlr->r_rid1, in ata_pci_attach()
114 if (ctlr->chipinit(dev)) in ata_pci_attach()
121 child = device_add_child(dev, "ata", in ata_pci_attach()
125 device_printf(dev, "failed to add ata child device\n"); in ata_pci_attach()
129 bus_generic_attach(dev); in ata_pci_attach()
134 ata_pci_detach(device_t dev) in ata_pci_detach() argument
136 struct ata_pci_controller *ctlr = device_get_softc(dev); in ata_pci_detach()
139 device_delete_children(dev); in ata_pci_detach()
142 bus_teardown_intr(dev, ctlr->r_irq, ctlr->handle); in ata_pci_detach()
143 bus_release_resource(dev, SYS_RES_IRQ, ctlr->r_irq_rid, ctlr->r_irq); in ata_pci_detach()
145 pci_release_msi(dev); in ata_pci_detach()
148 ctlr->chipdeinit(dev); in ata_pci_detach()
154 bus_release_resource(dev, ctlr->r_type2, ctlr->r_rid2, ctlr->r_res2); in ata_pci_detach()
161 bus_release_resource(dev, ctlr->r_type1, ctlr->r_rid1, ctlr->r_res1); in ata_pci_detach()
168 ata_pci_suspend(device_t dev) in ata_pci_suspend() argument
170 struct ata_pci_controller *ctlr = device_get_softc(dev); in ata_pci_suspend()
173 bus_generic_suspend(dev); in ata_pci_suspend()
175 error = ctlr->suspend(dev); in ata_pci_suspend()
180 ata_pci_resume(device_t dev) in ata_pci_resume() argument
182 struct ata_pci_controller *ctlr = device_get_softc(dev); in ata_pci_resume()
186 error = ctlr->resume(dev); in ata_pci_resume()
187 bus_generic_resume(dev); in ata_pci_resume()
192 ata_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) in ata_pci_read_ivar() argument
195 return (BUS_READ_IVAR(device_get_parent(dev), dev, which, result)); in ata_pci_read_ivar()
199 ata_pci_write_ivar(device_t dev, device_t child, int which, uintptr_t value) in ata_pci_write_ivar() argument
202 return (BUS_WRITE_IVAR(device_get_parent(dev), dev, which, value)); in ata_pci_write_ivar()
206 ata_pci_read_config(device_t dev, device_t child, int reg, int width) in ata_pci_read_config() argument
209 return (pci_read_config(dev, reg, width)); in ata_pci_read_config()
213 ata_pci_write_config(device_t dev, device_t child, int reg, in ata_pci_write_config() argument
217 pci_write_config(dev, reg, val, width); in ata_pci_write_config()
221 ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, in ata_pci_alloc_resource() argument
225 struct ata_pci_controller *controller = device_get_softc(dev); in ata_pci_alloc_resource()
241 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, in ata_pci_alloc_resource()
253 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, in ata_pci_alloc_resource()
263 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), child, in ata_pci_alloc_resource()
274 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, in ata_pci_alloc_resource()
282 ata_pci_release_resource(device_t dev, device_t child, int type, int rid, in ata_pci_release_resource() argument
287 struct ata_pci_controller *controller = device_get_softc(dev); in ata_pci_release_resource()
293 return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, in ata_pci_release_resource()
297 return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, in ata_pci_release_resource()
308 return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, in ata_pci_release_resource()
319 return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, in ata_pci_release_resource()
327 ata_pci_setup_intr(device_t dev, device_t child, struct resource *irq, in ata_pci_setup_intr() argument
331 struct ata_pci_controller *controller = device_get_softc(dev); in ata_pci_setup_intr()
334 return BUS_SETUP_INTR(device_get_parent(dev), child, irq, in ata_pci_setup_intr()
337 struct ata_pci_controller *controller = device_get_softc(dev); in ata_pci_setup_intr()
356 ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, in ata_pci_teardown_intr() argument
359 struct ata_pci_controller *controller = device_get_softc(dev); in ata_pci_teardown_intr()
362 return BUS_TEARDOWN_INTR(device_get_parent(dev), child, irq, cookie); in ata_pci_teardown_intr()
364 struct ata_pci_controller *controller = device_get_softc(dev); in ata_pci_teardown_intr()
378 ata_generic_setmode(device_t dev, int target, int mode) in ata_generic_setmode() argument
385 ata_generic_chipinit(device_t dev) in ata_generic_chipinit() argument
387 struct ata_pci_controller *ctlr = device_get_softc(dev); in ata_generic_chipinit()
389 if (ata_setup_interrupt(dev, ata_generic_intr)) in ata_generic_chipinit()
396 ata_pci_ch_attach(device_t dev) in ata_pci_ch_attach() argument
398 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); in ata_pci_ch_attach()
399 struct ata_channel *ch = device_get_softc(dev); in ata_pci_ch_attach()
404 if (!(io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE))) in ata_pci_ch_attach()
408 if (!(ctlio = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,RF_ACTIVE))){ in ata_pci_ch_attach()
409 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); in ata_pci_ch_attach()
413 ata_pci_dmainit(dev); in ata_pci_ch_attach()
422 ata_default_registers(dev); in ata_pci_ch_attach()
430 ata_pci_hw(dev); in ata_pci_ch_attach()
435 ata_pci_ch_detach(device_t dev) in ata_pci_ch_detach() argument
437 struct ata_channel *ch = device_get_softc(dev); in ata_pci_ch_detach()
439 ata_pci_dmafini(dev); in ata_pci_ch_detach()
441 bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, in ata_pci_ch_detach()
443 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, in ata_pci_ch_detach()
450 ata_pci_status(device_t dev) in ata_pci_status() argument
453 device_get_softc(device_get_parent(dev)); in ata_pci_status()
454 struct ata_channel *ch = device_get_softc(dev); in ata_pci_status()
475 ata_pci_hw(device_t dev) in ata_pci_hw() argument
477 struct ata_channel *ch = device_get_softc(dev); in ata_pci_hw()
479 ata_generic_hw(dev); in ata_pci_hw()
518 ata_pci_dmareset(device_t dev) in ata_pci_dmareset() argument
520 struct ata_channel *ch = device_get_softc(dev); in ata_pci_dmareset()
528 device_printf(dev, "DMA reset calling unload\n"); in ata_pci_dmareset()
534 ata_pci_dmainit(device_t dev) in ata_pci_dmainit() argument
536 struct ata_channel *ch = device_get_softc(dev); in ata_pci_dmainit()
538 ata_dmainit(dev); in ata_pci_dmainit()
545 ata_pci_dmafini(device_t dev) in ata_pci_dmafini() argument
548 ata_dmafini(dev); in ata_pci_dmafini()
552 ata_pci_print_child(device_t dev, device_t child) in ata_pci_print_child() argument
556 retval = bus_print_child_header(dev, child); in ata_pci_print_child()
559 retval += bus_print_child_footer(dev, child); in ata_pci_print_child()
565 ata_pci_child_location_str(device_t dev, device_t child, char *buf, in ata_pci_child_location_str() argument
621 ata_pcichannel_probe(device_t dev) in ata_pcichannel_probe() argument
624 if ((intptr_t)device_get_ivars(dev) < 0) in ata_pcichannel_probe()
626 device_set_desc(dev, "ATA channel"); in ata_pcichannel_probe()
628 return ata_probe(dev); in ata_pcichannel_probe()
632 ata_pcichannel_attach(device_t dev) in ata_pcichannel_attach() argument
634 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); in ata_pcichannel_attach()
635 struct ata_channel *ch = device_get_softc(dev); in ata_pcichannel_attach()
642 ch->dev = dev; in ata_pcichannel_attach()
643 ch->unit = (intptr_t)device_get_ivars(dev); in ata_pcichannel_attach()
645 resource_int_value(device_get_name(dev), in ata_pcichannel_attach()
646 device_get_unit(dev), "pm_level", &ch->pm_level); in ata_pcichannel_attach()
648 if ((error = ctlr->ch_attach(dev))) in ata_pcichannel_attach()
651 return ata_attach(dev); in ata_pcichannel_attach()
655 ata_pcichannel_detach(device_t dev) in ata_pcichannel_detach() argument
657 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); in ata_pcichannel_detach()
658 struct ata_channel *ch = device_get_softc(dev); in ata_pcichannel_detach()
665 if ((error = ata_detach(dev))) in ata_pcichannel_detach()
669 return (ctlr->ch_detach(dev)); in ata_pcichannel_detach()
674 ata_pcichannel_suspend(device_t dev) in ata_pcichannel_suspend() argument
676 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); in ata_pcichannel_suspend()
677 struct ata_channel *ch = device_get_softc(dev); in ata_pcichannel_suspend()
683 if ((error = ata_suspend(dev))) in ata_pcichannel_suspend()
686 if (ctlr->ch_suspend != NULL && (error = ctlr->ch_suspend(dev))) in ata_pcichannel_suspend()
693 ata_pcichannel_resume(device_t dev) in ata_pcichannel_resume() argument
695 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); in ata_pcichannel_resume()
696 struct ata_channel *ch = device_get_softc(dev); in ata_pcichannel_resume()
702 if (ctlr->ch_resume != NULL && (error = ctlr->ch_resume(dev))) in ata_pcichannel_resume()
705 return ata_resume(dev); in ata_pcichannel_resume()
709 ata_pcichannel_reset(device_t dev) in ata_pcichannel_reset() argument
711 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); in ata_pcichannel_reset()
712 struct ata_channel *ch = device_get_softc(dev); in ata_pcichannel_reset()
716 ch->dma.reset(dev); in ata_pcichannel_reset()
720 ctlr->reset(dev); in ata_pcichannel_reset()
722 ata_generic_reset(dev); in ata_pcichannel_reset()
726 ata_pcichannel_setmode(device_t dev, int target, int mode) in ata_pcichannel_setmode() argument
728 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); in ata_pcichannel_setmode()
731 return (ctlr->setmode(dev, target, mode)); in ata_pcichannel_setmode()
733 return (ata_generic_setmode(dev, target, mode)); in ata_pcichannel_setmode()
737 ata_pcichannel_getrev(device_t dev, int target) in ata_pcichannel_getrev() argument
739 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); in ata_pcichannel_getrev()
740 struct ata_channel *ch = device_get_softc(dev); in ata_pcichannel_getrev()
744 return (ctlr->getrev(dev, target)); in ata_pcichannel_getrev()
780 ata_legacy(device_t dev) in ata_legacy() argument
782 return (((pci_read_config(dev, PCIR_SUBCLASS, 1) == PCIS_STORAGE_IDE) && in ata_legacy()
783 (pci_read_config(dev, PCIR_PROGIF, 1)&PCIP_STORAGE_IDE_MASTERDEV)&& in ata_legacy()
784 ((pci_read_config(dev, PCIR_PROGIF, 1) & in ata_legacy()
787 (!pci_read_config(dev, PCIR_BAR(0), 4) && in ata_legacy()
788 !pci_read_config(dev, PCIR_BAR(1), 4) && in ata_legacy()
789 !pci_read_config(dev, PCIR_BAR(2), 4) && in ata_legacy()
790 !pci_read_config(dev, PCIR_BAR(3), 4) && in ata_legacy()
791 !pci_read_config(dev, PCIR_BAR(5), 4))); in ata_legacy()
808 ata_setup_interrupt(device_t dev, void *intr_func) in ata_setup_interrupt() argument
810 struct ata_pci_controller *ctlr = device_get_softc(dev); in ata_setup_interrupt()
814 if (resource_int_value(device_get_name(dev), in ata_setup_interrupt()
815 device_get_unit(dev), "msi", &i) == 0 && i != 0) in ata_setup_interrupt()
817 if (msi && pci_msi_count(dev) > 0 && pci_alloc_msi(dev, &msi) == 0) { in ata_setup_interrupt()
823 if (!(ctlr->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, in ata_setup_interrupt()
825 device_printf(dev, "unable to map interrupt\n"); in ata_setup_interrupt()
827 pci_release_msi(dev); in ata_setup_interrupt()
830 if ((bus_setup_intr(dev, ctlr->r_irq, ATA_INTR_FLAGS, NULL, in ata_setup_interrupt()
832 device_printf(dev, "unable to setup interrupt\n"); in ata_setup_interrupt()
833 bus_release_resource(dev, in ata_setup_interrupt()
836 pci_release_msi(dev); in ata_setup_interrupt()
844 ata_set_desc(device_t dev) in ata_set_desc() argument
846 struct ata_pci_controller *ctlr = device_get_softc(dev); in ata_set_desc()
850 ata_pcivendor2str(dev), ctlr->chip->text, in ata_set_desc()
852 device_set_desc_copy(dev, buffer); in ata_set_desc()
856 ata_match_chip(device_t dev, const struct ata_chip_id *index) in ata_match_chip() argument
861 devid = pci_get_devid(dev); in ata_match_chip()
862 revid = pci_get_revid(dev); in ata_match_chip()
872 ata_find_chip(device_t dev, const struct ata_chip_id *index, int slot) in ata_find_chip() argument
879 if (device_get_children(device_get_parent(dev), &children, &nchildren)) in ata_find_chip()
897 ata_pcivendor2str(device_t dev) in ata_pcivendor2str() argument
899 switch (pci_get_vendor(dev)) { in ata_pcivendor2str()