Lines Matching +full:dev +full:- +full:handle
1 /*-
43 #include <contrib/dev/acpica/include/acpi.h>
44 #include <contrib/dev/acpica/include/accommon.h>
46 #include <dev/acpica/acpivar.h>
47 #include <dev/acpica/acpi_pcivar.h>
50 #include <dev/pci/pcireg.h>
51 #include <dev/pci/pcivar.h>
52 #include <dev/pci/pci_private.h>
54 #include <dev/iommu/iommu.h>
77 static struct pci_devinfo *acpi_pci_alloc_devinfo(device_t dev);
78 static int acpi_pci_attach(device_t dev);
79 static void acpi_pci_child_deleted(device_t dev, device_t child);
84 static int acpi_pci_detach(device_t dev);
85 static int acpi_pci_probe(device_t dev);
86 static int acpi_pci_read_ivar(device_t dev, device_t child, int which,
88 static int acpi_pci_write_ivar(device_t dev, device_t child, int which,
90 static ACPI_STATUS acpi_pci_save_handle(ACPI_HANDLE handle, UINT32 level,
92 static int acpi_pci_set_powerstate_method(device_t dev, device_t child,
94 static void acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child);
96 static int acpi_pci_get_domain(device_t dev, device_t child, int *domain);
130 acpi_pci_alloc_devinfo(device_t dev) in acpi_pci_alloc_devinfo() argument
135 return (&dinfo->ap_dinfo); in acpi_pci_alloc_devinfo()
139 acpi_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) in acpi_pci_read_ivar() argument
146 *result = (uintptr_t)dinfo->ap_handle; in acpi_pci_read_ivar()
149 *result = (uintptr_t)dinfo->ap_flags; in acpi_pci_read_ivar()
152 return (pci_read_ivar(dev, child, which, result)); in acpi_pci_read_ivar()
156 acpi_pci_write_ivar(device_t dev, device_t child, int which, uintptr_t value) in acpi_pci_write_ivar() argument
163 dinfo->ap_handle = (ACPI_HANDLE)value; in acpi_pci_write_ivar()
166 dinfo->ap_flags = (int)value; in acpi_pci_write_ivar()
169 return (pci_write_ivar(dev, child, which, value)); in acpi_pci_write_ivar()
173 acpi_pci_child_deleted(device_t dev, device_t child) in acpi_pci_child_deleted() argument
177 if (acpi_get_device(dinfo->ap_handle) == child) in acpi_pci_child_deleted()
178 AcpiDetachData(dinfo->ap_handle, acpi_fake_objhandler); in acpi_pci_child_deleted()
179 pci_child_deleted(dev, child); in acpi_pci_child_deleted()
190 if (dinfo->ap_handle) { in acpi_pci_child_location_method()
191 sbuf_printf(sb, " handle=%s", acpi_name(dinfo->ap_handle)); in acpi_pci_child_location_method()
192 if (ACPI_SUCCESS(acpi_GetInteger(dinfo->ap_handle, "_PXM", &pxm))) { in acpi_pci_child_location_method()
211 * Fetch the NUMA domain for the given device 'dev'.
219 acpi_pci_get_domain(device_t dev, device_t child, int *domain) in acpi_pci_get_domain() argument
228 if (d == -1) in acpi_pci_get_domain()
232 return (bus_generic_get_domain(dev, child, domain)); in acpi_pci_get_domain()
239 acpi_pci_set_powerstate_method(device_t dev, device_t child, int state) in acpi_pci_set_powerstate_method() argument
261 error = pci_set_powerstate_method(dev, child, state); in acpi_pci_set_powerstate_method()
269 device_printf(dev, "set ACPI power state D%d on %s\n", in acpi_pci_set_powerstate_method()
272 device_printf(dev, in acpi_pci_set_powerstate_method()
276 error = pci_set_powerstate_method(dev, child, state); in acpi_pci_set_powerstate_method()
284 acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child) in acpi_pci_update_device() argument
292 * second PCI-ISA bridge that has a _HID for an in acpi_pci_update_device()
293 * acpi_sysresource device.) In that case, leave ACPI-CA's in acpi_pci_update_device()
294 * device data pointing at the ACPI-enumerated device. in acpi_pci_update_device()
296 child = acpi_get_device(handle); in acpi_pci_update_device()
301 acpi_name(handle))); in acpi_pci_update_device()
306 * Update ACPI-CA to use the PCI enumerated device_t for this handle. in acpi_pci_update_device()
308 status = AcpiAttachData(handle, acpi_fake_objhandler, pci_child); in acpi_pci_update_device()
310 printf("WARNING: Unable to attach object data to %s - %s\n", in acpi_pci_update_device()
311 acpi_name(handle), AcpiFormatException(status)); in acpi_pci_update_device()
315 acpi_pci_save_handle(ACPI_HANDLE handle, UINT32 level, void *context, in acpi_pci_save_handle() argument
326 if (ACPI_FAILURE(acpi_GetInteger(handle, "_ADR", &address))) in acpi_pci_save_handle()
331 if (dinfo->ap_dinfo.cfg.func == func && in acpi_pci_save_handle()
332 dinfo->ap_dinfo.cfg.slot == slot) { in acpi_pci_save_handle()
333 dinfo->ap_handle = handle; in acpi_pci_save_handle()
334 acpi_pci_update_device(handle, child); in acpi_pci_save_handle()
341 acpi_pci_child_added(device_t dev, device_t child) in acpi_pci_child_added() argument
356 AcpiWalkNamespace(ACPI_TYPE_DEVICE, acpi_get_handle(dev), 1, in acpi_pci_child_added()
361 acpi_pci_probe(device_t dev) in acpi_pci_probe() argument
364 if (acpi_get_handle(dev) == NULL) in acpi_pci_probe()
366 device_set_desc(dev, "ACPI PCI bus"); in acpi_pci_probe()
373 device_t dev; in acpi_pci_bus_notify_handler() local
375 dev = context; in acpi_pci_bus_notify_handler()
380 BUS_RESCAN(dev); in acpi_pci_bus_notify_handler()
384 device_printf(dev, "unknown notify %#x\n", notify); in acpi_pci_bus_notify_handler()
392 device_t child, dev; in acpi_pci_device_notify_handler() local
396 dev = context; in acpi_pci_device_notify_handler()
401 BUS_RESCAN(dev); in acpi_pci_device_notify_handler()
407 device_printf(dev, "no device to eject for %s\n", in acpi_pci_device_notify_handler()
415 device_printf(dev, "failed to detach %s: %d\n", in acpi_pci_device_notify_handler()
422 device_printf(dev, "failed to eject %s: %s\n", in acpi_pci_device_notify_handler()
426 BUS_RESCAN(dev); in acpi_pci_device_notify_handler()
430 device_printf(dev, "unknown notify %#x for %s\n", notify, in acpi_pci_device_notify_handler()
437 acpi_pci_install_device_notify_handler(ACPI_HANDLE handle, UINT32 level, in acpi_pci_install_device_notify_handler() argument
444 if (ACPI_FAILURE(AcpiGetHandle(handle, "_EJ0", &h))) in acpi_pci_install_device_notify_handler()
447 AcpiInstallNotifyHandler(handle, ACPI_SYSTEM_NOTIFY, in acpi_pci_install_device_notify_handler()
453 acpi_pci_attach(device_t dev) in acpi_pci_attach() argument
457 error = pci_attach(dev); in acpi_pci_attach()
460 AcpiInstallNotifyHandler(acpi_get_handle(dev), ACPI_SYSTEM_NOTIFY, in acpi_pci_attach()
461 acpi_pci_bus_notify_handler, dev); in acpi_pci_attach()
462 AcpiWalkNamespace(ACPI_TYPE_DEVICE, acpi_get_handle(dev), 1, in acpi_pci_attach()
463 acpi_pci_install_device_notify_handler, NULL, dev, NULL); in acpi_pci_attach()
469 acpi_pci_remove_notify_handler(ACPI_HANDLE handle, UINT32 level, void *context, in acpi_pci_remove_notify_handler() argument
476 if (ACPI_FAILURE(AcpiGetHandle(handle, "_EJ0", &h))) in acpi_pci_remove_notify_handler()
479 AcpiRemoveNotifyHandler(handle, ACPI_SYSTEM_NOTIFY, in acpi_pci_remove_notify_handler()
485 acpi_pci_detach(device_t dev) in acpi_pci_detach() argument
488 AcpiWalkNamespace(ACPI_TYPE_DEVICE, acpi_get_handle(dev), 1, in acpi_pci_detach()
489 acpi_pci_remove_notify_handler, NULL, dev, NULL); in acpi_pci_detach()
490 AcpiRemoveNotifyHandler(acpi_get_handle(dev), ACPI_SYSTEM_NOTIFY, in acpi_pci_detach()
492 return (pci_detach(dev)); in acpi_pci_detach()