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

firmware/pmdomain: xilinx: Move ->sync_state() support to firmware driver

Rather than having the genpd provider to add device_links for each device
that gets attached, to implement the ->sync_state() support, let's rely on
fw_devlink to do this for us.

In this way, we can simplify the code by moving the ->sync_state() callback
into the firmware driver, so let's do that.

Cc: Michael Tretter <m.tretter@pengutronix.de>
Cc: Michal Simek <michal.simek@amd.com>
Tested-by: Hiago De Franco <hiago.franco@toradex.com> # Colibri iMX8X
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> # TI AM62A,Xilinx ZynqMP ZCU106
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250701114733.636510-15-ulf.hansson@linaro.org

+10 -16
+10
drivers/firmware/xilinx/zynqmp.c
··· 2100 2100 platform_device_unregister(em_dev); 2101 2101 } 2102 2102 2103 + static void zynqmp_firmware_sync_state(struct device *dev) 2104 + { 2105 + if (!of_device_is_compatible(dev->of_node, "xlnx,zynqmp-firmware")) 2106 + return; 2107 + 2108 + if (zynqmp_pm_init_finalize()) 2109 + dev_warn(dev, "failed to release power management to firmware\n"); 2110 + } 2111 + 2103 2112 static const struct of_device_id zynqmp_firmware_of_match[] = { 2104 2113 {.compatible = "xlnx,zynqmp-firmware"}, 2105 2114 {.compatible = "xlnx,versal-firmware"}, ··· 2121 2112 .name = "zynqmp_firmware", 2122 2113 .of_match_table = zynqmp_firmware_of_match, 2123 2114 .dev_groups = zynqmp_firmware_groups, 2115 + .sync_state = zynqmp_firmware_sync_state, 2124 2116 }, 2125 2117 .probe = zynqmp_firmware_probe, 2126 2118 .remove = zynqmp_firmware_remove,
-16
drivers/pmdomain/xilinx/zynqmp-pm-domains.c
··· 153 153 struct device *dev) 154 154 { 155 155 struct zynqmp_pm_domain *pd = to_zynqmp_pm_domain(domain); 156 - struct device_link *link; 157 156 int ret; 158 - 159 - link = device_link_add(dev, &domain->dev, DL_FLAG_SYNC_STATE_ONLY); 160 - if (!link) 161 - dev_dbg(&domain->dev, "failed to create device link for %s\n", 162 - dev_name(dev)); 163 157 164 158 /* If this is not the first device to attach there is nothing to do */ 165 159 if (domain->device_count) ··· 292 298 of_genpd_del_provider(pdev->dev.parent->of_node); 293 299 } 294 300 295 - static void zynqmp_gpd_sync_state(struct device *dev) 296 - { 297 - int ret; 298 - 299 - ret = zynqmp_pm_init_finalize(); 300 - if (ret) 301 - dev_warn(dev, "failed to release power management to firmware\n"); 302 - } 303 - 304 301 static struct platform_driver zynqmp_power_domain_driver = { 305 302 .driver = { 306 303 .name = "zynqmp_power_controller", 307 - .sync_state = zynqmp_gpd_sync_state, 308 304 }, 309 305 .probe = zynqmp_gpd_probe, 310 306 .remove = zynqmp_gpd_remove,