| Message ID | 20191025175625.8011-5-jagan@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-amarula+bncBD7MFH7A7EEBB47OZTWQKGQEG5SHDAY@amarulasolutions.com> X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 480343F0E1 for <linux-amarula@patchwork.amarulasolutions.com>; Fri, 25 Oct 2019 19:57:09 +0200 (CEST) Received: by mail-pl1-f197.google.com with SMTP id y2sf1971718plk.19 for <linux-amarula@patchwork.amarulasolutions.com>; Fri, 25 Oct 2019 10:57:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1572026228; cv=pass; d=google.com; s=arc-20160816; b=znFiT0MyAaHGwRvvsZGXkmFuZ9PW7SJvLzG0StMsl1fAlbVNuvAzmy+vVvOa08ZsYA ZIsxbwPE5S0zBb53asM5mCqvU6/QId0igvTI6fb/xjrmDEMsozACHALEUc/F+EDfS9Fe jSOM8gSm0p0s1bHvAs+1Ug/O3ycepqnB31q9R57/xe9CbFujZCQiad9vogqcPYbt6wWD s840eXsxHRndjO0qZoTuTNJFx9iydsgOsiUTesSstFHkRabOxy/Eaghu/Ig9Bvg5hwxD sakoj28olsPwXwMCWXTPrspkk7AuOBkLUnC2fjj2fJj85nlv1iGAWr2YVt0MCAOuqCQk vaCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=qBt4iQX3pL+NEvmUmlVQMc6eMqHVC8ugc4L7U8DmT4E=; b=isEApXSMW+34zzVmTYQZyjs4xD4KaBezUu4huBAlE5svlmz6OolLreOprXNY5h43HD 2IX85uo3VzB8xJaCqpW2k7hNZl7KDyJQhSpZgk3D9acuBsB3BUuE+0YWL94DAyoVAr8y O4GBUO/zmxloS7PAKr9POEGKXnK+BYFISyfcaY2BpYdJRBmZtyfjvzEWSfRaPhsDzMv3 6hXxnhLR9A2Lz86sFNY24ZFDBAM4U5d1cfvxr2OccL5ym7/8krh91Y2gtWW3WaDIEbBy GCX3sf8UDqOgjq4hYop1aGGT8uiAcrYbIb3moxrqzftrjisc4Ovwjk3Z4AqIAPF3AQA0 xWZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=i3MIHeuY; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=qBt4iQX3pL+NEvmUmlVQMc6eMqHVC8ugc4L7U8DmT4E=; b=Nd7FtD1pLvNc7pOQqTToVr2AMZGX2LfHWnS43i9+fItwxpK/H7VeMKfE89vf8RbD7y nbTdcqiNjMosvrSKF8E6jlVqiabalFikoylg4icXcA/NlH4wcRKtcOSflwHtDIjYfRsg 46HeSKhkzWNVnhjL0DMJc7Bt48wNF/EaJEl58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=qBt4iQX3pL+NEvmUmlVQMc6eMqHVC8ugc4L7U8DmT4E=; b=h/qTY3wr4IfnH7YJgBxlR1sUrAdnCiyYa3xBVaE1Ev6CfDSwEGelYcXBGa3+xAt5nw kB9e7FjHrzkMdZuAnjlXCkaTvHOKW7DGphdbIaM3NCVmEgzv3nDCe7lyRA6dd5P7PHft FmjoZ/iXv7nuLxksI9fRiy7MQ/XOYdQ86OoKwwNUFhWiC+nBSXWMphknNIoi0ajdNFDN JnG+GEf3ubMx/6cLRk083Q4kxk5YsVXsrcoW9PSbduq+BZK8tcM5jArUTCsm5tCWREQG gZJ+PWsnIuRA+vWR1QHxMlbp91HFAGKc8K/hUn6RJpBX0VrvudKYzdA/JzOJNd9FxhUW 0vrA== X-Gm-Message-State: APjAAAUKf2xMHsdeCQrX6i8cgQTmgg6wYVVw0LqfKTkSAI3Zbq7LHahi tiHBGlRgMSjvucW6zrLv3vwXu6O5 X-Google-Smtp-Source: APXvYqx/DoMdpOAmg+62HyJQr/XyPTDwqXtcCKoe1w9zwHhubJPmU5GwUqHF7llMavl7d6jtXmFZvg== X-Received: by 2002:a63:471b:: with SMTP id u27mr5792000pga.96.1572026227957; Fri, 25 Oct 2019 10:57:07 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:6307:: with SMTP id x7ls3065633pfb.0.gmail; Fri, 25 Oct 2019 10:57:07 -0700 (PDT) X-Received: by 2002:a62:e90d:: with SMTP id j13mr5892784pfh.237.1572026227414; Fri, 25 Oct 2019 10:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572026227; cv=none; d=google.com; s=arc-20160816; b=fJo13RBCmri8E18vE6uTggoa5sLQtsqajNcGSJ94Z5vzXtqNV68NCYit5ft3ycSk31 C1NgAMSS+6ErNzAJiKEa3vtKRAmaSblcnofVgYvSdvZ0ZZOEZaOPE5HjnIqr3hc8ANVm i+FhpTSUsxAQATI1iLyYLsC2i/GUPoiti/UH8v5bqCi2i7ZoL7tlJYBeSHDaABd1IgMq A3kvUPVySYrIuxk4oPwrCOF7bV8igwRsc/iy4yDElJ7Ie6lo/ALf9hmJFxK9Ugp6UUtr pdlOeCm1TK+dk0lUM78FYFKhp+qS2NrzWPlwVWtftQGG5rsQVsX/4F+rHOVl90s13ujo LFow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=P3Mki6uub+NAK80E3ntfBcsFK0xNEI4Pl6xkUsSgIeM=; b=PO1cIE6IhOp50hrU/H3AB6z5W8NfiHuhwbwHh13qVV8c1bY1T4jRCoK0UvYpQb/vn5 a9Xk1jL7XzDAxF6jszIK+nX+zC+PeMHyRSBz4NNT/N6yc1jhn2wWqxvVrxkjJytl/die dyOYShW/IKlMAEhMOZZgZto2rSJFIW3o6lAQw66HTo+KyzmETDIAkj+jZiDJZV7jVg/d YG48I2z88mskxVGGD20rGSBcKzf6qCx/TVFr8O2SRKqACv5+oUSAuFfz4Ask0oGNIrhN 3BIHNlbKBOFh8T4fFEf6xnA33ZSUisxpnanbtx6vGPrfxzdfO4z03NGAvA0YOmFV8w7T sUQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=i3MIHeuY; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g8sor3068540pfk.3.2019.10.25.10.57.07 for <linux-amarula@amarulasolutions.com> (Google Transport Security); Fri, 25 Oct 2019 10:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a62:58c2:: with SMTP id m185mr6044311pfb.10.1572026227045; Fri, 25 Oct 2019 10:57:07 -0700 (PDT) Received: from localhost.localdomain ([115.97.180.31]) by smtp.gmail.com with ESMTPSA id n15sm2926580pfq.146.2019.10.25.10.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 10:57:06 -0700 (PDT) From: Jagan Teki <jagan@amarulasolutions.com> To: Maxime Ripard <mripard@kernel.org>, Chen-Yu Tsai <wens@csie.org>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>, Rob Herring <robh+dt@kernel.org>, Mark Rutland <mark.rutland@arm.com> Cc: michael@amarulasolutions.com, Icenowy Zheng <icenowy@aosc.io>, linux-sunxi <linux-sunxi@googlegroups.com>, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-amarula@amarulasolutions.com, Jagan Teki <jagan@amarulasolutions.com> Subject: [PATCH v11 4/7] =?utf-8?q?drm/sun4i=3A_dsi=3A_Handle_bus_clock_ex?= =?utf-8?q?plicitly=C2=A0?= Date: Fri, 25 Oct 2019 23:26:22 +0530 Message-Id: <20191025175625.8011-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20191025175625.8011-1-jagan@amarulasolutions.com> References: <20191025175625.8011-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=i3MIHeuY; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: <linux-amarula.amarulasolutions.com> X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>, <mailto:linux-amarula@amarulasolutions.com> List-Help: <https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>, <mailto:linux-amarula+help@amarulasolutions.com> List-Archive: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/> List-Unsubscribe: <mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>, <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe> |
| Series |
drm/sun4i: Allwinner A64 MIPI-DSI support
|
|
Commit Message
Jagan Teki
Oct. 25, 2019, 5:56 p.m. UTC
Usage of clocks are varies between different Allwinner
DSI controllers. Clocking in A33 would need bus and
mod clocks where as A64 would need only bus clock.
To support this kind of clocking structure variants
in the same dsi driver, explicit handling of common
clock would require since the A64 doesn't need to
mention the clock-names explicitly in dts since it
support only one bus clock.
Also pass clk_id NULL instead "bus" to regmap clock
init function since the single clock variants no need
to mention clock-names explicitly.
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
Comments
On Fri, Oct 25, 2019 at 11:26:22PM +0530, Jagan Teki wrote: > Usage of clocks are varies between different Allwinner > DSI controllers. Clocking in A33 would need bus and > mod clocks where as A64 would need only bus clock. > > To support this kind of clocking structure variants > in the same dsi driver, There's no variance in the clock structure as far as the bus clock is concerned. > explicit handling of common clock would require since the A64 > doesn't need to mention the clock-names explicitly in dts since it > support only one bus clock. > > Also pass clk_id NULL instead "bus" to regmap clock init function > since the single clock variants no need to mention clock-names > explicitly. You don't need explicit clock handling. Passing NULL as the argument in regmap_init_mmio_clk will make it use the first clock, which is the bus clock. Maxime
Hi Maxime, On Mon, Oct 28, 2019 at 9:06 PM Maxime Ripard <mripard@kernel.org> wrote: > > On Fri, Oct 25, 2019 at 11:26:22PM +0530, Jagan Teki wrote: > > Usage of clocks are varies between different Allwinner > > DSI controllers. Clocking in A33 would need bus and > > mod clocks where as A64 would need only bus clock. > > > > To support this kind of clocking structure variants > > in the same dsi driver, > > There's no variance in the clock structure as far as the bus clock is > concerned. > > > explicit handling of common clock would require since the A64 > > doesn't need to mention the clock-names explicitly in dts since it > > support only one bus clock. > > > > Also pass clk_id NULL instead "bus" to regmap clock init function > > since the single clock variants no need to mention clock-names > > explicitly. > > You don't need explicit clock handling. Passing NULL as the argument > in regmap_init_mmio_clk will make it use the first clock, which is the > bus clock. Indeed I tried that, since NULL clk_id wouldn't enable the bus clock during regmap_mmio_gen_context code, passing NULL triggering vblank timeout.
On Tue, Oct 29, 2019 at 04:03:56AM +0530, Jagan Teki wrote: > > > explicit handling of common clock would require since the A64 > > > doesn't need to mention the clock-names explicitly in dts since it > > > support only one bus clock. > > > > > > Also pass clk_id NULL instead "bus" to regmap clock init function > > > since the single clock variants no need to mention clock-names > > > explicitly. > > > > You don't need explicit clock handling. Passing NULL as the argument > > in regmap_init_mmio_clk will make it use the first clock, which is the > > bus clock. > > Indeed I tried that, since NULL clk_id wouldn't enable the bus clock > during regmap_mmio_gen_context code, passing NULL triggering vblank > timeout. There's a bunch of users of NULL in tree, so finding out why NULL doesn't work is the way forward. Maxime
Hi Maxime, On Tue, Oct 29, 2019 at 2:24 PM Maxime Ripard <mripard@kernel.org> wrote: > > On Tue, Oct 29, 2019 at 04:03:56AM +0530, Jagan Teki wrote: > > > > explicit handling of common clock would require since the A64 > > > > doesn't need to mention the clock-names explicitly in dts since it > > > > support only one bus clock. > > > > > > > > Also pass clk_id NULL instead "bus" to regmap clock init function > > > > since the single clock variants no need to mention clock-names > > > > explicitly. > > > > > > You don't need explicit clock handling. Passing NULL as the argument > > > in regmap_init_mmio_clk will make it use the first clock, which is the > > > bus clock. > > > > Indeed I tried that, since NULL clk_id wouldn't enable the bus clock > > during regmap_mmio_gen_context code, passing NULL triggering vblank > > timeout. > > There's a bunch of users of NULL in tree, so finding out why NULL > doesn't work is the way forward. I'd have looked the some of the users before checking the code as well. As I said passing NULL clk_id to devm_regmap_init_mmio_clk => __devm_regmap_init_mmio_clk would return before processing the clock. Here is the code snippet on the tree just to make sure I'm on the same page or not. static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, const char *clk_id, void __iomem *regs, const struct regmap_config *config) { ----------------------- -------------- if (clk_id == NULL) return ctx; ctx->clk = clk_get(dev, clk_id); if (IS_ERR(ctx->clk)) { ret = PTR_ERR(ctx->clk); goto err_free; } ret = clk_prepare(ctx->clk); if (ret < 0) { clk_put(ctx->clk); goto err_free; } ------------- --------------- } Yes, I did check on the driver in the tree before committing explicit clock handle, which make similar requirements like us in [1]. this imx2 wdt driver is handling the explicit clock as well. I'm sure this driver is updated as I have seen few changes related to this driver in ML. Let me know if I still miss any key change or note here, I will dig further on this for sure. [1] https://elixir.bootlin.com/linux/v5.4-rc4/source/drivers/watchdog/imx2_wdt.c#L264 thanks, Jagan.
On Fri, Nov 01, 2019 at 07:42:55PM +0530, Jagan Teki wrote: > Hi Maxime, > > On Tue, Oct 29, 2019 at 2:24 PM Maxime Ripard <mripard@kernel.org> wrote: > > > > On Tue, Oct 29, 2019 at 04:03:56AM +0530, Jagan Teki wrote: > > > > > explicit handling of common clock would require since the A64 > > > > > doesn't need to mention the clock-names explicitly in dts since it > > > > > support only one bus clock. > > > > > > > > > > Also pass clk_id NULL instead "bus" to regmap clock init function > > > > > since the single clock variants no need to mention clock-names > > > > > explicitly. > > > > > > > > You don't need explicit clock handling. Passing NULL as the argument > > > > in regmap_init_mmio_clk will make it use the first clock, which is the > > > > bus clock. > > > > > > Indeed I tried that, since NULL clk_id wouldn't enable the bus clock > > > during regmap_mmio_gen_context code, passing NULL triggering vblank > > > timeout. > > > > There's a bunch of users of NULL in tree, so finding out why NULL > > doesn't work is the way forward. > > I'd have looked the some of the users before checking the code as > well. As I said passing NULL clk_id to devm_regmap_init_mmio_clk => > __devm_regmap_init_mmio_clk would return before processing the clock. > > Here is the code snippet on the tree just to make sure I'm on the same > page or not. > > static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, > const char *clk_id, > void __iomem *regs, > const struct regmap_config *config) > { > ----------------------- > -------------- > if (clk_id == NULL) > return ctx; > > ctx->clk = clk_get(dev, clk_id); > if (IS_ERR(ctx->clk)) { > ret = PTR_ERR(ctx->clk); > goto err_free; > } > > ret = clk_prepare(ctx->clk); > if (ret < 0) { > clk_put(ctx->clk); > goto err_free; > } > ------------- > --------------- > } > > Yes, I did check on the driver in the tree before committing explicit > clock handle, which make similar requirements like us in [1]. this > imx2 wdt driver is handling the explicit clock as well. I'm sure this > driver is updated as I have seen few changes related to this driver in > ML. I guess we have two ways to go at this then. Either we remove the return, but it might have a few side-effects, or we call clk_get with NULL or bus depending on the case, and then call regmap_mmio_attach_clk. Maxime
Hi Maxime, On Sun, Nov 3, 2019 at 11:02 PM Maxime Ripard <mripard@kernel.org> wrote: > > On Fri, Nov 01, 2019 at 07:42:55PM +0530, Jagan Teki wrote: > > Hi Maxime, > > > > On Tue, Oct 29, 2019 at 2:24 PM Maxime Ripard <mripard@kernel.org> wrote: > > > > > > On Tue, Oct 29, 2019 at 04:03:56AM +0530, Jagan Teki wrote: > > > > > > explicit handling of common clock would require since the A64 > > > > > > doesn't need to mention the clock-names explicitly in dts since it > > > > > > support only one bus clock. > > > > > > > > > > > > Also pass clk_id NULL instead "bus" to regmap clock init function > > > > > > since the single clock variants no need to mention clock-names > > > > > > explicitly. > > > > > > > > > > You don't need explicit clock handling. Passing NULL as the argument > > > > > in regmap_init_mmio_clk will make it use the first clock, which is the > > > > > bus clock. > > > > > > > > Indeed I tried that, since NULL clk_id wouldn't enable the bus clock > > > > during regmap_mmio_gen_context code, passing NULL triggering vblank > > > > timeout. > > > > > > There's a bunch of users of NULL in tree, so finding out why NULL > > > doesn't work is the way forward. > > > > I'd have looked the some of the users before checking the code as > > well. As I said passing NULL clk_id to devm_regmap_init_mmio_clk => > > __devm_regmap_init_mmio_clk would return before processing the clock. > > > > Here is the code snippet on the tree just to make sure I'm on the same > > page or not. > > > > static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, > > const char *clk_id, > > void __iomem *regs, > > const struct regmap_config *config) > > { > > ----------------------- > > -------------- > > if (clk_id == NULL) > > return ctx; > > > > ctx->clk = clk_get(dev, clk_id); > > if (IS_ERR(ctx->clk)) { > > ret = PTR_ERR(ctx->clk); > > goto err_free; > > } > > > > ret = clk_prepare(ctx->clk); > > if (ret < 0) { > > clk_put(ctx->clk); > > goto err_free; > > } > > ------------- > > --------------- > > } > > > > Yes, I did check on the driver in the tree before committing explicit > > clock handle, which make similar requirements like us in [1]. this > > imx2 wdt driver is handling the explicit clock as well. I'm sure this > > driver is updated as I have seen few changes related to this driver in > > ML. > > I guess we have two ways to go at this then. > > Either we remove the return, but it might have a few side-effects, or > we call clk_get with NULL or bus depending on the case, and then call > regmap_mmio_attach_clk. Thanks for the inputs. Please have a look at this snippet, I have used your second suggestions. let me know if you have any comments? diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 8fa90cfc2ac8..91c95e56d870 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -1109,24 +1109,36 @@ static int sun6i_dsi_probe(struct platform_device *pdev) return PTR_ERR(dsi->regulator); } - dsi->regs = devm_regmap_init_mmio_clk(dev, "bus", base, - &sun6i_dsi_regmap_config); - if (IS_ERR(dsi->regs)) { - dev_err(dev, "Couldn't create the DSI encoder regmap\n"); - return PTR_ERR(dsi->regs); - } - dsi->reset = devm_reset_control_get_shared(dev, NULL); if (IS_ERR(dsi->reset)) { dev_err(dev, "Couldn't get our reset line\n"); return PTR_ERR(dsi->reset); } + dsi->regs = regmap_init_mmio(dev, base, &sun6i_dsi_regmap_config); + if (IS_ERR(dsi->regs)) { + dev_err(dev, "Couldn't init regmap\n"); + return PTR_ERR(dsi->regs); + } + + dsi->bus_clk = devm_clk_get(dev, NULL); + if (IS_ERR(dsi->bus_clk)) { + dev_err(dev, "Couldn't get the DSI bus clock\n"); + ret = PTR_ERR(dsi->bus_clk); + goto err_regmap; + } else { + printk("Jagan.. Got the BUS clock\n"); + ret = regmap_mmio_attach_clk(dsi->regs, dsi->bus_clk); + if (ret) + goto err_bus_clk; + } + if (dsi->variant->has_mod_clk) { dsi->mod_clk = devm_clk_get(dev, "mod"); if (IS_ERR(dsi->mod_clk)) { dev_err(dev, "Couldn't get the DSI mod clock\n"); - return PTR_ERR(dsi->mod_clk); + ret = PTR_ERR(dsi->mod_clk); + goto err_attach_clk; } } @@ -1167,6 +1179,14 @@ static int sun6i_dsi_probe(struct platform_device *pdev) err_unprotect_clk: if (dsi->variant->has_mod_clk) clk_rate_exclusive_put(dsi->mod_clk); +err_attach_clk: + if (!IS_ERR(dsi->bus_clk)) + regmap_mmio_detach_clk(dsi->regs); +err_bus_clk: + if (!IS_ERR(dsi->bus_clk)) + clk_put(dsi->bus_clk); +err_regmap: + regmap_exit(dsi->regs); return ret; } @@ -1181,6 +1201,13 @@ static int sun6i_dsi_remove(struct platform_device *pdev) if (dsi->variant->has_mod_clk) clk_rate_exclusive_put(dsi->mod_clk); + if (!IS_ERR(dsi->bus_clk)) { + regmap_mmio_detach_clk(dsi->regs); + clk_put(dsi->bus_clk); + } + + regmap_exit(dsi->regs); + return 0; } Jagan.
Hi, On Thu, Nov 21, 2019 at 05:24:47PM +0530, Jagan Teki wrote: > On Sun, Nov 3, 2019 at 11:02 PM Maxime Ripard <mripard@kernel.org> wrote: > > > > On Fri, Nov 01, 2019 at 07:42:55PM +0530, Jagan Teki wrote: > > > Hi Maxime, > > > > > > On Tue, Oct 29, 2019 at 2:24 PM Maxime Ripard <mripard@kernel.org> wrote: > > > > > > > > On Tue, Oct 29, 2019 at 04:03:56AM +0530, Jagan Teki wrote: > > > > > > > explicit handling of common clock would require since the A64 > > > > > > > doesn't need to mention the clock-names explicitly in dts since it > > > > > > > support only one bus clock. > > > > > > > > > > > > > > Also pass clk_id NULL instead "bus" to regmap clock init function > > > > > > > since the single clock variants no need to mention clock-names > > > > > > > explicitly. > > > > > > > > > > > > You don't need explicit clock handling. Passing NULL as the argument > > > > > > in regmap_init_mmio_clk will make it use the first clock, which is the > > > > > > bus clock. > > > > > > > > > > Indeed I tried that, since NULL clk_id wouldn't enable the bus clock > > > > > during regmap_mmio_gen_context code, passing NULL triggering vblank > > > > > timeout. > > > > > > > > There's a bunch of users of NULL in tree, so finding out why NULL > > > > doesn't work is the way forward. > > > > > > I'd have looked the some of the users before checking the code as > > > well. As I said passing NULL clk_id to devm_regmap_init_mmio_clk => > > > __devm_regmap_init_mmio_clk would return before processing the clock. > > > > > > Here is the code snippet on the tree just to make sure I'm on the same > > > page or not. > > > > > > static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, > > > const char *clk_id, > > > void __iomem *regs, > > > const struct regmap_config *config) > > > { > > > ----------------------- > > > -------------- > > > if (clk_id == NULL) > > > return ctx; > > > > > > ctx->clk = clk_get(dev, clk_id); > > > if (IS_ERR(ctx->clk)) { > > > ret = PTR_ERR(ctx->clk); > > > goto err_free; > > > } > > > > > > ret = clk_prepare(ctx->clk); > > > if (ret < 0) { > > > clk_put(ctx->clk); > > > goto err_free; > > > } > > > ------------- > > > --------------- > > > } > > > > > > Yes, I did check on the driver in the tree before committing explicit > > > clock handle, which make similar requirements like us in [1]. this > > > imx2 wdt driver is handling the explicit clock as well. I'm sure this > > > driver is updated as I have seen few changes related to this driver in > > > ML. > > > > I guess we have two ways to go at this then. > > > > Either we remove the return, but it might have a few side-effects, or > > we call clk_get with NULL or bus depending on the case, and then call > > regmap_mmio_attach_clk. > > Thanks for the inputs. > > Please have a look at this snippet, I have used your second > suggestions. let me know if you have any comments? > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > index 8fa90cfc2ac8..91c95e56d870 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > @@ -1109,24 +1109,36 @@ static int sun6i_dsi_probe(struct platform_device *pdev) > return PTR_ERR(dsi->regulator); > } > > - dsi->regs = devm_regmap_init_mmio_clk(dev, "bus", base, > - &sun6i_dsi_regmap_config); > - if (IS_ERR(dsi->regs)) { > - dev_err(dev, "Couldn't create the DSI encoder regmap\n"); > - return PTR_ERR(dsi->regs); > - } > - > dsi->reset = devm_reset_control_get_shared(dev, NULL); > if (IS_ERR(dsi->reset)) { > dev_err(dev, "Couldn't get our reset line\n"); > return PTR_ERR(dsi->reset); > } > > + dsi->regs = regmap_init_mmio(dev, base, &sun6i_dsi_regmap_config); You should use the devm variant here > + if (IS_ERR(dsi->regs)) { > + dev_err(dev, "Couldn't init regmap\n"); > + return PTR_ERR(dsi->regs); > + } > + > + dsi->bus_clk = devm_clk_get(dev, NULL); I guess you still need to pass 'bus' here? > + if (IS_ERR(dsi->bus_clk)) { > + dev_err(dev, "Couldn't get the DSI bus clock\n"); > + ret = PTR_ERR(dsi->bus_clk); > + goto err_regmap; > + } else { > + printk("Jagan.. Got the BUS clock\n"); > + ret = regmap_mmio_attach_clk(dsi->regs, dsi->bus_clk); > + if (ret) > + goto err_bus_clk; > + } > + > if (dsi->variant->has_mod_clk) { > dsi->mod_clk = devm_clk_get(dev, "mod"); > if (IS_ERR(dsi->mod_clk)) { > dev_err(dev, "Couldn't get the DSI mod clock\n"); > - return PTR_ERR(dsi->mod_clk); > + ret = PTR_ERR(dsi->mod_clk); > + goto err_attach_clk; > } > } > > @@ -1167,6 +1179,14 @@ static int sun6i_dsi_probe(struct platform_device *pdev) > err_unprotect_clk: > if (dsi->variant->has_mod_clk) > clk_rate_exclusive_put(dsi->mod_clk); > +err_attach_clk: > + if (!IS_ERR(dsi->bus_clk)) > + regmap_mmio_detach_clk(dsi->regs); > +err_bus_clk: > + if (!IS_ERR(dsi->bus_clk)) > + clk_put(dsi->bus_clk); > +err_regmap: > + regmap_exit(dsi->regs); > return ret; > } > > @@ -1181,6 +1201,13 @@ static int sun6i_dsi_remove(struct platform_device *pdev) > if (dsi->variant->has_mod_clk) > clk_rate_exclusive_put(dsi->mod_clk); > > + if (!IS_ERR(dsi->bus_clk)) { > + regmap_mmio_detach_clk(dsi->regs); > + clk_put(dsi->bus_clk); This will trigger a warning, you put down the reference twice Maxime
Hi, On Fri, Nov 22, 2019 at 11:48 PM Maxime Ripard <maxime@cerno.tech> wrote: > > Hi, > > On Thu, Nov 21, 2019 at 05:24:47PM +0530, Jagan Teki wrote: > > On Sun, Nov 3, 2019 at 11:02 PM Maxime Ripard <mripard@kernel.org> wrote: > > > > > > On Fri, Nov 01, 2019 at 07:42:55PM +0530, Jagan Teki wrote: > > > > Hi Maxime, > > > > > > > > On Tue, Oct 29, 2019 at 2:24 PM Maxime Ripard <mripard@kernel.org> wrote: > > > > > > > > > > On Tue, Oct 29, 2019 at 04:03:56AM +0530, Jagan Teki wrote: > > > > > > > > explicit handling of common clock would require since the A64 > > > > > > > > doesn't need to mention the clock-names explicitly in dts since it > > > > > > > > support only one bus clock. > > > > > > > > > > > > > > > > Also pass clk_id NULL instead "bus" to regmap clock init function > > > > > > > > since the single clock variants no need to mention clock-names > > > > > > > > explicitly. > > > > > > > > > > > > > > You don't need explicit clock handling. Passing NULL as the argument > > > > > > > in regmap_init_mmio_clk will make it use the first clock, which is the > > > > > > > bus clock. > > > > > > > > > > > > Indeed I tried that, since NULL clk_id wouldn't enable the bus clock > > > > > > during regmap_mmio_gen_context code, passing NULL triggering vblank > > > > > > timeout. > > > > > > > > > > There's a bunch of users of NULL in tree, so finding out why NULL > > > > > doesn't work is the way forward. > > > > > > > > I'd have looked the some of the users before checking the code as > > > > well. As I said passing NULL clk_id to devm_regmap_init_mmio_clk => > > > > __devm_regmap_init_mmio_clk would return before processing the clock. > > > > > > > > Here is the code snippet on the tree just to make sure I'm on the same > > > > page or not. > > > > > > > > static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev, > > > > const char *clk_id, > > > > void __iomem *regs, > > > > const struct regmap_config *config) > > > > { > > > > ----------------------- > > > > -------------- > > > > if (clk_id == NULL) > > > > return ctx; > > > > > > > > ctx->clk = clk_get(dev, clk_id); > > > > if (IS_ERR(ctx->clk)) { > > > > ret = PTR_ERR(ctx->clk); > > > > goto err_free; > > > > } > > > > > > > > ret = clk_prepare(ctx->clk); > > > > if (ret < 0) { > > > > clk_put(ctx->clk); > > > > goto err_free; > > > > } > > > > ------------- > > > > --------------- > > > > } > > > > > > > > Yes, I did check on the driver in the tree before committing explicit > > > > clock handle, which make similar requirements like us in [1]. this > > > > imx2 wdt driver is handling the explicit clock as well. I'm sure this > > > > driver is updated as I have seen few changes related to this driver in > > > > ML. > > > > > > I guess we have two ways to go at this then. > > > > > > Either we remove the return, but it might have a few side-effects, or > > > we call clk_get with NULL or bus depending on the case, and then call > > > regmap_mmio_attach_clk. > > > > Thanks for the inputs. > > > > Please have a look at this snippet, I have used your second > > suggestions. let me know if you have any comments? > > > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > index 8fa90cfc2ac8..91c95e56d870 100644 > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > @@ -1109,24 +1109,36 @@ static int sun6i_dsi_probe(struct platform_device *pdev) > > return PTR_ERR(dsi->regulator); > > } > > > > - dsi->regs = devm_regmap_init_mmio_clk(dev, "bus", base, > > - &sun6i_dsi_regmap_config); > > - if (IS_ERR(dsi->regs)) { > > - dev_err(dev, "Couldn't create the DSI encoder regmap\n"); > > - return PTR_ERR(dsi->regs); > > - } > > - > > dsi->reset = devm_reset_control_get_shared(dev, NULL); > > if (IS_ERR(dsi->reset)) { > > dev_err(dev, "Couldn't get our reset line\n"); > > return PTR_ERR(dsi->reset); > > } > > > > + dsi->regs = regmap_init_mmio(dev, base, &sun6i_dsi_regmap_config); > > You should use the devm variant here Sure. > > > + if (IS_ERR(dsi->regs)) { > > + dev_err(dev, "Couldn't init regmap\n"); > > + return PTR_ERR(dsi->regs); > > + } > > + > > + dsi->bus_clk = devm_clk_get(dev, NULL); > > I guess you still need to pass 'bus' here? But the idea here is not to specify clock name explicitly to support A64. otherwise A64 would fail as we are not specifying the clock-names explicitly on dsi node. dsi: dsi@1ca0000 { compatible = "allwinner,sun50i-a64-mipi-dsi"; reg = <0x01ca0000 0x1000>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; clocks = <&ccu CLK_BUS_MIPI_DSI>; resets = <&ccu RST_BUS_MIPI_DSI>; phys = <&dphy>; phy-names = "dphy"; ..... }; > > > + if (IS_ERR(dsi->bus_clk)) { > > + dev_err(dev, "Couldn't get the DSI bus clock\n"); > > + ret = PTR_ERR(dsi->bus_clk); > > + goto err_regmap; > > + } else { > > + printk("Jagan.. Got the BUS clock\n"); > > + ret = regmap_mmio_attach_clk(dsi->regs, dsi->bus_clk); > > + if (ret) > > + goto err_bus_clk; > > + } > > + > > if (dsi->variant->has_mod_clk) { > > dsi->mod_clk = devm_clk_get(dev, "mod"); > > if (IS_ERR(dsi->mod_clk)) { > > dev_err(dev, "Couldn't get the DSI mod clock\n"); > > - return PTR_ERR(dsi->mod_clk); > > + ret = PTR_ERR(dsi->mod_clk); > > + goto err_attach_clk; > > } > > } > > > > @@ -1167,6 +1179,14 @@ static int sun6i_dsi_probe(struct platform_device *pdev) > > err_unprotect_clk: > > if (dsi->variant->has_mod_clk) > > clk_rate_exclusive_put(dsi->mod_clk); > > +err_attach_clk: > > + if (!IS_ERR(dsi->bus_clk)) > > + regmap_mmio_detach_clk(dsi->regs); > > +err_bus_clk: > > + if (!IS_ERR(dsi->bus_clk)) > > + clk_put(dsi->bus_clk); > > +err_regmap: > > + regmap_exit(dsi->regs); > > return ret; > > } > > > > @@ -1181,6 +1201,13 @@ static int sun6i_dsi_remove(struct platform_device *pdev) > > if (dsi->variant->has_mod_clk) > > clk_rate_exclusive_put(dsi->mod_clk); > > > > + if (!IS_ERR(dsi->bus_clk)) { > > + regmap_mmio_detach_clk(dsi->regs); > > + clk_put(dsi->bus_clk); > > This will trigger a warning, you put down the reference twice You mean regmap_mmio_detach_clk will put the clk? Jagan.
On Sat, Nov 23, 2019 at 01:20:21AM +0530, Jagan Teki wrote: > > > Please have a look at this snippet, I have used your second > > > suggestions. let me know if you have any comments? > > > > > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > index 8fa90cfc2ac8..91c95e56d870 100644 > > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > @@ -1109,24 +1109,36 @@ static int sun6i_dsi_probe(struct platform_device *pdev) > > > return PTR_ERR(dsi->regulator); > > > } > > > > > > - dsi->regs = devm_regmap_init_mmio_clk(dev, "bus", base, > > > - &sun6i_dsi_regmap_config); > > > - if (IS_ERR(dsi->regs)) { > > > - dev_err(dev, "Couldn't create the DSI encoder regmap\n"); > > > - return PTR_ERR(dsi->regs); > > > - } > > > - > > > dsi->reset = devm_reset_control_get_shared(dev, NULL); > > > if (IS_ERR(dsi->reset)) { > > > dev_err(dev, "Couldn't get our reset line\n"); > > > return PTR_ERR(dsi->reset); > > > } > > > > > > + dsi->regs = regmap_init_mmio(dev, base, &sun6i_dsi_regmap_config); > > > > You should use the devm variant here > > Sure. > > > > > > + if (IS_ERR(dsi->regs)) { > > > + dev_err(dev, "Couldn't init regmap\n"); > > > + return PTR_ERR(dsi->regs); > > > + } > > > + > > > + dsi->bus_clk = devm_clk_get(dev, NULL); > > > > I guess you still need to pass 'bus' here? > > But the idea here is not to specify clock name explicitly to support > A64. otherwise A64 would fail as we are not specifying the clock-names > explicitly on dsi node. Right. But you have no guarantee that the bus clock is going to be the first one on the other SoCs either. What about something like that instead: char *clk_name = NULL; if (dsi->has_mod_clk) clk_name = "bus"; clk = devm_clk_get(dev, clk_name); if (IS_ERR(clk)) return PTR_ERR(clk)); regmap_mmio_attach_clk(regmap, clk); > > dsi: dsi@1ca0000 { > compatible = "allwinner,sun50i-a64-mipi-dsi"; > reg = <0x01ca0000 0x1000>; > interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; > clocks = <&ccu CLK_BUS_MIPI_DSI>; > resets = <&ccu RST_BUS_MIPI_DSI>; > phys = <&dphy>; > phy-names = "dphy"; > ..... > }; > > > > > > + if (IS_ERR(dsi->bus_clk)) { > > > + dev_err(dev, "Couldn't get the DSI bus clock\n"); > > > + ret = PTR_ERR(dsi->bus_clk); > > > + goto err_regmap; > > > + } else { > > > + printk("Jagan.. Got the BUS clock\n"); > > > + ret = regmap_mmio_attach_clk(dsi->regs, dsi->bus_clk); > > > + if (ret) > > > + goto err_bus_clk; > > > + } > > > + > > > if (dsi->variant->has_mod_clk) { > > > dsi->mod_clk = devm_clk_get(dev, "mod"); > > > if (IS_ERR(dsi->mod_clk)) { > > > dev_err(dev, "Couldn't get the DSI mod clock\n"); > > > - return PTR_ERR(dsi->mod_clk); > > > + ret = PTR_ERR(dsi->mod_clk); > > > + goto err_attach_clk; > > > } > > > } > > > > > > @@ -1167,6 +1179,14 @@ static int sun6i_dsi_probe(struct platform_device *pdev) > > > err_unprotect_clk: > > > if (dsi->variant->has_mod_clk) > > > clk_rate_exclusive_put(dsi->mod_clk); > > > +err_attach_clk: > > > + if (!IS_ERR(dsi->bus_clk)) > > > + regmap_mmio_detach_clk(dsi->regs); > > > +err_bus_clk: > > > + if (!IS_ERR(dsi->bus_clk)) > > > + clk_put(dsi->bus_clk); > > > +err_regmap: > > > + regmap_exit(dsi->regs); > > > return ret; > > > } > > > > > > @@ -1181,6 +1201,13 @@ static int sun6i_dsi_remove(struct platform_device *pdev) > > > if (dsi->variant->has_mod_clk) > > > clk_rate_exclusive_put(dsi->mod_clk); > > > > > > + if (!IS_ERR(dsi->bus_clk)) { > > > + regmap_mmio_detach_clk(dsi->regs); > > > + clk_put(dsi->bus_clk); > > > > This will trigger a warning, you put down the reference twice > > You mean regmap_mmio_detach_clk will put the clk? No, devm_clk_get will. Maxime
On Thu, Nov 28, 2019 at 11:21 PM Maxime Ripard <maxime@cerno.tech> wrote: > > On Sat, Nov 23, 2019 at 01:20:21AM +0530, Jagan Teki wrote: > > > > Please have a look at this snippet, I have used your second > > > > suggestions. let me know if you have any comments? > > > > > > > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > > b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > > index 8fa90cfc2ac8..91c95e56d870 100644 > > > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > > @@ -1109,24 +1109,36 @@ static int sun6i_dsi_probe(struct platform_device *pdev) > > > > return PTR_ERR(dsi->regulator); > > > > } > > > > > > > > - dsi->regs = devm_regmap_init_mmio_clk(dev, "bus", base, > > > > - &sun6i_dsi_regmap_config); > > > > - if (IS_ERR(dsi->regs)) { > > > > - dev_err(dev, "Couldn't create the DSI encoder regmap\n"); > > > > - return PTR_ERR(dsi->regs); > > > > - } > > > > - > > > > dsi->reset = devm_reset_control_get_shared(dev, NULL); > > > > if (IS_ERR(dsi->reset)) { > > > > dev_err(dev, "Couldn't get our reset line\n"); > > > > return PTR_ERR(dsi->reset); > > > > } > > > > > > > > + dsi->regs = regmap_init_mmio(dev, base, &sun6i_dsi_regmap_config); > > > > > > You should use the devm variant here > > > > Sure. > > > > > > > > > + if (IS_ERR(dsi->regs)) { > > > > + dev_err(dev, "Couldn't init regmap\n"); > > > > + return PTR_ERR(dsi->regs); > > > > + } > > > > + > > > > + dsi->bus_clk = devm_clk_get(dev, NULL); > > > > > > I guess you still need to pass 'bus' here? > > > > But the idea here is not to specify clock name explicitly to support > > A64. otherwise A64 would fail as we are not specifying the clock-names > > explicitly on dsi node. > > Right. But you have no guarantee that the bus clock is going to be the > first one on the other SoCs either. > > What about something like that instead: > > char *clk_name = NULL; > if (dsi->has_mod_clk) > clk_name = "bus"; > > clk = devm_clk_get(dev, clk_name); > if (IS_ERR(clk)) > return PTR_ERR(clk)); > > regmap_mmio_attach_clk(regmap, clk); This makes sense, thanks for your input. I have tested in A33, A64. > > > > > dsi: dsi@1ca0000 { > > compatible = "allwinner,sun50i-a64-mipi-dsi"; > > reg = <0x01ca0000 0x1000>; > > interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; > > clocks = <&ccu CLK_BUS_MIPI_DSI>; > > resets = <&ccu RST_BUS_MIPI_DSI>; > > phys = <&dphy>; > > phy-names = "dphy"; > > ..... > > }; > > > > > > > > > + if (IS_ERR(dsi->bus_clk)) { > > > > + dev_err(dev, "Couldn't get the DSI bus clock\n"); > > > > + ret = PTR_ERR(dsi->bus_clk); > > > > + goto err_regmap; > > > > + } else { > > > > + printk("Jagan.. Got the BUS clock\n"); > > > > + ret = regmap_mmio_attach_clk(dsi->regs, dsi->bus_clk); > > > > + if (ret) > > > > + goto err_bus_clk; > > > > + } > > > > + > > > > if (dsi->variant->has_mod_clk) { > > > > dsi->mod_clk = devm_clk_get(dev, "mod"); > > > > if (IS_ERR(dsi->mod_clk)) { > > > > dev_err(dev, "Couldn't get the DSI mod clock\n"); > > > > - return PTR_ERR(dsi->mod_clk); > > > > + ret = PTR_ERR(dsi->mod_clk); > > > > + goto err_attach_clk; > > > > } > > > > } > > > > > > > > @@ -1167,6 +1179,14 @@ static int sun6i_dsi_probe(struct platform_device *pdev) > > > > err_unprotect_clk: > > > > if (dsi->variant->has_mod_clk) > > > > clk_rate_exclusive_put(dsi->mod_clk); > > > > +err_attach_clk: > > > > + if (!IS_ERR(dsi->bus_clk)) > > > > + regmap_mmio_detach_clk(dsi->regs); > > > > +err_bus_clk: > > > > + if (!IS_ERR(dsi->bus_clk)) > > > > + clk_put(dsi->bus_clk); > > > > +err_regmap: > > > > + regmap_exit(dsi->regs); > > > > return ret; > > > > } > > > > > > > > @@ -1181,6 +1201,13 @@ static int sun6i_dsi_remove(struct platform_device *pdev) > > > > if (dsi->variant->has_mod_clk) > > > > clk_rate_exclusive_put(dsi->mod_clk); > > > > > > > > + if (!IS_ERR(dsi->bus_clk)) { > > > > + regmap_mmio_detach_clk(dsi->regs); > > > > + clk_put(dsi->bus_clk); > > > > > > This will trigger a warning, you put down the reference twice > > > > You mean regmap_mmio_detach_clk will put the clk? > > No, devm_clk_get will. Got it. Will update and send v12. Jagan.
diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 8c4c541224dd..eacdfcff64ad 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -1109,7 +1109,7 @@ static int sun6i_dsi_probe(struct platform_device *pdev) return PTR_ERR(dsi->regulator); } - dsi->regs = devm_regmap_init_mmio_clk(dev, "bus", base, + dsi->regs = devm_regmap_init_mmio_clk(dev, NULL, base, &sun6i_dsi_regmap_config); if (IS_ERR(dsi->regs)) { dev_err(dev, "Couldn't create the DSI encoder regmap\n"); @@ -1122,6 +1122,12 @@ static int sun6i_dsi_probe(struct platform_device *pdev) return PTR_ERR(dsi->reset); } + dsi->bus_clk = devm_clk_get(dev, NULL); + if (IS_ERR(dsi->bus_clk)) { + dev_err(dev, "Couldn't get the DSI bus clock\n"); + return PTR_ERR(dsi->bus_clk); + } + if (dsi->variant->has_mod_clk) { dsi->mod_clk = devm_clk_get(dev, "mod"); if (IS_ERR(dsi->mod_clk)) { @@ -1196,6 +1202,7 @@ static int __maybe_unused sun6i_dsi_runtime_resume(struct device *dev) } reset_control_deassert(dsi->reset); + clk_prepare_enable(dsi->bus_clk); if (dsi->variant->has_mod_clk) clk_prepare_enable(dsi->mod_clk); @@ -1227,6 +1234,7 @@ static int __maybe_unused sun6i_dsi_runtime_suspend(struct device *dev) if (dsi->variant->has_mod_clk) clk_disable_unprepare(dsi->mod_clk); + clk_disable_unprepare(dsi->bus_clk); reset_control_assert(dsi->reset); regulator_disable(dsi->regulator);