[v4,2/4] pmdomain: imx: gpcv2: Keep the domains left on by the bootloader
Commit Message
The PGC domains are all registered as off, so a domain left on by the
bootloader, e.g. DISPMIX to show a splash screen, is powered up again
by its first consumer. On the i.MX8MN this turns the display off and
hangs the system.
The GPC does not report the power state of a domain, but the ADB400
bridge acknowledges the power-up handshake only while the domain is
powered. Use it to register as on the domains left on by the
bootloader.
Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
(no changes since v3)
Changes in v3:
- Drop the runtime PM reference synchronously in the probe error path
Changes in v2:
- Release the resources of the domains left on when the driver is
removed
drivers/pmdomain/imx/gpcv2.c | 77 +++++++++++++++++++++++++++++++++++-
1 file changed, 75 insertions(+), 2 deletions(-)
--
2.43.0
Comments
On Sun, 22 Nov 2026 21:51:11 +0100 Dario Binacchi <dario.binacchi@amarulasolutions.com> wrote:
> The PGC domains are all registered as off, so a domain left on by the
> bootloader, e.g. DISPMIX to show a splash screen, is powered up again
> by its first consumer. On the i.MX8MN this turns the display off and
> hangs the system.
>
> The GPC does not report the power state of a domain, but the ADB400
> bridge acknowledges the power-up handshake only while the domain is
> powered. Use it to register as on the domains left on by the
> bootloader.
>
> Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
@@ -292,6 +292,7 @@ struct imx_pgc_domain {
const int voltage;
const bool keep_clocks;
+ bool boot_on; /* Left on by the bootloader */
struct device *dev;
unsigned int pgc_sw_pup_reg;
@@ -488,6 +489,8 @@ static int imx_pgc_power_down(struct generic_pm_domain *genpd)
pm_runtime_put_sync_suspend(domain->dev);
+ domain->boot_on = false;
+
return 0;
out_clk_disable:
@@ -1315,9 +1318,27 @@ static const struct imx_pgc_domain_data imx8mn_pgc_domain_data = {
.pgc_regs = &imx7_pgc_regs,
};
+/*
+ * The GPC does not report the power state of a domain, but the ADB400
+ * acknowledges the power-up handshake only while the domain is powered.
+ */
+static bool imx_pgc_domain_is_on(struct imx_pgc_domain *domain)
+{
+ u32 val;
+
+ if (!domain->bits.hskack)
+ return false;
+
+ if (regmap_read(domain->regmap, domain->regs->hsk, &val))
+ return false;
+
+ return (val & domain->bits.hskack) == domain->bits.hskack;
+}
+
static int imx_pgc_domain_probe(struct platform_device *pdev)
{
struct imx_pgc_domain *domain = pdev->dev.platform_data;
+ bool init_off;
int ret;
domain->dev = &pdev->dev;
@@ -1348,12 +1369,44 @@ static int imx_pgc_domain_probe(struct platform_device *pdev)
regmap_update_bits(domain->regmap, domain->regs->map,
domain->bits.map, domain->bits.map);
- ret = pm_genpd_init(&domain->genpd, NULL, true);
+ init_off = !imx_pgc_domain_is_on(domain);
+ ret = pm_genpd_init(&domain->genpd, NULL, init_off);
if (ret) {
dev_err_probe(domain->dev, ret, "Failed to init power domain\n");
goto out_domain_unmap;
}
+ /* Balance the first imx_pgc_power_down() */
+ if (!init_off) {
+ ret = pm_runtime_resume_and_get(domain->dev);
+ if (ret < 0) {
+ dev_err_probe(domain->dev, ret,
+ "Failed to resume domain\n");
+ goto out_genpd_remove;
+ }
+
+ if (!IS_ERR(domain->regulator)) {
+ ret = regulator_enable(domain->regulator);
+ if (ret) {
+ dev_err_probe(domain->dev, ret,
+ "Failed to enable domain's regulator\n");
+ goto out_put_pm;
+ }
+ }
+
+ if (domain->keep_clocks) {
+ ret = clk_bulk_prepare_enable(domain->num_clks,
+ domain->clks);
+ if (ret) {
+ dev_err_probe(domain->dev, ret,
+ "Failed to enable domain's clocks\n");
+ goto out_regulator_disable;
+ }
+ }
+
+ domain->boot_on = true;
+ }
+
if (IS_ENABLED(CONFIG_LOCKDEP) &&
of_property_present(domain->dev->of_node, "power-domains"))
lockdep_set_subclass(&domain->genpd.mlock, 1);
@@ -1362,11 +1415,20 @@ static int imx_pgc_domain_probe(struct platform_device *pdev)
&domain->genpd);
if (ret) {
dev_err_probe(domain->dev, ret, "Failed to add genpd provider\n");
- goto out_genpd_remove;
+ goto out_clk_disable;
}
return 0;
+out_clk_disable:
+ if (!init_off && domain->keep_clocks)
+ clk_bulk_disable_unprepare(domain->num_clks, domain->clks);
+out_regulator_disable:
+ if (!init_off && !IS_ERR(domain->regulator))
+ regulator_disable(domain->regulator);
+out_put_pm:
+ if (!init_off)
+ pm_runtime_put_sync(domain->dev);
out_genpd_remove:
pm_genpd_remove(&domain->genpd);
out_domain_unmap:
@@ -1385,6 +1447,17 @@ static void imx_pgc_domain_remove(struct platform_device *pdev)
of_genpd_del_provider(domain->dev->of_node);
pm_genpd_remove(&domain->genpd);
+ if (domain->boot_on) {
+ if (domain->keep_clocks)
+ clk_bulk_disable_unprepare(domain->num_clks,
+ domain->clks);
+
+ if (!IS_ERR(domain->regulator))
+ regulator_disable(domain->regulator);
+
+ pm_runtime_put_sync(domain->dev);
+ }
+
if (domain->bits.map)
regmap_update_bits(domain->regmap, domain->regs->map,
domain->bits.map, 0);