From patchwork Sun Nov 22 20:51:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 5056 Delivered-To: michael@amarulasolutions.com Received: by 2002:a05:7300:bf19:b0:386:abcc:ec87 with SMTP id ff25csp765017dyb; Sun, 22 Nov 2026 12:51:45 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErETGBlvmSgIon1M0zstRY17E8TggHtcz+rU5z9hn4Pi33cK/db3mNKeoIXR4q5T9MTh1dFSWdHq@amarulasolutions.com X-Received: by 2002:a05:600c:1c1c:b0:4a2:1364:252b with SMTP id 5b1f17b1804b1-4bb8892ac4amr215980055e9.35.1795380705461; Sun, 22 Nov 2026 12:51:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795380705; cv=none; d=google.com; s=arc-20260327; b=E2s6BY3iHhX5xgWFDZY/EaIAXPnqR5Be1mnyAAtmPPOa9JzmgktzukDQv3FbTGcgOF APEd+wEsEnTIj1cBBsBSZLmN2KLt6JvJCJH0XKmkvwT4BZDsZe8JIuVfDzH07gpf0BZb BjnXTZHHyV4rHq0npBHh0rd95SK5WKW4VPQ1LNEvAg7GdOtEBYl3dZ0E+6R1vSa1/wpc 9RWqE67GCkMwHTEluKyLNH+2CRG9OWLMjgIVzkdqvYFDS0bti6ZEm8STsXIyNhZW50lS tb+V7bhBuPsAJ6LBUPCw8Xjawsj/+b1ABZRnWySehJIOw0AhZyWzgselBdC7QX/MAP69 VKAQ== 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=EZ2863pKGWwBwjrMKzumFwAyyrjNnDcDdwgqcYg/Bpc=; fh=AwYuzbXKQsia1eIRvXrJkRT7eyLWA66IRGVdSqA3v1Q=; b=pSYdmluOjiyuReMbKnO5cp36oZZRQ9RtoxGEkiFttMWkNMB6GqBNxW4IqLRe2jz+eK yBQ14VXQ4D1vTTgOMdBaIKcMomUlOZDlSnZLL4UvajUzqmm2aqNchc+huPZH6K7vPckl fSgoW8WqfrWxXaI0PjdYnfIPrs/ShyU3qPMP/xa9wqd7VNc4XHumSEA0NF3/aCUcq2hy wIvuOdSrKon6Da6bD+m9ndxZa6HM3v9TxfNCaj4mHnUBD+iN+qcfHcRAnME9G15GFO0y eTy2NPi9NEsBFJtFHGkqlpVCxNpPF9KDeLlBWJ3RjGHApc5dGngyzQjGah0Jit+BAFxP 51Lg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LwEMLEuY; 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-4bb88483e5bsor14818325e9.13.2026.11.22.12.51.45 for (Google Transport Security); Sun, 22 Nov 2026 12:51:45 -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=LwEMLEuY; 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=1795380705; x=1795985505; 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=EZ2863pKGWwBwjrMKzumFwAyyrjNnDcDdwgqcYg/Bpc=; b=LwEMLEuYULmXi2WfeH4yagrJ30gV79fRxpgsZsH6Wc/5mKY7w/Ga3tOnT/YmmZrw6O SRdagE+WEP+qq0W9MVYTvEZ6p/zcdAbUOlh0jwYKzbeufJHKsvIpTezO7eUY4LpoiIBt ibBRDgQi2KLrMrls1oJNfSGxHmV5jHL1FxQrk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795380705; x=1795985505; 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=EZ2863pKGWwBwjrMKzumFwAyyrjNnDcDdwgqcYg/Bpc=; b=iRQjoYUnjlQgyKD7b+eIEtiRrtpmYR8WIdSKC2TacRGHc2tLiQAOlcGBCQQc+ZEumk L+3aP77kKgst24/dDl0vIxKdJLFrep475c9lRQISl5Rz6LTdlFH5i5C1UUpDcs1VbbPp muYJUSE9FSQzoRE7bqAspQwXFZL5h9A32ATFVxOnZJC8Nzq4TfTOZNtDk1c1cB+z7MOP o6YI8AJsM+9BX5Efb4c3Jw0pUomTdMPXKEuZ8+9WiiWR03WNqM3PNNYU8xStT0lNz4/1 5kgl42oMlV5hzNwfS+k7AhUAWhsXN1qYAHGD17OA1dt7q3Z9d0wblJPofvvCjZ/v89O7 WgIw== X-Forwarded-Encrypted: i=1; AL+hErFxbOcuLxtc5WWibNg+1vu7UnUOp7P0zHuiW61hEoKa4QpMfUb/T8xXY4SW44pGlA/fGGnfFJtw@amarulasolutions.com X-Gm-Message-State: APuU4Z+uwfcbbU8rUXwFTapC7oyBZeqG1Cpgbycjdhy5Akx6NWCDgf4K A4GSD49j6RswTOUNlW8VkuVplqv/nG2UkowE1gc8/3S+dPbCdwly3Pi0uqyfI+JQWyAMWw== X-Gm-Gg: AZFdTZeTb6Uq251zQF4ehfYAhr3PP9vx+3Aj4up1M7nwLsnjM5YfUZzEartZ4WeDH50 RJSV3vcPjIPiLtr1tk/zUCCeLW++u59vozVtdzFTrF4/kfp2xaDNoWhqK3eGAa7dCrZQV4N+1xY xVtEj1QRycXnj1UxqMQOxGCZcZoRCdX5vp5dO/7Gbm6SK1UEABsiUkws3Wbh1tBTrXafJnS+OUg ZbJrpzDVTF7DAueUhvQh5GJJdX9qKoI/6P2C9uNF1KPsHhE7RESrY1CnXC1dCAr9j8oOCgv1i4U 5v9jb5AexOWplaxIsUCtCod9mYUmxH5Ke4roxGxt6uy2InJiWRUoH973+RfoFFWMu+CJzlGDvMA BS1fIps7LKAZlERNfQjqKAXcxnfcCAfRe4QVU1ZLMMVzQht9t7SDJb/olRoVMGsozQh2+1i8Q2W NEYCfwVI1FRoFAFYZeUrSpjSJxUo1vz794COaA+TQemYWhW8b8Q1XJTsKGjGlIFzK8QiXYdrpCa ht5RVrDcVnYYhzl6mjtEsCa9fSZgQU+HqfGzU9FBC27RC/izC+53xPAWMj8hDuUyal2XVvEWwAE 6PX/G8gDnbiJKuJx1hUkXxkJRKvBJQuWZ4TN/xe7SYqvCXaLI1VzidFH5jHffqfWr8EpEEYE67r u2GcJdBC3XU8t36sXChiKnKfl7J8+FSS3j5MunF0VV3AyldP78122Khvojq1pV0N366DhAGn1IL V9stmyY2xYpSwwimAYkobGWuzjyg== X-Received: by 2002:a05:600c:800e:b0:4bb:7757:fe58 with SMTP id 5b1f17b1804b1-4bb8881b9d7mr201262775e9.19.1795380704844; Sun, 22 Nov 2026 12:51:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 12:51:44 -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 , 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 v4 2/4] pmdomain: imx: gpcv2: Keep the domains left on by the bootloader Date: Sun, 22 Nov 2026 21:51:11 +0100 Message-ID: <20261122205136.138173-3-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 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 Reviewed-by: Peng Fan --- (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 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);