[PATCH 2/7] pmdomain: st: add STM32MP power domain

Patrick DELAUNAY patrick.delaunay at foss.st.com
Mon Nov 16 07:10:59 PST 2026


Hi,

On 11/14/26 11:40, Ulf Hansson wrote:
> On Wed, Nov 4, 2026 at 3:02 PM Patrick Delaunay
> <patrick.delaunay at foss.st.com> wrote:
>> Add a generic PM domain for the STM32MP D1 domain, using the PM
>> framework to manage attached devices.
>>
>> Make D1 a subdomain of the PSCI cluster domain, so active devices keep
>> the Cortex-A35 cluster in Run1. Do not set GENPD_FLAG_ACTIVE_WAKEUP on
>> D1: system wakeups are handled by EXTI1 through the RET_PD PSCI domain.
> Would you mind elaborating on the system wakeups a bit more?
>
> The devices that get attached to the D1 PM domain do they have another
> PM domain as well, to support the system wakeups?


Each device in D1 domain use

- D1 domain to allow any low power mode  (Stop1) when they are suspended

- EXTI1 interruption to manage wake-up patch

For example for UART:

             usart2: serial at 400e0000 {
                 compatible = "st,stm32h7-uart";
                 reg = <0x400e0000 0x400>;
-                interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>;
+                interrupts-extended = <&exti1 27 IRQ_TYPE_LEVEL_HIGH>;
...
                 power-domains = <&d1_pd>;
+                wakeup-source;

                 status = "disabled";
             };


Then the system wake up for S2Idle  is managed by EXTI1 device wake-up state

  when interruptions are activated.


Moreover LPLV-Stop1 is not allowed when EXTI is "active" for OSI, i.e 
when at least

  one interruption of Group2 activated.


To explain deeper, when  OSI is fully activated  [1], i.e with full 
upstream for STM32MP25


- the PSCI power domain Cluster Domain allows "Stop1" and "LP-Stop1" low 
power mode as CpuIdle mode

    - D1 is part of Cluster => the device is D1 domain allow low power 
mode when they are suspended

                                           => active Wake-Up for device 
in D1 domain device is compatible with Stop1/LP-Stop1
                                                 the wake-up path is NOT 
propagated to parent domain


- the PSCI Retention Domain allows "LPLV-Stop1"

     EXTI is part of this domain (not yet upstreamed) [2] :


         exti1: interrupt-controller at 44220000 {
             compatible = "st,stm32mp1-exti";
             interrupt-controller;
             #interrupt-cells = <2>;
+            power-domains = <&ret_pd>;
             ....

         }

the Group2 wake up sources are handled by EXTI1 and but they are not 
functional when the LPLV mode is performed.

We handled this restriction by EXTI patches no yet upstreamed [3]

     - activating the wake-up path in EXTI1 device when at least one 
interruption of group2 is activated  for S2DIle mode

     - with EXTI1 pm_runtime state for OSI mode


So the "ret_pd" domain can't be deactivated when EXTI1 interrupts are 
activated for runtime (OSI) or

part of the wake-up patch for S2IDLE


[1] 
https://wiki.st.com/stm32mpu/wiki/Power_overview#STM32MP2_series_power_domains


[2] 
https://github.com/STMicroelectronics/linux/blob/v6.18-stm32mp/arch/arm64/boot/dts/st/stm32mp251.dtsi

  https://github.com/STMicroelectronics/linux/commit/d216f8439d14e0a11475495cf5445e05cc4a9da9


[3] 
https://github.com/STMicroelectronics/linux/blob/v6.18-stm32mp/drivers/irqchip/irq-stm32mp-exti.c

irqchip: stm32mp-exti: Add support of pm runtime

https://github.com/STMicroelectronics/linux/commit/4a4a20f5c5aae461a7a14c98efeddbc9cd08c672

      irqchip: stm32mp-exti: Add support of wake-up path for S2Idle

  https://github.com/STMicroelectronics/linux/commit/1d3b854e7b95318b67afd2dc16b8ff5fc060443a


>
> Just trying to make sure this gets modeled correctly.


I hope that follow the genPD model...

and if it is the case , do you need update in the commit message to 
clarify it ?


>
> One comment in the code below.
>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
>> ---
>>
>>   drivers/pmdomain/st/Kconfig             |  14 +++
>>   drivers/pmdomain/st/Makefile            |   1 +
>>   drivers/pmdomain/st/stm32mp-pm-domain.c | 128 ++++++++++++++++++++++++
>>   3 files changed, 143 insertions(+)
>>   create mode 100644 drivers/pmdomain/st/stm32mp-pm-domain.c
>>
>> diff --git a/drivers/pmdomain/st/Kconfig b/drivers/pmdomain/st/Kconfig
>> index a77a70211f61..da8a54d44158 100644
>> --- a/drivers/pmdomain/st/Kconfig
>> +++ b/drivers/pmdomain/st/Kconfig
>> @@ -1,4 +1,18 @@
>>   # SPDX-License-Identifier: GPL-2.0-only
>> +
>> +config STM32MP_PM_DOMAIN
>> +       tristate "STM32MP PM domain"
>> +       depends on ARCH_STM32 || COMPILE_TEST
>> +       select PM_GENERIC_DOMAINS
>> +       default y
>> +       help
>> +         Enable support for the STM32MP Power Management (PM) domain driver.
>> +         This driver implements a generic PM domain for STM32MP SoCs, allowing
>> +         the kernel to manage power domains for various hardware blocks using
>> +         the generic power management framework. It is typically used to
>> +         control the power state of devices and peripherals on STM32MP
>> +         platforms. If unsure, say Y.
>> +
>>   config UX500_PM_DOMAIN
>>          bool "ST-Ericsson ux500 Power Domain"
>>          depends on ARCH_U8500 || COMPILE_TEST
>> diff --git a/drivers/pmdomain/st/Makefile b/drivers/pmdomain/st/Makefile
>> index 6d8b617eb834..0e8131b7fe9d 100644
>> --- a/drivers/pmdomain/st/Makefile
>> +++ b/drivers/pmdomain/st/Makefile
>> @@ -1,2 +1,3 @@
>>   # SPDX-License-Identifier: GPL-2.0-only
>> +obj-$(CONFIG_STM32MP_PM_DOMAIN)                += stm32mp-pm-domain.o
>>   obj-$(CONFIG_UX500_PM_DOMAIN)          += ste-ux500-pm-domain.o
>> diff --git a/drivers/pmdomain/st/stm32mp-pm-domain.c b/drivers/pmdomain/st/stm32mp-pm-domain.c
>> new file mode 100644
>> index 000000000000..1a6393840f56
>> --- /dev/null
>> +++ b/drivers/pmdomain/st/stm32mp-pm-domain.c
>> @@ -0,0 +1,128 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Implements PM domain using the generic PM domain for STM32MP SoC.
>> + *
>> + * Copyright (C) STMicroelectronics 2026
>> + * Author(s): Patrick Delaunay <patrick.delaunay at foss.st.com>
>> + */
>> +
>> +#include <linux/device.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/pm_domain.h>
>> +#include <linux/pm_runtime.h>
>> +
>> +struct stm32mp_pm_subdomain_link {
>> +       struct generic_pm_domain *domain;
>> +       struct generic_pm_domain *subdomain;
>> +};
>> +
>> +static void stm32mp_pm_domain_genpd_remove(void *data)
>> +{
>> +       struct generic_pm_domain *genpd = data;
>> +
>> +       pm_genpd_remove(genpd);
>> +}
>> +
>> +static void stm32mp_pm_domain_release_subdomain(void *data)
>> +{
>> +       struct stm32mp_pm_subdomain_link *link = data;
>> +
>> +       pm_genpd_remove_subdomain(link->domain, link->subdomain);
>> +}
>> +
>> +static void stm32mp_pm_domain_release_genpd_provider(void *data)
>> +{
>> +       struct device_node *np = data;
>> +
>> +       of_genpd_del_provider(np);
>> +}
>> +
>> +static int stm32mp_pm_domain_probe(struct platform_device *pdev)
>> +{
>> +       struct device *dev = &pdev->dev;
>> +       struct device_node *np = dev->of_node;
>> +       struct generic_pm_domain *pd;
>> +       struct stm32mp_pm_subdomain_link *link;
>> +       int ret;
>> +
>> +       if (!np)
>> +               return -ENODEV;
>> +
>> +       /* The OF node must specify us as a power-domain provider. */
>> +       if (!of_property_present(np, "#power-domain-cells")) {
>> +               dev_warn(dev, "%pOF lacks #power-domain-cells\n", np);
>> +               return 0;
>> +       }
>> +
>> +       pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
>> +       if (!pd)
>> +               return -ENOMEM;
>> +
>> +       pd->name = dev_name(dev);
>> +
>> +       /*
>> +        * Domain based only on PM clk framework, no GENPD_FLAG_ACTIVE_WAKEUP
>> +        * support, the wake-up path is handled by interrupt driver with its
>> +        * power domain. GENPD_FLAG_NO_STAY_ON as domain no required sync state,
>> +        * domain allow low power modes even if devices are not probed
>> +        */
>> +       pd->flags = GENPD_FLAG_PM_CLK | GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_NO_STAY_ON;
>> +
>> +       ret = pm_genpd_init(pd, NULL, false);
>> +       if (ret)
>> +               return dev_err_probe(dev, ret, "failed to init power domain\n");
>> +
>> +       ret = devm_add_action_or_reset(dev, stm32mp_pm_domain_genpd_remove, pd);
>> +       if (ret)
>> +               return dev_err_probe(dev, ret, "failed to add action\n");
>> +
>> +       link = devm_kzalloc(dev, sizeof(*link), GFP_KERNEL);
>> +       if (!link)
>> +               return -ENOMEM;
>> +       link->domain = pd_to_genpd(dev->pm_domain);
>> +       link->subdomain = pd;
>> +
>> +       ret = pm_genpd_add_subdomain(link->domain, link->subdomain);
>> +       if (ret)
>> +               return dev_err_probe(dev, ret, "failed to add subdomain\n");
>> +
>> +       ret = devm_add_action_or_reset(dev, stm32mp_pm_domain_release_subdomain, link);
>> +       if (ret)
>> +               return dev_err_probe(dev, ret, "failed to add action\n");
>> +
>> +       ret = of_genpd_add_provider_simple(np, pd);
>> +       if (ret)
>> +               return dev_err_probe(dev, ret, "failed to add power domain provider\n");
>> +
>> +       ret = devm_add_action_or_reset(dev, stm32mp_pm_domain_release_genpd_provider, np);
>> +       if (ret)
>> +               return dev_err_probe(dev, ret, "failed to add action\n");
>> +
>> +       ret = devm_pm_runtime_enable(dev);
> What is this used for?


This pattfrom driver is part of power-domain-cluster because in device 
tree a power domain is associated to it DT node


     d1_pd: power-domain-d1 {
         compatible = "st,stm32mp-pm-domain";
         #power-domain-cells = <0>;
         power-domains = <&cluster_pd>;
     };


This power domain is used to create the GENPD sub domain "power-domain-d1"

but as side effect  the associated platform device is also in this PSCI 
domain

so it must manage correctly a PM state.


Without this line the runtime status is "unsupported" and the cluster 
domain is not deactivated


$> cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

domain                          status          children performance
     /device                         runtime status   managed by
------------------------------------------------------------------------------
power-domain-d1                 on                              0
     482c0000.ethernet               active                      0       
    SW
     482d0000.ethernet               active                      0       
    SW
     40130000.i2c                    suspended                   0       
    SW
     400e0000.serial                 active                      0       
    SW
     48220000.mmc                    suspended                   0       
    SW
     48030000.dcmipp                 suspended                   0       
    SW
power-domain-cpu1               on                              0
     genpd:0:cpu1                    active                      0       
    SW
power-domain-retention          on                              0
power-domain-cluster
     40400000.dma-controller         suspended                   0       
    SW
     40410000.dma-controller         suspended                   0       
    SW
     40420000.dma-controller         suspended                   0       
    SW
power-domain-cluster            on                              0
                                                 power-domain-cpu0, 
power-domain-cpu1, power-domain-d1
     power-domain-d1                 unsupported                 0       
    SW  <<<< HERE
power-domain-cpu0               off-0                           0
     genpd:0:cpu0                    suspended                   0       
    SW


a other (better?) solution is to remove the linked create by framework

as it i done in drivers/pmdomain/apple/pmgr-pwrstate.c:288:

with:


+    pm_genpd_remove_device(dev);


I change if you confirm that it is better.


>
>> +       if (ret)
>> +               return dev_err_probe(dev, ret, "failed to enable pm-runtime\n");
>> +
>> +       return 0;
>> +}
>> +
>> +static const struct of_device_id stm32mp_pm_domain_matches[] = {
>> +       { .compatible = "st,stm32mp-pm-domain", },
>> +       { }
>> +};
>> +MODULE_DEVICE_TABLE(of, stm32mp_pm_domain_matches);
>> +
>> +static struct platform_driver stm32mp_pm_domain_driver = {
>> +       .driver = {
>> +               .name = "stm32mp_pm_domain",
>> +               .of_match_table = stm32mp_pm_domain_matches,
>> +       },
>> +       .probe  = stm32mp_pm_domain_probe,
>> +};
>> +
>> +module_platform_driver(stm32mp_pm_domain_driver);
>> +
>> +MODULE_AUTHOR("Patrick Delaunay <patrick.delaunay at foss.st.com>");
>> +MODULE_DESCRIPTION("ST STM32MP power domain driver");
>> +MODULE_LICENSE("GPL");
>> --
>> 2.43.0
>>
> Kind regards
> Uffe


Regards

Patrick




More information about the linux-arm-kernel mailing list