From patchwork Mon Oct 28 10:25:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13853272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B958BD13588 for ; Mon, 28 Oct 2024 10:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vYexXqsopB/TorltyWtW3DQvmZVEoLO13n0GfiFkuag=; b=neQn+s0K0t5XHbQhmlqp5vFthW PADfrfFwGBrj78vns33VkclQJQa7MZ4L45GOyG5WLceB4Rnv+Gkn3BwlCeiv1cdzvY5UCDjp16DpC AxL3VjMjwhxtVJWG7sO/6n45ODhrRYYvmZNxjG8hJeYoFtaTA3eMlCaOdYLgzQ1b7w2lcnU4AqLlq Wa6FKWS2yW8vTN7Wmj2lLNk+pNAaEFJCO0ZBoLM6OjS8noedcA9MCSGkpohv6jQnVrkougjnbq1ew OBfQPPDL0L5wl7oZTg7GETIt1uH4Qk6IGVsrmVVQk2BUV8ArRQ1bFDWLvxYn0D23XBhigTrfES4o0 ib1/qJ2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5N09-0000000APDR-01qK; Mon, 28 Oct 2024 10:29:33 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5Mwv-0000000AON1-0Iuk for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2024 10:26:14 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-539e63c8678so4047256e87.0 for ; Mon, 28 Oct 2024 03:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1730111171; x=1730715971; darn=lists.infradead.org; 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; bh=vYexXqsopB/TorltyWtW3DQvmZVEoLO13n0GfiFkuag=; b=pv5arrNDjrbBYSScGvq2gJFqLRssFt8aRN8A/7fB3pszABgu4ACebDprXNDht3yGL6 z0Gkj1r3nFYofypzvfSfGYJrZtnaOX1jdmOqS4YE/iK2Uzv5mICjZfEvOZ0wHFEgz1Bo QSCM5xFniaL4RA8ggC8F/c6UWjD6DKxhAfQD8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730111171; x=1730715971; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vYexXqsopB/TorltyWtW3DQvmZVEoLO13n0GfiFkuag=; b=UBBi/Qmy6nXTmfZL6op7T0dhWSOZrPczNJhh4FelWeh4YPgBCN1/+oAHm2AbGwu4ZX 9wcJXY8lJLI0xv056FzZBw6X2HkqcH595DwWWoKK+WFN2d0kKJbobCACIUieGsSoQy04 7+opPxLNc13Pu2AgFUmDqHBmCi2wBIMixSC9ar36UtZGEi4OTX8KyxtJUcbCCm+9+K9P zcAUUHWQiGv4L8nTpGt9WqHrEyZG6hBzyrE9EdFXtC12bYQMh5ipVz5L4wz3vvRvfEvu rbRUXh6zAXheyOSZL2L93ueSNop+KqGUUSJe2kGjD6MqwKLTdQNKIeotgIRpivwgupzE 9sXg== X-Forwarded-Encrypted: i=1; AJvYcCXLKlerGFcvQy1C0uRaWE1o1LlEGRJ0ct63KLBIFvcLovkbHtYQB8C/yEgufILzvYg7eAQxLwD0HTwu9Ho3/4GL@lists.infradead.org X-Gm-Message-State: AOJu0Yxgk94d/8Zr8M2kBHqQGVW7eP1455upVQAxzJap1xbcGzd/TBGH BcQk7PbmdRaGykoSFeuHDvacJXxHteLANZzGpt2N1brj4aFLkB3Yd7WepQHUsQY= X-Google-Smtp-Source: AGHT+IFPiWSMUJsvLDsFUQKEPXeJtOq9dyzWbF9cm4SlPeUZQ8cIi4gauJvX3gywzP7yEJIBk1InHA== X-Received: by 2002:ac2:4c46:0:b0:535:82eb:21d1 with SMTP id 2adb3069b0e04-53b34a3516cmr2517575e87.57.1730111171159; Mon, 28 Oct 2024 03:26:11 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.41.121]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f297b04sm363613966b.134.2024.10.28.03.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 03:26:10 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Conor Dooley , Fabio Estevam , Krzysztof Kozlowski , Lucas Stach , Pengutronix Kernel Team , Rob Herring , Sascha Hauer , Shawn Guo , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 01/10] dt-bindings: soc: imx-blk-ctrl: add 'fsl,power-domains-boot-on' property Date: Mon, 28 Oct 2024 11:25:24 +0100 Message-ID: <20241028102559.1451383-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> References: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241028_032613_133189_59AA8618 X-CRM114-Status: GOOD ( 10.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This property lists the state of the power domains, indicating whether they have been left on or off by the bootloader/firmware. This information becomes relevant, for example, in the case of supporting the simple framebuffer. Signed-off-by: Dario Binacchi --- .../bindings/soc/imx/fsl,imx8mn-disp-blk-ctrl.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/imx/fsl,imx8mn-disp-blk-ctrl.yaml b/Documentation/devicetree/bindings/soc/imx/fsl,imx8mn-disp-blk-ctrl.yaml index eeec9965b091..00aa0b8d8ea9 100644 --- a/Documentation/devicetree/bindings/soc/imx/fsl,imx8mn-disp-blk-ctrl.yaml +++ b/Documentation/devicetree/bindings/soc/imx/fsl,imx8mn-disp-blk-ctrl.yaml @@ -56,6 +56,15 @@ properties: - const: csi-aclk - const: csi-pclk + fsl,power-domains-boot-on: + description: | + Provide the on/off (1/0) status of the power domains. It allows + specifying whether one or more power domains have already been + initialized and left powered on by the bootloader. + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 5 + maxItems: 5 + required: - compatible - reg From patchwork Mon Oct 28 10:25:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13853273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5C20BD13570 for ; Mon, 28 Oct 2024 10:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ErPoXh63XrcFWpHe9zG8v9aPuGfFzlqWX+d+j6TRc4A=; b=SHEK6xm0o0yrq4cEBHmQy3Y+43 ZbaN6/z/TBPJMvSM0L3UFOFKbGs4vnruqYowr3RIQy0iF8vSJwlbL7qZIeRpeZXSZCslnhDJ40UGl suoGqDb/Woq+gzY2VxNSAhkE0bmy9FiCy6aE27Gox9jxbilj3XDVGvVObHCf+x+A4roKWGNg1/Wpw BJZm45ech6YoL4FCi8DV98fgsDfNrLTnpS1r28LFmYxzFhrTfxrosLzHMv9CFYKp8OpAm3fhWCJ4b gFNr26IZd//ggaFSS2+CS35i3qjjxgG3G/2yW5cAp/W9SbxXchWsiuwKunAZ0jzLRvuBP+X2jaFNa uHWCX0WQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5N1g-0000000APMX-3WgK; Mon, 28 Oct 2024 10:31:08 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5Mww-0000000AONh-37jz for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2024 10:26:16 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a9932aa108cso619736066b.2 for ; Mon, 28 Oct 2024 03:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1730111173; x=1730715973; darn=lists.infradead.org; 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; bh=ErPoXh63XrcFWpHe9zG8v9aPuGfFzlqWX+d+j6TRc4A=; b=mU+MaTk51HIFoBnq1yiR1hrhb8/tYSI/bevK/0GOo1/RGG7zrK2stD2TFIeCjxRKZj 0P6MfGxAgbxXsqOPrfBuorYutwKoXsnWLKvc80nMrqzWsPKm4jibSuSbH1sk51yNPAsI ymCDyBKrTDPy+Cvp7OMHhrpXcPUtCojWqo1Hc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730111173; x=1730715973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ErPoXh63XrcFWpHe9zG8v9aPuGfFzlqWX+d+j6TRc4A=; b=j/FYu/f0oW3ABj+a6rXn+bULnE0KillOqiYgC+kyLm6LVj/5f3D7UqcuePa2b4xIsf VBvYb82GtIaN/U7wwAjbp2j5qUZEdheD2pbuy86qmlFTc6d2cfFfsbmA2BZ7OyvFlII+ v80MOEY5MhvtjT19aHMHNaxR2BF5CJtv8gprYWgiIz0ea7QBIUdEAU8Ny7fBfQKq1Z6V ACnl+mPCsfDiZEyddcaoYELX4Yp80twYQv5UaiPrDriibNJmTUstLPH53DXlV0+RB+tm 59r2NkVY4/RnunDHYWw4UGBvmX7BDmH9UTB52at4yYMGqidyGUcraedl6PJ6uj+zgzq6 x+Lg== X-Forwarded-Encrypted: i=1; AJvYcCXB3zNcQFPONpnp5fTCDdjfARLFN8EAkcsGukKZLW04cpZh9EvCFXs9PRXYNofDCUxihobaG7T/1lxxbheBx2uF@lists.infradead.org X-Gm-Message-State: AOJu0Yyok9r9rTuPCJxpXO9Ad2aOdXNZJa9I/yHyPL2waunUlB1RC2LY ODd4h21WbVjAgRGW+V7fFniC06+3Ve7PUQ7OKTEOAd9JYl57HCZGgLoSZsUqVgM= X-Google-Smtp-Source: AGHT+IGCR28JnEaozP81Xbh2KLif47qmv9KNL7NMIxup/Qx2H3ia0ChVJ6kRCnNRLDGwqzzr1QgmvA== X-Received: by 2002:a17:907:9712:b0:a9a:2afc:e4d7 with SMTP id a640c23a62f3a-a9de619d18bmr803160866b.44.1730111172695; Mon, 28 Oct 2024 03:26:12 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.41.121]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f297b04sm363613966b.134.2024.10.28.03.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 03:26:12 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Michael Trimarchi , Fabio Estevam , Marek Vasut , Peng Fan , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Ulf Hansson , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [RFC PATCH 02/10] pmdomain: imx8m-blk-ctrl: don't turn on a power domain already on Date: Mon, 28 Oct 2024 11:25:25 +0100 Message-ID: <20241028102559.1451383-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> References: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241028_032614_820523_9EAF7C37 X-CRM114-Status: GOOD ( 18.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The patch, by informing pm_genpd_init() with the "is_off" parameter that the power domain is already on, prevents the power_on() callback from being called, thus avoiding the unnecessary repetition of the hardware power-on procedure. This feature is crucial when supporting the simple framebuffer, as the power domains have already been initialized by the bootloader. Co-developed-by: Michael Trimarchi Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- drivers/pmdomain/imx/imx8m-blk-ctrl.c | 51 ++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c index ca942d7929c2..8dc1508571dd 100644 --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c @@ -166,6 +166,24 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) static struct lock_class_key blk_ctrl_genpd_lock_class; +static bool imx8m_blk_ctrl_is_off(struct device *dev, struct generic_pm_domain *genpd) +{ + struct device_node *node = dev->of_node; + struct imx8m_blk_ctrl_domain *domain = to_imx8m_blk_ctrl_domain(genpd); + const struct imx8m_blk_ctrl_domain_data *data = domain->data; + u32 boot_on; + int index; + + index = of_property_match_string(node, "power-domain-names", + data->gpc_name); + if (index < 0 || of_property_read_u32_index(node, + "fsl,power-domains-boot-on", + index, &boot_on)) + return true; + + return !boot_on; +} + static int imx8m_blk_ctrl_probe(struct platform_device *pdev) { const struct imx8m_blk_ctrl_data *bc_data; @@ -173,6 +191,8 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) struct imx8m_blk_ctrl *bc; void __iomem *base; int i, ret; + bool init_off; + bool *pm_runtime_cleanup; struct regmap_config regmap_config = { .reg_bits = 32, @@ -221,6 +241,11 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) "failed to attach power domain \"bus\"\n"); } + pm_runtime_cleanup = devm_kcalloc(dev, bc_data->num_domains, + sizeof(*pm_runtime_cleanup), GFP_KERNEL); + if (!pm_runtime_cleanup) + return -ENOMEM; + 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]; @@ -274,7 +299,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(dev, &domain->genpd); + ret = pm_genpd_init(&domain->genpd, NULL, init_off); if (ret) { dev_err_probe(dev, ret, "failed to init power domain \"%s\"\n", @@ -283,6 +309,24 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) goto cleanup_pds; } + if (!init_off) { + ret = pm_runtime_get_sync(bc->bus_power_dev); + if (ret < 0) { + pm_runtime_put_noidle(bc->bus_power_dev); + dev_err_probe(dev, ret, "failed to power up bus domain\n"); + goto cleanup_pds; + } + + ret = pm_runtime_get_sync(domain->power_dev); + if (ret < 0) { + pm_runtime_put(bc->bus_power_dev); + dev_err_probe(dev, ret, "failed to power up peripheral domain\n"); + goto cleanup_pds; + } + + pm_runtime_cleanup[i] = true; + } + /* * We use runtime PM to trigger power on/off of the upstream GPC * domain, as a strict hierarchical parent/child power domain @@ -324,6 +368,11 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) of_genpd_del_provider(dev->of_node); cleanup_pds: for (i--; i >= 0; i--) { + if (pm_runtime_cleanup[i]) { + pm_runtime_put(bc->domains[i].power_dev); + pm_runtime_put(bc->bus_power_dev); + } + pm_genpd_remove(&bc->domains[i].genpd); dev_pm_domain_detach(bc->domains[i].power_dev, true); } From patchwork Mon Oct 28 10:25:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13853274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44B8AD13570 for ; Mon, 28 Oct 2024 10:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3kjaoDHO/Cxmm9XfSkRfXuiq2XlHBj2nIJAqnJTFngw=; b=Wiree5Z/ia3NfFuNLtwFERzPSS wwWVX9bmKSKQexjCi9N6iTjCRZDgomzHpvR6/MwW+QMjetkK5fg1AYSUWXwlP5t9Af+TFrelezXKa oq5R3PuhHPGKoSgSx005lrYqfWeZILpZ5fjFYzVFUMqkyMwejPDf0y3KLW1KPauTG+8dZO8iacrtc dqEwhCC60qnOCzifu/YVlTfmeOhusL2TsbjpedJAnLh+lMgFaxX3AvvsD/qRjHBX2HVvS5EyBLXAE MIsXR5cvwmy9GP3elxvJijpDVBm7L+pdt+TZEBpqwAGveIBjPHcKE3RdzeAjL5J1sp7LTzQzuSE4f pSNbsoSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5N3H-0000000APZ7-246F; Mon, 28 Oct 2024 10:32:47 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5Mwy-0000000AOOR-1iN7 for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2024 10:26:17 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a9a0f198d38so597889566b.1 for ; Mon, 28 Oct 2024 03:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1730111174; x=1730715974; darn=lists.infradead.org; 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; bh=3kjaoDHO/Cxmm9XfSkRfXuiq2XlHBj2nIJAqnJTFngw=; b=UjYbjhDMOdEQ40DjNx6h9IYH87G87KIie/uM2dJOT8bzeDkG2Wm1Jw5nuyKFBZomq0 9BL4d52pruaar5Pf+K3v3c6wy0PQzfe4WM8G2Oy5g8zZXXJ64JUxWxfMlpVNuAuXzOKf NwsJHldCUwmexxhpQ9THjAP5PDb+4jsAzCg9M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730111174; x=1730715974; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3kjaoDHO/Cxmm9XfSkRfXuiq2XlHBj2nIJAqnJTFngw=; b=Z9aTXnPv0/rnV4KibOMeH9QPyrsF2YUU34IaeXr8Oj8QLscb5+5anCdAi9xT8L0n5x wXHi0H+OqGVmPYWmmVv8dHMkAxmKKNZJVmq20cpT9f0EucspN1eCOnT2E0WSFKt0EkGa U8s2zsBsgcETcR3pXyEGK2gr33xJ7NcYmLwVM85EEix90AJ0BH5tZhkUCZ5Bb+NyckuD iJxSj5bWV1xv+u/ao6TGSHXxWq4ii6ArRnCRi2VECyz2RXqUtwfRjv63GlUiCQbk5BDh 7U3eCG+HEbNKoPpuuMLRv3SflK4J5EPSyP28JKhzVIdFMk10SLkqNWXuWcNIilvM4QHn KMgw== X-Forwarded-Encrypted: i=1; AJvYcCUCSjKyp4VxhfuWWBr9Qy/LGH3pO0c3wmBdFsfmSpjF+davKM2uk9F8Lw5qhpdNNfaJvd69m27rtRNy3kOqIHFT@lists.infradead.org X-Gm-Message-State: AOJu0YwfZXDPxFaMi0K5Gr2/WHt0v61JXQklGaAs3UWqfbo1735y6vS7 I3p7M9i+4xeyP856PwzBsUaWYYaoCBG7z0q8Koph8tRnqEULnQ4DvijYB9Yfw/s= X-Google-Smtp-Source: AGHT+IEYNCvHyI4Ub76KdqemIzRCqERBXA/yyqTx2llDK0lvcsPc5x2y/hbBEKlGhDYQLy/s0WjfIA== X-Received: by 2002:a17:907:9721:b0:a99:89bd:d84a with SMTP id a640c23a62f3a-a9de5ee107dmr668398566b.25.1730111174240; Mon, 28 Oct 2024 03:26:14 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.41.121]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f297b04sm363613966b.134.2024.10.28.03.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 03:26:13 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrey Smirnov , Conor Dooley , Fabio Estevam , Krzysztof Kozlowski , Pengutronix Kernel Team , Rob Herring , Sascha Hauer , Shawn Guo , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 03/10] dt-bindings: power: gpcv2: add 'fsl,boot-on' property Date: Mon, 28 Oct 2024 11:25:26 +0100 Message-ID: <20241028102559.1451383-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> References: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241028_032616_468675_6EAEFDA0 X-CRM114-Status: GOOD ( 10.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The property states that the power-domain has been initialized and left on by the bootloader/firmware. This information becomes relevant, for example, in the case of supporting the simple framebuffer. Signed-off-by: Dario Binacchi --- Documentation/devicetree/bindings/power/fsl,imx-gpcv2.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/power/fsl,imx-gpcv2.yaml b/Documentation/devicetree/bindings/power/fsl,imx-gpcv2.yaml index dfdb8dfb6b65..718196f516ad 100644 --- a/Documentation/devicetree/bindings/power/fsl,imx-gpcv2.yaml +++ b/Documentation/devicetree/bindings/power/fsl,imx-gpcv2.yaml @@ -94,6 +94,12 @@ properties: minItems: 1 maxItems: 4 + fsl,boot-on: + description: | + The power-domain has been initialized and left on by the + bootloader/firmware. + type: boolean + required: - '#power-domain-cells' - reg From patchwork Mon Oct 28 10:25:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13853275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08482D13570 for ; Mon, 28 Oct 2024 10:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3tF2Wj+vRMtC983z9w7XL42BV51oFEPPNHEhybEVd+Q=; b=EY9QEmUGUnIjgrkZ9Z6E74e33T 5Pz+6jd+E7sa+DM/fmlGxrm3iy0AQYWZZXjTmp6V90hch0U79CHkz1ZIbWrCNOzOK2dloZRuocN4t fzufMSoLNSU8drJKNhE1fCY+rhGIrI0BNrPE1kAMst4VSNDfOJ8srYEOjtZ7bnu4pYIUfmYRKeyd2 En8nWne2AhoPsbwIputsFnYJh4huztog9SqNXKa3YBNtgKcaMLMt1BWAasw1Fx+h/Ppb1wq/KDWWu 0B/6hdfdl1A+tmbykGmNmByMeXA6Z9AB1EnOM0+8EU2ye51Iz+U+8ZxTPWlUlB5In0t0w5aX1cirY IXomwU3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5N4p-0000000APmw-1b8a; Mon, 28 Oct 2024 10:34:23 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5Mwz-0000000AOOz-3mEj for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2024 10:26:19 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a9a68480164so569092266b.3 for ; Mon, 28 Oct 2024 03:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1730111176; x=1730715976; darn=lists.infradead.org; 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; bh=3tF2Wj+vRMtC983z9w7XL42BV51oFEPPNHEhybEVd+Q=; b=fY9r6JxWdsQ0yMHrHmvKyYi+0yYTRvYO/3Z0PMdPLsOvkRhyw732zNOhi/DV8Q08Fz iy4rs2J/atnOUz8fhu6U0mA3y5rhJD9Pw4r91AZNIwKZ4VpvrOz4w2+tU3EfkrIdIAGC lkb0wpn71HsLDjaQm+KoIlKtxy2ehdPrx+FG8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730111176; x=1730715976; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3tF2Wj+vRMtC983z9w7XL42BV51oFEPPNHEhybEVd+Q=; b=HJniAeVC2IILdz/qSUa65ec4Xd2u/pjWM+ML+lMO/PoWfdf7SZR7in2FOU8Gyt/6tN a098EWQ2558YExoe0Us1j0+BqFjyZhHdHesz7Vc3w3TBAWtTpIrZLNC2CLdwzALw/P5B XculJEs+lTyMTPkbg12H3QRvTkjiSAmDhqazvTuCL4dwYcuIa2Q/k3ru/TRdP1wvVJoF 574f8dtdIB/DmmuL59y9BIBOuJQtBZsycqkisJQ6XcdOm8+TVsL6vhgiu/LbEcrNzzmG kVPxiNxWyFL0E2IH9VlS3307MAxIC9NvJCQ+QjAhXCfD34kzArxwG7D3YooDOcT3JNHV JcUg== X-Forwarded-Encrypted: i=1; AJvYcCVbaDGvHDqj7WEsygvEVWzpxwJpbCwTtkSo+l4wbeF4JfR/5o9mx/eFqs50+9Kf+GhCmyPo7ZKVrS10eTqly+oE@lists.infradead.org X-Gm-Message-State: AOJu0YyHGP33dZPgrFFU3h6BtwDCRLQuprpgq3F4y5KdyQ4niiaS5eEZ wXezdrDpEGScIUbSfJpNN3mad5M8JOxtbuI3fNP7Jl6ylStWD2MxQ8hRf/KOZaWyUkacB3d1rCR Dsz8= X-Google-Smtp-Source: AGHT+IFdXb6XtLDCZdRMrvkyA0aKsne7r7Yx41P1F2c1jET9YdgAPGWx1KeM7QlZRwkreW9voNIysQ== X-Received: by 2002:a17:907:1c22:b0:a99:f1aa:a71f with SMTP id a640c23a62f3a-a9de5c90d49mr793546866b.11.1730111175841; Mon, 28 Oct 2024 03:26:15 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.41.121]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f297b04sm363613966b.134.2024.10.28.03.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 03:26:15 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Michael Trimarchi , Fabio Estevam , Krzysztof Kozlowski , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Shengjiu Wang , Ulf Hansson , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [RFC PATCH 04/10] pmdomain: imx: gpcv2: don't turn on a power domain already on Date: Mon, 28 Oct 2024 11:25:27 +0100 Message-ID: <20241028102559.1451383-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> References: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241028_032617_973864_853D81D8 X-CRM114-Status: GOOD ( 16.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The patch, by informing pm_genpd_init() with the "is_off" parameter that the power domain is already on, prevents the power_on() callback from being called, thus avoiding the unnecessary repetition of the hardware power-on procedure. This feature is crucial when supporting the simple framebuffer, as the power domains have already been initialized by the bootloader. Co-developed-by: Michael Trimarchi Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- drivers/pmdomain/imx/gpcv2.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/pmdomain/imx/gpcv2.c b/drivers/pmdomain/imx/gpcv2.c index 963d61c5af6d..bf9fe4af03c5 100644 --- a/drivers/pmdomain/imx/gpcv2.c +++ b/drivers/pmdomain/imx/gpcv2.c @@ -1324,6 +1324,7 @@ static const struct imx_pgc_domain_data imx8mn_pgc_domain_data = { 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; @@ -1354,12 +1355,33 @@ 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 = !of_property_read_bool(domain->dev->of_node, + "fsl,boot-on"); + ret = pm_genpd_init(&domain->genpd, NULL, init_off); if (ret) { dev_err(domain->dev, "Failed to init power domain\n"); goto out_domain_unmap; } + if (!init_off) { + ret = pm_runtime_get_sync(domain->dev); + if (ret < 0) { + pm_runtime_put_noidle(domain->dev); + dev_err_probe(domain->dev, ret, "failed to power up bus domain\n"); + goto out_genpd_remove; + } + + 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 clocks for domain: %s\n", + domain->genpd.name); + goto out_pm_put; + } + } + } + if (IS_ENABLED(CONFIG_LOCKDEP) && of_property_read_bool(domain->dev->of_node, "power-domains")) lockdep_set_subclass(&domain->genpd.mlock, 1); @@ -1368,11 +1390,17 @@ static int imx_pgc_domain_probe(struct platform_device *pdev) &domain->genpd); if (ret) { dev_err(domain->dev, "Failed to add genpd provider\n"); - goto out_genpd_remove; + goto out_clk_unprepare; } return 0; +out_clk_unprepare: + if (!init_off && domain->keep_clocks) + clk_bulk_disable_unprepare(domain->num_clks, domain->clks); +out_pm_put: + if (!init_off) + pm_runtime_put(domain->dev); out_genpd_remove: pm_genpd_remove(&domain->genpd); out_domain_unmap: From patchwork Mon Oct 28 10:25:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13853276 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A751BD13588 for ; Mon, 28 Oct 2024 10:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aIDm7KBT1s0AbOc3yV3TQ9ohvs8sUqIvua5HhBI5V8A=; b=MxBiltWpntB7ca3h8BtUxHeTWk YmpUwTaBMyKMkqP2tgg+pK1syAM0Ti+b7SbJUEFGu0rw9Kop6uPozBjCj7FpvF8ZXCi74hqucXJXg KxhpfVDvOvbtqrhiX2Ba/RduDkpUa+RBn3BF3c+EohZDkJv3q2evdOMu8i/7gmzlrP3FNc+g+ARbF L4poCJYxBbnlZ8hBD/q+D42e55VrC9QRjqjyy0HCJutuAylA2zo1QqSahUtXK+t4jwCsCXX6ZO1M/ Vy6bMxFpXrytiqhZ4aeETL93BY9a2uArdxducfStqOMlFiX1bP2L1kGWW85VLZVh1pI+EOb8tErEu HCZwAW9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5N6O-0000000APzj-3i8V; Mon, 28 Oct 2024 10:36:00 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5Mx9-0000000AOSN-1Dth for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2024 10:26:28 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a86e9db75b9so614950466b.1 for ; Mon, 28 Oct 2024 03:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1730111186; x=1730715986; darn=lists.infradead.org; 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; bh=aIDm7KBT1s0AbOc3yV3TQ9ohvs8sUqIvua5HhBI5V8A=; b=UoSxzFggnBHuBMowTO6/zmAHT8dNHP1FwkSLDrPl+xPBH5bIz69LtUaLeJ6dz7mtJb irm7bkk/MYuw/5RuOgBD6pHS3VOQFUOYTPRscTQnvmNq89lJ+cRhmQ3vEwdj2Im/ZnV0 Ry80qZMmM8D1G2592iFH4g++DQBB4D1uj7Wu0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730111186; x=1730715986; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aIDm7KBT1s0AbOc3yV3TQ9ohvs8sUqIvua5HhBI5V8A=; b=AIqG5QcySyyG7KA7uxAGSp/E3ekqp96hSU27hFiEIdvJaD22CPtGKA21o75gLlWvZK 5SLWXIlMAomPZqR0Cv2SaiQkBOWEl5JzJxkhZWdXrrAFxd/KopFw1pWkqYxekyWn+t2N Do7XssbEH1ElckLeYuS6tA9BhxKL2/zoIERZrxzCe1Fe7XRbi+u9vH58+vMcnBb6xJmh aT23BFz1BrD8S9he2Y50bdduILN6yzefQfLXqW4yLph+II3XOuAuVfljLmc0VeG6f98+ XHOi13AfRNJQGxysOS8CgCv7GY66T38LEHL/M3LLeWUctqet4C7WycILKvbRAaBvoyUv J0iw== X-Forwarded-Encrypted: i=1; AJvYcCVqPzrmabFslQXQsdcrZohbG5+p6ud8zK0/7DDzZv3NoYuDkczfx/whAT3HwSsJRE7ah66mfrqKoH+FHqvzTi19@lists.infradead.org X-Gm-Message-State: AOJu0YwOiAyFg+orfpH2NLK78/MRNIBrEJTO+qF9keWKZUjwp+3W5t6i 1on6WMjD6XzgzXCIMdMg3aQg8FfeuN4v/1I1K+NrVLM/4PHwUcxvhFdChxqLbco= X-Google-Smtp-Source: AGHT+IEA5nCg2j7DVomJoAqNLW+z2Nbv9V6XM3cl17RychbK0FRUPkeqVCDGC4TH9y5e5TfNamZx8g== X-Received: by 2002:a17:906:da8a:b0:a99:425c:c653 with SMTP id a640c23a62f3a-a9de5ce24f6mr866426966b.22.1730111185881; Mon, 28 Oct 2024 03:26:25 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.41.121]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f297b04sm363613966b.134.2024.10.28.03.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 03:26:25 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , David Airlie , Fabio Estevam , Maarten Lankhorst , Marek Vasut , Maxime Ripard , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Simona Vetter , Stefan Agner , Thomas Zimmermann , dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 10/10] drm/mxsfb: stop controller and drain FIFOs if already initialized Date: Mon, 28 Oct 2024 11:25:33 +0100 Message-ID: <20241028102559.1451383-11-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> References: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241028_032627_357905_B13028A7 X-CRM114-Status: GOOD ( 15.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org You can't re-program the controller if it is still running. This may lead to shifted pictures, so stop the controller and drain its FIFOs in case it's already properly setup. This patch is crucial when supporting the simple framebuffer, as the controller has already been initialized by the bootloader. Signed-off-by: Dario Binacchi --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 3 +++ drivers/gpu/drm/mxsfb/mxsfb_drv.h | 1 + drivers/gpu/drm/mxsfb/mxsfb_kms.c | 14 +++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index cb5ce4e81fc7..38c94cdc8f6c 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -221,6 +222,8 @@ static int mxsfb_load(struct drm_device *drm, if (!mxsfb) return -ENOMEM; + mxsfb->enabled = + of_property_read_bool(drm->dev->of_node, "fsl,boot-on"); mxsfb->drm = drm; drm->dev_private = mxsfb; mxsfb->devdata = devdata; diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h b/drivers/gpu/drm/mxsfb/mxsfb_drv.h index d160d921b25f..0f9ae4ce450c 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h @@ -47,6 +47,7 @@ struct mxsfb_drm_private { struct drm_bridge *bridge; bool crc_active; + bool enabled; }; static inline struct mxsfb_drm_private * diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c index 7ed2516b6de0..d064a2bb65df 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -202,9 +202,11 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb) writel(reg, mxsfb->base + LCDC_CTRL1); writel(CTRL_RUN, mxsfb->base + LCDC_CTRL + REG_SET); + + mxsfb->enabled = true; } -static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) +static void _mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) { u32 reg; @@ -221,6 +223,13 @@ static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) reg &= ~VDCTRL4_SYNC_SIGNALS_ON; writel(reg, mxsfb->base + LCDC_VDCTRL4); + mxsfb->enabled = false; +} + +static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) +{ + _mxsfb_disable_controller(mxsfb); + clk_disable_unprepare(mxsfb->clk); if (mxsfb->clk_disp_axi) clk_disable_unprepare(mxsfb->clk_disp_axi); @@ -354,6 +363,9 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc, u32 bus_format = 0; dma_addr_t dma_addr; + if (mxsfb->enabled) + _mxsfb_disable_controller(mxsfb); + pm_runtime_get_sync(drm->dev); mxsfb_enable_axi_clk(mxsfb);