Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1633195 > unrolled thread

[PATCH v4 1/3] drm/vc4: Turn the V3D clock on at runtime.

Started byEric Anholt <eric@anholt.net>
First post2017-04-29 00:50 +0200
Last post2017-05-02 01:10 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v4 1/3] drm/vc4: Turn the V3D clock on at runtime. Eric Anholt <eric@anholt.net> - 2017-04-29 00:50 +0200
    [PATCH v4 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D. Eric Anholt <eric@anholt.net> - 2017-04-29 00:50 +0200
      Re: [PATCH v4 2/3] drm/vc4: Don't try to initialize FBDEV if we're  only bound to V3D. Daniel Vetter <daniel@ffwll.ch> - 2017-05-02 11:30 +0200
        Re: [PATCH v4 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D. Eric Anholt <eric@anholt.net> - 2017-05-03 21:10 +0200
    [PATCH v4 3/3] drm/vc4: Add specific compatible strings for Cygnus. Eric Anholt <eric@anholt.net> - 2017-04-29 00:50 +0200
    Re: [PATCH v4 1/3] drm/vc4: Turn the V3D clock on at runtime. Rob Herring <robh+dt@kernel.org> - 2017-05-02 01:10 +0200

#1633195 — [PATCH v4 1/3] drm/vc4: Turn the V3D clock on at runtime.

FromEric Anholt <eric@anholt.net>
Date2017-04-29 00:50 +0200
Subject[PATCH v4 1/3] drm/vc4: Turn the V3D clock on at runtime.
Message-ID<tBmS5-5Fv-5@gated-at.bofh.it>
For the Raspberry Pi's bindings, the power domain also implicitly
turns on the clock and deasserts reset, but for the new Cygnus port we
start representing the clock in the devicetree.

v2: Document the clock-names property, check for -ENOENT for no clock
    in DT.
v3: Drop NULL checks around clk calls which embed NULL checks.
v4: Drop clk-names (feedback by Rob Herring)

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |  3 +++
 drivers/gpu/drm/vc4/vc4_drv.h                      |  1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                      | 31 +++++++++++++++++++++-
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
index ca02d3e4db91..bc1756f4f791 100644
--- a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
+++ b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
@@ -59,6 +59,9 @@ Required properties for V3D:
 - interrupts:	The interrupt number
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
 
+Optional properties for V3D:
+- clocks:	The clock the unit runs on
+
 Required properties for DSI:
 - compatible:	Should be "brcm,bcm2835-dsi0" or "brcm,bcm2835-dsi1"
 - reg:		Physical base address and length of the DSI block's registers
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index b0967e2f7e88..92eb7d811bf2 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -200,6 +200,7 @@ struct vc4_v3d {
 	struct vc4_dev *vc4;
 	struct platform_device *pdev;
 	void __iomem *regs;
+	struct clk *clk;
 };
 
 struct vc4_hvs {
diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
index a88078d7c9d1..7500820e5cd5 100644
--- a/drivers/gpu/drm/vc4/vc4_v3d.c
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
@@ -16,6 +16,7 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "linux/clk.h"
 #include "linux/component.h"
 #include "linux/pm_runtime.h"
 #include "vc4_drv.h"
@@ -305,6 +306,8 @@ static int vc4_v3d_runtime_suspend(struct device *dev)
 	drm_gem_object_put_unlocked(&vc4->bin_bo->base.base);
 	vc4->bin_bo = NULL;
 
+	clk_disable_unprepare(v3d->clk);
+
 	return 0;
 }
 
@@ -318,6 +321,10 @@ static int vc4_v3d_runtime_resume(struct device *dev)
 	if (ret)
 		return ret;
 
+	ret = clk_prepare_enable(v3d->clk);
+	if (ret != 0)
+		return ret;
+
 	vc4_v3d_init_hw(vc4->dev);
 	vc4_irq_postinstall(vc4->dev);
 
@@ -348,15 +355,37 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
 	vc4->v3d = v3d;
 	v3d->vc4 = vc4;
 
+	v3d->clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(v3d->clk)) {
+		int ret = PTR_ERR(v3d->clk);
+
+		if (ret == -ENOENT) {
+			/* bcm2835 didn't have a clock reference in the DT. */
+			ret = 0;
+			v3d->clk = NULL;
+		} else {
+			if (ret != -EPROBE_DEFER)
+				dev_err(dev, "Failed to get V3D clock: %d\n",
+					ret);
+			return ret;
+		}
+	}
+
 	if (V3D_READ(V3D_IDENT0) != V3D_EXPECTED_IDENT0) {
 		DRM_ERROR("V3D_IDENT0 read 0x%08x instead of 0x%08x\n",
 			  V3D_READ(V3D_IDENT0), V3D_EXPECTED_IDENT0);
 		return -EINVAL;
 	}
 
+	ret = clk_prepare_enable(v3d->clk);
+	if (ret != 0)
+		return ret;
+
 	ret = vc4_allocate_bin_bo(drm);
-	if (ret)
+	if (ret) {
+		clk_disable_unprepare(v3d->clk);
 		return ret;
+	}
 
 	/* Reset the binner overflow address/size at setup, to be sure
 	 * we don't reuse an old one.
-- 
2.11.0

[toc] | [next] | [standalone]


#1633198 — [PATCH v4 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

FromEric Anholt <eric@anholt.net>
Date2017-04-29 00:50 +0200
Subject[PATCH v4 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.
Message-ID<tBmS5-5Fv-11@gated-at.bofh.it>
In reply to#1633195
The FBDEV initialization would throw an error in dmesg, when we just
want to silently not initialize fbdev on a V3D-only VC4 instance.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/vc4/vc4_kms.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index ad7925a9e0ea..237a504f11f0 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -230,10 +230,12 @@ int vc4_kms_load(struct drm_device *dev)
 
 	drm_mode_config_reset(dev);
 
-	vc4->fbdev = drm_fbdev_cma_init(dev, 32,
-					dev->mode_config.num_connector);
-	if (IS_ERR(vc4->fbdev))
-		vc4->fbdev = NULL;
+	if (dev->mode_config.num_connector) {
+		vc4->fbdev = drm_fbdev_cma_init(dev, 32,
+						dev->mode_config.num_connector);
+		if (IS_ERR(vc4->fbdev))
+			vc4->fbdev = NULL;
+	}
 
 	drm_kms_helper_poll_init(dev);
 
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1634283 — Re: [PATCH v4 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

FromDaniel Vetter <daniel@ffwll.ch>
Date2017-05-02 11:30 +0200
SubjectRe: [PATCH v4 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.
Message-ID<tCCi6-4Jn-15@gated-at.bofh.it>
In reply to#1633198
On Fri, Apr 28, 2017 at 03:42:22PM -0700, Eric Anholt wrote:
> The FBDEV initialization would throw an error in dmesg, when we just
> want to silently not initialize fbdev on a V3D-only VC4 instance.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>

With the commit message updated that passing num_connector is the bug that
throws the error (and not that we set up a no-op fbdev):

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Still kinda hoping for a follow-up to entirely get rid fo num_connector in
the fbdev init funcs.
-Daniel
> ---
>  drivers/gpu/drm/vc4/vc4_kms.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
> index ad7925a9e0ea..237a504f11f0 100644
> --- a/drivers/gpu/drm/vc4/vc4_kms.c
> +++ b/drivers/gpu/drm/vc4/vc4_kms.c
> @@ -230,10 +230,12 @@ int vc4_kms_load(struct drm_device *dev)
>  
>  	drm_mode_config_reset(dev);
>  
> -	vc4->fbdev = drm_fbdev_cma_init(dev, 32,
> -					dev->mode_config.num_connector);
> -	if (IS_ERR(vc4->fbdev))
> -		vc4->fbdev = NULL;
> +	if (dev->mode_config.num_connector) {
> +		vc4->fbdev = drm_fbdev_cma_init(dev, 32,
> +						dev->mode_config.num_connector);
> +		if (IS_ERR(vc4->fbdev))
> +			vc4->fbdev = NULL;
> +	}
>  
>  	drm_kms_helper_poll_init(dev);
>  
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

[toc] | [prev] | [next] | [standalone]


#1635219 — Re: [PATCH v4 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.

FromEric Anholt <eric@anholt.net>
Date2017-05-03 21:10 +0200
SubjectRe: [PATCH v4 2/3] drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.
Message-ID<tD7OW-13Q-3@gated-at.bofh.it>
In reply to#1634283

[Multipart message — attachments visible in raw view] — view raw

Daniel Vetter <daniel@ffwll.ch> writes:

> On Fri, Apr 28, 2017 at 03:42:22PM -0700, Eric Anholt wrote:
>> The FBDEV initialization would throw an error in dmesg, when we just
>> want to silently not initialize fbdev on a V3D-only VC4 instance.
>> 
>> Signed-off-by: Eric Anholt <eric@anholt.net>
>
> With the commit message updated that passing num_connector is the bug that
> throws the error (and not that we set up a no-op fbdev):
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> Still kinda hoping for a follow-up to entirely get rid fo num_connector in
> the fbdev init funcs.

New commit message:

    drm/vc4: Don't try to initialize FBDEV if we're only bound to V3D.
    
    There's no sense in having an fbdev if there's no display, since
    connectors don't get hotplugged to this hardware.  On Cygnus we were
    getting a dmesg error from passing in num_connectors (0), when that
    argument is supposed to be the maximum number of cloned connectors per
    CRTC (1).

Still no drm-misc acks on the other two patches, so I don't think I can
merge them.

[toc] | [prev] | [next] | [standalone]


#1633199 — [PATCH v4 3/3] drm/vc4: Add specific compatible strings for Cygnus.

FromEric Anholt <eric@anholt.net>
Date2017-04-29 00:50 +0200
Subject[PATCH v4 3/3] drm/vc4: Add specific compatible strings for Cygnus.
Message-ID<tBmS5-5Fv-15@gated-at.bofh.it>
In reply to#1633195
Cygnus has V3D 2.6 instead of 2.1, and doesn't use the VC4 display
modules.  The V3D can be uniquely identified by the IDENT[01]
registers, and there's nothing to key off of for the display change
other than the lack of DT nodes for the display components, but it's
convention to have new compatible strings anyway.

Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 4 ++--
 drivers/gpu/drm/vc4/vc4_drv.c                              | 1 +
 drivers/gpu/drm/vc4/vc4_v3d.c                              | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
index bc1756f4f791..284e2b14cfbe 100644
--- a/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
+++ b/Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
@@ -5,7 +5,7 @@ with HDMI output and the HVS (Hardware Video Scaler) for compositing
 display planes.
 
 Required properties for VC4:
-- compatible:	Should be "brcm,bcm2835-vc4"
+- compatible:	Should be "brcm,bcm2835-vc4" or "brcm,cygnus-vc4"
 
 Required properties for Pixel Valve:
 - compatible:	Should be one of "brcm,bcm2835-pixelvalve0",
@@ -54,7 +54,7 @@ Required properties for VEC:
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
 
 Required properties for V3D:
-- compatible:	Should be "brcm,bcm2835-v3d"
+- compatible:	Should be "brcm,bcm2835-v3d" or "brcm,cygnus-v3d"
 - reg:		Physical base address and length of the V3D's registers
 - interrupts:	The interrupt number
 		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 92fb9a41fe7c..754ce76d4b98 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -335,6 +335,7 @@ static int vc4_platform_drm_remove(struct platform_device *pdev)
 
 static const struct of_device_id vc4_of_match[] = {
 	{ .compatible = "brcm,bcm2835-vc4", },
+	{ .compatible = "brcm,cygnus-vc4", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, vc4_of_match);
diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
index 7500820e5cd5..c53afec34586 100644
--- a/drivers/gpu/drm/vc4/vc4_v3d.c
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
@@ -450,6 +450,7 @@ static int vc4_v3d_dev_remove(struct platform_device *pdev)
 
 static const struct of_device_id vc4_v3d_dt_match[] = {
 	{ .compatible = "brcm,bcm2835-v3d" },
+	{ .compatible = "brcm,cygnus-v3d" },
 	{ .compatible = "brcm,vc4-v3d" },
 	{}
 };
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1634046

FromRob Herring <robh+dt@kernel.org>
Date2017-05-02 01:10 +0200
Message-ID<tCsC5-6S5-3@gated-at.bofh.it>
In reply to#1633195
On Fri, Apr 28, 2017 at 5:42 PM, Eric Anholt <eric@anholt.net> wrote:
> For the Raspberry Pi's bindings, the power domain also implicitly
> turns on the clock and deasserts reset, but for the new Cygnus port we
> start representing the clock in the devicetree.
>
> v2: Document the clock-names property, check for -ENOENT for no clock
>     in DT.
> v3: Drop NULL checks around clk calls which embed NULL checks.
> v4: Drop clk-names (feedback by Rob Herring)
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
> ---
>  .../devicetree/bindings/display/brcm,bcm-vc4.txt   |  3 +++
>  drivers/gpu/drm/vc4/vc4_drv.h                      |  1 +
>  drivers/gpu/drm/vc4/vc4_v3d.c                      | 31 +++++++++++++++++++++-
>  3 files changed, 34 insertions(+), 1 deletion(-)

Acked-by: Rob Herring <robh@kernel.org>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web