Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI/pwrctrl: Add 'struct pci_pwrctrl::power_{on/off}' callbacks

To allow the pwrctrl core to control the power on/off sequences of the
pwrctrl drivers, add the 'struct pci_pwrctrl::power_{on/off}' callbacks and
populate them in the respective pwrctrl drivers.

The pwrctrl drivers still power on the resources on their own now. So there
is no functional change.

Co-developed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260115-pci-pwrctrl-rework-v5-9-9d26da3ce903@oss.qualcomm.com

authored by

Manivannan Sadhasivam and committed by
Bjorn Helgaas
113f44ed 2045c352

+26 -6
+3
drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c
··· 111 111 if (ret) 112 112 return ret; 113 113 114 + pwrseq->pwrctrl.power_on = pwrseq_pwrctrl_power_on; 115 + pwrseq->pwrctrl.power_off = pwrseq_pwrctrl_power_off; 116 + 114 117 pci_pwrctrl_init(&pwrseq->pwrctrl, dev); 115 118 116 119 ret = devm_pci_pwrctrl_device_set_ready(dev, &pwrseq->pwrctrl);
+16 -6
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
··· 450 450 return 0; 451 451 } 452 452 453 - static void tc9563_pwrctrl_power_off(struct tc9563_pwrctrl *tc9563) 453 + static int tc9563_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl) 454 454 { 455 + struct tc9563_pwrctrl *tc9563 = container_of(pwrctrl, 456 + struct tc9563_pwrctrl, pwrctrl); 457 + 455 458 gpiod_set_value(tc9563->reset_gpio, 1); 456 459 457 460 regulator_bulk_disable(ARRAY_SIZE(tc9563->supplies), tc9563->supplies); 461 + 462 + return 0; 458 463 } 459 464 460 - static int tc9563_pwrctrl_bring_up(struct tc9563_pwrctrl *tc9563) 465 + static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) 461 466 { 467 + struct tc9563_pwrctrl *tc9563 = container_of(pwrctrl, 468 + struct tc9563_pwrctrl, pwrctrl); 462 469 struct device *dev = tc9563->pwrctrl.dev; 463 470 struct tc9563_pwrctrl_cfg *cfg; 464 471 int ret, i; ··· 527 520 return 0; 528 521 529 522 power_off: 530 - tc9563_pwrctrl_power_off(tc9563); 523 + tc9563_pwrctrl_power_off(&tc9563->pwrctrl); 531 524 return ret; 532 525 } 533 526 ··· 620 613 goto remove_i2c; 621 614 } 622 615 623 - ret = tc9563_pwrctrl_bring_up(tc9563); 616 + ret = tc9563_pwrctrl_power_on(&tc9563->pwrctrl); 624 617 if (ret) 625 618 goto remove_i2c; 626 619 ··· 629 622 if (ret) 630 623 goto power_off; 631 624 } 625 + 626 + tc9563->pwrctrl.power_on = tc9563_pwrctrl_power_on; 627 + tc9563->pwrctrl.power_off = tc9563_pwrctrl_power_off; 632 628 633 629 ret = devm_pci_pwrctrl_device_set_ready(dev, &tc9563->pwrctrl); 634 630 if (ret) ··· 642 632 return 0; 643 633 644 634 power_off: 645 - tc9563_pwrctrl_power_off(tc9563); 635 + tc9563_pwrctrl_power_off(&tc9563->pwrctrl); 646 636 remove_i2c: 647 637 i2c_unregister_device(tc9563->client); 648 638 put_device(&tc9563->adapter->dev); ··· 653 643 { 654 644 struct tc9563_pwrctrl *tc9563 = platform_get_drvdata(pdev); 655 645 656 - tc9563_pwrctrl_power_off(tc9563); 646 + tc9563_pwrctrl_power_off(&tc9563->pwrctrl); 657 647 i2c_unregister_device(tc9563->client); 658 648 put_device(&tc9563->adapter->dev); 659 649 }
+3
drivers/pci/pwrctrl/slot.c
··· 85 85 86 86 slot_pwrctrl_power_on(&slot->pwrctrl); 87 87 88 + slot->pwrctrl.power_on = slot_pwrctrl_power_on; 89 + slot->pwrctrl.power_off = slot_pwrctrl_power_off; 90 + 88 91 pci_pwrctrl_init(&slot->pwrctrl, dev); 89 92 90 93 ret = devm_pci_pwrctrl_device_set_ready(dev, &slot->pwrctrl);
+4
include/linux/pci-pwrctrl.h
··· 31 31 /** 32 32 * struct pci_pwrctrl - PCI device power control context. 33 33 * @dev: Address of the power controlling device. 34 + * @power_on: Callback to power on the power controlling device. 35 + * @power_off: Callback to power off the power controlling device. 34 36 * 35 37 * An object of this type must be allocated by the PCI power control device and 36 38 * passed to the pwrctrl subsystem to trigger a bus rescan and setup a device ··· 40 38 */ 41 39 struct pci_pwrctrl { 42 40 struct device *dev; 41 + int (*power_on)(struct pci_pwrctrl *pwrctrl); 42 + int (*power_off)(struct pci_pwrctrl *pwrctrl); 43 43 44 44 /* private: internal use only */ 45 45 struct notifier_block nb;