Lines Matching +full:pci +full:- +full:dev
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
39 #include <dev/agp/agppriv.h>
40 #include <dev/agp/agpreg.h>
41 #include <dev/pci/pcivar.h>
42 #include <dev/pci/pcireg.h>
65 agp_via_match(device_t dev) in agp_via_match() argument
67 if (pci_get_class(dev) != PCIC_BRIDGE in agp_via_match()
68 || pci_get_subclass(dev) != PCIS_BRIDGE_HOST) in agp_via_match()
71 if (agp_find_caps(dev) == 0) in agp_via_match()
74 switch (pci_get_devid(dev)) { in agp_via_match()
76 return ("VIA 8763 (P4X600) host to PCI bridge"); in agp_via_match()
78 return ("VIA PM800/PN800/PM880/PN880 host to PCI bridge"); in agp_via_match()
80 return ("VIA KT880 host to PCI bridge"); in agp_via_match()
82 return ("VIA 3296 (P4M800) host to PCI bridge"); in agp_via_match()
84 return ("VIA 82C8363 (Apollo KT133x/KM133) host to PCI bridge"); in agp_via_match()
86 return ("VIA 3314 (P4M800CE) host to PCI bridge"); in agp_via_match()
88 return ("VIA VT3324 (CX700) host to PCI bridge"); in agp_via_match()
90 return ("VIA 3327 (P4M890) host to PCI bridge"); in agp_via_match()
92 return ("VIA 3364 (P4M900) host to PCI bridge"); in agp_via_match()
94 return ("VIA 8371 (Apollo KX133) host to PCI bridge"); in agp_via_match()
96 return ("VIA 8501 (Apollo MVP4) host to PCI bridge"); in agp_via_match()
98 return ("VIA 82C597 (Apollo VP3) host to PCI bridge"); in agp_via_match()
100 return ("VIA 82C598 (Apollo MVP3) host to PCI bridge"); in agp_via_match()
102 return ("VIA 8601 (Apollo ProMedia/PLE133Ta) host to PCI bridge"); in agp_via_match()
104 return ("VIA 82C694X (Apollo Pro 133A) host to PCI bridge"); in agp_via_match()
106 return ("VIA 82C691 (Apollo Pro) host to PCI bridge"); in agp_via_match()
108 return ("VIA 8633 (Pro 266) host to PCI bridge"); in agp_via_match()
110 return ("VIA 8367 (KT266/KY266x/KT333) host to PCI bridge"); in agp_via_match()
112 return ("VIA 8653 (Pro266T) host to PCI bridge"); in agp_via_match()
114 return ("VIA 8361 (KLE133) host to PCI bridge"); in agp_via_match()
116 return ("VIA XM266 (PM266/KM266) host to PCI bridge"); in agp_via_match()
118 return ("VIA 862x (CLE266) host to PCI bridge"); in agp_via_match()
120 return ("VIA 8753 (P4X266) host to PCI bridge"); in agp_via_match()
122 return ("VIA 8703 (P4M266x/P4N266) host to PCI bridge"); in agp_via_match()
124 return ("VIA XN266 (Apollo Pro266) host to PCI bridge"); in agp_via_match()
126 return ("VIA 8754 (PT800) host to PCI bridge"); in agp_via_match()
128 return ("VIA 8377 (Apollo KT400/KT400A/KT600) host to PCI bridge"); in agp_via_match()
130 return ("VIA 8235/8237 (Apollo KM400/KM400A) host to PCI bridge"); in agp_via_match()
132 return ("VIA 8783 (PT890) host to PCI bridge"); in agp_via_match()
134 return ("VIA PT880 host to PCI bridge"); in agp_via_match()
136 return ("VIA VT83xx/VT87xx/KTxxx/Px8xx host to PCI bridge"); in agp_via_match()
143 agp_via_probe(device_t dev) in agp_via_probe() argument
147 if (resource_disabled("agp", device_get_unit(dev))) in agp_via_probe()
149 desc = agp_via_match(dev); in agp_via_probe()
151 device_set_desc(dev, desc); in agp_via_probe()
159 agp_via_attach(device_t dev) in agp_via_attach() argument
161 struct agp_via_softc *sc = device_get_softc(dev); in agp_via_attach()
167 sc->regs = via_v2_regs; in agp_via_attach()
170 capid = pci_read_config(dev, agp_find_caps(dev) + AGP_CAPID, 4); in agp_via_attach()
172 agpsel = pci_read_config(dev, AGP_VIA_AGPSEL, 1); in agp_via_attach()
174 sc->regs = via_v3_regs; in agp_via_attach()
177 error = agp_generic_attach(dev); in agp_via_attach()
181 sc->initial_aperture = AGP_GET_APERTURE(dev); in agp_via_attach()
184 gatt = agp_alloc_gatt(dev); in agp_via_attach()
192 if (AGP_SET_APERTURE(dev, AGP_GET_APERTURE(dev) / 2)) { in agp_via_attach()
193 agp_generic_detach(dev); in agp_via_attach()
197 sc->gatt = gatt; in agp_via_attach()
199 if (sc->regs == via_v2_regs) { in agp_via_attach()
201 pci_write_config(dev, sc->regs[REG_ATTBASE], gatt->ag_physical | 3, 4); in agp_via_attach()
204 pci_write_config(dev, sc->regs[REG_GARTCTRL], 0x0f, 4); in agp_via_attach()
209 pci_write_config(dev, sc->regs[REG_ATTBASE], gatt->ag_physical, 4); in agp_via_attach()
212 gartctrl = pci_read_config(dev, sc->regs[REG_GARTCTRL], 4); in agp_via_attach()
213 pci_write_config(dev, sc->regs[REG_GARTCTRL], gartctrl | (3 << 7), 4); in agp_via_attach()
216 device_printf(dev, "aperture size is %dM\n", in agp_via_attach()
217 sc->initial_aperture / 1024 / 1024); in agp_via_attach()
223 agp_via_detach(device_t dev) in agp_via_detach() argument
225 struct agp_via_softc *sc = device_get_softc(dev); in agp_via_detach()
227 agp_free_cdev(dev); in agp_via_detach()
229 pci_write_config(dev, sc->regs[REG_GARTCTRL], 0, 4); in agp_via_detach()
230 pci_write_config(dev, sc->regs[REG_ATTBASE], 0, 4); in agp_via_detach()
231 AGP_SET_APERTURE(dev, sc->initial_aperture); in agp_via_detach()
232 agp_free_gatt(sc->gatt); in agp_via_detach()
233 agp_free_res(dev); in agp_via_detach()
239 agp_via_get_aperture(device_t dev) in agp_via_get_aperture() argument
241 struct agp_via_softc *sc = device_get_softc(dev); in agp_via_get_aperture()
244 if (sc->regs == via_v2_regs) { in agp_via_get_aperture()
245 apsize = pci_read_config(dev, sc->regs[REG_APSIZE], 1); in agp_via_get_aperture()
254 return (((apsize ^ 0xff) << 20) | ((1 << 20) - 1)) + 1; in agp_via_get_aperture()
256 apsize = pci_read_config(dev, sc->regs[REG_APSIZE], 2) & 0xfff; in agp_via_get_aperture()
279 device_printf(dev, "Invalid aperture setting 0x%x\n", in agp_via_get_aperture()
280 pci_read_config(dev, sc->regs[REG_APSIZE], 2)); in agp_via_get_aperture()
287 agp_via_set_aperture(device_t dev, u_int32_t aperture) in agp_via_set_aperture() argument
289 struct agp_via_softc *sc = device_get_softc(dev); in agp_via_set_aperture()
292 if (sc->regs == via_v2_regs) { in agp_via_set_aperture()
296 apsize = ((aperture - 1) >> 20) ^ 0xff; in agp_via_set_aperture()
301 if ((((apsize ^ 0xff) << 20) | ((1 << 20) - 1)) + 1 != aperture) in agp_via_set_aperture()
304 pci_write_config(dev, sc->regs[REG_APSIZE], apsize, 1); in agp_via_set_aperture()
338 device_printf(dev, "Invalid aperture size (%dMb)\n", in agp_via_set_aperture()
342 val = pci_read_config(dev, sc->regs[REG_APSIZE], 2); in agp_via_set_aperture()
343 pci_write_config(dev, sc->regs[REG_APSIZE], in agp_via_set_aperture()
350 agp_via_bind_page(device_t dev, vm_offset_t offset, vm_offset_t physical) in agp_via_bind_page() argument
352 struct agp_via_softc *sc = device_get_softc(dev); in agp_via_bind_page()
354 if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) in agp_via_bind_page()
357 sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical; in agp_via_bind_page()
362 agp_via_unbind_page(device_t dev, vm_offset_t offset) in agp_via_unbind_page() argument
364 struct agp_via_softc *sc = device_get_softc(dev); in agp_via_unbind_page()
366 if (offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) in agp_via_unbind_page()
369 sc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0; in agp_via_unbind_page()
374 agp_via_flush_tlb(device_t dev) in agp_via_flush_tlb() argument
376 struct agp_via_softc *sc = device_get_softc(dev); in agp_via_flush_tlb()
379 if (sc->regs == via_v2_regs) { in agp_via_flush_tlb()
380 pci_write_config(dev, sc->regs[REG_GARTCTRL], 0x8f, 4); in agp_via_flush_tlb()
381 pci_write_config(dev, sc->regs[REG_GARTCTRL], 0x0f, 4); in agp_via_flush_tlb()
383 gartctrl = pci_read_config(dev, sc->regs[REG_GARTCTRL], 4); in agp_via_flush_tlb()
384 pci_write_config(dev, sc->regs[REG_GARTCTRL], gartctrl & in agp_via_flush_tlb()
386 pci_write_config(dev, sc->regs[REG_GARTCTRL], gartctrl, 4); in agp_via_flush_tlb()
422 MODULE_DEPEND(agp_via, pci, 1, 1, 1);