summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>2026-01-15 10:29:01 +0300
committerBjorn Helgaas <bhelgaas@google.com>2026-01-16 22:23:38 +0300
commit113f44ed50d274447a3b76cf250989a423f179a5 (patch)
tree318184577be27e00bd4a601de642fb6f636538fa
parent2045c352812e5a2eec0aa9d2b1e5d2fe1127b919 (diff)
downloadlinux-113f44ed50d274447a3b76cf250989a423f179a5.tar.xz
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
-rw-r--r--drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c3
-rw-r--r--drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c22
-rw-r--r--drivers/pci/pwrctrl/slot.c3
-rw-r--r--include/linux/pci-pwrctrl.h4
4 files changed, 26 insertions, 6 deletions
diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c b/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c
index 9b698c5426c5..23ee1a9e7f77 100644
--- a/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c
+++ b/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c
@@ -111,6 +111,9 @@ static int pwrseq_pwrctrl_probe(struct platform_device *pdev)
if (ret)
return ret;
+ 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);
diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
index af3bd1d01ad9..23095d8ecebc 100644
--- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
+++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
@@ -450,15 +450,22 @@ static int tc9563_pwrctrl_parse_device_dt(struct tc9563_pwrctrl *tc9563,
return 0;
}
-static void tc9563_pwrctrl_power_off(struct tc9563_pwrctrl *tc9563)
+static int tc9563_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl)
{
+ struct tc9563_pwrctrl *tc9563 = container_of(pwrctrl,
+ struct tc9563_pwrctrl, pwrctrl);
+
gpiod_set_value(tc9563->reset_gpio, 1);
regulator_bulk_disable(ARRAY_SIZE(tc9563->supplies), tc9563->supplies);
+
+ return 0;
}
-static int tc9563_pwrctrl_bring_up(struct tc9563_pwrctrl *tc9563)
+static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl)
{
+ struct tc9563_pwrctrl *tc9563 = container_of(pwrctrl,
+ struct tc9563_pwrctrl, pwrctrl);
struct device *dev = tc9563->pwrctrl.dev;
struct tc9563_pwrctrl_cfg *cfg;
int ret, i;
@@ -520,7 +527,7 @@ static int tc9563_pwrctrl_bring_up(struct tc9563_pwrctrl *tc9563)
return 0;
power_off:
- tc9563_pwrctrl_power_off(tc9563);
+ tc9563_pwrctrl_power_off(&tc9563->pwrctrl);
return ret;
}
@@ -613,7 +620,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
goto remove_i2c;
}
- ret = tc9563_pwrctrl_bring_up(tc9563);
+ ret = tc9563_pwrctrl_power_on(&tc9563->pwrctrl);
if (ret)
goto remove_i2c;
@@ -623,6 +630,9 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
goto power_off;
}
+ tc9563->pwrctrl.power_on = tc9563_pwrctrl_power_on;
+ tc9563->pwrctrl.power_off = tc9563_pwrctrl_power_off;
+
ret = devm_pci_pwrctrl_device_set_ready(dev, &tc9563->pwrctrl);
if (ret)
goto power_off;
@@ -632,7 +642,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
return 0;
power_off:
- tc9563_pwrctrl_power_off(tc9563);
+ tc9563_pwrctrl_power_off(&tc9563->pwrctrl);
remove_i2c:
i2c_unregister_device(tc9563->client);
put_device(&tc9563->adapter->dev);
@@ -643,7 +653,7 @@ static void tc9563_pwrctrl_remove(struct platform_device *pdev)
{
struct tc9563_pwrctrl *tc9563 = platform_get_drvdata(pdev);
- tc9563_pwrctrl_power_off(tc9563);
+ tc9563_pwrctrl_power_off(&tc9563->pwrctrl);
i2c_unregister_device(tc9563->client);
put_device(&tc9563->adapter->dev);
}
diff --git a/drivers/pci/pwrctrl/slot.c b/drivers/pci/pwrctrl/slot.c
index 094c7df454fc..71aaddd24253 100644
--- a/drivers/pci/pwrctrl/slot.c
+++ b/drivers/pci/pwrctrl/slot.c
@@ -85,6 +85,9 @@ static int slot_pwrctrl_probe(struct platform_device *pdev)
slot_pwrctrl_power_on(&slot->pwrctrl);
+ slot->pwrctrl.power_on = slot_pwrctrl_power_on;
+ slot->pwrctrl.power_off = slot_pwrctrl_power_off;
+
pci_pwrctrl_init(&slot->pwrctrl, dev);
ret = devm_pci_pwrctrl_device_set_ready(dev, &slot->pwrctrl);
diff --git a/include/linux/pci-pwrctrl.h b/include/linux/pci-pwrctrl.h
index 4aefc7901cd1..435b822c841e 100644
--- a/include/linux/pci-pwrctrl.h
+++ b/include/linux/pci-pwrctrl.h
@@ -31,6 +31,8 @@ struct device_link;
/**
* struct pci_pwrctrl - PCI device power control context.
* @dev: Address of the power controlling device.
+ * @power_on: Callback to power on the power controlling device.
+ * @power_off: Callback to power off the power controlling device.
*
* An object of this type must be allocated by the PCI power control device and
* passed to the pwrctrl subsystem to trigger a bus rescan and setup a device
@@ -38,6 +40,8 @@ struct device_link;
*/
struct pci_pwrctrl {
struct device *dev;
+ int (*power_on)(struct pci_pwrctrl *pwrctrl);
+ int (*power_off)(struct pci_pwrctrl *pwrctrl);
/* private: internal use only */
struct notifier_block nb;