From patchwork Sun Nov 22 15:55:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 5052 Delivered-To: michael@amarulasolutions.com Received: by 2002:a05:7300:bf19:b0:386:abcc:ec87 with SMTP id ff25csp522815dyb; Sun, 22 Nov 2026 07:55:24 -0800 (PST) X-Received: by 2002:a05:6000:454f:b0:48e:6419:ddf2 with SMTP id ffacd0b85a97d-4abb2168ec7mr11621108f8f.17.1795362924255; Sun, 22 Nov 2026 07:55:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795362924; cv=none; d=google.com; s=arc-20260327; b=LtBBNFmsQRvCPETdazOxXOR8ftioxqeLF6VFQkfdFdPoiqtTCfeLtsSeaD6oVIw1Dx 8/Q75fsHIVWNh2X6P3XjZbvbXXcwG/3nWxd/A9G/26quvdZkBJusL0ePSrvGsfI2JkkU mTf+sr4Z1rbEdJ5Z4VJU/vhIi/RmgbomMeqJNoS2OUrBcEUu5/nwXk2xUiT0Lqeo7T/Z kwQG4fsvPTtQcTtvPoU5ouBrSXgjiMGtTep9jxyhi0fka8ghBZIlzKlOk042riSxqI9J CUPi0t0lziANg2Do56nRDjszePDl8y9oNdodg1TNnNq0FAwoBOAobZjgRyHM5mCcyxj/ asWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0VEXadRTs4mVJ4mB3xY7u+vAwlCzDe/yNMl9zPs8LH0=; fh=xgmO7m9cHP+l0Ql86Ki+oq/uFTumX4KXro3QQNE2moM=; b=gNveCv1+54iZVdZrzQy43Uzw9AbmyfrI5G0XRH4p1/k3181hTb9zLYgo3DBPfJsAEb Bg5YBVXCe0hiaHWhHjGDALoKQ5AyndaHYISanbq8UZT/LI6XtxiMifiMMfgo0GRxil4D qcExDJJ56PUAsrBqCbARYfGMVBq9ckpFqCD2r8CuSSF6B85GuMxJTIBQoR2MdawyPDBR WNkxNNKfw3tqjWSXpyJq0d498ck9x1w/mR5MRMTMRoRrww5X6/27GYisAuCM7uxbR7c3 XtfD5inuvbwlzFGF8hVhWwbXTA3zldw4IV9+odlcWv8FGw0fos/l2bsVmFV6pZM6b7RI KBeQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=L+hT+PMh; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=neutral header.i=@amarulasolutions.com Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-4ab6b206328sor2297802f8f.11.2026.11.22.07.55.24 for (Google Transport Security); Sun, 22 Nov 2026 07:55:24 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=L+hT+PMh; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=neutral header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1795362924; x=1795967724; darn=amarulasolutions.com; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0VEXadRTs4mVJ4mB3xY7u+vAwlCzDe/yNMl9zPs8LH0=; b=L+hT+PMhowRfejhqHOjPw9NPpWspY3qQbngYjw0DlRLyGb45h+Teap3V83x553wray gOHDfka1hHkKBHFt6bIRdDpt+7cDtaJ1drHrD2TsAZcUzBC1KGs2vahKvynoQXA7pDwj dw7VT1z3HXPBvBXmAI7+4KqWMZlcsRxcLQVHc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795362924; x=1795967724; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0VEXadRTs4mVJ4mB3xY7u+vAwlCzDe/yNMl9zPs8LH0=; b=Da/Jk2/XAFOaq2NC8tZKiw4OYn0B5AAsJCzaNuMLfmZs+cQheLttfnvhQlYdM03Tid BxckfbuWl+KkA6nol/mHfkITx/PdnsYL0D/f30nSwSATyFhmJzKD/ph/GJ7ZgdfdNJPk X92WCbPptAyjKbTDzZCBKZLwIfrl1+iH93N9kpno78/MVqSwopPwMtnEu6DyQQJbVn73 SoI27ntzcpouJ1zjDdUeq7d1QFH/QQi/8eJYBnIhB2PN/ORkSc0Bi5x4lfzOveyoTHNt vNzN8pM+sXR9vaAY4pGNsbmeBXlKkDdWy/vB9gKCjotuKFTvbzYx1o3z9hYkbEQzs4Py 6smA== X-Gm-Message-State: APuU4Z80NMrew3Z972T3Tco0POKnpzIzvib2eof3aIvEjgYIkj4caj20 0O6x84dp4lJAGlOCUpCMxBL1YTJ+3SF4DgBz60d5JQnKn4UoxYCBi13cCExkIjVwjdUOyUaYvwI 2cjkkt2w= X-Gm-Gg: AZFdTZfu/bcJ+o2odwfpIPjwIxXJ3uS2ReYVWA119AXXDRnXMxCopAeByWNgVYOqKpj LB5JlzEdJVrLFnuqBsR0qCneDgU7ci53O6gvRQtIvni1tNsS/S2KSmpi5zt+LKXByTenS7Qt/cC DBZYE47Hkj8lB+AvT8mO4TkGHW3LdoAkq44oLRdk9MIglbNs3ZLkgq15NrMqEeT0cABbCKfOcMS zVeRzC3+LoWjtnzmthbTdjHv0JiQm06j7nz+Dya6VNunwVxLbm6arco5D6OGhnESaneaL5jK+pC 39W2ZWW7ypJZC0T5/stf6T9i8HGPVWzzJSJquxdtOxQwWGSNYf2MJWzko04ZF9jXh35qlJrR2+2 w2R/ZopBLu0Y0mooA85d9Jf3vxeFSbjQIowVFMfa6Anoz9s1N7xIMF5jWc/U8D7xsE1CgR+Yni3 7FCyas53d6BeXISI7Ybq8SiXov98LEcOAnzdgF/CvkF3FyW/5tF5YjDc1BDPgnzQzFZnoDbk8AE gEqJ8NIu6TuTUux8w2M3THxcr746JbMuvJBEaBC7H3kFbd+vQceDDV+KnHWsdLw57w1SVeYdAcv QequBUuPFNaiWzomKuns5nI7JaKVU34EfF8qSvi/BgeuO94e0E0LnCUk3oy1tywqS1mZKhqWKX1 6Auw1ed0lTtmIrIYb/tZJJRhiNFSpA3mxaUZ9xbSuNDTH9sY8rWE+3UTUS6r8qSDjtCeDI2n025 rwuf81v8EEDsEZkoewLYj76FplNQ== X-Received: by 2002:a05:600c:4f07:b0:4bb:5dbf:af06 with SMTP id 5b1f17b1804b1-4bb88804d58mr224971215e9.9.1795362923616; Sun, 22 Nov 2026 07:55:23 -0800 (PST) Return-Path: Received: from dario-ThinkPad-P14s-Gen-5.homenet.telecomitalia.it (host-79-14-29-58.business.telecomitalia.it. [79.14.29.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6c340df4sm20046526f8f.55.2026.11.22.07.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 07:55:23 -0800 (PST) From: Dario Binacchi To: Ulf Hansson Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Peng Fan , Lucas Stach , Dario Binacchi , Fabio Estevam , Frank Li , Jacky Bai , Pengutronix Kernel Team , "Rafael J. Wysocki" , Sascha Hauer , bui duc phuc , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH v3 2/4] pmdomain: imx: gpcv2: Keep the domains left on by the bootloader Date: Sun, 22 Nov 2026 16:55:09 +0100 Message-ID: <20261122155514.10289-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261122155514.10289-1-dario.binacchi@amarulasolutions.com> References: <20261122155514.10289-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 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 Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- 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 diff --git a/drivers/pmdomain/imx/gpcv2.c b/drivers/pmdomain/imx/gpcv2.c index 6a54ee734514..f8f2d38c1b2a 100644 --- a/drivers/pmdomain/imx/gpcv2.c +++ b/drivers/pmdomain/imx/gpcv2.c @@ -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);