drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c
Source file repositories/reference/linux-study-clean/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c- Extension
.c- Size
- 3748 bytes
- Lines
- 142
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/mod_devicetable.hlinux/module.hlinux/pci-pwrctrl.hlinux/platform_device.hlinux/property.hlinux/pwrseq/consumer.hlinux/slab.hlinux/types.h
Detected Declarations
struct pwrseq_pwrctrlstruct pwrseq_pwrctrl_pdatafunction pwrseq_pwrctrl_qcm_wcn_validate_devicefunction pwrseq_pwrctrl_power_onfunction pwrseq_pwrctrl_power_offfunction pwrseq_pwrctrl_probe
Annotated Snippet
struct pwrseq_pwrctrl {
struct pci_pwrctrl pwrctrl;
struct pwrseq_desc *pwrseq;
};
struct pwrseq_pwrctrl_pdata {
const char *target;
/*
* Called before doing anything else to perform device-specific
* verification between requesting the power sequencing handle.
*/
int (*validate_device)(struct device *dev);
};
static int pwrseq_pwrctrl_qcm_wcn_validate_device(struct device *dev)
{
/*
* Old device trees for some platforms already define wifi nodes for
* the WCN family of chips since before power sequencing was added
* upstream.
*
* These nodes don't consume the regulator outputs from the PMU, and
* if we allow this driver to bind to one of such "incomplete" nodes,
* we'll see a kernel log error about the indefinite probe deferral.
*
* Check the existence of the regulator supply that exists on all
* WCN models before moving forward.
*/
if (!device_property_present(dev, "vddaon-supply"))
return -ENODEV;
return 0;
}
static const struct pwrseq_pwrctrl_pdata pwrseq_pwrctrl_qcom_wcn_pdata = {
.target = "wlan",
.validate_device = pwrseq_pwrctrl_qcm_wcn_validate_device,
};
static int pwrseq_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl)
{
struct pwrseq_pwrctrl *pwrseq = container_of(pwrctrl,
struct pwrseq_pwrctrl, pwrctrl);
return pwrseq_power_on(pwrseq->pwrseq);
}
static int pwrseq_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl)
{
struct pwrseq_pwrctrl *pwrseq = container_of(pwrctrl,
struct pwrseq_pwrctrl, pwrctrl);
return pwrseq_power_off(pwrseq->pwrseq);
}
static int pwrseq_pwrctrl_probe(struct platform_device *pdev)
{
const struct pwrseq_pwrctrl_pdata *pdata;
struct pwrseq_pwrctrl *pwrseq;
struct device *dev = &pdev->dev;
int ret;
pdata = device_get_match_data(dev);
if (!pdata || !pdata->target)
return -EINVAL;
if (pdata->validate_device) {
ret = pdata->validate_device(dev);
if (ret)
return ret;
}
pwrseq = devm_kzalloc(dev, sizeof(*pwrseq), GFP_KERNEL);
if (!pwrseq)
return -ENOMEM;
pwrseq->pwrseq = devm_pwrseq_get(dev, pdata->target);
if (IS_ERR(pwrseq->pwrseq))
return dev_err_probe(dev, PTR_ERR(pwrseq->pwrseq),
"Failed to get the power sequencer\n");
pwrseq->pwrctrl.power_on = pwrseq_pwrctrl_power_on;
pwrseq->pwrctrl.power_off = pwrseq_pwrctrl_power_off;
pci_pwrctrl_init(&pwrseq->pwrctrl, dev);
ret = devm_pci_pwrctrl_device_set_ready(dev, &pwrseq->pwrctrl);
if (ret)
return dev_err_probe(dev, ret,
"Failed to register the pwrctrl wrapper\n");
Annotation
- Immediate include surface: `linux/device.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/pci-pwrctrl.h`, `linux/platform_device.h`, `linux/property.h`, `linux/pwrseq/consumer.h`, `linux/slab.h`.
- Detected declarations: `struct pwrseq_pwrctrl`, `struct pwrseq_pwrctrl_pdata`, `function pwrseq_pwrctrl_qcm_wcn_validate_device`, `function pwrseq_pwrctrl_power_on`, `function pwrseq_pwrctrl_power_off`, `function pwrseq_pwrctrl_probe`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.