55 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Copyright (C) 2024 Linaro Ltd.4 */5 6#ifndef __PCI_PWRCTL_H__7#define __PCI_PWRCTL_H__8 9#include <linux/notifier.h>10#include <linux/workqueue.h>11 12struct device;13struct device_link;14 15/*16 * This is a simple framework for solving the issue of PCI devices that require17 * certain resources (regulators, GPIOs, clocks) to be enabled before the18 * device can actually be detected on the PCI bus.19 *20 * The idea is to reuse the platform bus to populate OF nodes describing the21 * PCI device and its resources, let these platform devices probe and enable22 * relevant resources and then trigger a rescan of the PCI bus allowing for the23 * same device (with a second associated struct device) to be registered with24 * the PCI subsystem.25 *26 * To preserve a correct hierarchy for PCI power management and device reset,27 * we create a device link between the power control platform device (parent)28 * and the supplied PCI device (child).29 */30 31/**32 * struct pci_pwrctl - PCI device power control context.33 * @dev: Address of the power controlling device.34 *35 * An object of this type must be allocated by the PCI power control device and36 * passed to the pwrctl subsystem to trigger a bus rescan and setup a device37 * link with the device once it's up.38 */39struct pci_pwrctl {40 struct device *dev;41 42 /* Private: don't use. */43 struct notifier_block nb;44 struct device_link *link;45 struct work_struct work;46};47 48void pci_pwrctl_init(struct pci_pwrctl *pwrctl, struct device *dev);49int pci_pwrctl_device_set_ready(struct pci_pwrctl *pwrctl);50void pci_pwrctl_device_unset_ready(struct pci_pwrctl *pwrctl);51int devm_pci_pwrctl_device_set_ready(struct device *dev,52 struct pci_pwrctl *pwrctl);53 54#endif /* __PCI_PWRCTL_H__ */55