]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
firmware: arm_scmi: Add power management operations to SCMI bus
authorPeng Fan <peng.fan@nxp.com>
Fri, 4 Jul 2025 03:09:35 +0000 (11:09 +0800)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 7 Jul 2025 15:53:16 +0000 (16:53 +0100)
Introduce suspend and resume power management callbacks for `scmi_bus_type`,
modeled after `platform_pm_ops`. This enables SCMI devices on the bus to
implement their own suspend and resume behavior, allowing for more
fine-grained power control at the device level.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Message-Id: <20250704-scmi-pm-v2-1-9316cec2f9cc@nxp.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/bus.c

index 1adef03894751dae9bb752b8c7f86e5d01c5d4fd..24e59ddf85e7c774ee2827d7457a565d2624ca41 100644 (file)
@@ -323,6 +323,31 @@ static struct attribute *scmi_device_attributes_attrs[] = {
 };
 ATTRIBUTE_GROUPS(scmi_device_attributes);
 
+static int scmi_pm_suspend(struct device *dev)
+{
+       const struct device_driver *drv = dev->driver;
+
+       if (drv && drv->pm && drv->pm->suspend)
+               return drv->pm->suspend(dev);
+
+       return 0;
+}
+
+static int scmi_pm_resume(struct device *dev)
+{
+       const struct device_driver *drv = dev->driver;
+
+       if (drv && drv->pm && drv->pm->resume)
+               return drv->pm->resume(dev);
+
+       return 0;
+}
+
+static const struct dev_pm_ops scmi_dev_pm_ops = {
+       .suspend = pm_sleep_ptr(scmi_pm_suspend),
+       .resume = pm_sleep_ptr(scmi_pm_resume),
+};
+
 const struct bus_type scmi_bus_type = {
        .name = "scmi_protocol",
        .match = scmi_dev_match,
@@ -330,6 +355,7 @@ const struct bus_type scmi_bus_type = {
        .remove = scmi_dev_remove,
        .uevent = scmi_device_uevent,
        .dev_groups = scmi_device_attributes_groups,
+       .pm = &scmi_dev_pm_ops,
 };
 EXPORT_SYMBOL_GPL(scmi_bus_type);