Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
To: Liu Ying <victor.liu@nxp.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
	 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	 Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>,
	 Simona Vetter <simona@ffwll.ch>, Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	 Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	 Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	 Dmitry Baryshkov <lumag@kernel.org>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	 imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org,
	Marek Vasut <marek.vasut@mailbox.org>,
	 Alexander Stein <alexander.stein@ew.tq-group.com>
Subject: Re: [PATCH v7 05/15] drm/imx: dc: Flag CRTC status in GERNERALPURPOSE register
Date: Thu, 29 Oct 2026 11:28:37 +0200	[thread overview]
Message-ID: <auH5iQyk6HBDvxiP@vm> (raw)
In-Reply-To: <20261026-imx8-dc-prefetch-v7-5-a0b50cc4fc65@nxp.com>

On Mon, Oct 26, 2026 at 06:05:10PM +0800, Liu Ying wrote:
> Map Display Controller's register GERNERALPURPOSE at offset 0x100 and
> create an MMIO regmap to access the register.  Create helpers
> dc_drv_flag_crtc_{enable,disable}() with the 2 LSB bits in the register
> to flag the CRTC enablement/disablement status.  Also, create a helper
> dc_drv_crtc_was_enabled() so that the CRTC driver can use it to check
> if the CRTC was enabled by a previous boot or not.  This is a preparation
> for an upcoming patch to disable display controller at boot if the CRTC
> was enabled by the driver during a previous boot instead of a bootloader.
> 
> Signed-off-by: Liu Ying <victor.liu@nxp.com>
> --
> v7:
> - Newly introduced in v7 as a preparation for fixing Sashiko AI bot's
>   comment on an upcoming patch.  (Sashiko AI bot)
> ---
>  drivers/gpu/drm/imx/dc/dc-drv.c | 76 +++++++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/imx/dc/dc-drv.h |  7 ++++
>  2 files changed, 83 insertions(+)
> 
> diff --git a/drivers/gpu/drm/imx/dc/dc-drv.c b/drivers/gpu/drm/imx/dc/dc-drv.c
> index 13795a2ad735..ac1321adf1c8 100644
> --- a/drivers/gpu/drm/imx/dc/dc-drv.c
> +++ b/drivers/gpu/drm/imx/dc/dc-drv.c
> @@ -13,6 +13,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/pm.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/regmap.h>
>  
>  #include <drm/clients/drm_client_setup.h>
>  #include <drm/drm_atomic_helper.h>
> @@ -28,9 +29,21 @@
>  #include "dc-drv.h"
>  #include "dc-pe.h"
>  
> +/* General Purpose register offset used to flag driver usage. */
> +#define GENERALPURPOSE		0x100
> +#define  CRTC_ENABLED(x)	BIT(x)
> +
>  struct dc_priv {
>  	struct drm_device *drm;
>  	struct clk *clk_cfg;
> +	struct regmap *gp_regmap;
> +};
> +
> +static const struct regmap_config dc_gp_regmap_config = {
> +	.reg_bits = 32,
> +	.reg_stride = 4,
> +	.val_bits = 32,
> +	.max_register = 0,
>  };
>  
>  DEFINE_DRM_GEM_DMA_FOPS(dc_drm_driver_fops);
> @@ -156,6 +169,8 @@ static int dc_probe(struct platform_device *pdev)
>  {
>  	struct component_match *match = NULL;
>  	struct dc_priv *priv;
> +	struct resource *r;
> +	void __iomem *base;
>  	int ret;
>  
>  	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> @@ -167,6 +182,28 @@ static int dc_probe(struct platform_device *pdev)
>  		return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk_cfg),
>  				     "failed to get cfg clock\n");
>  
> +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!r)
> +		return -EINVAL;
> +
> +	if (!devm_request_mem_region(&pdev->dev, r->start + GENERALPURPOSE, 4,
> +				     dev_name(&pdev->dev))) {
> +		dev_err(&pdev->dev, "failed to request memory region\n");
> +		return -EBUSY;

Use 'return dev_err_probe()'.

> +	}
> +
> +	base = devm_ioremap(&pdev->dev, r->start + GENERALPURPOSE, 4);
> +	if (!base) {
> +		dev_err(&pdev->dev, "failed to do ioremap\n");
> +		return -ENOMEM;

Use 'return dev_err_probe()'.

> +	}
> +
> +	priv->gp_regmap = devm_regmap_init_mmio(&pdev->dev, base,
> +						&dc_gp_regmap_config);
> +	if (IS_ERR(priv->gp_regmap))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(priv->gp_regmap),
> +				     "failed to init General Purpose regmap\n");
> +
>  	dev_set_drvdata(&pdev->dev, priv);
>  
>  	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> @@ -196,6 +233,45 @@ static void dc_remove(struct platform_device *pdev)
>  	component_master_del(&pdev->dev, &dc_drm_ops);
>  }
>  
> +void dc_drv_set_crtc_enable(struct dc_drm_device *dc_drm,
> +			    unsigned int crtc_index)
> +{
> +	struct dc_priv *priv = dev_get_drvdata(dc_drm->base.dev);
> +
> +	if (WARN_ON(crtc_index > 1))
> +		return;
> +
> +	regmap_set_bits(priv->gp_regmap, 0, CRTC_ENABLED(crtc_index));
> +}
> +
> +void dc_drv_set_crtc_disable(struct dc_drm_device *dc_drm,
> +			     unsigned int crtc_index)
> +{
> +	struct dc_priv *priv = dev_get_drvdata(dc_drm->base.dev);
> +
> +	if (WARN_ON(crtc_index > 1))
> +		return;
> +
> +	regmap_clear_bits(priv->gp_regmap, 0, CRTC_ENABLED(crtc_index));
> +}
> +
> +bool dc_drv_crtc_was_enabled(struct dc_drm_device *dc_drm,

I believe it would be better to rename this one to 'dc_drv_crtc_is_enabled'.
After all, you're checking whether the crtc is enabled *now*. Reading those
bits in GENERALPURPOSE show the current status, not a past one.

With the above addressed:
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>

-- 
Thanks,
Laurentiu

  reply	other threads:[~2026-10-29  9:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 10:05 [PATCH v7 00/15] drm/imx: dc: Use prefetch engine Liu Ying
2026-10-26 10:05 ` [PATCH v7 01/15] dt-bindings: display: imx: Add i.MX8qxp/qm PRG binding Liu Ying
2026-10-26 10:05 ` [PATCH v7 02/15] dt-bindings: display: imx: Add i.MX8qxp/qm DPR channel binding Liu Ying
2026-10-26 10:05 ` [PATCH v7 03/15] drm/imx: dc-plane: Disable plane when it is invisible Liu Ying
2026-10-29  9:28   ` Laurentiu Palcu
2026-10-26 10:05 ` [PATCH v7 04/15] drm/imx: dc-fu: Fix dimensions Liu Ying
2026-10-26 10:05 ` [PATCH v7 05/15] drm/imx: dc: Flag CRTC status in GERNERALPURPOSE register Liu Ying
2026-10-29  9:28   ` Laurentiu Palcu [this message]
2026-10-26 10:05 ` [PATCH v7 06/15] drm/imx: dc-crtc: Disable at boot Liu Ying
2026-10-26 11:18   ` sashiko-bot
2026-10-29  9:30   ` Laurentiu Palcu
2026-10-26 10:05 ` [PATCH v7 07/15] drm/imx: dc: Add PRG support Liu Ying
2026-10-26 11:32   ` sashiko-bot
2026-10-29  9:30   ` Laurentiu Palcu
2026-10-26 10:05 ` [PATCH v7 08/15] drm/imx: dc: Add DPR channel support Liu Ying
2026-10-26 11:52   ` sashiko-bot
2026-10-29  9:31   ` Laurentiu Palcu
2026-10-26 10:05 ` [PATCH v7 09/15] drm/imx: dc: Use TCON operation mode Liu Ying
2026-10-26 10:05 ` [PATCH v7 10/15] drm/imx: dc-ed: Support getting source selection Liu Ying
2026-10-26 10:41   ` Alexander Stein
2026-10-26 12:01   ` sashiko-bot
2026-10-26 10:05 ` [PATCH v7 11/15] drm/imx: dc-lb: Support getting secondary input selection Liu Ying
2026-10-26 10:05 ` [PATCH v7 12/15] drm/imx: dc-ed: Drop initial source selection Liu Ying
2026-10-26 10:05 ` [PATCH v7 13/15] drm/imx: dc-lb: Drop initial primary and secondary input selections Liu Ying
2026-10-26 10:05 ` [PATCH v7 14/15] drm/imx: dc-fu: Get DPR channel Liu Ying
2026-10-26 10:05 ` [PATCH v7 15/15] drm/imx: dc: Use prefetch engine Liu Ying
2026-10-26 12:41   ` sashiko-bot

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=auH5iQyk6HBDvxiP@vm \
    --to=laurentiu.palcu@oss.nxp.com \
    --cc=airlied@gmail.com \
    --cc=alexander.stein@ew.tq-group.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=marek.vasut@mailbox.org \
    --cc=mripard@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=victor.liu@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