linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Otto Pflüger" <otto.pflueger@abscue.de>
To: Maxime Ripard <mripard@kernel.org>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Orson Zhai <orsonzhai@gmail.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Kevin Tang <kevin.tang@unisoc.com>,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 10/15] drm: sprd: add clock gating support
Date: Wed, 23 Jul 2025 10:32:11 +0200	[thread overview]
Message-ID: <aICeC5lSSW0qR7oh@abscue.de> (raw)
In-Reply-To: <20250723-resourceful-intrepid-beaver-cbeada@houat>

Hi Maxime,

On Wed, Jul 23, 2025 at 09:00:28AM +0200, Maxime Ripard wrote:
> Hi,
> 
> On Tue, Jul 22, 2025 at 04:41:12PM +0200, Otto Pflüger wrote:
> > Enable the DPU and DSI clocks specified in the device tree.
> > Disable the DSI clock when it is not needed.
> > 
> > Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de>
> > ---
> >  drivers/gpu/drm/sprd/sprd_dpu.c | 7 +++++++
> >  drivers/gpu/drm/sprd/sprd_dpu.h | 1 +
> >  drivers/gpu/drm/sprd/sprd_dsi.c | 9 +++++++++
> >  drivers/gpu/drm/sprd/sprd_dsi.h | 4 +++-
> >  4 files changed, 20 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/sprd/sprd_dpu.c b/drivers/gpu/drm/sprd/sprd_dpu.c
> > index 0d9eb778794d92418b39f8535d94abde3566de43..9d274600e6a80bdfc435f6c6eff77c9dd71cb38c 100644
> > --- a/drivers/gpu/drm/sprd/sprd_dpu.c
> > +++ b/drivers/gpu/drm/sprd/sprd_dpu.c
> > @@ -3,6 +3,7 @@
> >   * Copyright (C) 2020 Unisoc Inc.
> >   */
> >  
> > +#include <linux/clk.h>
> >  #include <linux/component.h>
> >  #include <linux/delay.h>
> >  #include <linux/dma-buf.h>
> > @@ -794,6 +795,12 @@ static int sprd_dpu_context_init(struct sprd_dpu *dpu,
> >  	if (ctx->irq < 0)
> >  		return ctx->irq;
> >  
> > +	ctx->clk = devm_clk_get_optional_enabled(dev, "core");
> > +	if (IS_ERR(ctx->clk)) {
> > +		dev_err(dev, "failed to get DPU core clock\n");
> > +		return PTR_ERR(ctx->clk);
> > +	}
> > +
> >  	/* disable and clear interrupts before register dpu IRQ. */
> >  	writel(0x00, ctx->base + REG_DPU_INT_EN);
> >  	writel(0xff, ctx->base + REG_DPU_INT_CLR);
> > diff --git a/drivers/gpu/drm/sprd/sprd_dpu.h b/drivers/gpu/drm/sprd/sprd_dpu.h
> > index 157a78f24dc18b071602552ea9d005af66525263..d48b922de580a8a4bf07c4610c431d3321f7b810 100644
> > --- a/drivers/gpu/drm/sprd/sprd_dpu.h
> > +++ b/drivers/gpu/drm/sprd/sprd_dpu.h
> > @@ -44,6 +44,7 @@ enum {
> >   */
> >  struct dpu_context {
> >  	void __iomem *base;
> > +	struct clk *clk;
> >  	int irq;
> >  	u8 if_type;
> >  	struct videomode vm;
> > diff --git a/drivers/gpu/drm/sprd/sprd_dsi.c b/drivers/gpu/drm/sprd/sprd_dsi.c
> > index e01d1d28fe579644ec2e0c83ec9170269932adfe..2af4273a6c73185084290c9d14b8ac18914d514b 100644
> > --- a/drivers/gpu/drm/sprd/sprd_dsi.c
> > +++ b/drivers/gpu/drm/sprd/sprd_dsi.c
> > @@ -828,6 +828,8 @@ static void sprd_dsi_bridge_pre_enable(struct drm_bridge *bridge)
> >  	struct sprd_dsi *dsi = bridge_to_dsi(bridge);
> >  	struct dsi_context *ctx = &dsi->ctx;
> >  
> > +	clk_prepare_enable(ctx->clk);
> > +
> >  	if (ctx->enabled) {
> >  		drm_warn(dsi->drm, "dsi is initialized\n");
> >  		return;
> > @@ -875,6 +877,8 @@ static void sprd_dsi_bridge_post_disable(struct drm_bridge *bridge)
> >  	sprd_dphy_fini(ctx);
> >  	sprd_dsi_fini(ctx);
> >  
> > +	clk_disable_unprepare(ctx->clk);
> > +
> >  	ctx->enabled = false;
> >  }
> 
> I'm a bit confused. Why do you need to enable / disable that clock in
> pre_enable / post_disable, if you already enabled it at probe?

These are two different clocks. DPU uses devm_clk_get_optional_enabled,
while DSI uses devm_clk_get_optional and enables/disables it when
needed. Ideally both clocks should be disabled when not needed, but this
will be implemented later.

Best regards,
Otto Pflüger

  reply	other threads:[~2025-07-23  8:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22 14:41 [PATCH v2 00/15] drm: sprd: Make the Unisoc DRM driver usable on UMS9230 Otto Pflüger
2025-07-22 14:41 ` [PATCH v2 01/15] dt-bindings: display: sprd: adapt for UMS9230 support Otto Pflüger
2025-07-23  7:50   ` Krzysztof Kozlowski
2025-07-22 14:41 ` [PATCH v2 02/15] dt-bindings: display: sprd: add memory-region property Otto Pflüger
2025-07-23  7:51   ` Krzysztof Kozlowski
2025-07-22 14:41 ` [PATCH v2 03/15] dt-bindings: display: sprd: allow attaching a DSI panel Otto Pflüger
2025-07-23  7:54   ` Krzysztof Kozlowski
2025-07-23  8:03     ` Krzysztof Kozlowski
2025-07-22 14:41 ` [PATCH v2 04/15] drm: of: try binding port parent node instead of the port itself Otto Pflüger
2025-07-23  7:02   ` Maxime Ripard
2025-07-22 14:41 ` [PATCH v2 05/15] drm: sprd: remove plane and crtc destroy callbacks Otto Pflüger
2025-07-22 14:41 ` [PATCH v2 06/15] drm: sprd: register a DSI bridge and move init code to pre_enable Otto Pflüger
2025-07-22 14:41 ` [PATCH v2 07/15] drm: sprd: add support for UMS9230 DSI PLL Otto Pflüger
2025-07-22 14:41 ` [PATCH v2 08/15] drm: sprd: fix DSI rate and PLL setup code Otto Pflüger
2025-07-22 14:41 ` [PATCH v2 09/15] drm: sprd: select REGMAP in Kconfig Otto Pflüger
2025-07-22 14:41 ` [PATCH v2 10/15] drm: sprd: add clock gating support Otto Pflüger
2025-07-23  7:00   ` Maxime Ripard
2025-07-23  8:32     ` Otto Pflüger [this message]
2025-07-22 14:41 ` [PATCH v2 11/15] drm: sprd: add support for newer DPU versions Otto Pflüger
2025-07-22 14:41 ` [PATCH v2 12/15] drm: sprd: always initialize DPU and DSI registers Otto Pflüger
2025-07-22 14:41 ` [PATCH v2 13/15] drm: sprd: do not access IOMMU registers Otto Pflüger
2025-07-22 14:41 ` [PATCH v2 14/15] drm: sprd: implement IOMMU-based buffer management Otto Pflüger
2025-07-23 22:43   ` kernel test robot
2025-07-22 14:41 ` [PATCH v2 15/15] drm: sprd: add fbdev support Otto Pflüger

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=aICeC5lSSW0qR7oh@abscue.de \
    --to=otto.pflueger@abscue.de \
    --cc=airlied@gmail.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kevin.tang@unisoc.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=robh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=zhang.lyra@gmail.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;
as well as URLs for NNTP newsgroup(s).