From patchwork Sun Nov 22 20:51:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 5057 Delivered-To: michael@amarulasolutions.com Received: by 2002:a05:7300:bf19:b0:386:abcc:ec87 with SMTP id ff25csp765038dyb; Sun, 22 Nov 2026 12:51:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFeynp6YMm/vXiTd1j7E7shguAI9U/8AYxJjmwHQT/DcrIYuJQcl4bz1OpioKL3njwePFEgGYAd@amarulasolutions.com X-Received: by 2002:a05:600c:4f0f:b0:4bb:87f4:3674 with SMTP id 5b1f17b1804b1-4bb8880ef40mr247789555e9.15.1795380707569; Sun, 22 Nov 2026 12:51:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795380707; cv=none; d=google.com; s=arc-20260327; b=WsorpGbbFICEyjecUjNNp0B9JhVfFAOdXFhAAbt3IvxahepdBBIIQNim5qV3VeRM6G fTBKDQ3o/Zsx2Y/4ItmrwtOmT7TvzyjmgIaN0qz1HSqFYiKsiIxaa5WMh7P/mt1vR5ql iwlq7Mur+5hPOTiDN4sFeISU10RYzFjwm9AManMsCzVOkubJh1n7O4tlB1G3quc+rI7K QWH6wHGQmXPjuhvDvoyh3cHsbxL4N7s79ebPMEEH25C2Gt2IyvluVdJheYN9Y6ntRPbb UgD7cVsoDdisjfjtQrybu/pvOJ8/uVeRoZeW9wSRmA23J5B8GTETgrSEUPeR8NLSQPXq GxSw== 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=6PicXai3zi/Jeul0tDyGLavGDqHdliZb/sSdP134yZc=; fh=GUbJaYIIxGNjBZ3QE77d065Qnu9qICM6pjl8FWUxJSU=; b=X8vaSMvAa81/VdNJENZfxXqZxSXSKi8G9sOFAWqsIzdoojU45CPo0jyRz91m9o7PoM CBLCliqqzGNRXh8IHxQzSVjpsRLkYxFv2PHTQL9jlpZFT0g7vrJt/vizwtqYW2cbL7mf f+qJiYXMI7Qozc9jnYWU3yMZsIAl/glLsxlPd+YwgmlkGtdfBX0nz1CN6QPd+7ZTFtZH 8OW4YGbK7RSmdv8kNnSAf4D5ctJQrx5rLfnbtvNsnN/86ZKTKI3nenmHYpBR1CkGmyVR NPZjscQm0AnYOsYnLPgEGjyNPK9R7vhgPynpAAhUKWWycfJ/AaRYm+s5wrEFzQtk9NO6 wNIA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PAj018DK; 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 5b1f17b1804b1-4bb884520cfsor14780915e9.4.2026.11.22.12.51.47 for (Google Transport Security); Sun, 22 Nov 2026 12:51:47 -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=PAj018DK; 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=1795380707; x=1795985507; 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=6PicXai3zi/Jeul0tDyGLavGDqHdliZb/sSdP134yZc=; b=PAj018DKjD/EQrB2+7tdnBvql84HLEqDa8H8Acmqc52dFhYBzt8pMJ8+ILuG+tlKEA k8MoDO6Jl3hWhwmHSOwu4GUoDoZZcJFf9SiDXaYi+yK1+lxxMXOm2Ium3jLR0i7o6oTK KHRMfnDjLGfjT7htM0MVUAM9j6OZ8KvqCZDxo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795380707; x=1795985507; 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=6PicXai3zi/Jeul0tDyGLavGDqHdliZb/sSdP134yZc=; b=lyJtIKBONQj2zhhtwIf+Tg94QlaVj07nIw68aGgFLA9Hu1qi21ox3dufE0diSiBzxa 1/bPRrzbHSy6DJ8Xzgzjgz76zQanofXlH8vrQHOs0SKweEanqwXvROTpwrIlWr5OwO+r TMTfMyD4aSioMImg6dS8HQABJNs6ELc/Lg9Kw29KljZ/fkSOPtkvmaSZmvYsP1MOXSsN OzljvHXy4J/CxUQTDDa7ScNUqDQnQAUPeD4ivgpAbe+drWUZetSTpDLQGhaKeO31EUzt PYE98RNv6EU135kp2Jh+HkS1oPeXnWDmjabkdWJU07nXQkOLXucw/SRMqhixpnwxXOgA nVfg== X-Forwarded-Encrypted: i=1; AL+hErEdM+zKGoTMdci/TU00z0CUqSLMA0l/+2eBKEe4G4zSO/j5mE0GtLqdG55trcQ4toU6+CvUIsjN@amarulasolutions.com X-Gm-Message-State: APuU4Z/Hgu+rP94GoZhQcsjzKdx7g6U9SXCDDdlq+woXsJPdK4PXEgzU S8FXnnnTlY1LKBmLw2acTrb+fWjn/4eOaOGk9jqTeXwpLoThEttQrUNg2eJSN3QlCdoDyA== X-Gm-Gg: AZFdTZe4RrSuZCPIkUiLRSZOJDEFlLm0dZ2njjCq4lmI7UQbNwvJG99uyoi8cErqdpT lKx9CxSInYFSJob4bcb8oUNCmSmViW9s1SLV9L9QnpLS1mT4m/qC+61bIVhtd+NXzwaLNPcGAB1 LgchYpdAEkBrZX9kG/lq7crDZB/TpTwtTBII7WbQ0uVCowlz8yTF83rXJHx+SngGwaVLZmeRt6k AuOPpZqJ4m+Btylz/W1VzNC4uXIsYquZA3zQuTBSGLcYZCuUWRIkH4Mr2CKS5tzeXvYsI6y1Nk2 LWlxzpjkgMxhuEkCgiQoRh/vO1Pn28T/pkEGMUGLH7qX6mbg59HgcQ9jgq0FnO+6vPL4KqIPMH2 2rKuiQBUNl1tlOZYyxIqPQZIMSlU6gewtBrgZVBbwwO5VEN3hiI6vUAwkLiBsjVBri+Rarujeu7 OVO0cRHULIRKL0wxlvPdUM01noLa9yq5ykhDfTWaKyTf8d/lCoeZnAYZ+qQ6EqgWi0HxCnBdW2P KhrOrxEINKzq+jRNsiBQFIIfqF34hWya67eUO/74HGzBx4rDfvY/argJnFNmIsz+4hnKTK8Pega vr4azn4jGJnXc9m7iaGOGgkSYt8LUNMqCibYuKztgHp64VsJiimPdzJeUfpq8aervX1DatO2oMK HeysI3VBBpqwJg28+PtXh1y4xSHt9CJ1+Dt8KWlCnRJAoqtGcbwsfqg7u61hskrwHsrHWxGPtfN 0MhBBX1qZCcwdTdc4LXwfvVgWnOw== X-Received: by 2002:a05:600c:8b11:b0:4a1:dda8:eb73 with SMTP id 5b1f17b1804b1-4bb8881c630mr212608835e9.27.1795380706996; Sun, 22 Nov 2026 12:51:46 -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 5b1f17b1804b1-4bb884b7515sm397355305e9.13.2026.11.22.12.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 12:51:46 -0800 (PST) From: Dario Binacchi To: Ulf Hansson Cc: Lucas Stach , linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Peng Fan , Dario Binacchi , Fabio Estevam , Frank Li , Kees Cook , Ming Qian , Pengutronix Kernel Team , Sascha Hauer , Xu Yang , bui duc phuc , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH v4 3/4] pmdomain: imx8m-blk-ctrl: Keep the domains left on by the bootloader Date: Sun, 22 Nov 2026 21:51:12 +0100 Message-ID: <20261122205136.138173-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261122205136.138173-1-dario.binacchi@amarulasolutions.com> References: <20261122205136.138173-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 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 Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi Reviewed-by: Peng Fan --- Changes in v4: - Register the power notifier before powering up the bus domain Changes in v3: - Keep the bus domain on while the state of the domains is read - Remove the domains before releasing their boot-on references 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 | 128 +++++++++++++++++++++++--- 1 file changed, 117 insertions(+), 11 deletions(-) -- 2.43.0 diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c index 7d6735728d8c..04383d7e40cb 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,18 +190,87 @@ 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) + 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; + + 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"); + + domain->boot_on = true; + + 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; struct device *dev = &pdev->dev; struct imx8m_blk_ctrl *bc; void __iomem *base; + unsigned long boot_on = 0, bit; int i, ret; + bool init_off; struct regmap_config regmap_config = { .reg_bits = 32, @@ -250,6 +322,23 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) "failed to attach power domain \"bus\"\n"); } + bc->power_nb.notifier_call = bc_data->power_notifier_fn; + ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb); + if (ret) { + dev_err_probe(dev, ret, "failed to add power notifier\n"); + goto cleanup_bus; + } + + if (bc_data->boot_state_readable) { + /* Keep the bus domain on while the state is read */ + ret = pm_runtime_resume_and_get(bc->bus_power_dev); + if (ret < 0) { + dev_err_probe(dev, ret, + "failed to power up bus domain\n"); + goto cleanup_notifier; + } + } + for (i = 0; i < bc_data->num_domains; i++) { const struct imx8m_blk_ctrl_domain_data *data = &bc_data->domains[i]; struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; @@ -303,7 +392,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 +402,9 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) goto cleanup_pds; } + if (!init_off) + boot_on |= BIT(i); + /* * We use runtime PM to trigger power on/off of the upstream GPC * domain, as a strict hierarchical parent/child power domain @@ -328,37 +421,48 @@ 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_each_set_bit(bit, &boot_on, bc_data->num_domains) { + ret = imx8m_blk_ctrl_get_boot_on(&bc->domains[bit]); + if (ret) + goto cleanup_pds; + } + 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; } - bc->power_nb.notifier_call = bc_data->power_notifier_fn; - ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb); - if (ret) { - dev_err_probe(dev, ret, "failed to add power notifier\n"); - goto cleanup_provider; - } - dev_set_drvdata(dev, bc); ret = devm_of_platform_populate(dev); if (ret) - goto cleanup_notifier; + goto cleanup_provider; + + if (bc_data->boot_state_readable) + pm_runtime_put(bc->bus_power_dev); return 0; -cleanup_notifier: - dev_pm_genpd_remove_notifier(bc->bus_power_dev); cleanup_provider: of_genpd_del_provider(dev->of_node); cleanup_pds: for (i--; i >= 0; i--) { pm_genpd_remove(&bc->domains[i].genpd); + imx8m_blk_ctrl_put_boot_on(&bc->domains[i]); dev_pm_domain_detach(bc->domains[i].power_dev, true); } + if (bc_data->boot_state_readable) + pm_runtime_put_sync(bc->bus_power_dev); + +cleanup_notifier: + dev_pm_genpd_remove_notifier(bc->bus_power_dev); +cleanup_bus: dev_pm_domain_detach(bc->bus_power_dev, true); return ret; @@ -375,6 +479,7 @@ static void imx8m_blk_ctrl_remove(struct platform_device *pdev) struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; pm_genpd_remove(&domain->genpd); + imx8m_blk_ctrl_put_boot_on(domain); dev_pm_domain_detach(domain->power_dev, true); } @@ -709,6 +814,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),