On one side we have a power domain uclass which is mostly clueless about the topology of the power domains it manages.
On the other side we have SoCs which are getting more and more complex, ie. with several layers of power domains. Sometimes (eg. on TI K3 platforms) all power domains are defined by a single device tree node and the "subdomains" are referenced using an identification cell (#power-domain-cells = <1 or more>). Sometimes however (eg. on NXP i.MX8 SoCs), the description uses many device tree nodes. When a power domain is referenced several times, it is likely that the power_domain_on() function will be called several times in a row, which in some cases may lead to glitches or even breakages. This situation is problematic on i.MX8MP and only with proper reference counting we can safely support the video pipeline. There was a first attempt to bring refcount support to the power domain uclass, but it miserably failed because of the details mentioned above: https://lore.kernel.org/u-boot/20250403-ge-mainline-display-support-v6-5-478b5e3dd...@bootlin.com/ So here is a new version of it, which takes into consideration: - the fact that a single power domain udev can target several power domain IDs (referred as "subdomains") - the fact that some platforms might count on a uneven count of on/off calls to work, and "fixing" this may break the platforms. So refcounting is an opt-in parameter, it is a matter of filling the platform (public part of a per-uclass structure) subdomains number with the number of subdomains this device nodes features (one per power_domain->id) in the probe function of the power domain driver. This series shows how it can be done by enabling refcounting on i.MX8MP. Samuel, Neha, Wadim, Heiko, could you please confirm it works on your side? For once, CI is green :-) https://github.com/u-boot/u-boot/pull/753 --- Miquel Raynal (2): power-domain: Add support for refcounting (again) imx: power-domain: Enable refcounting on imx8mp arch/sandbox/include/asm/power-domain.h | 2 + drivers/firmware/scmi/sandbox-scmi_devices.c | 1 + drivers/power/domain/imx8m-power-domain.c | 4 ++ drivers/power/domain/imx8mp-hsiomix.c | 4 ++ drivers/power/domain/imx8mp-mediamix.c | 4 ++ drivers/power/domain/power-domain-uclass.c | 90 ++++++++++++++++++++++-- drivers/power/domain/sandbox-power-domain-test.c | 15 ++++ drivers/power/domain/sandbox-power-domain.c | 4 ++ include/power-domain.h | 69 +++++++++++++++--- test/dm/power-domain.c | 11 ++- 10 files changed, 189 insertions(+), 15 deletions(-) --- base-commit: 233fda6af674736dbc6ff37a9ef003b9fa4b8074 change-id: 20250424-ge-ian-display-support-a305ddb47f2b Best regards, -- Miquel Raynal <miquel.ray...@bootlin.com>