From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: Ulf Hansson <ulfh@kernel.org>
Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com,
Lucas Stach <l.stach@pengutronix.de>, Peng Fan <peng.fan@nxp.com>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Fabio Estevam <festevam@gmail.com>, Frank Li <Frank.Li@nxp.com>,
Kees Cook <kees+treewide@kernel.org>,
Ming Qian <ming.qian@oss.nxp.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Sascha Hauer <s.hauer@pengutronix.de>,
Xu Yang <xu.yang_2@nxp.com>, bui duc phuc <phucduc.bui@gmail.com>,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-pm@vger.kernel.org
Subject: [PATCH v2 3/4] pmdomain: imx8m-blk-ctrl: Keep the domains left on by the bootloader
Date: Sun, 22 Nov 2026 10:59:18 +0100 [thread overview]
Message-ID: <20261122095927.2631909-4-dario.binacchi@amarulasolutions.com> (raw)
In-Reply-To: <20261122095927.2631909-1-dario.binacchi@amarulasolutions.com>
The blk-ctrl domains are all registered as off, so a domain left on by
the bootloader is powered up again by its first consumer. On the
i.MX8MN this resets the display pipeline set up by U-Boot to show a
splash screen.
Read the state of the domains from the blk-ctrl registers and register
as on the ones left on by the bootloader.
Enable this only for the i.MX8MN DISP blk-ctrl, as on other blk-ctrls
(e.g. the i.MX8MP VPUMIX) the registers do not reset to 0.
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>
---
Changes in v2:
- Take the references once the probe can no longer be deferred
- Clear the boot-on state when the domain is powered off
- Release the references when the driver is removed
drivers/pmdomain/imx/imx8m-blk-ctrl.c | 96 ++++++++++++++++++++++++++-
1 file changed, 94 insertions(+), 2 deletions(-)
diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
index 7d6735728d8c..5ab201eefeb3 100644
--- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
+++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
@@ -83,10 +83,13 @@ struct imx8m_blk_ctrl_domain {
struct device *power_dev;
struct imx8m_blk_ctrl *bc;
int num_paths;
+ bool boot_on; /* Left on by the bootloader */
};
struct imx8m_blk_ctrl_data {
int max_reg;
+ /* SFT_RSTN and CLK_EN reset to 0, so a domain left on can be detected */
+ bool boot_state_readable;
notifier_fn_t power_notifier_fn;
const struct imx8m_blk_ctrl_domain_data *domains;
int num_domains;
@@ -187,11 +190,80 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
/* allow bus domain to suspend */
pm_runtime_put(bc->bus_power_dev);
+ domain->boot_on = false;
+
return 0;
}
static struct lock_class_key blk_ctrl_genpd_lock_class;
+/*
+ * A domain left on by the bootloader has its resets deasserted and its
+ * clocks enabled. The registers can only be read if the bus domain is
+ * on, so a domain is considered off whenever the bus domain is off.
+ */
+static bool imx8m_blk_ctrl_is_off(struct imx8m_blk_ctrl *bc,
+ const struct imx8m_blk_ctrl_data *bc_data,
+ const struct imx8m_blk_ctrl_domain_data *data)
+{
+ u32 rst, clk, mipi = 0;
+
+ if (!bc_data->boot_state_readable ||
+ !dev_pm_genpd_is_on(bc->bus_power_dev))
+ return true;
+
+ if (regmap_read(bc->regmap, BLK_SFT_RSTN, &rst) ||
+ regmap_read(bc->regmap, BLK_CLK_EN, &clk))
+ return true;
+
+ if (data->mipi_phy_rst_mask &&
+ regmap_read(bc->regmap, BLK_MIPI_RESET_DIV, &mipi))
+ return true;
+
+ return (rst & data->rst_mask) != data->rst_mask ||
+ (clk & data->clk_mask) != data->clk_mask ||
+ (mipi & data->mipi_phy_rst_mask) != data->mipi_phy_rst_mask;
+}
+
+/* Take the references of imx8m_blk_ctrl_power_on() for a domain left on */
+static int imx8m_blk_ctrl_get_boot_on(struct imx8m_blk_ctrl_domain *domain)
+{
+ struct imx8m_blk_ctrl *bc = domain->bc;
+ int ret;
+
+ if (!domain->boot_on)
+ return 0;
+
+ ret = pm_runtime_resume_and_get(bc->bus_power_dev);
+ if (ret < 0) {
+ dev_err(bc->dev, "failed to power up bus domain\n");
+ return ret;
+ }
+
+ ret = pm_runtime_resume_and_get(domain->power_dev);
+ if (ret < 0) {
+ dev_err(bc->dev, "failed to power up peripheral domain\n");
+ pm_runtime_put(bc->bus_power_dev);
+ return ret;
+ }
+
+ if (icc_bulk_set_bw(domain->num_paths, domain->paths))
+ dev_err(bc->dev, "failed to set icc bw\n");
+
+ return 0;
+}
+
+static void imx8m_blk_ctrl_put_boot_on(struct imx8m_blk_ctrl_domain *domain)
+{
+ if (!domain->boot_on)
+ return;
+
+ /* Sync, to power down the bus domain before its notifier is removed */
+ pm_runtime_put_sync(domain->power_dev);
+ pm_runtime_put_sync(domain->bc->bus_power_dev);
+ domain->boot_on = false;
+}
+
static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
{
const struct imx8m_blk_ctrl_data *bc_data;
@@ -199,6 +271,7 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
struct imx8m_blk_ctrl *bc;
void __iomem *base;
int i, ret;
+ bool init_off;
struct regmap_config regmap_config = {
.reg_bits = 32,
@@ -303,7 +376,8 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
domain->genpd.power_off = imx8m_blk_ctrl_power_off;
domain->bc = bc;
- ret = pm_genpd_init(&domain->genpd, NULL, true);
+ init_off = imx8m_blk_ctrl_is_off(bc, bc_data, data);
+ ret = pm_genpd_init(&domain->genpd, NULL, init_off);
if (ret) {
dev_err_probe(dev, ret,
"failed to init power domain \"%s\"\n",
@@ -312,6 +386,8 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
goto cleanup_pds;
}
+ domain->boot_on = !init_off;
+
/*
* We use runtime PM to trigger power on/off of the upstream GPC
* domain, as a strict hierarchical parent/child power domain
@@ -328,10 +404,20 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
bc->onecell_data.domains[i] = &domain->genpd;
}
+ /*
+ * The probe can no longer be deferred. Releasing these references
+ * would power down the domains left on by the bootloader.
+ */
+ for (i = 0; i < bc_data->num_domains; i++) {
+ ret = imx8m_blk_ctrl_get_boot_on(&bc->domains[i]);
+ if (ret)
+ goto cleanup_boot_on;
+ }
+
ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data);
if (ret) {
dev_err_probe(dev, ret, "failed to add power domain provider\n");
- goto cleanup_pds;
+ goto cleanup_boot_on;
}
bc->power_nb.notifier_call = bc_data->power_notifier_fn;
@@ -353,6 +439,10 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
dev_pm_genpd_remove_notifier(bc->bus_power_dev);
cleanup_provider:
of_genpd_del_provider(dev->of_node);
+cleanup_boot_on:
+ while (i--)
+ imx8m_blk_ctrl_put_boot_on(&bc->domains[i]);
+ i = bc_data->num_domains;
cleanup_pds:
for (i--; i >= 0; i--) {
pm_genpd_remove(&bc->domains[i].genpd);
@@ -374,6 +464,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev)
for (i = 0; i < bc->onecell_data.num_domains; i++) {
struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
+ imx8m_blk_ctrl_put_boot_on(domain);
pm_genpd_remove(&domain->genpd);
dev_pm_domain_detach(domain->power_dev, true);
}
@@ -709,6 +800,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mn_disp_blk_ctl_domain_data[]
static const struct imx8m_blk_ctrl_data imx8mn_disp_blk_ctl_dev_data = {
.max_reg = 0x84,
+ .boot_state_readable = true,
.power_notifier_fn = imx8mn_disp_power_notifier,
.domains = imx8mn_disp_blk_ctl_domain_data,
.num_domains = ARRAY_SIZE(imx8mn_disp_blk_ctl_domain_data),
--
2.43.0
next prev parent reply other threads:[~2026-11-22 9:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 9:59 [PATCH v2 0/4] pmdomain: imx: Keep the domains left on by the bootloader Dario Binacchi
2026-11-22 9:59 ` [PATCH v2 1/4] pmdomain: imx8m-blk-ctrl: Remove the power notifier on probe failure Dario Binacchi
2026-11-22 9:59 ` [PATCH v2 2/4] pmdomain: imx: gpcv2: Keep the domains left on by the bootloader Dario Binacchi
2026-11-22 9:59 ` Dario Binacchi [this message]
2026-11-22 9:59 ` [PATCH v2 4/4] pmdomain: imx8m-blk-ctrl: Hold boot-on domain clocks until sync_state Dario Binacchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261122095927.2631909-4-dario.binacchi@amarulasolutions.com \
--to=dario.binacchi@amarulasolutions.com \
--cc=Frank.Li@nxp.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kees+treewide@kernel.org \
--cc=kernel@pengutronix.de \
--cc=l.stach@pengutronix.de \
--cc=linux-amarula@amarulasolutions.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=michael@amarulasolutions.com \
--cc=ming.qian@oss.nxp.com \
--cc=peng.fan@nxp.com \
--cc=phucduc.bui@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=ulfh@kernel.org \
--cc=xu.yang_2@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox