/* Disable runtime wake capability if it is enabled */ void zpodd_disable_run_wake(struct ata_device *dev) { struct zpodd *zpodd = dev->zpodd; if (zpodd->powered_off) { acpi_pm_device_run_wake(&dev->sdev->sdev_gendev, false); device_set_run_wake(&dev->sdev->sdev_gendev, false); } }
/* * Enable runtime wake capability through ACPI and set the powered_off flag, * this flag will be used during resume to decide what operations are needed * to take. * * Also, media poll needs to be silenced, so that it doesn't bring the ODD * back to full power state every few seconds. */ void zpodd_enable_run_wake(struct ata_device *dev) { struct zpodd *zpodd = dev->zpodd; sdev_disable_disk_events(dev->sdev); zpodd->powered_off = true; device_set_run_wake(&dev->sdev->sdev_gendev, true); acpi_pm_device_run_wake(&dev->sdev->sdev_gendev, true); }
static int acpi_pci_bind(struct acpi_device *device) { acpi_status status; acpi_handle handle; unsigned char bus; struct pci_dev *dev; dev = acpi_get_pci_dev(device->handle); if (!dev) return 0; pci_acpi_add_pm_notifier(device, dev); acpi_power_resource_register_device(&dev->dev, device->handle); if (device->wakeup.flags.run_wake) device_set_run_wake(&dev->dev, true); /* * Install the 'bind' function to facilitate callbacks for * children of the P2P bridge. */ if (dev->subordinate) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device %04x:%02x:%02x.%d is a PCI bridge\n", pci_domain_nr(dev->bus), dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn))); device->ops.bind = acpi_pci_bind; device->ops.unbind = acpi_pci_unbind; } /* * Evaluate and parse _PRT, if exists. This code allows parsing of * _PRT objects within the scope of non-bridge devices. Note that * _PRTs within the scope of a PCI bridge assume the bridge's * subordinate bus number. * * TBD: Can _PRTs exist within the scope of non-bridge PCI devices? */ status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); if (ACPI_FAILURE(status)) goto out; if (dev->subordinate) bus = dev->subordinate->number; else bus = dev->bus->number; acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus); out: pci_dev_put(dev); return 0; }
static int acpi_pci_unbind(struct acpi_device *device) { struct pci_dev *dev; dev = acpi_get_pci_dev(device->handle); if (!dev) goto out; device_set_run_wake(&dev->dev, false); pci_acpi_remove_pm_notifier(device); acpi_power_resource_unregister_device(&dev->dev, device->handle); if (!dev->subordinate) goto out; acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number); device->ops.bind = NULL; device->ops.unbind = NULL; out: pci_dev_put(dev); return 0; }
static void __devinit txe_pci_early_quirks(struct pci_dev *pci_dev) { dev_info(&pci_dev->dev, "txe: set run wake flag\n"); device_set_run_wake(&pci_dev->dev, true); }
static int dwc3_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) { struct dwc3_pci *dwc; struct resource res[2]; int ret; struct device *dev = &pci->dev; ret = pcim_enable_device(pci); if (ret) { dev_err(dev, "failed to enable pci device\n"); return -ENODEV; } pci_set_master(pci); dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL); if (!dwc) return -ENOMEM; dwc->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); if (!dwc->dwc3) return -ENOMEM; memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res)); res[0].start = pci_resource_start(pci, 0); res[0].end = pci_resource_end(pci, 0); res[0].name = "dwc_usb3"; res[0].flags = IORESOURCE_MEM; res[1].start = pci->irq; res[1].name = "dwc_usb3"; res[1].flags = IORESOURCE_IRQ; ret = platform_device_add_resources(dwc->dwc3, res, ARRAY_SIZE(res)); if (ret) { dev_err(dev, "couldn't add resources to dwc3 device\n"); return ret; } dwc->pci = pci; dwc->dwc3->dev.parent = dev; ACPI_COMPANION_SET(&dwc->dwc3->dev, ACPI_COMPANION(dev)); ret = dwc3_pci_quirks(dwc); if (ret) goto err; ret = platform_device_add(dwc->dwc3); if (ret) { dev_err(dev, "failed to register dwc3 device\n"); goto err; } device_init_wakeup(dev, true); device_set_run_wake(dev, true); pci_set_drvdata(pci, dwc); pm_runtime_put(dev); return 0; err: platform_device_put(dwc->dwc3); return ret; }